@sphereon/ui-components.credential-branding 0.2.1-unstable.97 → 0.3.1-next.14
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.
- package/dist/details/CredentialDetails.d.ts +15 -2
- package/dist/details/CredentialDetails.js +145 -123
- package/package.json +10 -7
|
@@ -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,118 @@ 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
|
|
110
|
+
var downloadedImage;
|
|
109
111
|
return __generator(this, function (_a) {
|
|
110
112
|
switch (_a.label) {
|
|
111
|
-
case 0: return [4, (0,
|
|
113
|
+
case 0: return [4, (0, utils_2.isImageAddress)(image)];
|
|
112
114
|
case 1:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
if (!(_a.sent())) {
|
|
116
|
+
return [2];
|
|
117
|
+
}
|
|
118
|
+
if (!(image.startsWith('http://') && !image.startsWith('https://'))) return [3, 3];
|
|
119
|
+
return [4, (0, ssi_sdk_core_1.downloadImage)(image)];
|
|
116
120
|
case 2:
|
|
117
|
-
|
|
118
|
-
|
|
121
|
+
downloadedImage = _a.sent();
|
|
122
|
+
if (downloadedImage) {
|
|
123
|
+
return [2, (0, ssi_sdk_core_1.getImageDimensions)(downloadedImage.base64Content)];
|
|
124
|
+
}
|
|
125
|
+
return [3, 4];
|
|
119
126
|
case 3:
|
|
120
|
-
|
|
127
|
+
if (ui_components_core_1.IS_IMAGE_URI_REGEX.test(image)) {
|
|
128
|
+
return [2, (0, ssi_sdk_core_1.getImageDimensions)(image.split('base64,')[1])];
|
|
129
|
+
}
|
|
121
130
|
_a.label = 4;
|
|
122
|
-
case 4: return [2
|
|
131
|
+
case 4: return [2];
|
|
123
132
|
}
|
|
124
133
|
});
|
|
125
134
|
}); };
|
|
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
|
-
|
|
135
|
+
var toCredentialDetailsRow = function (_a) {
|
|
136
|
+
var object = _a.object, subject = _a.subject, issuer = _a.issuer;
|
|
137
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
138
|
+
var rows, _i, _b, _c, key, value, _d, _e, label, contacts, imageSize, _f;
|
|
139
|
+
return __generator(this, function (_g) {
|
|
140
|
+
switch (_g.label) {
|
|
141
|
+
case 0:
|
|
142
|
+
rows = [];
|
|
143
|
+
if (!object) {
|
|
144
|
+
return [2, rows];
|
|
145
|
+
}
|
|
146
|
+
_i = 0, _b = Object.entries(object);
|
|
147
|
+
_g.label = 1;
|
|
148
|
+
case 1:
|
|
149
|
+
if (!(_i < _b.length)) return [3, 9];
|
|
150
|
+
_c = _b[_i], key = _c[0], value = _c[1];
|
|
151
|
+
if (!key) {
|
|
152
|
+
return [3, 8];
|
|
153
|
+
}
|
|
154
|
+
if (key === 'type') {
|
|
155
|
+
rows.push({
|
|
156
|
+
id: (0, uuid_1.v4)(),
|
|
157
|
+
label: key,
|
|
158
|
+
value: value
|
|
159
|
+
});
|
|
160
|
+
return [3, 8];
|
|
161
|
+
}
|
|
162
|
+
if (!(typeof value === 'object' && value !== null && value !== undefined)) return [3, 3];
|
|
163
|
+
_e = (_d = rows).concat;
|
|
164
|
+
return [4, toCredentialDetailsRow({ object: value, subject: subject, issuer: issuer })];
|
|
165
|
+
case 2:
|
|
166
|
+
rows = _e.apply(_d, [_g.sent()]);
|
|
167
|
+
return [3, 8];
|
|
168
|
+
case 3:
|
|
169
|
+
if (key === '0' || value === undefined || value === null) {
|
|
170
|
+
return [3, 8];
|
|
171
|
+
}
|
|
172
|
+
label = key;
|
|
173
|
+
if (key === 'id' && typeof value === 'string' && value.startsWith('did:')) {
|
|
174
|
+
label = 'subject';
|
|
175
|
+
}
|
|
176
|
+
if (typeof value === 'string' && value.startsWith('did:')) {
|
|
177
|
+
contacts = __spreadArray(__spreadArray([], (issuer ? [issuer] : []), true), (subject ? [subject] : []), true);
|
|
178
|
+
value = findCorrelationIdName(value, contacts);
|
|
179
|
+
}
|
|
180
|
+
return [4, (0, utils_2.isImageAddress)(value)];
|
|
181
|
+
case 4:
|
|
182
|
+
if (!(_g.sent())) return [3, 6];
|
|
183
|
+
return [4, getImageSize(value)];
|
|
184
|
+
case 5:
|
|
185
|
+
_f = _g.sent();
|
|
186
|
+
return [3, 7];
|
|
187
|
+
case 6:
|
|
188
|
+
_f = undefined;
|
|
189
|
+
_g.label = 7;
|
|
190
|
+
case 7:
|
|
191
|
+
imageSize = _f;
|
|
153
192
|
rows.push({
|
|
154
193
|
id: (0, uuid_1.v4)(),
|
|
155
|
-
label:
|
|
156
|
-
value: value
|
|
194
|
+
label: label,
|
|
195
|
+
value: value,
|
|
196
|
+
imageSize: imageSize
|
|
157
197
|
});
|
|
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
|
-
}
|
|
198
|
+
_g.label = 8;
|
|
199
|
+
case 8:
|
|
200
|
+
_i++;
|
|
201
|
+
return [3, 1];
|
|
202
|
+
case 9: return [2, rows];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
var toNonPersistedCredentialSummary = function (_a) {
|
|
208
|
+
var verifiableCredential = _a.verifiableCredential, credentialRole = _a.credentialRole, branding = _a.branding, issuer = _a.issuer, subject = _a.subject;
|
|
209
|
+
return (0, exports.toCredentialSummary)({
|
|
210
|
+
verifiableCredential: verifiableCredential,
|
|
211
|
+
hash: (0, utils_1.computeEntryHash)(verifiableCredential),
|
|
212
|
+
credentialRole: credentialRole,
|
|
213
|
+
branding: branding,
|
|
214
|
+
issuer: issuer,
|
|
215
|
+
subject: subject
|
|
196
216
|
});
|
|
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
217
|
};
|
|
201
218
|
exports.toNonPersistedCredentialSummary = toNonPersistedCredentialSummary;
|
|
202
219
|
var getDate = function () {
|
|
@@ -236,9 +253,7 @@ exports.getCredentialDisplayName = getCredentialDisplayName;
|
|
|
236
253
|
var getCredentialIssuerNameAndAlias = function (_a) {
|
|
237
254
|
var _b;
|
|
238
255
|
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;
|
|
256
|
+
var issuerName = typeof verifiableCredential.issuer === 'string' ? verifiableCredential.issuer : (_b = verifiableCredential.issuer) === null || _b === void 0 ? void 0 : _b.id;
|
|
242
257
|
var issuerAlias = undefined;
|
|
243
258
|
if (typeof (verifiableCredential === null || verifiableCredential === void 0 ? void 0 : verifiableCredential.issuer) === 'object') {
|
|
244
259
|
issuerAlias = verifiableCredential.issuer.name;
|
|
@@ -264,47 +279,54 @@ var getTermsOfUse = function (_a) {
|
|
|
264
279
|
return __assign((_a = {}, _a[type] = id, _a), rest);
|
|
265
280
|
});
|
|
266
281
|
};
|
|
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
|
-
|
|
282
|
+
var toCredentialSummary = function (_a) {
|
|
283
|
+
var verifiableCredential = _a.verifiableCredential, hash = _a.hash, credentialRole = _a.credentialRole, branding = _a.branding, issuer = _a.issuer, subject = _a.subject;
|
|
284
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
285
|
+
var expirationDate, issueDate, localeBranding, credentialStatus, title, properties, logo, url, _b, issuerName, issuerAlias, termsOfUse;
|
|
286
|
+
var _c, _d;
|
|
287
|
+
return __generator(this, function (_e) {
|
|
288
|
+
switch (_e.label) {
|
|
289
|
+
case 0:
|
|
290
|
+
expirationDate = (_c = (0, exports.getDate)(verifiableCredential.expirationDate, verifiableCredential.validTo, verifiableCredential.exp)) !== null && _c !== void 0 ? _c : 0;
|
|
291
|
+
issueDate = (0, exports.getDate)(verifiableCredential.issuanceDate, verifiableCredential.validFrom, verifiableCredential.nbf, verifiableCredential.iat);
|
|
292
|
+
return [4, (0, exports.selectAppLocaleBranding)({ localeBranding: branding })];
|
|
293
|
+
case 1:
|
|
294
|
+
localeBranding = _e.sent();
|
|
295
|
+
credentialStatus = (0, utils_2.getCredentialStatus)(verifiableCredential);
|
|
296
|
+
title = (0, exports.getCredentialDisplayName)({ verifiableCredential: verifiableCredential, localeBranding: localeBranding });
|
|
297
|
+
return [4, toCredentialDetailsRow({
|
|
298
|
+
object: __assign(__assign({}, (_d = verifiableCredential.vc) === null || _d === void 0 ? void 0 : _d.credentialSubject), verifiableCredential.credentialSubject),
|
|
299
|
+
subject: subject,
|
|
300
|
+
issuer: issuer
|
|
301
|
+
})];
|
|
302
|
+
case 2:
|
|
303
|
+
properties = _e.sent();
|
|
304
|
+
logo = (0, utils_2.getIssuerLogo)(verifiableCredential, localeBranding);
|
|
305
|
+
url = verifiableCredential.issuer && typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
|
|
306
|
+
_b = (0, exports.getCredentialIssuerNameAndAlias)({ verifiableCredential: verifiableCredential, issuer: issuer }), issuerName = _b.issuerName, issuerAlias = _b.issuerAlias;
|
|
307
|
+
termsOfUse = getTermsOfUse({ verifiableCredential: verifiableCredential });
|
|
308
|
+
return [2, {
|
|
309
|
+
hash: hash,
|
|
310
|
+
id: verifiableCredential.id,
|
|
311
|
+
title: title,
|
|
312
|
+
credentialStatus: credentialStatus,
|
|
313
|
+
credentialRole: credentialRole,
|
|
314
|
+
issueDate: issueDate,
|
|
315
|
+
expirationDate: expirationDate,
|
|
316
|
+
properties: properties,
|
|
317
|
+
branding: localeBranding,
|
|
318
|
+
termsOfUse: termsOfUse,
|
|
319
|
+
issuer: {
|
|
320
|
+
name: issuerName,
|
|
321
|
+
alias: issuerAlias ? (issuerAlias.length > 50 ? "".concat(issuerAlias.substring(0, 50), "...") : issuerAlias) : '',
|
|
322
|
+
image: logo,
|
|
323
|
+
url: url
|
|
324
|
+
}
|
|
325
|
+
}];
|
|
326
|
+
}
|
|
327
|
+
});
|
|
306
328
|
});
|
|
307
|
-
}
|
|
329
|
+
};
|
|
308
330
|
exports.toCredentialSummary = toCredentialSummary;
|
|
309
331
|
var selectAppLocaleBranding = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
310
332
|
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.14+a2c5adf",
|
|
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.14+a2c5adf",
|
|
35
35
|
"@veramo/core": "4.2.0",
|
|
36
36
|
"@veramo/utils": "4.2.0",
|
|
37
37
|
"i18n-js": "^3.8.0",
|
|
@@ -39,14 +39,17 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/i18n-js": "^3.8.4",
|
|
42
|
+
"@types/jest": "^29.5.12",
|
|
42
43
|
"@types/node": "^20.4.0",
|
|
43
|
-
"@types/react": "~18.2.
|
|
44
|
+
"@types/react": "~18.2.79",
|
|
44
45
|
"@types/uuid": "^9.0.8",
|
|
46
|
+
"jest": "^29.7.0",
|
|
45
47
|
"react": "18.2.0",
|
|
48
|
+
"ts-jest": "^29.2.5",
|
|
46
49
|
"typescript": "4.9.5"
|
|
47
50
|
},
|
|
48
51
|
"peerDependencies": {
|
|
49
52
|
"react": ">= 18"
|
|
50
53
|
},
|
|
51
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "a2c5adfd01626310b0585f531315024ef5b7e1b1"
|
|
52
55
|
}
|