@sphereon/ui-components.credential-branding 0.2.1-unstable.97 → 0.3.1-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,7 +2,13 @@ import { VerifiableCredential } from '@veramo/core';
|
|
|
2
2
|
import { CredentialRole, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding, Party } from '@sphereon/ssi-sdk.data-store';
|
|
3
3
|
import { CredentialSummary, ISelectAppLocaleBrandingArgs } from '../types';
|
|
4
4
|
import { ICredential } from '@sphereon/ssi-types';
|
|
5
|
-
export declare const toNonPersistedCredentialSummary: (verifiableCredential
|
|
5
|
+
export declare const toNonPersistedCredentialSummary: ({ verifiableCredential, credentialRole, branding, issuer, subject, }: {
|
|
6
|
+
verifiableCredential: ICredential | VerifiableCredential;
|
|
7
|
+
credentialRole: CredentialRole;
|
|
8
|
+
branding?: IBasicCredentialLocaleBranding[] | undefined;
|
|
9
|
+
issuer?: Party | undefined;
|
|
10
|
+
subject?: Party | undefined;
|
|
11
|
+
}) => Promise<CredentialSummary>;
|
|
6
12
|
export declare const getDate: (...dates: (number | string | undefined)[]) => number | undefined;
|
|
7
13
|
export declare const getCredentialDisplayName: ({ verifiableCredential, localeBranding, }: {
|
|
8
14
|
verifiableCredential: VerifiableCredential;
|
|
@@ -15,5 +21,12 @@ export declare const getCredentialIssuerNameAndAlias: ({ verifiableCredential, i
|
|
|
15
21
|
issuerAlias: string;
|
|
16
22
|
issuerName: string;
|
|
17
23
|
};
|
|
18
|
-
export declare const toCredentialSummary: (verifiableCredential
|
|
24
|
+
export declare const toCredentialSummary: ({ verifiableCredential, hash, credentialRole, branding, issuer, subject, }: {
|
|
25
|
+
verifiableCredential: VerifiableCredential;
|
|
26
|
+
hash: string;
|
|
27
|
+
credentialRole: CredentialRole;
|
|
28
|
+
branding?: IBasicCredentialLocaleBranding[] | undefined;
|
|
29
|
+
issuer?: Party | undefined;
|
|
30
|
+
subject?: Party | undefined;
|
|
31
|
+
}) => Promise<CredentialSummary>;
|
|
19
32
|
export declare const selectAppLocaleBranding: (args: ISelectAppLocaleBrandingArgs) => Promise<IBasicCredentialLocaleBranding | IBasicIssuerLocaleBranding | undefined>;
|
|
@@ -102,101 +102,127 @@ function findCorrelationIdName(correlationId, parties, activeUser) {
|
|
|
102
102
|
if (activeUser) {
|
|
103
103
|
parties.push(activeUser);
|
|
104
104
|
}
|
|
105
|
-
return ((_b = (_a = allParties === null || allParties === void 0 ? void 0 : allParties.find(function (contact) {
|
|
105
|
+
return ((_b = (_a = allParties === null || allParties === void 0 ? void 0 : allParties.find(function (contact) {
|
|
106
|
+
return contact.identities.some(function (identity) { return identity.identifier.correlationId === correlationId; });
|
|
107
|
+
})) === null || _a === void 0 ? void 0 : _a.contact.displayName) !== null && _b !== void 0 ? _b : correlationId);
|
|
106
108
|
}
|
|
107
109
|
var getImageSize = function (image) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
-
var downloadedImage, imageSize;
|
|
109
|
-
return __generator(this, function (
|
|
110
|
-
switch (
|
|
110
|
+
var downloadedImage, imageSize, _a;
|
|
111
|
+
return __generator(this, function (_b) {
|
|
112
|
+
switch (_b.label) {
|
|
111
113
|
case 0: return [4, (0, ssi_sdk_core_1.downloadImage)(image)];
|
|
112
114
|
case 1:
|
|
113
|
-
downloadedImage =
|
|
115
|
+
downloadedImage = _b.sent();
|
|
114
116
|
imageSize = undefined;
|
|
117
|
+
_a = downloadedImage;
|
|
118
|
+
if (!_a) return [3, 3];
|
|
115
119
|
return [4, (0, utils_2.isImageAddress)(image)];
|
|
116
120
|
case 2:
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
_a = (_b.sent());
|
|
122
|
+
_b.label = 3;
|
|
119
123
|
case 3:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
case 4:
|
|
124
|
+
if (!_a) return [3, 5];
|
|
125
|
+
return [4, (0, ssi_sdk_core_1.getImageDimensions)(downloadedImage.base64Content)];
|
|
126
|
+
case 4:
|
|
127
|
+
imageSize = _b.sent();
|
|
128
|
+
_b.label = 5;
|
|
129
|
+
case 5: return [2, imageSize];
|
|
123
130
|
}
|
|
124
131
|
});
|
|
125
132
|
}); };
|
|
126
|
-
var toCredentialDetailsRow = function (
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
133
|
+
var toCredentialDetailsRow = function (_a) {
|
|
134
|
+
var object = _a.object, subject = _a.subject, issuer = _a.issuer;
|
|
135
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
136
|
+
var rows, _i, _b, _c, key, value, image, _d, _e, _f, _g, label, contacts, imageSize, _h;
|
|
137
|
+
var _j;
|
|
138
|
+
return __generator(this, function (_k) {
|
|
139
|
+
switch (_k.label) {
|
|
140
|
+
case 0:
|
|
141
|
+
rows = [];
|
|
142
|
+
_i = 0, _b = Object.entries(object);
|
|
143
|
+
_k.label = 1;
|
|
144
|
+
case 1:
|
|
145
|
+
if (!(_i < _b.length)) return [3, 12];
|
|
146
|
+
_c = _b[_i], key = _c[0], value = _c[1];
|
|
147
|
+
if (!key.toLowerCase().includes('image')) return [3, 3];
|
|
148
|
+
image = typeof value === 'string' ? value : value.id;
|
|
149
|
+
_e = (_d = rows).push;
|
|
150
|
+
_j = {
|
|
151
|
+
id: (0, uuid_1.v4)(),
|
|
152
|
+
label: 'image',
|
|
153
|
+
value: image
|
|
154
|
+
};
|
|
155
|
+
return [4, getImageSize(image)];
|
|
156
|
+
case 2:
|
|
157
|
+
_e.apply(_d, [(_j.imageSize = _k.sent(),
|
|
158
|
+
_j)]);
|
|
159
|
+
return [3, 11];
|
|
160
|
+
case 3:
|
|
161
|
+
if (key === 'type') {
|
|
162
|
+
rows.push({
|
|
163
|
+
id: (0, uuid_1.v4)(),
|
|
164
|
+
label: key,
|
|
165
|
+
value: value
|
|
166
|
+
});
|
|
167
|
+
return [3, 11];
|
|
168
|
+
}
|
|
169
|
+
_k.label = 4;
|
|
170
|
+
case 4:
|
|
171
|
+
if (!(typeof value !== 'string')) return [3, 6];
|
|
172
|
+
_g = (_f = rows).concat;
|
|
173
|
+
return [4, toCredentialDetailsRow({ object: value, subject: subject, issuer: issuer })];
|
|
174
|
+
case 5:
|
|
175
|
+
rows = _g.apply(_f, [_k.sent()]);
|
|
176
|
+
return [3, 11];
|
|
177
|
+
case 6:
|
|
178
|
+
if (key === '0' || value === undefined) {
|
|
179
|
+
return [3, 11];
|
|
180
|
+
}
|
|
181
|
+
label = key;
|
|
182
|
+
if (key === 'id' && value.startsWith('did:')) {
|
|
183
|
+
label = 'subject';
|
|
184
|
+
}
|
|
185
|
+
if (value.startsWith('did:')) {
|
|
186
|
+
contacts = __spreadArray(__spreadArray([], (issuer ? [issuer] : []), true), (subject ? [subject] : []), true);
|
|
187
|
+
value = findCorrelationIdName(value, contacts);
|
|
188
|
+
}
|
|
189
|
+
return [4, (0, utils_2.isImageAddress)(value)];
|
|
190
|
+
case 7:
|
|
191
|
+
if (!(_k.sent())) return [3, 9];
|
|
192
|
+
return [4, getImageSize(value)];
|
|
193
|
+
case 8:
|
|
194
|
+
_h = _k.sent();
|
|
195
|
+
return [3, 10];
|
|
196
|
+
case 9:
|
|
197
|
+
_h = undefined;
|
|
198
|
+
_k.label = 10;
|
|
199
|
+
case 10:
|
|
200
|
+
imageSize = _h;
|
|
153
201
|
rows.push({
|
|
154
202
|
id: (0, uuid_1.v4)(),
|
|
155
|
-
label:
|
|
156
|
-
value: value
|
|
203
|
+
label: label,
|
|
204
|
+
value: value,
|
|
205
|
+
imageSize: imageSize
|
|
157
206
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (value.startsWith('did:')) {
|
|
177
|
-
contacts = __spreadArray(__spreadArray([], (issuer ? [issuer] : []), true), (subject ? [subject] : []), true);
|
|
178
|
-
value = findCorrelationIdName(value, contacts);
|
|
179
|
-
}
|
|
180
|
-
_h = (_g = rows).push;
|
|
181
|
-
_k = {
|
|
182
|
-
id: (0, uuid_1.v4)(),
|
|
183
|
-
label: label,
|
|
184
|
-
value: value
|
|
185
|
-
};
|
|
186
|
-
return [4, getImageSize(value)];
|
|
187
|
-
case 7:
|
|
188
|
-
_h.apply(_g, [(_k.imageSize = _l.sent(),
|
|
189
|
-
_k)]);
|
|
190
|
-
_l.label = 8;
|
|
191
|
-
case 8:
|
|
192
|
-
_i++;
|
|
193
|
-
return [3, 1];
|
|
194
|
-
case 9: return [2, rows];
|
|
195
|
-
}
|
|
207
|
+
_k.label = 11;
|
|
208
|
+
case 11:
|
|
209
|
+
_i++;
|
|
210
|
+
return [3, 1];
|
|
211
|
+
case 12: return [2, rows];
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
var toNonPersistedCredentialSummary = function (_a) {
|
|
217
|
+
var verifiableCredential = _a.verifiableCredential, credentialRole = _a.credentialRole, branding = _a.branding, issuer = _a.issuer, subject = _a.subject;
|
|
218
|
+
return (0, exports.toCredentialSummary)({
|
|
219
|
+
verifiableCredential: verifiableCredential,
|
|
220
|
+
hash: (0, utils_1.computeEntryHash)(verifiableCredential),
|
|
221
|
+
credentialRole: credentialRole,
|
|
222
|
+
branding: branding,
|
|
223
|
+
issuer: issuer,
|
|
224
|
+
subject: subject
|
|
196
225
|
});
|
|
197
|
-
}); };
|
|
198
|
-
var toNonPersistedCredentialSummary = function (verifiableCredential, credentialRole, branding, issuer, subject) {
|
|
199
|
-
return (0, exports.toCredentialSummary)(verifiableCredential, (0, utils_1.computeEntryHash)(verifiableCredential), credentialRole, branding, issuer, subject);
|
|
200
226
|
};
|
|
201
227
|
exports.toNonPersistedCredentialSummary = toNonPersistedCredentialSummary;
|
|
202
228
|
var getDate = function () {
|
|
@@ -236,9 +262,7 @@ exports.getCredentialDisplayName = getCredentialDisplayName;
|
|
|
236
262
|
var getCredentialIssuerNameAndAlias = function (_a) {
|
|
237
263
|
var _b;
|
|
238
264
|
var verifiableCredential = _a.verifiableCredential, issuer = _a.issuer;
|
|
239
|
-
var issuerName = typeof verifiableCredential.issuer === 'string'
|
|
240
|
-
? verifiableCredential.issuer
|
|
241
|
-
: (_b = verifiableCredential.issuer) === null || _b === void 0 ? void 0 : _b.id;
|
|
265
|
+
var issuerName = typeof verifiableCredential.issuer === 'string' ? verifiableCredential.issuer : (_b = verifiableCredential.issuer) === null || _b === void 0 ? void 0 : _b.id;
|
|
242
266
|
var issuerAlias = undefined;
|
|
243
267
|
if (typeof (verifiableCredential === null || verifiableCredential === void 0 ? void 0 : verifiableCredential.issuer) === 'object') {
|
|
244
268
|
issuerAlias = verifiableCredential.issuer.name;
|
|
@@ -264,47 +288,54 @@ var getTermsOfUse = function (_a) {
|
|
|
264
288
|
return __assign((_a = {}, _a[type] = id, _a), rest);
|
|
265
289
|
});
|
|
266
290
|
};
|
|
267
|
-
var toCredentialSummary = function (
|
|
268
|
-
var
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
291
|
+
var toCredentialSummary = function (_a) {
|
|
292
|
+
var verifiableCredential = _a.verifiableCredential, hash = _a.hash, credentialRole = _a.credentialRole, branding = _a.branding, issuer = _a.issuer, subject = _a.subject;
|
|
293
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
294
|
+
var expirationDate, issueDate, localeBranding, credentialStatus, title, properties, logo, url, _b, issuerName, issuerAlias, termsOfUse;
|
|
295
|
+
var _c, _d;
|
|
296
|
+
return __generator(this, function (_e) {
|
|
297
|
+
switch (_e.label) {
|
|
298
|
+
case 0:
|
|
299
|
+
expirationDate = (_c = (0, exports.getDate)(verifiableCredential.expirationDate, verifiableCredential.validTo, verifiableCredential.exp)) !== null && _c !== void 0 ? _c : 0;
|
|
300
|
+
issueDate = (0, exports.getDate)(verifiableCredential.issuanceDate, verifiableCredential.validFrom, verifiableCredential.nbf, verifiableCredential.iat);
|
|
301
|
+
return [4, (0, exports.selectAppLocaleBranding)({ localeBranding: branding })];
|
|
302
|
+
case 1:
|
|
303
|
+
localeBranding = _e.sent();
|
|
304
|
+
credentialStatus = (0, utils_2.getCredentialStatus)(verifiableCredential);
|
|
305
|
+
title = (0, exports.getCredentialDisplayName)({ verifiableCredential: verifiableCredential, localeBranding: localeBranding });
|
|
306
|
+
return [4, toCredentialDetailsRow({
|
|
307
|
+
object: __assign(__assign({}, (_d = verifiableCredential.vc) === null || _d === void 0 ? void 0 : _d.credentialSubject), verifiableCredential.credentialSubject),
|
|
308
|
+
subject: subject,
|
|
309
|
+
issuer: issuer
|
|
310
|
+
})];
|
|
311
|
+
case 2:
|
|
312
|
+
properties = _e.sent();
|
|
313
|
+
logo = (0, utils_2.getIssuerLogo)(verifiableCredential, localeBranding);
|
|
314
|
+
url = typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
|
|
315
|
+
_b = (0, exports.getCredentialIssuerNameAndAlias)({ verifiableCredential: verifiableCredential, issuer: issuer }), issuerName = _b.issuerName, issuerAlias = _b.issuerAlias;
|
|
316
|
+
termsOfUse = getTermsOfUse({ verifiableCredential: verifiableCredential });
|
|
317
|
+
return [2, {
|
|
318
|
+
hash: hash,
|
|
319
|
+
id: verifiableCredential.id,
|
|
320
|
+
title: title,
|
|
321
|
+
credentialStatus: credentialStatus,
|
|
322
|
+
credentialRole: credentialRole,
|
|
323
|
+
issueDate: issueDate,
|
|
324
|
+
expirationDate: expirationDate,
|
|
325
|
+
properties: properties,
|
|
326
|
+
branding: localeBranding,
|
|
327
|
+
termsOfUse: termsOfUse,
|
|
328
|
+
issuer: {
|
|
329
|
+
name: issuerName,
|
|
330
|
+
alias: issuerAlias ? (issuerAlias.length > 50 ? "".concat(issuerAlias.substring(0, 50), "...") : issuerAlias) : '',
|
|
331
|
+
image: logo,
|
|
332
|
+
url: url
|
|
333
|
+
}
|
|
334
|
+
}];
|
|
335
|
+
}
|
|
336
|
+
});
|
|
306
337
|
});
|
|
307
|
-
}
|
|
338
|
+
};
|
|
308
339
|
exports.toCredentialSummary = toCredentialSummary;
|
|
309
340
|
var selectAppLocaleBranding = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
310
341
|
var appLocale, localeBranding, logo, imagePreloader, ReactNativeImagePreloader, WebImagePreloader, backgroundImage;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ui-components.credential-branding",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1-next.4+4fddd6c",
|
|
5
5
|
"description": "SSI UI components credential branding",
|
|
6
6
|
"repository": "git@github.com:Sphereon-Opensource/UI-Components.git",
|
|
7
7
|
"author": "Sphereon <dev@sphereon.com>",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@sphereon/ssi-sdk.core": "0.
|
|
32
|
-
"@sphereon/ssi-sdk.data-store": "0.
|
|
33
|
-
"@sphereon/ssi-types": "0.
|
|
34
|
-
"@sphereon/ui-components.core": "0.
|
|
31
|
+
"@sphereon/ssi-sdk.core": "0.29.0",
|
|
32
|
+
"@sphereon/ssi-sdk.data-store": "0.29.0",
|
|
33
|
+
"@sphereon/ssi-types": "0.29.0",
|
|
34
|
+
"@sphereon/ui-components.core": "0.3.1-next.4+4fddd6c",
|
|
35
35
|
"@veramo/core": "4.2.0",
|
|
36
36
|
"@veramo/utils": "4.2.0",
|
|
37
37
|
"i18n-js": "^3.8.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/i18n-js": "^3.8.4",
|
|
42
42
|
"@types/node": "^20.4.0",
|
|
43
|
-
"@types/react": "~18.2.
|
|
43
|
+
"@types/react": "~18.2.79",
|
|
44
44
|
"@types/uuid": "^9.0.8",
|
|
45
45
|
"react": "18.2.0",
|
|
46
46
|
"typescript": "4.9.5"
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": ">= 18"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "4fddd6c22fa6283b5e2504d00592c31c45d4cdf1"
|
|
52
52
|
}
|