@sphereon/ui-components.credential-branding 0.3.0 → 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.
@@ -107,108 +107,99 @@ function findCorrelationIdName(correlationId, parties, activeUser) {
107
107
  })) === null || _a === void 0 ? void 0 : _a.contact.displayName) !== null && _b !== void 0 ? _b : correlationId);
108
108
  }
109
109
  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)];
110
+ var downloadedImage;
111
+ return __generator(this, function (_a) {
112
+ switch (_a.label) {
113
+ case 0: return [4, (0, utils_2.isImageAddress)(image)];
114
114
  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)];
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)];
120
120
  case 2:
121
- _a = (_b.sent());
122
- _b.label = 3;
121
+ downloadedImage = _a.sent();
122
+ if (downloadedImage) {
123
+ return [2, (0, ssi_sdk_core_1.getImageDimensions)(downloadedImage.base64Content)];
124
+ }
125
+ return [3, 4];
123
126
  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];
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
+ }
130
+ _a.label = 4;
131
+ case 4: return [2];
130
132
  }
131
133
  });
132
134
  }); };
133
135
  var toCredentialDetailsRow = function (_a) {
134
136
  var object = _a.object, subject = _a.subject, issuer = _a.issuer;
135
137
  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) {
138
+ var rows, _i, _b, _c, key, value, _d, _e, label, contacts, imageSize, _f;
139
+ return __generator(this, function (_g) {
140
+ switch (_g.label) {
140
141
  case 0:
141
142
  rows = [];
143
+ if (!object) {
144
+ return [2, rows];
145
+ }
142
146
  _i = 0, _b = Object.entries(object);
143
- _k.label = 1;
147
+ _g.label = 1;
144
148
  case 1:
145
- if (!(_i < _b.length)) return [3, 12];
149
+ if (!(_i < _b.length)) return [3, 9];
146
150
  _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:
151
+ if (!key) {
152
+ return [3, 8];
153
+ }
161
154
  if (key === 'type') {
162
155
  rows.push({
163
156
  id: (0, uuid_1.v4)(),
164
157
  label: key,
165
158
  value: value
166
159
  });
167
- return [3, 11];
160
+ return [3, 8];
168
161
  }
169
- _k.label = 4;
170
- case 4:
171
- if (!(typeof value !== 'string')) return [3, 6];
172
- _g = (_f = rows).concat;
162
+ if (!(typeof value === 'object' && value !== null && value !== undefined)) return [3, 3];
163
+ _e = (_d = rows).concat;
173
164
  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];
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];
180
171
  }
181
172
  label = key;
182
- if (key === 'id' && value.startsWith('did:')) {
173
+ if (key === 'id' && typeof value === 'string' && value.startsWith('did:')) {
183
174
  label = 'subject';
184
175
  }
185
- if (value.startsWith('did:')) {
176
+ if (typeof value === 'string' && value.startsWith('did:')) {
186
177
  contacts = __spreadArray(__spreadArray([], (issuer ? [issuer] : []), true), (subject ? [subject] : []), true);
187
178
  value = findCorrelationIdName(value, contacts);
188
179
  }
189
180
  return [4, (0, utils_2.isImageAddress)(value)];
190
- case 7:
191
- if (!(_k.sent())) return [3, 9];
181
+ case 4:
182
+ if (!(_g.sent())) return [3, 6];
192
183
  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;
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;
201
192
  rows.push({
202
193
  id: (0, uuid_1.v4)(),
203
194
  label: label,
204
195
  value: value,
205
196
  imageSize: imageSize
206
197
  });
207
- _k.label = 11;
208
- case 11:
198
+ _g.label = 8;
199
+ case 8:
209
200
  _i++;
210
201
  return [3, 1];
211
- case 12: return [2, rows];
202
+ case 9: return [2, rows];
212
203
  }
213
204
  });
214
205
  });
@@ -311,7 +302,7 @@ var toCredentialSummary = function (_a) {
311
302
  case 2:
312
303
  properties = _e.sent();
313
304
  logo = (0, utils_2.getIssuerLogo)(verifiableCredential, localeBranding);
314
- url = typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
305
+ url = verifiableCredential.issuer && typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
315
306
  _b = (0, exports.getCredentialIssuerNameAndAlias)({ verifiableCredential: verifiableCredential, issuer: issuer }), issuerName = _b.issuerName, issuerAlias = _b.issuerAlias;
316
307
  termsOfUse = getTermsOfUse({ verifiableCredential: verifiableCredential });
317
308
  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.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>",
@@ -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.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
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": "a2c5adfd01626310b0585f531315024ef5b7e1b1"
52
55
  }