@mattrglobal/verifier-sdk-web 2.3.1-unstable.4 → 2.3.1-unstable.41
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/README.md +5 -4
- package/dist/lib/verifier-js-no-deps.cjs.js +77 -10
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +159 -66
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/verifier/requestCredentialsDigitalCredentialsApi.d.ts +13 -2
- package/dist/typings/verifier/types/credential-presentation.d.ts +20 -0
- package/dist/typings/verifier/utils.d.ts +10 -2
- package/dist/verifier-js.development.js +153 -66
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +3 -3
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +3 -3
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +5 -5
|
@@ -7,13 +7,13 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated: 2026-
|
|
10
|
+
* Generated: 2026-11-05
|
|
11
11
|
* Version: 2.3.0
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*
|
|
14
14
|
* neverthrow -- 4.3.0
|
|
15
15
|
*
|
|
16
|
-
* valibot -- 1.2
|
|
16
|
+
* valibot -- 1.4.2
|
|
17
17
|
*
|
|
18
18
|
* is-mobile -- 4.0.0
|
|
19
19
|
*/
|
|
@@ -581,8 +581,16 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
581
581
|
|
|
582
582
|
var store$4;
|
|
583
583
|
|
|
584
|
+
var DEFAULT_CONFIG = {
|
|
585
|
+
lang: void 0,
|
|
586
|
+
message: void 0,
|
|
587
|
+
abortEarly: void 0,
|
|
588
|
+
abortPipeEarly: void 0
|
|
589
|
+
};
|
|
590
|
+
|
|
584
591
|
function getGlobalConfig(config$1) {
|
|
585
592
|
var _config$1$lang, _store$, _config$1$abortEarly, _store$2, _config$1$abortPipeEa, _store$3;
|
|
593
|
+
if (!config$1 && !store$4) return DEFAULT_CONFIG;
|
|
586
594
|
return {
|
|
587
595
|
lang: (_config$1$lang = config$1 === null || config$1 === void 0 ? void 0 : config$1.lang) !== null && _config$1$lang !== void 0 ? _config$1$lang : (_store$ = store$4) === null || _store$ === void 0 ? void 0 : _store$.lang,
|
|
588
596
|
message: config$1 === null || config$1 === void 0 ? void 0 : config$1.message,
|
|
@@ -647,20 +655,27 @@ function _addIssue(context, label, dataset, config$1, other) {
|
|
|
647
655
|
if (dataset.issues) dataset.issues.push(issue); else dataset.issues = [ issue ];
|
|
648
656
|
}
|
|
649
657
|
|
|
658
|
+
var _standardCache = new WeakMap;
|
|
659
|
+
|
|
650
660
|
function _getStandardProps(context) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
661
|
+
var cached = _standardCache.get(context);
|
|
662
|
+
if (!cached) {
|
|
663
|
+
cached = {
|
|
664
|
+
version: 1,
|
|
665
|
+
vendor: "valibot",
|
|
666
|
+
validate: function validate(value$1) {
|
|
667
|
+
return context["~run"]({
|
|
668
|
+
value: value$1
|
|
669
|
+
}, getGlobalConfig());
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
_standardCache.set(context, cached);
|
|
673
|
+
}
|
|
674
|
+
return cached;
|
|
660
675
|
}
|
|
661
676
|
|
|
662
677
|
function _isValidObjectKey(object$1, key) {
|
|
663
|
-
return Object.
|
|
678
|
+
return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
664
679
|
}
|
|
665
680
|
|
|
666
681
|
function _joinExpects(values$1, separator) {
|
|
@@ -783,18 +798,18 @@ function array(item, message$1) {
|
|
|
783
798
|
key: key,
|
|
784
799
|
value: value$1
|
|
785
800
|
};
|
|
786
|
-
var
|
|
801
|
+
var _iterator16 = _createForOfIteratorHelper(itemDataset.issues), _step16;
|
|
787
802
|
try {
|
|
788
|
-
for (
|
|
803
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done; ) {
|
|
789
804
|
var _dataset$issues;
|
|
790
|
-
var issue =
|
|
805
|
+
var issue = _step16.value;
|
|
791
806
|
if (issue.path) issue.path.unshift(pathItem); else issue.path = [ pathItem ];
|
|
792
807
|
(_dataset$issues = dataset.issues) === null || _dataset$issues === void 0 || _dataset$issues.push(issue);
|
|
793
808
|
}
|
|
794
809
|
} catch (err) {
|
|
795
|
-
|
|
810
|
+
_iterator16.e(err);
|
|
796
811
|
} finally {
|
|
797
|
-
|
|
812
|
+
_iterator16.f();
|
|
798
813
|
}
|
|
799
814
|
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
800
815
|
if (config$1.abortEarly) {
|
|
@@ -898,18 +913,18 @@ function object(entries$1, message$1) {
|
|
|
898
913
|
key: key,
|
|
899
914
|
value: value$1
|
|
900
915
|
};
|
|
901
|
-
var
|
|
916
|
+
var _iterator34 = _createForOfIteratorHelper(valueDataset.issues), _step34;
|
|
902
917
|
try {
|
|
903
|
-
for (
|
|
904
|
-
var _dataset$
|
|
905
|
-
var issue =
|
|
918
|
+
for (_iterator34.s(); !(_step34 = _iterator34.n()).done; ) {
|
|
919
|
+
var _dataset$issues11;
|
|
920
|
+
var issue = _step34.value;
|
|
906
921
|
if (issue.path) issue.path.unshift(pathItem); else issue.path = [ pathItem ];
|
|
907
|
-
(_dataset$
|
|
922
|
+
(_dataset$issues11 = dataset.issues) === null || _dataset$issues11 === void 0 || _dataset$issues11.push(issue);
|
|
908
923
|
}
|
|
909
924
|
} catch (err) {
|
|
910
|
-
|
|
925
|
+
_iterator34.e(err);
|
|
911
926
|
} finally {
|
|
912
|
-
|
|
927
|
+
_iterator34.f();
|
|
913
928
|
}
|
|
914
929
|
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
915
930
|
if (config$1.abortEarly) {
|
|
@@ -1015,18 +1030,18 @@ function record(key, value$1, message$1) {
|
|
|
1015
1030
|
key: entryKey,
|
|
1016
1031
|
value: entryValue
|
|
1017
1032
|
};
|
|
1018
|
-
var
|
|
1033
|
+
var _iterator43 = _createForOfIteratorHelper(keyDataset.issues), _step43;
|
|
1019
1034
|
try {
|
|
1020
|
-
for (
|
|
1021
|
-
var _dataset$
|
|
1022
|
-
var issue =
|
|
1035
|
+
for (_iterator43.s(); !(_step43 = _iterator43.n()).done; ) {
|
|
1036
|
+
var _dataset$issues17;
|
|
1037
|
+
var issue = _step43.value;
|
|
1023
1038
|
issue.path = [ pathItem ];
|
|
1024
|
-
(_dataset$
|
|
1039
|
+
(_dataset$issues17 = dataset.issues) === null || _dataset$issues17 === void 0 || _dataset$issues17.push(issue);
|
|
1025
1040
|
}
|
|
1026
1041
|
} catch (err) {
|
|
1027
|
-
|
|
1042
|
+
_iterator43.e(err);
|
|
1028
1043
|
} finally {
|
|
1029
|
-
|
|
1044
|
+
_iterator43.f();
|
|
1030
1045
|
}
|
|
1031
1046
|
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
1032
1047
|
if (config$1.abortEarly) {
|
|
@@ -1045,18 +1060,18 @@ function record(key, value$1, message$1) {
|
|
|
1045
1060
|
key: entryKey,
|
|
1046
1061
|
value: entryValue
|
|
1047
1062
|
};
|
|
1048
|
-
var
|
|
1063
|
+
var _iterator44 = _createForOfIteratorHelper(valueDataset.issues), _step44;
|
|
1049
1064
|
try {
|
|
1050
|
-
for (
|
|
1051
|
-
var _dataset$
|
|
1052
|
-
var _issue5 =
|
|
1065
|
+
for (_iterator44.s(); !(_step44 = _iterator44.n()).done; ) {
|
|
1066
|
+
var _dataset$issues18;
|
|
1067
|
+
var _issue5 = _step44.value;
|
|
1053
1068
|
if (_issue5.path) _issue5.path.unshift(_pathItem5); else _issue5.path = [ _pathItem5 ];
|
|
1054
|
-
(_dataset$
|
|
1069
|
+
(_dataset$issues18 = dataset.issues) === null || _dataset$issues18 === void 0 || _dataset$issues18.push(_issue5);
|
|
1055
1070
|
}
|
|
1056
1071
|
} catch (err) {
|
|
1057
|
-
|
|
1072
|
+
_iterator44.e(err);
|
|
1058
1073
|
} finally {
|
|
1059
|
-
|
|
1074
|
+
_iterator44.f();
|
|
1060
1075
|
}
|
|
1061
1076
|
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1062
1077
|
if (config$1.abortEarly) {
|
|
@@ -1105,18 +1120,18 @@ function strictObject(entries$1, message$1) {
|
|
|
1105
1120
|
key: key,
|
|
1106
1121
|
value: value$1
|
|
1107
1122
|
};
|
|
1108
|
-
var
|
|
1123
|
+
var _iterator52 = _createForOfIteratorHelper(valueDataset.issues), _step52;
|
|
1109
1124
|
try {
|
|
1110
|
-
for (
|
|
1111
|
-
var _dataset$
|
|
1112
|
-
var issue =
|
|
1125
|
+
for (_iterator52.s(); !(_step52 = _iterator52.n()).done; ) {
|
|
1126
|
+
var _dataset$issues23;
|
|
1127
|
+
var issue = _step52.value;
|
|
1113
1128
|
if (issue.path) issue.path.unshift(pathItem); else issue.path = [ pathItem ];
|
|
1114
|
-
(_dataset$
|
|
1129
|
+
(_dataset$issues23 = dataset.issues) === null || _dataset$issues23 === void 0 || _dataset$issues23.push(issue);
|
|
1115
1130
|
}
|
|
1116
1131
|
} catch (err) {
|
|
1117
|
-
|
|
1132
|
+
_iterator52.e(err);
|
|
1118
1133
|
} finally {
|
|
1119
|
-
|
|
1134
|
+
_iterator52.f();
|
|
1120
1135
|
}
|
|
1121
1136
|
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
1122
1137
|
if (config$1.abortEarly) {
|
|
@@ -1184,17 +1199,28 @@ function string(message$1) {
|
|
|
1184
1199
|
function _subIssues(datasets) {
|
|
1185
1200
|
var issues;
|
|
1186
1201
|
if (datasets) {
|
|
1187
|
-
var
|
|
1202
|
+
var _iterator67 = _createForOfIteratorHelper(datasets), _step67;
|
|
1188
1203
|
try {
|
|
1189
|
-
for (
|
|
1190
|
-
var
|
|
1191
|
-
|
|
1192
|
-
|
|
1204
|
+
for (_iterator67.s(); !(_step67 = _iterator67.n()).done; ) {
|
|
1205
|
+
var dataset = _step67.value;
|
|
1206
|
+
if (issues) {
|
|
1207
|
+
var _iterator68 = _createForOfIteratorHelper(dataset.issues), _step68;
|
|
1208
|
+
try {
|
|
1209
|
+
for (_iterator68.s(); !(_step68 = _iterator68.n()).done; ) {
|
|
1210
|
+
var issue = _step68.value;
|
|
1211
|
+
issues.push(issue);
|
|
1212
|
+
}
|
|
1213
|
+
} catch (err) {
|
|
1214
|
+
_iterator68.e(err);
|
|
1215
|
+
} finally {
|
|
1216
|
+
_iterator68.f();
|
|
1217
|
+
}
|
|
1218
|
+
} else issues = dataset.issues;
|
|
1193
1219
|
}
|
|
1194
1220
|
} catch (err) {
|
|
1195
|
-
|
|
1221
|
+
_iterator67.e(err);
|
|
1196
1222
|
} finally {
|
|
1197
|
-
|
|
1223
|
+
_iterator67.f();
|
|
1198
1224
|
}
|
|
1199
1225
|
}
|
|
1200
1226
|
return issues;
|
|
@@ -1219,10 +1245,10 @@ function union(options, message$1) {
|
|
|
1219
1245
|
var validDataset;
|
|
1220
1246
|
var typedDatasets;
|
|
1221
1247
|
var untypedDatasets;
|
|
1222
|
-
var
|
|
1248
|
+
var _iterator69 = _createForOfIteratorHelper(this.options), _step69;
|
|
1223
1249
|
try {
|
|
1224
|
-
for (
|
|
1225
|
-
var schema =
|
|
1250
|
+
for (_iterator69.s(); !(_step69 = _iterator69.n()).done; ) {
|
|
1251
|
+
var schema = _step69.value;
|
|
1226
1252
|
var optionDataset = schema["~run"]({
|
|
1227
1253
|
value: dataset.value
|
|
1228
1254
|
}, config$1);
|
|
@@ -1236,9 +1262,9 @@ function union(options, message$1) {
|
|
|
1236
1262
|
} else if (untypedDatasets) untypedDatasets.push(optionDataset); else untypedDatasets = [ optionDataset ];
|
|
1237
1263
|
}
|
|
1238
1264
|
} catch (err) {
|
|
1239
|
-
|
|
1265
|
+
_iterator69.e(err);
|
|
1240
1266
|
} finally {
|
|
1241
|
-
|
|
1267
|
+
_iterator69.f();
|
|
1242
1268
|
}
|
|
1243
1269
|
if (validDataset) return validDataset;
|
|
1244
1270
|
if (typedDatasets) {
|
|
@@ -1441,12 +1467,19 @@ var SessionType;
|
|
|
1441
1467
|
SessionType["Openid4vp"] = "openid4vp";
|
|
1442
1468
|
})(SessionType || (SessionType = {}));
|
|
1443
1469
|
|
|
1470
|
+
const VerifierConfigurationValidator = object({
|
|
1471
|
+
dcApi: object({
|
|
1472
|
+
protocols: array(string())
|
|
1473
|
+
})
|
|
1474
|
+
});
|
|
1475
|
+
|
|
1444
1476
|
object({
|
|
1445
1477
|
credentialQuery: array(CredentialQueryValidator),
|
|
1446
1478
|
challenge: string(),
|
|
1447
1479
|
redirectUri: optional(string()),
|
|
1448
1480
|
walletProviderId: optional(string()),
|
|
1449
1481
|
dcApiSupported: optional(_boolean()),
|
|
1482
|
+
dcApiProtocols: optional(array(string())),
|
|
1450
1483
|
state: optional(pipe(string(), minLength(1)))
|
|
1451
1484
|
});
|
|
1452
1485
|
|
|
@@ -1764,18 +1797,41 @@ const getHashParamValue = (hash, param) => {
|
|
|
1764
1797
|
return urlParams.get(param);
|
|
1765
1798
|
};
|
|
1766
1799
|
|
|
1767
|
-
const
|
|
1800
|
+
const getVerifierConfiguration = async uri => {
|
|
1801
|
+
const responseResult = await safeFetch(`${uri}/v2/presentations/web/configuration`, {
|
|
1802
|
+
method: "GET",
|
|
1803
|
+
headers: {
|
|
1804
|
+
"Content-Type": "application/json"
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1807
|
+
if (responseResult.isErr()) {
|
|
1808
|
+
return err(responseResult.error);
|
|
1809
|
+
}
|
|
1810
|
+
const body = await responseResult.value.json().catch((() => undefined));
|
|
1811
|
+
if (!isType(VerifierConfigurationValidator)(body)) {
|
|
1812
|
+
return err({
|
|
1813
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1814
|
+
message: "Verifier configuration returned unsupported response"
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
return ok(body);
|
|
1818
|
+
};
|
|
1819
|
+
|
|
1820
|
+
const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId, dcApiSupported: dcApiSupported, dcApiProtocols: dcApiProtocols, applicationId: applicationId, state: state}) => {
|
|
1768
1821
|
const openid4vpConfiguration = !!walletProviderId || !!redirectUri ? {
|
|
1769
1822
|
redirectUri: redirectUri,
|
|
1770
1823
|
walletProviderId: walletProviderId
|
|
1771
1824
|
} : undefined;
|
|
1772
|
-
const postData = Object.assign({
|
|
1825
|
+
const postData = Object.assign(Object.assign(Object.assign({
|
|
1773
1826
|
credentialQuery: credentialQuery,
|
|
1774
1827
|
challenge: challenge,
|
|
1775
1828
|
applicationId: applicationId,
|
|
1776
|
-
dcApiSupported: dcApiSupported
|
|
1829
|
+
dcApiSupported: dcApiSupported
|
|
1830
|
+
}, dcApiProtocols !== undefined ? {
|
|
1831
|
+
dcApiProtocols: dcApiProtocols
|
|
1832
|
+
} : {}), {
|
|
1777
1833
|
openid4vpConfiguration: openid4vpConfiguration
|
|
1778
|
-
}, state !== undefined ? {
|
|
1834
|
+
}), state !== undefined ? {
|
|
1779
1835
|
state: state
|
|
1780
1836
|
} : {});
|
|
1781
1837
|
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions`, {
|
|
@@ -2220,9 +2276,45 @@ const verifyCredentialResponse = async options => {
|
|
|
2220
2276
|
return ok(credentialVerificationResponse);
|
|
2221
2277
|
};
|
|
2222
2278
|
|
|
2223
|
-
const
|
|
2224
|
-
var _a;
|
|
2225
|
-
return "DigitalCredential" in
|
|
2279
|
+
const digitalCredentialsApiSupported = target => {
|
|
2280
|
+
var _a, _b;
|
|
2281
|
+
return "DigitalCredential" in target && typeof ((_b = (_a = target.navigator) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b.get) === "function" && typeof target.DigitalCredential === "function" && (!("userAgentAllowsProtocol" in target.DigitalCredential) || typeof target.DigitalCredential.userAgentAllowsProtocol === "function");
|
|
2282
|
+
};
|
|
2283
|
+
|
|
2284
|
+
const isDigitalCredentialsApiSupported = () => digitalCredentialsApiSupported(window);
|
|
2285
|
+
|
|
2286
|
+
const getDigitalCredentialsApiSupport = async apiBaseUrl => {
|
|
2287
|
+
if (!digitalCredentialsApiSupported(window)) {
|
|
2288
|
+
return {
|
|
2289
|
+
supported: false
|
|
2290
|
+
};
|
|
2291
|
+
}
|
|
2292
|
+
const {DigitalCredential: digitalCredential} = window;
|
|
2293
|
+
if (!digitalCredential.userAgentAllowsProtocol) {
|
|
2294
|
+
return {
|
|
2295
|
+
supported: true
|
|
2296
|
+
};
|
|
2297
|
+
}
|
|
2298
|
+
const configurationResult = await getVerifierConfiguration(apiBaseUrl);
|
|
2299
|
+
if (configurationResult.isErr()) {
|
|
2300
|
+
return {
|
|
2301
|
+
supported: true
|
|
2302
|
+
};
|
|
2303
|
+
}
|
|
2304
|
+
const protocols = configurationResult.value.dcApi.protocols.filter((protocol => {
|
|
2305
|
+
var _a;
|
|
2306
|
+
try {
|
|
2307
|
+
return ((_a = digitalCredential.userAgentAllowsProtocol) === null || _a === void 0 ? void 0 : _a.call(digitalCredential, protocol)) === true;
|
|
2308
|
+
} catch (_b) {
|
|
2309
|
+
return false;
|
|
2310
|
+
}
|
|
2311
|
+
}));
|
|
2312
|
+
return protocols.length > 0 ? {
|
|
2313
|
+
supported: true,
|
|
2314
|
+
protocols: protocols
|
|
2315
|
+
} : {
|
|
2316
|
+
supported: false
|
|
2317
|
+
};
|
|
2226
2318
|
};
|
|
2227
2319
|
|
|
2228
2320
|
const sleep = ms => new Promise((resolve => setTimeout(resolve, ms)));
|
|
@@ -2304,7 +2396,7 @@ const requestCredentials = async options => {
|
|
|
2304
2396
|
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
2305
2397
|
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initializeOptions;
|
|
2306
2398
|
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration, state: state, onPresentationRequest: onPresentationRequest} = options;
|
|
2307
|
-
const
|
|
2399
|
+
const dcApiSupport = await getDigitalCredentialsApiSupport(apiBaseUrl);
|
|
2308
2400
|
const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
|
|
2309
2401
|
const createSessionResult = await createSession({
|
|
2310
2402
|
credentialQuery: credentialQuery,
|
|
@@ -2313,7 +2405,8 @@ const requestCredentials = async options => {
|
|
|
2313
2405
|
walletProviderId: (_a = openid4vpConfiguration === null || openid4vpConfiguration === void 0 ? void 0 : openid4vpConfiguration.walletProviderId) !== null && _a !== void 0 ? _a : undefined,
|
|
2314
2406
|
apiBaseUrl: apiBaseUrl,
|
|
2315
2407
|
applicationId: applicationId,
|
|
2316
|
-
dcApiSupported:
|
|
2408
|
+
dcApiSupported: dcApiSupport.supported,
|
|
2409
|
+
dcApiProtocols: dcApiSupport.protocols,
|
|
2317
2410
|
state: state
|
|
2318
2411
|
});
|
|
2319
2412
|
if (createSessionResult.isErr()) {
|