@sphereon/ui-components.credential-branding 0.3.1-unstable.12 → 0.3.1-unstable.18
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,7 +1,12 @@
|
|
|
1
1
|
import { VerifiableCredential } from '@veramo/core';
|
|
2
2
|
import { CredentialRole, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding, Party } from '@sphereon/ssi-sdk.data-store';
|
|
3
|
-
import { CredentialSummary, ISelectAppLocaleBrandingArgs } from '../types';
|
|
3
|
+
import { CredentialDetailsRow, CredentialSummary, ISelectAppLocaleBrandingArgs } from '../types';
|
|
4
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[]>;
|
|
5
10
|
export declare const toNonPersistedCredentialSummary: ({ verifiableCredential, credentialRole, branding, issuer, subject, }: {
|
|
6
11
|
verifiableCredential: ICredential | VerifiableCredential;
|
|
7
12
|
credentialRole: CredentialRole;
|
|
@@ -90,7 +90,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
90
90
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
91
91
|
};
|
|
92
92
|
exports.__esModule = true;
|
|
93
|
-
exports.selectAppLocaleBranding = exports.toCredentialSummary = exports.getCredentialIssuerNameAndAlias = exports.getCredentialDisplayName = exports.getDate = exports.toNonPersistedCredentialSummary = void 0;
|
|
93
|
+
exports.selectAppLocaleBranding = exports.toCredentialSummary = exports.getCredentialIssuerNameAndAlias = exports.getCredentialDisplayName = exports.getDate = exports.toNonPersistedCredentialSummary = exports.toCredentialDetailsRow = void 0;
|
|
94
94
|
var uuid_1 = require("uuid");
|
|
95
95
|
var utils_1 = require("@veramo/utils");
|
|
96
96
|
var ui_components_core_1 = require("@sphereon/ui-components.core");
|
|
@@ -102,87 +102,70 @@ 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
|
|
111
|
-
return __generator(this, function (
|
|
112
|
-
switch (
|
|
113
|
-
case 0: return [4, (0,
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (!
|
|
119
|
-
return [4, (0,
|
|
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
|
-
|
|
122
|
-
|
|
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 (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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,
|
|
137
|
-
|
|
138
|
-
|
|
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 = [];
|
|
142
141
|
if (!object) {
|
|
143
142
|
return [2, rows];
|
|
144
143
|
}
|
|
145
144
|
_i = 0, _b = Object.entries(object);
|
|
146
|
-
|
|
145
|
+
_g.label = 1;
|
|
147
146
|
case 1:
|
|
148
|
-
if (!(_i < _b.length)) return [3,
|
|
147
|
+
if (!(_i < _b.length)) return [3, 9];
|
|
149
148
|
_c = _b[_i], key = _c[0], value = _c[1];
|
|
150
149
|
if (!key) {
|
|
151
|
-
return [3,
|
|
150
|
+
return [3, 8];
|
|
152
151
|
}
|
|
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
152
|
if (key === 'type') {
|
|
168
153
|
rows.push({
|
|
169
154
|
id: (0, uuid_1.v4)(),
|
|
170
155
|
label: key,
|
|
171
156
|
value: value
|
|
172
157
|
});
|
|
173
|
-
return [3,
|
|
158
|
+
return [3, 8];
|
|
174
159
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return [3, 11];
|
|
183
|
-
case 6:
|
|
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:
|
|
184
167
|
if (key === '0' || value === undefined || value === null) {
|
|
185
|
-
return [3,
|
|
168
|
+
return [3, 8];
|
|
186
169
|
}
|
|
187
170
|
label = key;
|
|
188
171
|
if (key === 'id' && typeof value === 'string' && value.startsWith('did:')) {
|
|
@@ -193,32 +176,33 @@ var toCredentialDetailsRow = function (_a) {
|
|
|
193
176
|
value = findCorrelationIdName(value, contacts);
|
|
194
177
|
}
|
|
195
178
|
return [4, (0, utils_2.isImageAddress)(value)];
|
|
196
|
-
case
|
|
197
|
-
if (!(
|
|
179
|
+
case 4:
|
|
180
|
+
if (!(_g.sent())) return [3, 6];
|
|
198
181
|
return [4, getImageSize(value)];
|
|
199
|
-
case
|
|
200
|
-
|
|
201
|
-
return [3,
|
|
202
|
-
case
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
case
|
|
206
|
-
imageSize =
|
|
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;
|
|
207
190
|
rows.push({
|
|
208
191
|
id: (0, uuid_1.v4)(),
|
|
209
192
|
label: label,
|
|
210
193
|
value: value,
|
|
211
194
|
imageSize: imageSize
|
|
212
195
|
});
|
|
213
|
-
|
|
214
|
-
case
|
|
196
|
+
_g.label = 8;
|
|
197
|
+
case 8:
|
|
215
198
|
_i++;
|
|
216
199
|
return [3, 1];
|
|
217
|
-
case
|
|
200
|
+
case 9: return [2, rows];
|
|
218
201
|
}
|
|
219
202
|
});
|
|
220
203
|
});
|
|
221
204
|
};
|
|
205
|
+
exports.toCredentialDetailsRow = toCredentialDetailsRow;
|
|
222
206
|
var toNonPersistedCredentialSummary = function (_a) {
|
|
223
207
|
var verifiableCredential = _a.verifiableCredential, credentialRole = _a.credentialRole, branding = _a.branding, issuer = _a.issuer, subject = _a.subject;
|
|
224
208
|
return (0, exports.toCredentialSummary)({
|
|
@@ -309,7 +293,7 @@ var toCredentialSummary = function (_a) {
|
|
|
309
293
|
localeBranding = _e.sent();
|
|
310
294
|
credentialStatus = (0, utils_2.getCredentialStatus)(verifiableCredential);
|
|
311
295
|
title = (0, exports.getCredentialDisplayName)({ verifiableCredential: verifiableCredential, localeBranding: localeBranding });
|
|
312
|
-
return [4, toCredentialDetailsRow({
|
|
296
|
+
return [4, (0, exports.toCredentialDetailsRow)({
|
|
313
297
|
object: __assign(__assign({}, (_d = verifiableCredential.vc) === null || _d === void 0 ? void 0 : _d.credentialSubject), verifiableCredential.credentialSubject),
|
|
314
298
|
subject: subject,
|
|
315
299
|
issuer: issuer
|
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.18+09c00b6",
|
|
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-unstable.
|
|
34
|
+
"@sphereon/ui-components.core": "0.3.1-unstable.18+09c00b6",
|
|
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": "09c00b6596d3919cda54b3e9c3355fed4a7f328d"
|
|
55
55
|
}
|