@sphereon/ui-components.credential-branding 0.4.1-next.154 → 0.4.1-next.179
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.
- package/dist/details/CredentialDetails.d.ts +1 -1
- package/dist/details/CredentialDetails.js +235 -289
- package/dist/details/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/services/IPreloadImage.js +1 -1
- package/dist/services/ReactNativeImagePreloader.js +11 -63
- package/dist/services/WebImagePreloader.js +12 -62
- package/dist/services/index.js +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +1 -1
- package/dist/utils/ImageUtils.d.ts +1 -1
- package/dist/utils/ImageUtils.js +8 -46
- package/dist/utils/MappingUtils.js +6 -6
- package/dist/utils/index.js +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding } from '@sphereon/ssi-sdk.data-store';
|
|
1
|
+
import type { IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding } from '@sphereon/ssi-sdk.data-store-types';
|
|
2
2
|
import { CredentialDetailsRow, CredentialSummary, GetCredentialDisplayNameArgs, GetCredentialIssuerNameAndAliasArgs, ISelectAppLocaleBrandingArgs, ToCredentialDetailsRowArgs, ToCredentialSummaryArgs, ToNonPersistedCredentialSummaryArgs } from '../types';
|
|
3
3
|
export declare const toCredentialDetailsRow: (args: ToCredentialDetailsRowArgs) => Promise<CredentialDetailsRow[]>;
|
|
4
4
|
export declare const toNonPersistedCredentialSummary: (args: ToNonPersistedCredentialSummaryArgs) => Promise<CredentialSummary>;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -26,49 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
26
15
|
}) : function(o, v) {
|
|
27
16
|
o["default"] = v;
|
|
28
17
|
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
72
35
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
73
36
|
var t = {};
|
|
74
37
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -80,160 +43,161 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
80
43
|
}
|
|
81
44
|
return t;
|
|
82
45
|
};
|
|
83
|
-
|
|
84
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
85
|
-
if (ar || !(i in from)) {
|
|
86
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
87
|
-
ar[i] = from[i];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
91
|
-
};
|
|
92
|
-
exports.__esModule = true;
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
93
47
|
exports.selectAppLocaleBranding = exports.toCredentialSummary = exports.getCredentialIssuerNameAndAlias = exports.getCredentialDisplayName = exports.getDate = exports.toNonPersistedCredentialSummary = exports.toCredentialDetailsRow = void 0;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
48
|
+
const uuid_1 = require("uuid");
|
|
49
|
+
const utils_1 = require("@veramo/utils");
|
|
50
|
+
const ui_components_core_1 = require("@sphereon/ui-components.core");
|
|
51
|
+
const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
|
|
52
|
+
const utils_2 = require("../utils");
|
|
99
53
|
function findCorrelationIdName(correlationId, parties, activeUser) {
|
|
100
54
|
var _a, _b;
|
|
101
|
-
|
|
55
|
+
let allParties = parties;
|
|
102
56
|
if (activeUser) {
|
|
103
57
|
parties.push(activeUser);
|
|
104
58
|
}
|
|
105
|
-
return ((_b = (_a = allParties === null || allParties === void 0 ? void 0 : allParties.find(
|
|
59
|
+
return ((_b = (_a = allParties === null || allParties === void 0 ? void 0 : allParties.find((contact) => { var _a; return (_a = contact.identities) === null || _a === void 0 ? void 0 : _a.some((identity) => identity.identifier.correlationId === correlationId); })) === null || _a === void 0 ? void 0 : _a.contact.displayName) !== null && _b !== void 0 ? _b : correlationId);
|
|
106
60
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
if (!(image.startsWith('http://') && !image.startsWith('https://'))) return [3, 3];
|
|
117
|
-
return [4, (0, ssi_sdk_core_1.downloadImage)(image)];
|
|
118
|
-
case 2:
|
|
119
|
-
downloadedImage = _a.sent();
|
|
120
|
-
if (downloadedImage) {
|
|
121
|
-
return [2, (0, ssi_sdk_core_1.getImageDimensions)(downloadedImage.base64Content)];
|
|
122
|
-
}
|
|
123
|
-
return [3, 4];
|
|
124
|
-
case 3:
|
|
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];
|
|
61
|
+
const getImageSize = async (image) => {
|
|
62
|
+
if (!(await (0, utils_2.isImageAddress)(image))) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (image.startsWith('http://') && !image.startsWith('https://')) {
|
|
66
|
+
const downloadedImage = await (0, ssi_sdk_core_1.downloadImage)(image);
|
|
67
|
+
if (downloadedImage) {
|
|
68
|
+
return (0, ssi_sdk_core_1.getImageDimensions)(downloadedImage.base64Content);
|
|
130
69
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
case 1:
|
|
164
|
-
rows = _h.apply(_g, [_k.sent()]);
|
|
165
|
-
return [3, 7];
|
|
166
|
-
case 2:
|
|
167
|
-
if (key === '0' || value === undefined || value === null) {
|
|
168
|
-
return [2, "continue"];
|
|
169
|
-
}
|
|
170
|
-
label = (_e = (_d = branding === null || branding === void 0 ? void 0 : branding.find(function (claim) { return claim.key === (parentKey ? "".concat(parentKey, ".").concat(key) : key); })) === null || _d === void 0 ? void 0 : _d.name) !== null && _e !== void 0 ? _e : key;
|
|
171
|
-
if (key === 'id' && typeof value === 'string' && value.startsWith('did:')) {
|
|
172
|
-
label = 'subject';
|
|
173
|
-
}
|
|
174
|
-
if (typeof value === 'string' && value.startsWith('did:')) {
|
|
175
|
-
contacts = __spreadArray(__spreadArray([], (issuer ? [issuer] : []), true), (subject ? [subject] : []), true);
|
|
176
|
-
value = findCorrelationIdName(value, contacts);
|
|
177
|
-
}
|
|
178
|
-
return [4, (0, utils_2.isImageAddress)(value)];
|
|
179
|
-
case 3:
|
|
180
|
-
if (!(_k.sent())) return [3, 5];
|
|
181
|
-
return [4, getImageSize(value)];
|
|
182
|
-
case 4:
|
|
183
|
-
_j = _k.sent();
|
|
184
|
-
return [3, 6];
|
|
185
|
-
case 5:
|
|
186
|
-
_j = undefined;
|
|
187
|
-
_k.label = 6;
|
|
188
|
-
case 6:
|
|
189
|
-
imageSize = _j;
|
|
190
|
-
rows.push({
|
|
191
|
-
id: (0, uuid_1.v4)(),
|
|
192
|
-
label: label,
|
|
193
|
-
value: value,
|
|
194
|
-
imageSize: imageSize
|
|
195
|
-
});
|
|
196
|
-
_k.label = 7;
|
|
197
|
-
case 7: return [2];
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
_i = 0, _b = Object.entries(object);
|
|
202
|
-
_f.label = 1;
|
|
203
|
-
case 1:
|
|
204
|
-
if (!(_i < _b.length)) return [3, 4];
|
|
205
|
-
_c = _b[_i], key = _c[0], value = _c[1];
|
|
206
|
-
return [5, _loop_1(key, value)];
|
|
207
|
-
case 2:
|
|
208
|
-
_f.sent();
|
|
209
|
-
_f.label = 3;
|
|
210
|
-
case 3:
|
|
211
|
-
_i++;
|
|
212
|
-
return [3, 1];
|
|
213
|
-
case 4: return [2, rows];
|
|
70
|
+
}
|
|
71
|
+
else if (ui_components_core_1.IS_IMAGE_URI_REGEX.test(image)) {
|
|
72
|
+
return (0, ssi_sdk_core_1.getImageDimensions)(image.split('base64,')[1]);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const toCredentialDetailsRow = async (args) => {
|
|
76
|
+
var _a, _b, _c, _d, _e, _f;
|
|
77
|
+
const { object, subject, issuer, branding, parentKey = '', depth = 0 } = args;
|
|
78
|
+
let rows = [];
|
|
79
|
+
if (!object) {
|
|
80
|
+
return rows;
|
|
81
|
+
}
|
|
82
|
+
const entries = Object.entries(object);
|
|
83
|
+
if (branding === null || branding === void 0 ? void 0 : branding.some(claim => claim.order != null)) {
|
|
84
|
+
entries.sort(([keyA], [keyB]) => {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
const fullKeyA = parentKey ? `${parentKey}.${keyA}` : keyA;
|
|
87
|
+
const fullKeyB = parentKey ? `${parentKey}.${keyB}` : keyB;
|
|
88
|
+
const orderA = (_a = branding.find(claim => claim.key === fullKeyA)) === null || _a === void 0 ? void 0 : _a.order;
|
|
89
|
+
const orderB = (_b = branding.find(claim => claim.key === fullKeyB)) === null || _b === void 0 ? void 0 : _b.order;
|
|
90
|
+
if (orderA != null && orderB != null)
|
|
91
|
+
return orderA - orderB;
|
|
92
|
+
if (orderA != null)
|
|
93
|
+
return -1;
|
|
94
|
+
if (orderB != null)
|
|
95
|
+
return 1;
|
|
96
|
+
return 0;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
for (let [key, value] of entries) {
|
|
100
|
+
if (!key) {
|
|
101
|
+
continue;
|
|
214
102
|
}
|
|
215
|
-
|
|
216
|
-
|
|
103
|
+
if (key === 'type') {
|
|
104
|
+
rows.push({
|
|
105
|
+
id: (0, uuid_1.v4)(),
|
|
106
|
+
label: key,
|
|
107
|
+
value: value,
|
|
108
|
+
depth,
|
|
109
|
+
});
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (Array.isArray(value)) {
|
|
113
|
+
const label = (_b = (_a = branding === null || branding === void 0 ? void 0 : branding.find(claim => claim.key === (parentKey ? `${parentKey}.${key}` : key))) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : key;
|
|
114
|
+
const items = value.filter(item => item !== undefined && item !== null);
|
|
115
|
+
const primitiveItems = items.filter(item => typeof item !== 'object');
|
|
116
|
+
const objectItems = items.filter(item => typeof item === 'object');
|
|
117
|
+
if (primitiveItems.length > 0) {
|
|
118
|
+
rows.push({
|
|
119
|
+
id: (0, uuid_1.v4)(),
|
|
120
|
+
label,
|
|
121
|
+
value: primitiveItems.length === 1 ? primitiveItems[0] : primitiveItems,
|
|
122
|
+
depth,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else if (items.length > 0) {
|
|
126
|
+
rows.push({
|
|
127
|
+
id: (0, uuid_1.v4)(),
|
|
128
|
+
label,
|
|
129
|
+
value: undefined,
|
|
130
|
+
depth,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
for (const item of objectItems) {
|
|
134
|
+
rows = rows.concat(await (0, exports.toCredentialDetailsRow)({
|
|
135
|
+
object: item,
|
|
136
|
+
subject,
|
|
137
|
+
issuer,
|
|
138
|
+
branding,
|
|
139
|
+
parentKey: parentKey ? `${parentKey}.${key}` : key,
|
|
140
|
+
depth: depth + 1,
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (typeof value === 'object' && value !== null) {
|
|
145
|
+
const label = (_d = (_c = branding === null || branding === void 0 ? void 0 : branding.find(claim => claim.key === (parentKey ? `${parentKey}.${key}` : key))) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : key;
|
|
146
|
+
rows.push({
|
|
147
|
+
id: (0, uuid_1.v4)(),
|
|
148
|
+
label,
|
|
149
|
+
value: undefined,
|
|
150
|
+
depth,
|
|
151
|
+
});
|
|
152
|
+
rows = rows.concat(await (0, exports.toCredentialDetailsRow)({
|
|
153
|
+
object: value,
|
|
154
|
+
subject,
|
|
155
|
+
issuer,
|
|
156
|
+
branding,
|
|
157
|
+
parentKey: parentKey ? `${parentKey}.${key}` : key,
|
|
158
|
+
depth: depth + 1,
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
if (key === '0' || value === undefined || value === null) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
let label = (_f = (_e = branding === null || branding === void 0 ? void 0 : branding.find(claim => claim.key === (parentKey ? `${parentKey}.${key}` : key))) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : key;
|
|
166
|
+
if (key === 'id' && typeof value === 'string' && value.startsWith('did:')) {
|
|
167
|
+
label = 'subject';
|
|
168
|
+
}
|
|
169
|
+
if (typeof value === 'string' && value.startsWith('did:')) {
|
|
170
|
+
const contacts = [...(issuer ? [issuer] : []), ...(subject ? [subject] : [])];
|
|
171
|
+
value = findCorrelationIdName(value, contacts);
|
|
172
|
+
}
|
|
173
|
+
const imageSize = (await (0, utils_2.isImageAddress)(value)) ? await getImageSize(value) : undefined;
|
|
174
|
+
rows.push({
|
|
175
|
+
id: (0, uuid_1.v4)(),
|
|
176
|
+
label,
|
|
177
|
+
value,
|
|
178
|
+
depth,
|
|
179
|
+
imageSize,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return rows;
|
|
184
|
+
};
|
|
217
185
|
exports.toCredentialDetailsRow = toCredentialDetailsRow;
|
|
218
|
-
|
|
219
|
-
|
|
186
|
+
const toNonPersistedCredentialSummary = (args) => {
|
|
187
|
+
const { verifiableCredential, credentialRole, branding, issuer, subject, linkedVp } = args;
|
|
220
188
|
return (0, exports.toCredentialSummary)({
|
|
221
189
|
verifiableCredential: verifiableCredential,
|
|
222
190
|
hash: (0, utils_1.computeEntryHash)(verifiableCredential),
|
|
223
|
-
credentialRole
|
|
224
|
-
branding
|
|
225
|
-
issuer
|
|
226
|
-
subject
|
|
227
|
-
linkedVp
|
|
191
|
+
credentialRole,
|
|
192
|
+
branding,
|
|
193
|
+
issuer,
|
|
194
|
+
subject,
|
|
195
|
+
linkedVp,
|
|
228
196
|
});
|
|
229
197
|
};
|
|
230
198
|
exports.toNonPersistedCredentialSummary = toNonPersistedCredentialSummary;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
234
|
-
dates[_i] = arguments[_i];
|
|
235
|
-
}
|
|
236
|
-
var date = dates === null || dates === void 0 ? void 0 : dates.find(function (date) { return date !== null && date !== undefined; });
|
|
199
|
+
const getDate = (...dates) => {
|
|
200
|
+
const date = dates === null || dates === void 0 ? void 0 : dates.find(date => date !== null && date !== undefined);
|
|
237
201
|
if (!date) {
|
|
238
202
|
return;
|
|
239
203
|
}
|
|
@@ -243,12 +207,12 @@ var getDate = function () {
|
|
|
243
207
|
return Math.round(new Date(date + '').valueOf() / ui_components_core_1.EPOCH_MILLISECONDS);
|
|
244
208
|
};
|
|
245
209
|
exports.getDate = getDate;
|
|
246
|
-
|
|
210
|
+
const getCredentialDisplayName = (args) => {
|
|
247
211
|
var _a, _b;
|
|
248
|
-
|
|
249
|
-
|
|
212
|
+
const { verifiableCredential, localeBranding } = args;
|
|
213
|
+
let title = (_b = (_a = localeBranding === null || localeBranding === void 0 ? void 0 : localeBranding.alias) !== null && _a !== void 0 ? _a : verifiableCredential.name) !== null && _b !== void 0 ? _b : (!verifiableCredential.type ? 'unknown' : undefined);
|
|
250
214
|
if (verifiableCredential.type) {
|
|
251
|
-
|
|
215
|
+
const types = (0, utils_1.asArray)(verifiableCredential.type).filter(val => val !== 'VerifiableCredential');
|
|
252
216
|
if (types.length === 1) {
|
|
253
217
|
title = types[0];
|
|
254
218
|
}
|
|
@@ -262,11 +226,11 @@ var getCredentialDisplayName = function (args) {
|
|
|
262
226
|
return title;
|
|
263
227
|
};
|
|
264
228
|
exports.getCredentialDisplayName = getCredentialDisplayName;
|
|
265
|
-
|
|
229
|
+
const getCredentialIssuerNameAndAlias = (args) => {
|
|
266
230
|
var _a;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
231
|
+
const { verifiableCredential, issuer } = args;
|
|
232
|
+
const issuerName = typeof verifiableCredential.issuer === 'string' ? verifiableCredential.issuer : (_a = verifiableCredential.issuer) === null || _a === void 0 ? void 0 : _a.id;
|
|
233
|
+
let issuerAlias = undefined;
|
|
270
234
|
if (typeof (verifiableCredential === null || verifiableCredential === void 0 ? void 0 : verifiableCredential.issuer) === 'object') {
|
|
271
235
|
issuerAlias = verifiableCredential.issuer.name;
|
|
272
236
|
}
|
|
@@ -276,102 +240,84 @@ var getCredentialIssuerNameAndAlias = function (args) {
|
|
|
276
240
|
if (!issuerAlias) {
|
|
277
241
|
issuerAlias = issuerName;
|
|
278
242
|
}
|
|
279
|
-
return { issuerName
|
|
243
|
+
return { issuerName, issuerAlias };
|
|
280
244
|
};
|
|
281
245
|
exports.getCredentialIssuerNameAndAlias = getCredentialIssuerNameAndAlias;
|
|
282
|
-
|
|
283
|
-
|
|
246
|
+
const getTermsOfUse = (args) => {
|
|
247
|
+
const { verifiableCredential } = args;
|
|
284
248
|
if (!verifiableCredential.termsOfUse) {
|
|
285
249
|
return;
|
|
286
250
|
}
|
|
287
|
-
|
|
288
|
-
return termsOfUse.map(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return __assign((_a = {}, _a[type] = id, _a), rest);
|
|
251
|
+
const termsOfUse = (0, utils_1.asArray)(verifiableCredential.termsOfUse);
|
|
252
|
+
return termsOfUse.map((tou) => {
|
|
253
|
+
const { type, id } = tou, rest = __rest(tou, ["type", "id"]);
|
|
254
|
+
return Object.assign({ [type]: id }, rest);
|
|
292
255
|
});
|
|
293
256
|
};
|
|
294
|
-
|
|
295
|
-
var
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
title = (0, exports.getCredentialDisplayName)({ verifiableCredential: verifiableCredential, localeBranding: localeBranding });
|
|
308
|
-
return [4, (0, exports.toCredentialDetailsRow)({
|
|
309
|
-
object: __assign(__assign({}, (_c = verifiableCredential.vc) === null || _c === void 0 ? void 0 : _c.credentialSubject), verifiableCredential.credentialSubject),
|
|
310
|
-
subject: subject,
|
|
311
|
-
issuer: issuer,
|
|
312
|
-
branding: localeBranding === null || localeBranding === void 0 ? void 0 : localeBranding.claims
|
|
313
|
-
})];
|
|
314
|
-
case 2:
|
|
315
|
-
properties = _d.sent();
|
|
316
|
-
logo = (0, utils_2.getIssuerLogo)(verifiableCredential, localeBranding);
|
|
317
|
-
url = verifiableCredential.issuer && typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
|
|
318
|
-
_a = (0, exports.getCredentialIssuerNameAndAlias)({ verifiableCredential: verifiableCredential, issuer: issuer }), issuerName = _a.issuerName, issuerAlias = _a.issuerAlias;
|
|
319
|
-
termsOfUse = getTermsOfUse({ verifiableCredential: verifiableCredential });
|
|
320
|
-
return [2, {
|
|
321
|
-
hash: hash,
|
|
322
|
-
id: verifiableCredential.id,
|
|
323
|
-
title: title,
|
|
324
|
-
credentialStatus: credentialStatus,
|
|
325
|
-
credentialRole: credentialRole,
|
|
326
|
-
issueDate: issueDate,
|
|
327
|
-
expirationDate: expirationDate,
|
|
328
|
-
properties: properties,
|
|
329
|
-
branding: localeBranding,
|
|
330
|
-
termsOfUse: termsOfUse,
|
|
331
|
-
issuer: {
|
|
332
|
-
name: issuerName,
|
|
333
|
-
alias: issuerAlias ? (issuerAlias.length > 50 ? "".concat(issuerAlias.substring(0, 50), "...") : issuerAlias) : '',
|
|
334
|
-
image: logo,
|
|
335
|
-
url: url
|
|
336
|
-
},
|
|
337
|
-
linkedVp: linkedVp
|
|
338
|
-
}];
|
|
339
|
-
}
|
|
257
|
+
const toCredentialSummary = async (args) => {
|
|
258
|
+
var _a, _b;
|
|
259
|
+
const { verifiableCredential, hash, credentialRole, branding, issuer, subject, linkedVp } = args;
|
|
260
|
+
const expirationDate = (_a = (0, exports.getDate)(verifiableCredential.expirationDate, verifiableCredential.validTo, verifiableCredential.exp)) !== null && _a !== void 0 ? _a : 0;
|
|
261
|
+
const issueDate = (0, exports.getDate)(verifiableCredential.issuanceDate, verifiableCredential.validFrom, verifiableCredential.nbf, verifiableCredential.iat);
|
|
262
|
+
const localeBranding = await (0, exports.selectAppLocaleBranding)({ localeBranding: branding });
|
|
263
|
+
const credentialStatus = (0, utils_2.getCredentialStatus)(verifiableCredential);
|
|
264
|
+
const title = (0, exports.getCredentialDisplayName)({ verifiableCredential, localeBranding });
|
|
265
|
+
const properties = await (0, exports.toCredentialDetailsRow)({
|
|
266
|
+
object: Object.assign(Object.assign({}, (_b = verifiableCredential.vc) === null || _b === void 0 ? void 0 : _b.credentialSubject), verifiableCredential.credentialSubject),
|
|
267
|
+
subject,
|
|
268
|
+
issuer,
|
|
269
|
+
branding: localeBranding === null || localeBranding === void 0 ? void 0 : localeBranding.claims,
|
|
340
270
|
});
|
|
341
|
-
|
|
271
|
+
const logo = (0, utils_2.getIssuerLogo)(verifiableCredential, localeBranding);
|
|
272
|
+
const url = verifiableCredential.issuer && typeof verifiableCredential.issuer !== 'string' ? verifiableCredential.issuer.url : undefined;
|
|
273
|
+
const { issuerName, issuerAlias } = (0, exports.getCredentialIssuerNameAndAlias)({ verifiableCredential, issuer });
|
|
274
|
+
const termsOfUse = getTermsOfUse({ verifiableCredential });
|
|
275
|
+
return {
|
|
276
|
+
hash,
|
|
277
|
+
id: verifiableCredential.id,
|
|
278
|
+
title,
|
|
279
|
+
credentialStatus,
|
|
280
|
+
credentialRole,
|
|
281
|
+
issueDate,
|
|
282
|
+
expirationDate,
|
|
283
|
+
properties,
|
|
284
|
+
branding: localeBranding,
|
|
285
|
+
termsOfUse,
|
|
286
|
+
issuer: {
|
|
287
|
+
name: issuerName,
|
|
288
|
+
alias: issuerAlias ? (issuerAlias.length > 50 ? `${issuerAlias.substring(0, 50)}...` : issuerAlias) : '',
|
|
289
|
+
image: logo,
|
|
290
|
+
url,
|
|
291
|
+
},
|
|
292
|
+
linkedVp,
|
|
293
|
+
};
|
|
294
|
+
};
|
|
342
295
|
exports.toCredentialSummary = toCredentialSummary;
|
|
343
|
-
|
|
344
|
-
var
|
|
345
|
-
|
|
346
|
-
return
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
imagePreloader.preload([{ uri: backgroundImage }])["catch"](function () {
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
return [2, localeBranding];
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
}); };
|
|
296
|
+
const selectAppLocaleBranding = async (args) => {
|
|
297
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
298
|
+
const appLocale = ui_components_core_1.Localization.getLocale();
|
|
299
|
+
const byLocalePrefix = (locale) => (b) => { var _a; return (_a = b.locale) === null || _a === void 0 ? void 0 : _a.startsWith(locale); };
|
|
300
|
+
const noLocale = (b) => b.locale === undefined || b.locale === '';
|
|
301
|
+
const localeBranding = (_f = (_d = (_b = (_a = args.localeBranding) === null || _a === void 0 ? void 0 : _a.find(byLocalePrefix(appLocale))) !== null && _b !== void 0 ? _b : (_c = args.localeBranding) === null || _c === void 0 ? void 0 : _c.find(noLocale)) !== null && _d !== void 0 ? _d : (appLocale !== 'en' ? (_e = args.localeBranding) === null || _e === void 0 ? void 0 : _e.find(byLocalePrefix('en')) : undefined)) !== null && _f !== void 0 ? _f : (_g = args.localeBranding) === null || _g === void 0 ? void 0 : _g[0];
|
|
302
|
+
const logo = ((_h = localeBranding === null || localeBranding === void 0 ? void 0 : localeBranding.logo) === null || _h === void 0 ? void 0 : _h.dataUri) || ((_j = localeBranding === null || localeBranding === void 0 ? void 0 : localeBranding.logo) === null || _j === void 0 ? void 0 : _j.uri);
|
|
303
|
+
let imagePreloader;
|
|
304
|
+
if (typeof window === 'undefined') {
|
|
305
|
+
const { ReactNativeImagePreloader } = await Promise.resolve().then(() => __importStar(require('../services/ReactNativeImagePreloader')));
|
|
306
|
+
imagePreloader = new ReactNativeImagePreloader();
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
const { WebImagePreloader } = await Promise.resolve().then(() => __importStar(require('../services/WebImagePreloader')));
|
|
310
|
+
imagePreloader = new WebImagePreloader();
|
|
311
|
+
}
|
|
312
|
+
if (logo) {
|
|
313
|
+
imagePreloader.preload([{ uri: logo }]).catch(() => {
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
const backgroundImage = ((_l = (_k = localeBranding === null || localeBranding === void 0 ? void 0 : localeBranding.background) === null || _k === void 0 ? void 0 : _k.image) === null || _l === void 0 ? void 0 : _l.dataUri) || ((_o = (_m = localeBranding === null || localeBranding === void 0 ? void 0 : localeBranding.background) === null || _m === void 0 ? void 0 : _m.image) === null || _o === void 0 ? void 0 : _o.uri);
|
|
317
|
+
if (backgroundImage) {
|
|
318
|
+
imagePreloader.preload([{ uri: backgroundImage }]).catch(() => {
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
return localeBranding;
|
|
322
|
+
};
|
|
377
323
|
exports.selectAppLocaleBranding = selectAppLocaleBranding;
|
package/dist/details/index.js
CHANGED
|
@@ -13,5 +13,5 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./CredentialDetails"), exports);
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./details"), exports);
|
|
18
18
|
__exportStar(require("./services"), exports);
|
|
19
19
|
__exportStar(require("./types"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,67 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.__esModule = true;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.ReactNativeImagePreloader = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
4
|
+
class ReactNativeImagePreloader {
|
|
5
|
+
async preload(sources) {
|
|
6
|
+
const promises = sources.map(source => new Promise((resolve, reject) => {
|
|
7
|
+
const img = new Image();
|
|
8
|
+
img.src = source.uri;
|
|
9
|
+
img.onload = () => resolve();
|
|
10
|
+
img.onerror = error => reject(error);
|
|
11
|
+
}));
|
|
12
|
+
await Promise.all(promises);
|
|
42
13
|
}
|
|
43
|
-
|
|
44
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var promises;
|
|
46
|
-
return __generator(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
promises = sources.map(function (source) {
|
|
50
|
-
return new Promise(function (resolve, reject) {
|
|
51
|
-
var img = new Image();
|
|
52
|
-
img.src = source.uri;
|
|
53
|
-
img.onload = function () { return resolve(); };
|
|
54
|
-
img.onerror = function (error) { return reject(error); };
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
return [4, Promise.all(promises)];
|
|
58
|
-
case 1:
|
|
59
|
-
_a.sent();
|
|
60
|
-
return [2];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
return ReactNativeImagePreloader;
|
|
66
|
-
}());
|
|
14
|
+
}
|
|
67
15
|
exports.ReactNativeImagePreloader = ReactNativeImagePreloader;
|
|
@@ -1,67 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.__esModule = true;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.WebImagePreloader = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
case 0:
|
|
49
|
-
promises = sources.map(function (source) {
|
|
50
|
-
return new Promise(function (resolve, reject) {
|
|
51
|
-
var img = new Image();
|
|
52
|
-
img.src = source.uri;
|
|
53
|
-
img.onload = function () { return resolve(); };
|
|
54
|
-
img.onerror = function (error) { return reject(error); };
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
return [4, Promise.all(promises)];
|
|
58
|
-
case 1:
|
|
59
|
-
_a.sent();
|
|
60
|
-
return [2];
|
|
61
|
-
}
|
|
4
|
+
class WebImagePreloader {
|
|
5
|
+
async preload(sources) {
|
|
6
|
+
const promises = sources.map(source => {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const img = new Image();
|
|
9
|
+
img.src = source.uri;
|
|
10
|
+
img.onload = () => resolve();
|
|
11
|
+
img.onerror = error => reject(error);
|
|
62
12
|
});
|
|
63
13
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
14
|
+
await Promise.all(promises);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
67
17
|
exports.WebImagePreloader = WebImagePreloader;
|
package/dist/services/index.js
CHANGED
|
@@ -13,5 +13,5 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./IPreloadImage"), exports);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CredentialStatus, ImageSize, IssuerStatus } from '@sphereon/ui-components.core';
|
|
2
|
-
import type { IBasicCredentialClaim, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding, Party } from '@sphereon/ssi-sdk.data-store';
|
|
2
|
+
import type { IBasicCredentialClaim, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding, Party } from '@sphereon/ssi-sdk.data-store-types';
|
|
3
3
|
import { CredentialRole } from '@sphereon/ssi-types';
|
|
4
4
|
import { ICredential } from '@sphereon/ssi-types';
|
|
5
5
|
import { VerifiableCredential } from '@veramo/core';
|
|
@@ -29,6 +29,7 @@ export type CredentialDetailsRow = {
|
|
|
29
29
|
id: string;
|
|
30
30
|
label: string;
|
|
31
31
|
value: any;
|
|
32
|
+
depth?: number;
|
|
32
33
|
isEditable?: boolean;
|
|
33
34
|
status?: LabelStatus;
|
|
34
35
|
imageSize?: ImageSize;
|
|
@@ -41,6 +42,7 @@ export interface ISelectAppLocaleBrandingArgs {
|
|
|
41
42
|
export type ToCredentialDetailsRowArgs = {
|
|
42
43
|
object: Record<string, any>;
|
|
43
44
|
parentKey?: string;
|
|
45
|
+
depth?: number;
|
|
44
46
|
subject?: Party;
|
|
45
47
|
issuer?: Party;
|
|
46
48
|
branding?: Array<IBasicCredentialClaim>;
|
package/dist/types/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VerifiableCredential } from '@veramo/core';
|
|
2
2
|
import { CredentialSummary } from '../types';
|
|
3
|
-
import type { IBasicCredentialLocaleBranding } from '@sphereon/ssi-sdk.data-store';
|
|
3
|
+
import type { IBasicCredentialLocaleBranding } from '@sphereon/ssi-sdk.data-store-types';
|
|
4
4
|
export declare const isImageAddress: (value: string) => Promise<boolean>;
|
|
5
5
|
export declare function getIssuerLogo(verifiableCredential: VerifiableCredential | CredentialSummary, localeBranding?: IBasicCredentialLocaleBranding): string | undefined;
|
|
6
6
|
export declare const getImageFromObjectOrString: (image?: string | object) => string | undefined;
|
package/dist/utils/ImageUtils.js
CHANGED
|
@@ -1,52 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImageFromObjectOrString = exports.isImageAddress = void 0;
|
|
4
|
+
exports.getIssuerLogo = getIssuerLogo;
|
|
5
|
+
const ui_components_core_1 = require("@sphereon/ui-components.core");
|
|
6
|
+
const isImageAddress = async (value) => {
|
|
7
|
+
return ui_components_core_1.IS_IMAGE_URI_REGEX.test(value) || ui_components_core_1.IS_IMAGE_FILE_EXTENSION_REGEX.test(value);
|
|
37
8
|
};
|
|
38
|
-
exports.__esModule = true;
|
|
39
|
-
exports.getImageFromObjectOrString = exports.getIssuerLogo = exports.isImageAddress = void 0;
|
|
40
|
-
var ui_components_core_1 = require("@sphereon/ui-components.core");
|
|
41
|
-
var isImageAddress = function (value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
-
return __generator(this, function (_a) {
|
|
43
|
-
return [2, ui_components_core_1.IS_IMAGE_URI_REGEX.test(value) || ui_components_core_1.IS_IMAGE_FILE_EXTENSION_REGEX.test(value)];
|
|
44
|
-
});
|
|
45
|
-
}); };
|
|
46
9
|
exports.isImageAddress = isImageAddress;
|
|
47
10
|
function getIssuerLogo(verifiableCredential, localeBranding) {
|
|
48
11
|
var _a;
|
|
49
|
-
|
|
12
|
+
let logo;
|
|
50
13
|
if (localeBranding === null || localeBranding === void 0 ? void 0 : localeBranding.logo) {
|
|
51
14
|
logo = (_a = localeBranding.logo.dataUri) !== null && _a !== void 0 ? _a : localeBranding.logo.uri;
|
|
52
15
|
}
|
|
@@ -60,8 +23,7 @@ function getIssuerLogo(verifiableCredential, localeBranding) {
|
|
|
60
23
|
}
|
|
61
24
|
return logo;
|
|
62
25
|
}
|
|
63
|
-
|
|
64
|
-
var getImageFromObjectOrString = function (image) {
|
|
26
|
+
const getImageFromObjectOrString = (image) => {
|
|
65
27
|
if (!image) {
|
|
66
28
|
return undefined;
|
|
67
29
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isExpired = exports.isRevoked = exports.getCredentialStatus = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const ui_components_core_1 = require("@sphereon/ui-components.core");
|
|
5
|
+
const getCredentialStatus = (credential) => {
|
|
6
6
|
if ((0, exports.isRevoked)()) {
|
|
7
7
|
return ui_components_core_1.CredentialStatus.REVOKED;
|
|
8
8
|
}
|
|
@@ -12,15 +12,15 @@ var getCredentialStatus = function (credential) {
|
|
|
12
12
|
return ui_components_core_1.CredentialStatus.VALID;
|
|
13
13
|
};
|
|
14
14
|
exports.getCredentialStatus = getCredentialStatus;
|
|
15
|
-
|
|
15
|
+
const isRevoked = () => {
|
|
16
16
|
return false;
|
|
17
17
|
};
|
|
18
18
|
exports.isRevoked = isRevoked;
|
|
19
|
-
|
|
19
|
+
const isExpired = (value) => {
|
|
20
20
|
if (!value) {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
let expirationDate = typeof value === 'string' ? new Date(value).valueOf() : value;
|
|
24
24
|
expirationDate = (0, ui_components_core_1.makeEpochMilli)(expirationDate);
|
|
25
25
|
return expirationDate < Date.now();
|
|
26
26
|
};
|
package/dist/utils/index.js
CHANGED
|
@@ -13,6 +13,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./ImageUtils"), exports);
|
|
18
18
|
__exportStar(require("./MappingUtils"), exports);
|
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.4.1-next.
|
|
4
|
+
"version": "0.4.1-next.179+216c7c7",
|
|
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,10 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@sphereon/ssi-sdk.core": "0.
|
|
32
|
-
"@sphereon/ssi-sdk.data-store": "0.
|
|
33
|
-
"@sphereon/ssi-types": "0.
|
|
34
|
-
"@sphereon/ui-components.core": "0.4.1-next.
|
|
31
|
+
"@sphereon/ssi-sdk.core": "0.36.1-next.159",
|
|
32
|
+
"@sphereon/ssi-sdk.data-store-types": "0.36.1-next.159",
|
|
33
|
+
"@sphereon/ssi-types": "0.36.1-next.159",
|
|
34
|
+
"@sphereon/ui-components.core": "0.4.1-next.179+216c7c7",
|
|
35
35
|
"@veramo/core": "4.2.0",
|
|
36
36
|
"@veramo/utils": "4.2.0",
|
|
37
37
|
"i18n-js": "^3.8.0",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"jest": "^29.7.0",
|
|
47
47
|
"react": "18.3.1",
|
|
48
48
|
"ts-jest": "^29.2.5",
|
|
49
|
-
"typescript": "
|
|
49
|
+
"typescript": "~5.8.3"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": ">= 18.2"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "216c7c7dd49b3f1ed6048ed17f746d5b477682da"
|
|
55
55
|
}
|