@sphereon/ui-components.credential-branding 0.2.1-unstable.87 → 0.2.1-unstable.89

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,8 +1,8 @@
1
- import { UniqueVerifiableCredential, VerifiableCredential } from '@veramo/core';
1
+ import { VerifiableCredential } from '@veramo/core';
2
2
  import { IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding, Party } from '@sphereon/ssi-sdk.data-store';
3
- import { ICredential } from '@sphereon/ssi-types';
4
3
  import { CredentialSummary, ISelectAppLocaleBrandingArgs } from '../types';
5
- export declare const toNonPersistedCredentialSummary: (verifiableCredential: ICredential | VerifiableCredential, branding?: Array<IBasicCredentialLocaleBranding>, issuer?: Party, subject?: Party) => Promise<CredentialSummary>;
4
+ import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store';
5
+ export declare const toNonPersistedCredentialSummary: (digitalCredential: UniqueDigitalCredential, branding?: Array<IBasicCredentialLocaleBranding>, issuer?: Party, subject?: Party) => Promise<CredentialSummary>;
6
6
  export declare const getDate: (...dates: (number | string | undefined)[]) => number | undefined;
7
7
  export declare const getCredentialDisplayName: ({ verifiableCredential, localeBranding, }: {
8
8
  verifiableCredential: VerifiableCredential;
@@ -15,5 +15,5 @@ export declare const getCredentialIssuerNameAndAlias: ({ verifiableCredential, i
15
15
  issuerAlias: string;
16
16
  issuerName: string;
17
17
  };
18
- export declare const toCredentialSummary: ({ hash, verifiableCredential }: UniqueVerifiableCredential, branding?: Array<IBasicCredentialLocaleBranding>, issuer?: Party, subject?: Party) => Promise<CredentialSummary>;
18
+ export declare const toCredentialSummary: ({ hash, uniformVerifiableCredential }: UniqueDigitalCredential, branding?: Array<IBasicCredentialLocaleBranding>, issuer?: Party, subject?: Party) => Promise<CredentialSummary>;
19
19
  export declare const selectAppLocaleBranding: (args: ISelectAppLocaleBrandingArgs) => Promise<IBasicCredentialLocaleBranding | IBasicIssuerLocaleBranding | undefined>;
@@ -104,62 +104,70 @@ function findCorrelationIdName(correlationId, parties, activeUser) {
104
104
  }
105
105
  return ((_b = (_a = allParties.find(function (contact) { return contact.identities.some(function (identity) { return identity.identifier.correlationId === correlationId; }); })) === null || _a === void 0 ? void 0 : _a.contact.displayName) !== null && _b !== void 0 ? _b : correlationId);
106
106
  }
107
+ var getImageSize = function (image) { return __awaiter(void 0, void 0, void 0, function () {
108
+ var downloadedImage, imageSize;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0: return [4, (0, ssi_sdk_core_1.downloadImage)(image)];
112
+ case 1:
113
+ downloadedImage = _a.sent();
114
+ imageSize = undefined;
115
+ return [4, (0, utils_2.isImageAddress)(image)];
116
+ case 2:
117
+ if (!((_a.sent()) && downloadedImage)) return [3, 4];
118
+ return [4, (0, ssi_sdk_core_1.getImageDimensions)(downloadedImage.base64Content)];
119
+ case 3:
120
+ imageSize = _a.sent();
121
+ _a.label = 4;
122
+ case 4: return [2, imageSize];
123
+ }
124
+ });
125
+ }); };
107
126
  var toCredentialDetailsRow = function (object, subject, issuer) { return __awaiter(void 0, void 0, void 0, function () {
108
- var rows, _i, _a, _b, key, value, image, _c, _d, _e, _f, _g, _h, label, contacts, _j, _k, _l, _m;
109
- var _o, _p;
110
- return __generator(this, function (_q) {
111
- switch (_q.label) {
127
+ var rows, _i, _a, _b, key, value, image, _c, _d, _e, _f, label, contacts, _g, _h;
128
+ var _j, _k;
129
+ return __generator(this, function (_l) {
130
+ switch (_l.label) {
112
131
  case 0:
113
132
  rows = [];
114
133
  _i = 0, _a = Object.entries(object);
115
- _q.label = 1;
134
+ _l.label = 1;
116
135
  case 1:
117
- if (!(_i < _a.length)) return [3, 17];
136
+ if (!(_i < _a.length)) return [3, 9];
118
137
  _b = _a[_i], key = _b[0], value = _b[1];
119
- if (!key.toLowerCase().includes('image')) return [3, 7];
138
+ if (!key.toLowerCase().includes('image')) return [3, 3];
120
139
  image = typeof value === 'string' ? value : value.id;
121
140
  _d = (_c = rows).push;
122
- _o = {
141
+ _j = {
123
142
  id: (0, uuid_1.v4)(),
124
143
  label: 'image',
125
144
  value: image
126
145
  };
127
- return [4, (0, utils_2.isImageAddress)(image)];
146
+ return [4, getImageSize(image)];
128
147
  case 2:
129
- if (!(_q.sent())) return [3, 5];
130
- _f = ssi_sdk_core_1.getImageDimensions;
131
- return [4, (0, ssi_sdk_core_1.downloadImage)(image)];
132
- case 3: return [4, _f.apply(void 0, [(_q.sent()).base64Content])];
133
- case 4:
134
- _e = _q.sent();
135
- return [3, 6];
136
- case 5:
137
- _e = undefined;
138
- _q.label = 6;
139
- case 6:
140
- _d.apply(_c, [(_o.imageSize = _e,
141
- _o)]);
142
- return [3, 16];
143
- case 7:
148
+ _d.apply(_c, [(_j.imageSize = _l.sent(),
149
+ _j)]);
150
+ return [3, 8];
151
+ case 3:
144
152
  if (key === 'type') {
145
153
  rows.push({
146
154
  id: (0, uuid_1.v4)(),
147
155
  label: key,
148
156
  value: value
149
157
  });
150
- return [3, 16];
158
+ return [3, 8];
151
159
  }
152
- _q.label = 8;
153
- case 8:
154
- if (!(typeof value !== 'string')) return [3, 10];
155
- _h = (_g = rows).concat;
160
+ _l.label = 4;
161
+ case 4:
162
+ if (!(typeof value !== 'string')) return [3, 6];
163
+ _f = (_e = rows).concat;
156
164
  return [4, toCredentialDetailsRow(value, subject, issuer)];
157
- case 9:
158
- rows = _h.apply(_g, [_q.sent()]);
159
- return [3, 16];
160
- case 10:
165
+ case 5:
166
+ rows = _f.apply(_e, [_l.sent()]);
167
+ return [3, 8];
168
+ case 6:
161
169
  if (key === '0' || value === undefined) {
162
- return [3, 16];
170
+ return [3, 8];
163
171
  }
164
172
  label = key;
165
173
  if (key === 'id' && value.startsWith('did:')) {
@@ -169,40 +177,26 @@ var toCredentialDetailsRow = function (object, subject, issuer) { return __await
169
177
  contacts = __spreadArray(__spreadArray([], (issuer ? [issuer] : []), true), (subject ? [subject] : []), true);
170
178
  value = findCorrelationIdName(value, contacts);
171
179
  }
172
- _k = (_j = rows).push;
173
- _p = {
180
+ _h = (_g = rows).push;
181
+ _k = {
174
182
  id: (0, uuid_1.v4)(),
175
183
  label: label,
176
184
  value: value
177
185
  };
178
- return [4, (0, utils_2.isImageAddress)(value)];
179
- case 11:
180
- if (!(_q.sent())) return [3, 14];
181
- _m = ssi_sdk_core_1.getImageDimensions;
182
- return [4, (0, ssi_sdk_core_1.downloadImage)(value)];
183
- case 12: return [4, _m.apply(void 0, [(_q.sent()).base64Content])];
184
- case 13:
185
- _l = _q.sent();
186
- return [3, 15];
187
- case 14:
188
- _l = undefined;
189
- _q.label = 15;
190
- case 15:
191
- _k.apply(_j, [(_p.imageSize = _l,
192
- _p)]);
193
- _q.label = 16;
194
- case 16:
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:
195
192
  _i++;
196
193
  return [3, 1];
197
- case 17: return [2, rows];
194
+ case 9: return [2, rows];
198
195
  }
199
196
  });
200
197
  }); };
201
- var toNonPersistedCredentialSummary = function (verifiableCredential, branding, issuer, subject) {
202
- return (0, exports.toCredentialSummary)({
203
- verifiableCredential: verifiableCredential,
204
- hash: (0, utils_1.computeEntryHash)(verifiableCredential)
205
- }, branding, issuer, subject);
198
+ var toNonPersistedCredentialSummary = function (digitalCredential, branding, issuer, subject) {
199
+ return (0, exports.toCredentialSummary)(digitalCredential, branding, issuer, subject);
206
200
  };
207
201
  exports.toNonPersistedCredentialSummary = toNonPersistedCredentialSummary;
208
202
  var getDate = function () {
@@ -242,7 +236,9 @@ exports.getCredentialDisplayName = getCredentialDisplayName;
242
236
  var getCredentialIssuerNameAndAlias = function (_a) {
243
237
  var _b;
244
238
  var verifiableCredential = _a.verifiableCredential, issuer = _a.issuer;
245
- var issuerName = typeof verifiableCredential.issuer === 'string' ? verifiableCredential.issuer : (_b = verifiableCredential.issuer) === null || _b === void 0 ? void 0 : _b.id;
239
+ var issuerName = typeof verifiableCredential.issuer === 'string'
240
+ ? verifiableCredential.issuer
241
+ : (_b = verifiableCredential.issuer) === null || _b === void 0 ? void 0 : _b.id;
246
242
  var issuerAlias = undefined;
247
243
  if (typeof (verifiableCredential === null || verifiableCredential === void 0 ? void 0 : verifiableCredential.issuer) === 'object') {
248
244
  issuerAlias = verifiableCredential.issuer.name;
@@ -269,23 +265,24 @@ var getTermsOfUse = function (_a) {
269
265
  });
270
266
  };
271
267
  var toCredentialSummary = function (_a, branding, issuer, subject) {
272
- var hash = _a.hash, verifiableCredential = _a.verifiableCredential;
268
+ var hash = _a.hash, uniformVerifiableCredential = _a.uniformVerifiableCredential;
273
269
  return __awaiter(void 0, void 0, void 0, function () {
274
- var expirationDate, issueDate, localeBranding, credentialStatus, title, properties, logo, url, _b, issuerName, issuerAlias, termsOfUse;
275
- var _c, _d;
276
- return __generator(this, function (_e) {
277
- switch (_e.label) {
270
+ var verifiableCredential, expirationDate, issueDate, localeBranding, credentialStatus, title, properties, logo, url, _b, issuerName, issuerAlias, termsOfUse;
271
+ var _c, _d, _e;
272
+ return __generator(this, function (_f) {
273
+ switch (_f.label) {
278
274
  case 0:
279
- expirationDate = (_c = (0, exports.getDate)(verifiableCredential.expirationDate, verifiableCredential.validTo, verifiableCredential.exp)) !== null && _c !== void 0 ? _c : 0;
275
+ verifiableCredential = (_c = uniformVerifiableCredential) !== null && _c !== void 0 ? _c : (0, ui_components_core_1.orElseThrow)("uniformVerifiableCredential is undefined");
276
+ expirationDate = (_d = (0, exports.getDate)(verifiableCredential.expirationDate, verifiableCredential.validTo, verifiableCredential.exp)) !== null && _d !== void 0 ? _d : 0;
280
277
  issueDate = (0, exports.getDate)(verifiableCredential.issuanceDate, verifiableCredential.validFrom, verifiableCredential.nbf, verifiableCredential.iat);
281
278
  return [4, (0, exports.selectAppLocaleBranding)({ localeBranding: branding })];
282
279
  case 1:
283
- localeBranding = _e.sent();
280
+ localeBranding = _f.sent();
284
281
  credentialStatus = (0, utils_2.getCredentialStatus)(verifiableCredential);
285
282
  title = (0, exports.getCredentialDisplayName)({ verifiableCredential: verifiableCredential, localeBranding: localeBranding });
286
- return [4, toCredentialDetailsRow(__assign(__assign({}, (_d = verifiableCredential.vc) === null || _d === void 0 ? void 0 : _d.credentialSubject), verifiableCredential.credentialSubject), subject, issuer)];
283
+ return [4, toCredentialDetailsRow(__assign(__assign({}, (_e = verifiableCredential.vc) === null || _e === void 0 ? void 0 : _e.credentialSubject), verifiableCredential.credentialSubject), subject, issuer)];
287
284
  case 2:
288
- properties = _e.sent();
285
+ properties = _f.sent();
289
286
  logo = (0, utils_2.getIssuerLogo)(verifiableCredential, localeBranding);
290
287
  url = typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
291
288
  _b = (0, exports.getCredentialIssuerNameAndAlias)({ verifiableCredential: verifiableCredential, issuer: issuer }), issuerName = _b.issuerName, issuerAlias = _b.issuerAlias;
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.2.1-unstable.87+6894ab8",
4
+ "version": "0.2.1-unstable.89+ad8f031",
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,11 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@sphereon/ssi-sdk.core": "^0.28.0",
32
- "@sphereon/ssi-sdk.data-store": "^0.28.0",
33
- "@sphereon/ssi-types": "^0.28.0",
34
- "@sphereon/ui-components.core": "0.2.1-unstable.87+6894ab8",
31
+ "@sphereon/ssi-sdk.core": "00.28.1-next.39",
32
+ "@sphereon/ssi-sdk.credential-store": "00.28.1-next.39",
33
+ "@sphereon/ssi-sdk.data-store": "00.28.1-next.39",
34
+ "@sphereon/ssi-types": "00.28.1-next.39",
35
+ "@sphereon/ui-components.core": "0.2.1-unstable.89+ad8f031",
35
36
  "@veramo/core": "4.2.0",
36
37
  "@veramo/utils": "4.2.0",
37
38
  "i18n-js": "^3.8.0",
@@ -40,7 +41,7 @@
40
41
  "devDependencies": {
41
42
  "@types/i18n-js": "^3.8.4",
42
43
  "@types/node": "^20.4.0",
43
- "@types/react": "~18.2.79",
44
+ "@types/react": "~18.2.67",
44
45
  "@types/uuid": "^9.0.8",
45
46
  "react": "18.2.0",
46
47
  "typescript": "4.9.5"
@@ -48,5 +49,5 @@
48
49
  "peerDependencies": {
49
50
  "react": ">= 18"
50
51
  },
51
- "gitHead": "6894ab8498cb051bfdaf85973cb44e3f419956ce"
52
+ "gitHead": "ad8f031641f8d58a427323fe7d35baf11e98384b"
52
53
  }