@sphereon/ui-components.credential-branding 0.3.0 → 0.3.1-next.16

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.
@@ -102,113 +102,102 @@ 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) {
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);
105
+ return ((_b = (_a = allParties === null || allParties === void 0 ? void 0 : allParties.find(function (contact) { var _a; return (_a = contact.identities) === null || _a === void 0 ? void 0 : _a.some(function (identity) { return identity.identifier.correlationId === correlationId; }); })) === null || _a === void 0 ? void 0 : _a.contact.displayName) !== null && _b !== void 0 ? _b : correlationId);
108
106
  }
109
107
  var getImageSize = function (image) { return __awaiter(void 0, void 0, void 0, function () {
110
- var downloadedImage, imageSize, _a;
111
- return __generator(this, function (_b) {
112
- switch (_b.label) {
113
- case 0: return [4, (0, ssi_sdk_core_1.downloadImage)(image)];
108
+ var downloadedImage;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0: return [4, (0, utils_2.isImageAddress)(image)];
114
112
  case 1:
115
- downloadedImage = _b.sent();
116
- imageSize = undefined;
117
- _a = downloadedImage;
118
- if (!_a) return [3, 3];
119
- return [4, (0, utils_2.isImageAddress)(image)];
113
+ if (!(_a.sent())) {
114
+ return [2];
115
+ }
116
+ if (!(image.startsWith('http://') && !image.startsWith('https://'))) return [3, 3];
117
+ return [4, (0, ssi_sdk_core_1.downloadImage)(image)];
120
118
  case 2:
121
- _a = (_b.sent());
122
- _b.label = 3;
119
+ downloadedImage = _a.sent();
120
+ if (downloadedImage) {
121
+ return [2, (0, ssi_sdk_core_1.getImageDimensions)(downloadedImage.base64Content)];
122
+ }
123
+ return [3, 4];
123
124
  case 3:
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];
125
+ if (ui_components_core_1.IS_IMAGE_URI_REGEX.test(image)) {
126
+ return [2, (0, ssi_sdk_core_1.getImageDimensions)(image.split('base64,')[1])];
127
+ }
128
+ _a.label = 4;
129
+ case 4: return [2];
130
130
  }
131
131
  });
132
132
  }); };
133
133
  var toCredentialDetailsRow = function (_a) {
134
134
  var object = _a.object, subject = _a.subject, issuer = _a.issuer;
135
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) {
136
+ var rows, _i, _b, _c, key, value, _d, _e, label, contacts, imageSize, _f;
137
+ return __generator(this, function (_g) {
138
+ switch (_g.label) {
140
139
  case 0:
141
140
  rows = [];
141
+ if (!object) {
142
+ return [2, rows];
143
+ }
142
144
  _i = 0, _b = Object.entries(object);
143
- _k.label = 1;
145
+ _g.label = 1;
144
146
  case 1:
145
- if (!(_i < _b.length)) return [3, 12];
147
+ if (!(_i < _b.length)) return [3, 9];
146
148
  _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:
149
+ if (!key) {
150
+ return [3, 8];
151
+ }
161
152
  if (key === 'type') {
162
153
  rows.push({
163
154
  id: (0, uuid_1.v4)(),
164
155
  label: key,
165
156
  value: value
166
157
  });
167
- return [3, 11];
158
+ return [3, 8];
168
159
  }
169
- _k.label = 4;
170
- case 4:
171
- if (!(typeof value !== 'string')) return [3, 6];
172
- _g = (_f = rows).concat;
160
+ if (!(typeof value === 'object' && value !== null && value !== undefined)) return [3, 3];
161
+ _e = (_d = rows).concat;
173
162
  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];
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];
180
169
  }
181
170
  label = key;
182
- if (key === 'id' && value.startsWith('did:')) {
171
+ if (key === 'id' && typeof value === 'string' && value.startsWith('did:')) {
183
172
  label = 'subject';
184
173
  }
185
- if (value.startsWith('did:')) {
174
+ if (typeof value === 'string' && value.startsWith('did:')) {
186
175
  contacts = __spreadArray(__spreadArray([], (issuer ? [issuer] : []), true), (subject ? [subject] : []), true);
187
176
  value = findCorrelationIdName(value, contacts);
188
177
  }
189
178
  return [4, (0, utils_2.isImageAddress)(value)];
190
- case 7:
191
- if (!(_k.sent())) return [3, 9];
179
+ case 4:
180
+ if (!(_g.sent())) return [3, 6];
192
181
  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;
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;
201
190
  rows.push({
202
191
  id: (0, uuid_1.v4)(),
203
192
  label: label,
204
193
  value: value,
205
194
  imageSize: imageSize
206
195
  });
207
- _k.label = 11;
208
- case 11:
196
+ _g.label = 8;
197
+ case 8:
209
198
  _i++;
210
199
  return [3, 1];
211
- case 12: return [2, rows];
200
+ case 9: return [2, rows];
212
201
  }
213
202
  });
214
203
  });
@@ -311,7 +300,7 @@ var toCredentialSummary = function (_a) {
311
300
  case 2:
312
301
  properties = _e.sent();
313
302
  logo = (0, utils_2.getIssuerLogo)(verifiableCredential, localeBranding);
314
- url = typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
303
+ url = verifiableCredential.issuer && typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
315
304
  _b = (0, exports.getCredentialIssuerNameAndAlias)({ verifiableCredential: verifiableCredential, issuer: issuer }), issuerName = _b.issuerName, issuerAlias = _b.issuerAlias;
316
305
  termsOfUse = getTermsOfUse({ verifiableCredential: verifiableCredential });
317
306
  return [2, {
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.0",
4
+ "version": "0.3.1-next.16+de29629",
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>",
@@ -31,7 +31,7 @@
31
31
  "@sphereon/ssi-sdk.core": "0.29.0",
32
32
  "@sphereon/ssi-sdk.data-store": "0.29.0",
33
33
  "@sphereon/ssi-types": "0.29.0",
34
- "@sphereon/ui-components.core": "0.3.0",
34
+ "@sphereon/ui-components.core": "0.3.1-next.16+de29629",
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
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": "bd5efc629991766c207eeec3f8ca2a9337a4e61f"
54
+ "gitHead": "de2962975c215ed93bc920674564e8b871ee496e"
52
55
  }