@sphereon/ui-components.credential-branding 0.3.1-unstable.27 → 0.3.1-unstable.28
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.
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { VerifiableCredential } from '@veramo/core';
|
|
2
|
+
import { CredentialRole, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding, Party } from '@sphereon/ssi-sdk.data-store';
|
|
3
|
+
import { CredentialDetailsRow, CredentialSummary, ISelectAppLocaleBrandingArgs } from '../types';
|
|
4
|
+
import { ICredential } from '@sphereon/ssi-types';
|
|
5
|
+
export declare const toCredentialDetailsRow: ({ object, subject, issuer, }: {
|
|
6
|
+
object: Record<string, any>;
|
|
7
|
+
subject?: Party | undefined;
|
|
8
|
+
issuer?: Party | undefined;
|
|
9
|
+
}) => Promise<CredentialDetailsRow[]>;
|
|
10
|
+
export declare const toNonPersistedCredentialSummary: ({ verifiableCredential, credentialRole, branding, issuer, subject, }: {
|
|
11
|
+
verifiableCredential: ICredential | VerifiableCredential;
|
|
12
|
+
credentialRole: CredentialRole;
|
|
13
|
+
branding?: IBasicCredentialLocaleBranding[] | undefined;
|
|
14
|
+
issuer?: Party | undefined;
|
|
15
|
+
subject?: Party | undefined;
|
|
16
|
+
}) => Promise<CredentialSummary>;
|
|
5
17
|
export declare const getDate: (...dates: (number | string | undefined)[]) => number | undefined;
|
|
6
|
-
export declare const getCredentialDisplayName: (
|
|
7
|
-
|
|
18
|
+
export declare const getCredentialDisplayName: ({ verifiableCredential, localeBranding, }: {
|
|
19
|
+
verifiableCredential: VerifiableCredential;
|
|
20
|
+
localeBranding?: IBasicCredentialLocaleBranding | undefined;
|
|
21
|
+
}) => string;
|
|
22
|
+
export declare const getCredentialIssuerNameAndAlias: ({ verifiableCredential, issuer, }: {
|
|
23
|
+
verifiableCredential: VerifiableCredential;
|
|
24
|
+
issuer?: Party | undefined;
|
|
25
|
+
}) => {
|
|
8
26
|
issuerAlias: string;
|
|
9
27
|
issuerName: string;
|
|
10
28
|
};
|
|
11
|
-
export declare const toCredentialSummary: (
|
|
29
|
+
export declare const toCredentialSummary: ({ verifiableCredential, hash, credentialRole, branding, issuer, subject, }: {
|
|
30
|
+
verifiableCredential: VerifiableCredential;
|
|
31
|
+
hash: string;
|
|
32
|
+
credentialRole: CredentialRole;
|
|
33
|
+
branding?: IBasicCredentialLocaleBranding[] | undefined;
|
|
34
|
+
issuer?: Party | undefined;
|
|
35
|
+
subject?: Party | undefined;
|
|
36
|
+
}) => Promise<CredentialSummary>;
|
|
12
37
|
export declare const selectAppLocaleBranding: (args: ISelectAppLocaleBrandingArgs) => Promise<IBasicCredentialLocaleBranding | IBasicIssuerLocaleBranding | undefined>;
|
|
@@ -130,93 +130,81 @@ var getImageSize = function (image) { return __awaiter(void 0, void 0, void 0, f
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
}); };
|
|
133
|
-
var toCredentialDetailsRow = function (
|
|
134
|
-
var object
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
_k.label = 7;
|
|
197
|
-
case 7: return [2];
|
|
198
|
-
}
|
|
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, _d, _e, label, contacts, imageSize, _f;
|
|
137
|
+
return __generator(this, function (_g) {
|
|
138
|
+
switch (_g.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
rows = [];
|
|
141
|
+
if (!object) {
|
|
142
|
+
return [2, rows];
|
|
143
|
+
}
|
|
144
|
+
_i = 0, _b = Object.entries(object);
|
|
145
|
+
_g.label = 1;
|
|
146
|
+
case 1:
|
|
147
|
+
if (!(_i < _b.length)) return [3, 9];
|
|
148
|
+
_c = _b[_i], key = _c[0], value = _c[1];
|
|
149
|
+
if (!key) {
|
|
150
|
+
return [3, 8];
|
|
151
|
+
}
|
|
152
|
+
if (key === 'type') {
|
|
153
|
+
rows.push({
|
|
154
|
+
id: (0, uuid_1.v4)(),
|
|
155
|
+
label: key,
|
|
156
|
+
value: value
|
|
157
|
+
});
|
|
158
|
+
return [3, 8];
|
|
159
|
+
}
|
|
160
|
+
if (!(typeof value === 'object' && value !== null && value !== undefined)) return [3, 3];
|
|
161
|
+
_e = (_d = rows).concat;
|
|
162
|
+
return [4, (0, exports.toCredentialDetailsRow)({ object: value, subject: subject, issuer: issuer })];
|
|
163
|
+
case 2:
|
|
164
|
+
rows = _e.apply(_d, [_g.sent()]);
|
|
165
|
+
return [3, 8];
|
|
166
|
+
case 3:
|
|
167
|
+
if (key === '0' || value === undefined || value === null) {
|
|
168
|
+
return [3, 8];
|
|
169
|
+
}
|
|
170
|
+
label = key;
|
|
171
|
+
if (key === 'id' && typeof value === 'string' && value.startsWith('did:')) {
|
|
172
|
+
label = 'subject';
|
|
173
|
+
}
|
|
174
|
+
if (typeof value === 'string' && value.startsWith('did:')) {
|
|
175
|
+
contacts = __spreadArray(__spreadArray([], (issuer ? [issuer] : []), true), (subject ? [subject] : []), true);
|
|
176
|
+
value = findCorrelationIdName(value, contacts);
|
|
177
|
+
}
|
|
178
|
+
return [4, (0, utils_2.isImageAddress)(value)];
|
|
179
|
+
case 4:
|
|
180
|
+
if (!(_g.sent())) return [3, 6];
|
|
181
|
+
return [4, getImageSize(value)];
|
|
182
|
+
case 5:
|
|
183
|
+
_f = _g.sent();
|
|
184
|
+
return [3, 7];
|
|
185
|
+
case 6:
|
|
186
|
+
_f = undefined;
|
|
187
|
+
_g.label = 7;
|
|
188
|
+
case 7:
|
|
189
|
+
imageSize = _f;
|
|
190
|
+
rows.push({
|
|
191
|
+
id: (0, uuid_1.v4)(),
|
|
192
|
+
label: label,
|
|
193
|
+
value: value,
|
|
194
|
+
imageSize: imageSize
|
|
199
195
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
case 2:
|
|
208
|
-
_f.sent();
|
|
209
|
-
_f.label = 3;
|
|
210
|
-
case 3:
|
|
211
|
-
_i++;
|
|
212
|
-
return [3, 1];
|
|
213
|
-
case 4: return [2, rows];
|
|
214
|
-
}
|
|
196
|
+
_g.label = 8;
|
|
197
|
+
case 8:
|
|
198
|
+
_i++;
|
|
199
|
+
return [3, 1];
|
|
200
|
+
case 9: return [2, rows];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
215
203
|
});
|
|
216
|
-
}
|
|
204
|
+
};
|
|
217
205
|
exports.toCredentialDetailsRow = toCredentialDetailsRow;
|
|
218
|
-
var toNonPersistedCredentialSummary = function (
|
|
219
|
-
var verifiableCredential =
|
|
206
|
+
var toNonPersistedCredentialSummary = function (_a) {
|
|
207
|
+
var verifiableCredential = _a.verifiableCredential, credentialRole = _a.credentialRole, branding = _a.branding, issuer = _a.issuer, subject = _a.subject;
|
|
220
208
|
return (0, exports.toCredentialSummary)({
|
|
221
209
|
verifiableCredential: verifiableCredential,
|
|
222
210
|
hash: (0, utils_1.computeEntryHash)(verifiableCredential),
|
|
@@ -242,10 +230,10 @@ var getDate = function () {
|
|
|
242
230
|
return Math.round(new Date(date + '').valueOf() / ui_components_core_1.EPOCH_MILLISECONDS);
|
|
243
231
|
};
|
|
244
232
|
exports.getDate = getDate;
|
|
245
|
-
var getCredentialDisplayName = function (
|
|
246
|
-
var
|
|
247
|
-
var verifiableCredential =
|
|
248
|
-
var title = (
|
|
233
|
+
var getCredentialDisplayName = function (_a) {
|
|
234
|
+
var _b, _c;
|
|
235
|
+
var verifiableCredential = _a.verifiableCredential, localeBranding = _a.localeBranding;
|
|
236
|
+
var title = (_c = (_b = localeBranding === null || localeBranding === void 0 ? void 0 : localeBranding.alias) !== null && _b !== void 0 ? _b : verifiableCredential.name) !== null && _c !== void 0 ? _c : (!verifiableCredential.type ? 'unknown' : undefined);
|
|
249
237
|
if (verifiableCredential.type) {
|
|
250
238
|
var types = (0, utils_1.asArray)(verifiableCredential.type).filter(function (val) { return val !== 'VerifiableCredential'; });
|
|
251
239
|
if (types.length === 1) {
|
|
@@ -261,10 +249,10 @@ var getCredentialDisplayName = function (args) {
|
|
|
261
249
|
return title;
|
|
262
250
|
};
|
|
263
251
|
exports.getCredentialDisplayName = getCredentialDisplayName;
|
|
264
|
-
var getCredentialIssuerNameAndAlias = function (
|
|
265
|
-
var
|
|
266
|
-
var verifiableCredential =
|
|
267
|
-
var issuerName = typeof verifiableCredential.issuer === 'string' ? verifiableCredential.issuer : (
|
|
252
|
+
var getCredentialIssuerNameAndAlias = function (_a) {
|
|
253
|
+
var _b;
|
|
254
|
+
var verifiableCredential = _a.verifiableCredential, issuer = _a.issuer;
|
|
255
|
+
var issuerName = typeof verifiableCredential.issuer === 'string' ? verifiableCredential.issuer : (_b = verifiableCredential.issuer) === null || _b === void 0 ? void 0 : _b.id;
|
|
268
256
|
var issuerAlias = undefined;
|
|
269
257
|
if (typeof (verifiableCredential === null || verifiableCredential === void 0 ? void 0 : verifiableCredential.issuer) === 'object') {
|
|
270
258
|
issuerAlias = verifiableCredential.issuer.name;
|
|
@@ -278,8 +266,8 @@ var getCredentialIssuerNameAndAlias = function (args) {
|
|
|
278
266
|
return { issuerName: issuerName, issuerAlias: issuerAlias };
|
|
279
267
|
};
|
|
280
268
|
exports.getCredentialIssuerNameAndAlias = getCredentialIssuerNameAndAlias;
|
|
281
|
-
var getTermsOfUse = function (
|
|
282
|
-
var verifiableCredential =
|
|
269
|
+
var getTermsOfUse = function (_a) {
|
|
270
|
+
var verifiableCredential = _a.verifiableCredential;
|
|
283
271
|
if (!verifiableCredential.termsOfUse) {
|
|
284
272
|
return;
|
|
285
273
|
}
|
|
@@ -290,53 +278,54 @@ var getTermsOfUse = function (args) {
|
|
|
290
278
|
return __assign((_a = {}, _a[type] = id, _a), rest);
|
|
291
279
|
});
|
|
292
280
|
};
|
|
293
|
-
var toCredentialSummary = function (
|
|
294
|
-
var verifiableCredential
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
281
|
+
var toCredentialSummary = function (_a) {
|
|
282
|
+
var verifiableCredential = _a.verifiableCredential, hash = _a.hash, credentialRole = _a.credentialRole, branding = _a.branding, issuer = _a.issuer, subject = _a.subject;
|
|
283
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
284
|
+
var expirationDate, issueDate, localeBranding, credentialStatus, title, properties, logo, url, _b, issuerName, issuerAlias, termsOfUse;
|
|
285
|
+
var _c, _d;
|
|
286
|
+
return __generator(this, function (_e) {
|
|
287
|
+
switch (_e.label) {
|
|
288
|
+
case 0:
|
|
289
|
+
expirationDate = (_c = (0, exports.getDate)(verifiableCredential.expirationDate, verifiableCredential.validTo, verifiableCredential.exp)) !== null && _c !== void 0 ? _c : 0;
|
|
290
|
+
issueDate = (0, exports.getDate)(verifiableCredential.issuanceDate, verifiableCredential.validFrom, verifiableCredential.nbf, verifiableCredential.iat);
|
|
291
|
+
return [4, (0, exports.selectAppLocaleBranding)({ localeBranding: branding })];
|
|
292
|
+
case 1:
|
|
293
|
+
localeBranding = _e.sent();
|
|
294
|
+
credentialStatus = (0, utils_2.getCredentialStatus)(verifiableCredential);
|
|
295
|
+
title = (0, exports.getCredentialDisplayName)({ verifiableCredential: verifiableCredential, localeBranding: localeBranding });
|
|
296
|
+
return [4, (0, exports.toCredentialDetailsRow)({
|
|
297
|
+
object: __assign(__assign({}, (_d = verifiableCredential.vc) === null || _d === void 0 ? void 0 : _d.credentialSubject), verifiableCredential.credentialSubject),
|
|
298
|
+
subject: subject,
|
|
299
|
+
issuer: issuer
|
|
300
|
+
})];
|
|
301
|
+
case 2:
|
|
302
|
+
properties = _e.sent();
|
|
303
|
+
logo = (0, utils_2.getIssuerLogo)(verifiableCredential, localeBranding);
|
|
304
|
+
url = verifiableCredential.issuer && typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
|
|
305
|
+
_b = (0, exports.getCredentialIssuerNameAndAlias)({ verifiableCredential: verifiableCredential, issuer: issuer }), issuerName = _b.issuerName, issuerAlias = _b.issuerAlias;
|
|
306
|
+
termsOfUse = getTermsOfUse({ verifiableCredential: verifiableCredential });
|
|
307
|
+
return [2, {
|
|
308
|
+
hash: hash,
|
|
309
|
+
id: verifiableCredential.id,
|
|
310
|
+
title: title,
|
|
311
|
+
credentialStatus: credentialStatus,
|
|
312
|
+
credentialRole: credentialRole,
|
|
313
|
+
issueDate: issueDate,
|
|
314
|
+
expirationDate: expirationDate,
|
|
315
|
+
properties: properties,
|
|
316
|
+
branding: localeBranding,
|
|
317
|
+
termsOfUse: termsOfUse,
|
|
318
|
+
issuer: {
|
|
319
|
+
name: issuerName,
|
|
320
|
+
alias: issuerAlias ? (issuerAlias.length > 50 ? "".concat(issuerAlias.substring(0, 50), "...") : issuerAlias) : '',
|
|
321
|
+
image: logo,
|
|
322
|
+
url: url
|
|
323
|
+
}
|
|
324
|
+
}];
|
|
325
|
+
}
|
|
326
|
+
});
|
|
338
327
|
});
|
|
339
|
-
}
|
|
328
|
+
};
|
|
340
329
|
exports.toCredentialSummary = toCredentialSummary;
|
|
341
330
|
var selectAppLocaleBranding = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
342
331
|
var appLocale, localeBranding, logo, imagePreloader, ReactNativeImagePreloader, WebImagePreloader, backgroundImage;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { CredentialStatus, ImageSize, IssuerStatus } from '@sphereon/ui-components.core';
|
|
2
|
-
import { CredentialRole,
|
|
3
|
-
import { ICredential } from '@sphereon/ssi-types';
|
|
4
|
-
import { VerifiableCredential } from '@veramo/core';
|
|
2
|
+
import { CredentialRole, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding } from '@sphereon/ssi-sdk.data-store';
|
|
5
3
|
export type CredentialSummary = {
|
|
6
4
|
hash: string;
|
|
7
5
|
id?: string;
|
|
@@ -36,36 +34,3 @@ export type LabelStatus = CredentialStatus | IssuerStatus;
|
|
|
36
34
|
export interface ISelectAppLocaleBrandingArgs {
|
|
37
35
|
localeBranding?: Array<IBasicCredentialLocaleBranding | IBasicIssuerLocaleBranding>;
|
|
38
36
|
}
|
|
39
|
-
export type ToCredentialDetailsRowArgs = {
|
|
40
|
-
object: Record<string, any>;
|
|
41
|
-
parentKey?: string;
|
|
42
|
-
subject?: Party;
|
|
43
|
-
issuer?: Party;
|
|
44
|
-
branding?: Array<IBasicCredentialClaim>;
|
|
45
|
-
};
|
|
46
|
-
export type ToNonPersistedCredentialSummaryArgs = {
|
|
47
|
-
verifiableCredential: ICredential | VerifiableCredential;
|
|
48
|
-
credentialRole: CredentialRole;
|
|
49
|
-
branding?: Array<IBasicCredentialLocaleBranding>;
|
|
50
|
-
issuer?: Party;
|
|
51
|
-
subject?: Party;
|
|
52
|
-
};
|
|
53
|
-
export type GetCredentialDisplayNameArgs = {
|
|
54
|
-
verifiableCredential: VerifiableCredential;
|
|
55
|
-
localeBranding?: IBasicCredentialLocaleBranding;
|
|
56
|
-
};
|
|
57
|
-
export type GetCredentialIssuerNameAndAliasArgs = {
|
|
58
|
-
verifiableCredential: VerifiableCredential;
|
|
59
|
-
issuer?: Party;
|
|
60
|
-
};
|
|
61
|
-
export type GetTermsOfUseArgs = {
|
|
62
|
-
verifiableCredential: VerifiableCredential;
|
|
63
|
-
};
|
|
64
|
-
export type ToCredentialSummaryArgs = {
|
|
65
|
-
verifiableCredential: VerifiableCredential;
|
|
66
|
-
hash: string;
|
|
67
|
-
credentialRole: CredentialRole;
|
|
68
|
-
branding?: Array<IBasicCredentialLocaleBranding>;
|
|
69
|
-
issuer?: Party;
|
|
70
|
-
subject?: Party;
|
|
71
|
-
};
|
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.3.1-unstable.
|
|
4
|
+
"version": "0.3.1-unstable.28+70bbd0e",
|
|
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.3.1-unstable.
|
|
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-unstable.28+70bbd0e",
|
|
35
35
|
"@veramo/core": "4.2.0",
|
|
36
36
|
"@veramo/utils": "4.2.0",
|
|
37
37
|
"i18n-js": "^3.8.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": ">= 18"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "70bbd0e63c13733ff58f32dd2f570b62a74e2c8c"
|
|
55
55
|
}
|