@sphereon/ui-components.credential-branding 0.3.1-next.9 → 0.3.1-unstable.13

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,114 +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 = [];
142
143
  if (!object) {
143
144
  return [2, rows];
144
145
  }
145
146
  _i = 0, _b = Object.entries(object);
146
- _k.label = 1;
147
+ _g.label = 1;
147
148
  case 1:
148
- if (!(_i < _b.length)) return [3, 12];
149
+ if (!(_i < _b.length)) return [3, 9];
149
150
  _c = _b[_i], key = _c[0], value = _c[1];
150
151
  if (!key) {
151
- return [3, 11];
152
+ return [3, 8];
152
153
  }
153
- if (!key.toLowerCase().includes('image')) return [3, 3];
154
- image = typeof value === 'string' ? value : value.id;
155
- _e = (_d = rows).push;
156
- _j = {
157
- id: (0, uuid_1.v4)(),
158
- label: 'image',
159
- value: image
160
- };
161
- return [4, getImageSize(image)];
162
- case 2:
163
- _e.apply(_d, [(_j.imageSize = _k.sent(),
164
- _j)]);
165
- return [3, 11];
166
- case 3:
167
154
  if (key === 'type') {
168
155
  rows.push({
169
156
  id: (0, uuid_1.v4)(),
170
157
  label: key,
171
158
  value: value
172
159
  });
173
- return [3, 11];
160
+ return [3, 8];
174
161
  }
175
- _k.label = 4;
176
- case 4:
177
- if (!(typeof value !== 'string' && value !== null && value !== undefined)) return [3, 6];
178
- _g = (_f = rows).concat;
162
+ if (!(typeof value === 'object' && value !== null && value !== undefined)) return [3, 3];
163
+ _e = (_d = rows).concat;
179
164
  return [4, toCredentialDetailsRow({ object: value, subject: subject, issuer: issuer })];
180
- case 5:
181
- rows = _g.apply(_f, [_k.sent()]);
182
- return [3, 11];
183
- case 6:
165
+ case 2:
166
+ rows = _e.apply(_d, [_g.sent()]);
167
+ return [3, 8];
168
+ case 3:
184
169
  if (key === '0' || value === undefined || value === null) {
185
- return [3, 11];
170
+ return [3, 8];
186
171
  }
187
172
  label = key;
188
- if (key === 'id' && value.startsWith('did:')) {
173
+ if (key === 'id' && typeof value === 'string' && value.startsWith('did:')) {
189
174
  label = 'subject';
190
175
  }
191
- if (value.startsWith('did:')) {
176
+ if (typeof value === 'string' && value.startsWith('did:')) {
192
177
  contacts = __spreadArray(__spreadArray([], (issuer ? [issuer] : []), true), (subject ? [subject] : []), true);
193
178
  value = findCorrelationIdName(value, contacts);
194
179
  }
195
180
  return [4, (0, utils_2.isImageAddress)(value)];
196
- case 7:
197
- if (!(_k.sent())) return [3, 9];
181
+ case 4:
182
+ if (!(_g.sent())) return [3, 6];
198
183
  return [4, getImageSize(value)];
199
- case 8:
200
- _h = _k.sent();
201
- return [3, 10];
202
- case 9:
203
- _h = undefined;
204
- _k.label = 10;
205
- case 10:
206
- 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;
207
192
  rows.push({
208
193
  id: (0, uuid_1.v4)(),
209
194
  label: label,
210
195
  value: value,
211
196
  imageSize: imageSize
212
197
  });
213
- _k.label = 11;
214
- case 11:
198
+ _g.label = 8;
199
+ case 8:
215
200
  _i++;
216
201
  return [3, 1];
217
- case 12: return [2, rows];
202
+ case 9: return [2, rows];
218
203
  }
219
204
  });
220
205
  });
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-next.9+89203cc",
4
+ "version": "0.3.1-unstable.13+a83d5f0",
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.1-next.9+89203cc",
34
+ "@sphereon/ui-components.core": "0.3.1-unstable.13+a83d5f0",
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": "89203ccd1b27ea8d7c1ca157e42d7aa3ad64544a"
54
+ "gitHead": "a83d5f09209403b80922c098cb599772ea43d3f1"
55
55
  }