@mattrglobal/verifier-sdk-web 1.1.1-unstable.15 → 1.1.1-unstable.154
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 +39 -24
- package/dist/lib/verifier-js-no-deps.cjs.js +573 -185
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +699 -299
- package/dist/lib/verifier-js.cjs.js.map +1 -1
- package/dist/typings/common/safeFetch.d.ts +6 -3
- package/dist/typings/common/sleep.d.ts +1 -0
- package/dist/typings/index.d.ts +6 -6
- package/dist/typings/verifier/abortCredentialRequest.d.ts +6 -0
- package/dist/typings/verifier/handleRedirectCallback.d.ts +1 -1
- package/dist/typings/verifier/index.d.ts +2 -0
- package/dist/typings/verifier/instanceContext.d.ts +7 -0
- package/dist/typings/verifier/requestCredentialsCrossDevice.d.ts +3 -47
- package/dist/typings/verifier/requestCredentialsDigitalCredentialsApi.d.ts +16 -0
- package/dist/typings/verifier/requestCredentialsSameDevice.d.ts +1 -1
- package/dist/typings/verifier/types/credential-presentation.d.ts +128 -20
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +126 -183
- package/dist/typings/verifier/utils.d.ts +25 -5
- package/dist/verifier-js.development.js +644 -281
- package/dist/verifier-js.development.js.map +1 -1
- package/dist/verifier-js.production.esm.js +2 -2
- package/dist/verifier-js.production.esm.js.map +1 -1
- package/dist/verifier-js.production.js +2 -2
- package/dist/verifier-js.production.js.map +1 -1
- package/package.json +2 -2
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Do Not Translate or Localize
|
|
8
8
|
*
|
|
9
9
|
* Bundle of @mattrglobal/verifier-sdk-web
|
|
10
|
-
* Generated: 2025-
|
|
10
|
+
* Generated: 2025-05-18
|
|
11
11
|
* Version: 1.1.0
|
|
12
12
|
* Dependencies:
|
|
13
13
|
*
|
|
@@ -426,6 +426,73 @@
|
|
|
426
426
|
};
|
|
427
427
|
ResultAsync.fromPromise;
|
|
428
428
|
ResultAsync.fromSafePromise;
|
|
429
|
+
function _arrayLikeToArray(r, a) {
|
|
430
|
+
(null == a || a > r.length) && (a = r.length);
|
|
431
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
432
|
+
return n;
|
|
433
|
+
}
|
|
434
|
+
function _arrayWithoutHoles(r) {
|
|
435
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
436
|
+
}
|
|
437
|
+
function _createForOfIteratorHelper(r, e) {
|
|
438
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
439
|
+
if (!t) {
|
|
440
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
441
|
+
t && (r = t);
|
|
442
|
+
var n = 0, F = function() {};
|
|
443
|
+
return {
|
|
444
|
+
s: F,
|
|
445
|
+
n: function() {
|
|
446
|
+
return n >= r.length ? {
|
|
447
|
+
done: !0
|
|
448
|
+
} : {
|
|
449
|
+
done: !1,
|
|
450
|
+
value: r[n++]
|
|
451
|
+
};
|
|
452
|
+
},
|
|
453
|
+
e: function(r) {
|
|
454
|
+
throw r;
|
|
455
|
+
},
|
|
456
|
+
f: F
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
460
|
+
}
|
|
461
|
+
var o, a = !0, u = !1;
|
|
462
|
+
return {
|
|
463
|
+
s: function() {
|
|
464
|
+
t = t.call(r);
|
|
465
|
+
},
|
|
466
|
+
n: function() {
|
|
467
|
+
var r = t.next();
|
|
468
|
+
return a = r.done, r;
|
|
469
|
+
},
|
|
470
|
+
e: function(r) {
|
|
471
|
+
u = !0, o = r;
|
|
472
|
+
},
|
|
473
|
+
f: function() {
|
|
474
|
+
try {
|
|
475
|
+
a || null == t.return || t.return();
|
|
476
|
+
} finally {
|
|
477
|
+
if (u) throw o;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
function _defineProperty(e, r, t) {
|
|
483
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
484
|
+
value: t,
|
|
485
|
+
enumerable: !0,
|
|
486
|
+
configurable: !0,
|
|
487
|
+
writable: !0
|
|
488
|
+
}) : e[r] = t, e;
|
|
489
|
+
}
|
|
490
|
+
function _iterableToArray(r) {
|
|
491
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
492
|
+
}
|
|
493
|
+
function _nonIterableSpread() {
|
|
494
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
495
|
+
}
|
|
429
496
|
function ownKeys(e, r) {
|
|
430
497
|
var t = Object.keys(e);
|
|
431
498
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -447,6 +514,23 @@
|
|
|
447
514
|
}
|
|
448
515
|
return e;
|
|
449
516
|
}
|
|
517
|
+
function _toConsumableArray(r) {
|
|
518
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
519
|
+
}
|
|
520
|
+
function _toPrimitive(t, r) {
|
|
521
|
+
if ("object" != typeof t || !t) return t;
|
|
522
|
+
var e = t[Symbol.toPrimitive];
|
|
523
|
+
if (void 0 !== e) {
|
|
524
|
+
var i = e.call(t, r || "default");
|
|
525
|
+
if ("object" != typeof i) return i;
|
|
526
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
527
|
+
}
|
|
528
|
+
return ("string" === r ? String : Number)(t);
|
|
529
|
+
}
|
|
530
|
+
function _toPropertyKey(t) {
|
|
531
|
+
var i = _toPrimitive(t, "string");
|
|
532
|
+
return "symbol" == typeof i ? i : i + "";
|
|
533
|
+
}
|
|
450
534
|
function _typeof(o) {
|
|
451
535
|
"@babel/helpers - typeof";
|
|
452
536
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -455,107 +539,12 @@
|
|
|
455
539
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
456
540
|
}, _typeof(o);
|
|
457
541
|
}
|
|
458
|
-
function
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
enumerable: true,
|
|
464
|
-
configurable: true,
|
|
465
|
-
writable: true
|
|
466
|
-
});
|
|
467
|
-
} else {
|
|
468
|
-
obj[key] = value;
|
|
469
|
-
}
|
|
470
|
-
return obj;
|
|
471
|
-
}
|
|
472
|
-
function _toConsumableArray(arr) {
|
|
473
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
474
|
-
}
|
|
475
|
-
function _arrayWithoutHoles(arr) {
|
|
476
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
477
|
-
}
|
|
478
|
-
function _iterableToArray(iter) {
|
|
479
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
480
|
-
}
|
|
481
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
482
|
-
if (!o) return;
|
|
483
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
484
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
485
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
486
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
487
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
488
|
-
}
|
|
489
|
-
function _arrayLikeToArray(arr, len) {
|
|
490
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
491
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
492
|
-
return arr2;
|
|
493
|
-
}
|
|
494
|
-
function _nonIterableSpread() {
|
|
495
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
496
|
-
}
|
|
497
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
498
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
499
|
-
if (!it) {
|
|
500
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
501
|
-
if (it) o = it;
|
|
502
|
-
var i = 0;
|
|
503
|
-
var F = function() {};
|
|
504
|
-
return {
|
|
505
|
-
s: F,
|
|
506
|
-
n: function() {
|
|
507
|
-
if (i >= o.length) return {
|
|
508
|
-
done: true
|
|
509
|
-
};
|
|
510
|
-
return {
|
|
511
|
-
done: false,
|
|
512
|
-
value: o[i++]
|
|
513
|
-
};
|
|
514
|
-
},
|
|
515
|
-
e: function(e) {
|
|
516
|
-
throw e;
|
|
517
|
-
},
|
|
518
|
-
f: F
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
522
|
-
}
|
|
523
|
-
var normalCompletion = true, didErr = false, err;
|
|
524
|
-
return {
|
|
525
|
-
s: function() {
|
|
526
|
-
it = it.call(o);
|
|
527
|
-
},
|
|
528
|
-
n: function() {
|
|
529
|
-
var step = it.next();
|
|
530
|
-
normalCompletion = step.done;
|
|
531
|
-
return step;
|
|
532
|
-
},
|
|
533
|
-
e: function(e) {
|
|
534
|
-
didErr = true;
|
|
535
|
-
err = e;
|
|
536
|
-
},
|
|
537
|
-
f: function() {
|
|
538
|
-
try {
|
|
539
|
-
if (!normalCompletion && it.return != null) it.return();
|
|
540
|
-
} finally {
|
|
541
|
-
if (didErr) throw err;
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
function _toPrimitive(input, hint) {
|
|
547
|
-
if (typeof input !== "object" || input === null) return input;
|
|
548
|
-
var prim = input[Symbol.toPrimitive];
|
|
549
|
-
if (prim !== undefined) {
|
|
550
|
-
var res = prim.call(input, hint || "default");
|
|
551
|
-
if (typeof res !== "object") return res;
|
|
552
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
542
|
+
function _unsupportedIterableToArray(r, a) {
|
|
543
|
+
if (r) {
|
|
544
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
545
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
546
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
553
547
|
}
|
|
554
|
-
return (hint === "string" ? String : Number)(input);
|
|
555
|
-
}
|
|
556
|
-
function _toPropertyKey(arg) {
|
|
557
|
-
var key = _toPrimitive(arg, "string");
|
|
558
|
-
return typeof key === "symbol" ? key : String(key);
|
|
559
548
|
}
|
|
560
549
|
var store;
|
|
561
550
|
function getGlobalConfig(config2) {
|
|
@@ -661,6 +650,19 @@
|
|
|
661
650
|
function getDefault(schema, dataset, config2) {
|
|
662
651
|
return typeof schema["default"] === "function" ? schema["default"](dataset, config2) : schema["default"];
|
|
663
652
|
}
|
|
653
|
+
function any() {
|
|
654
|
+
return {
|
|
655
|
+
kind: "schema",
|
|
656
|
+
type: "any",
|
|
657
|
+
reference: any,
|
|
658
|
+
expects: "any",
|
|
659
|
+
async: false,
|
|
660
|
+
_run: function _run(dataset) {
|
|
661
|
+
dataset.typed = true;
|
|
662
|
+
return dataset;
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
}
|
|
664
666
|
function array(item, message) {
|
|
665
667
|
return {
|
|
666
668
|
kind: "schema",
|
|
@@ -744,16 +746,35 @@
|
|
|
744
746
|
}
|
|
745
747
|
};
|
|
746
748
|
}
|
|
747
|
-
function
|
|
749
|
+
function literal(literal_, message) {
|
|
750
|
+
return {
|
|
751
|
+
kind: "schema",
|
|
752
|
+
type: "literal",
|
|
753
|
+
reference: literal,
|
|
754
|
+
expects: _stringify(literal_),
|
|
755
|
+
async: false,
|
|
756
|
+
literal: literal_,
|
|
757
|
+
message: message,
|
|
758
|
+
_run: function _run(dataset, config2) {
|
|
759
|
+
if (dataset.value === this.literal) {
|
|
760
|
+
dataset.typed = true;
|
|
761
|
+
} else {
|
|
762
|
+
_addIssue(this, "type", dataset, config2);
|
|
763
|
+
}
|
|
764
|
+
return dataset;
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
function number(message) {
|
|
748
769
|
return {
|
|
749
770
|
kind: "schema",
|
|
750
|
-
type: "
|
|
751
|
-
reference:
|
|
752
|
-
expects: "
|
|
771
|
+
type: "number",
|
|
772
|
+
reference: number,
|
|
773
|
+
expects: "number",
|
|
753
774
|
async: false,
|
|
754
775
|
message: message,
|
|
755
776
|
_run: function _run(dataset, config2) {
|
|
756
|
-
if (typeof dataset.value === "
|
|
777
|
+
if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
|
|
757
778
|
dataset.typed = true;
|
|
758
779
|
} else {
|
|
759
780
|
_addIssue(this, "type", dataset, config2);
|
|
@@ -1242,41 +1263,20 @@
|
|
|
1242
1263
|
});
|
|
1243
1264
|
}
|
|
1244
1265
|
};
|
|
1245
|
-
var SafeFetchCommonRespondErrorType;
|
|
1246
|
-
(function(SafeFetchCommonRespondErrorType) {
|
|
1247
|
-
SafeFetchCommonRespondErrorType["UnexpectedRespond"] = "UnexpectedRespond";
|
|
1248
|
-
})(SafeFetchCommonRespondErrorType || (SafeFetchCommonRespondErrorType = {}));
|
|
1249
|
-
var SafeFetchErrorType;
|
|
1250
|
-
(function(SafeFetchErrorType) {
|
|
1251
|
-
SafeFetchErrorType["HttpError"] = "HttpError";
|
|
1252
|
-
SafeFetchErrorType["UnknownError"] = "UnknownError";
|
|
1253
|
-
})(SafeFetchErrorType || (SafeFetchErrorType = {}));
|
|
1254
|
-
const safeFetch = async (input, init) => {
|
|
1255
|
-
try {
|
|
1256
|
-
const response = await fetch(input, init);
|
|
1257
|
-
if (response.status > 299 || response.status < 200) {
|
|
1258
|
-
return err({
|
|
1259
|
-
type: SafeFetchErrorType.HttpError,
|
|
1260
|
-
message: `HTTP error, status = ${response.status}`,
|
|
1261
|
-
status: response.status
|
|
1262
|
-
});
|
|
1263
|
-
}
|
|
1264
|
-
return ok(response);
|
|
1265
|
-
} catch (error) {
|
|
1266
|
-
return err({
|
|
1267
|
-
type: SafeFetchErrorType.UnknownError,
|
|
1268
|
-
message: "Unknown error",
|
|
1269
|
-
cause: error
|
|
1270
|
-
});
|
|
1271
|
-
}
|
|
1272
|
-
};
|
|
1273
1266
|
exports.MobileCredentialVerificationReasonType = void 0;
|
|
1274
1267
|
(function(MobileCredentialVerificationReasonType) {
|
|
1275
|
-
MobileCredentialVerificationReasonType["
|
|
1276
|
-
MobileCredentialVerificationReasonType["
|
|
1277
|
-
MobileCredentialVerificationReasonType["
|
|
1278
|
-
MobileCredentialVerificationReasonType["
|
|
1279
|
-
MobileCredentialVerificationReasonType["
|
|
1268
|
+
MobileCredentialVerificationReasonType["TrustedIssuerCertificateExpired"] = "TrustedIssuerCertificateExpired";
|
|
1269
|
+
MobileCredentialVerificationReasonType["TrustedIssuerCertificateNotYetValid"] = "TrustedIssuerCertificateNotYetValid";
|
|
1270
|
+
MobileCredentialVerificationReasonType["IssuerNotTrusted"] = "IssuerNotTrusted";
|
|
1271
|
+
MobileCredentialVerificationReasonType["MobileCredentialInvalid"] = "MobileCredentialInvalid";
|
|
1272
|
+
MobileCredentialVerificationReasonType["MobileCredentialExpired"] = "MobileCredentialExpired";
|
|
1273
|
+
MobileCredentialVerificationReasonType["MobileCredentialNotYetValid"] = "MobileCredentialNotYetValid";
|
|
1274
|
+
MobileCredentialVerificationReasonType["InvalidSignerCertificate"] = "InvalidSignerCertificate";
|
|
1275
|
+
MobileCredentialVerificationReasonType["DeviceKeyInvalid"] = "DeviceKeyInvalid";
|
|
1276
|
+
MobileCredentialVerificationReasonType["UnsupportedCurve"] = "UnsupportedCurve";
|
|
1277
|
+
MobileCredentialVerificationReasonType["StatusRevoked"] = "StatusRevoked";
|
|
1278
|
+
MobileCredentialVerificationReasonType["StatusSuspended"] = "StatusSuspended";
|
|
1279
|
+
MobileCredentialVerificationReasonType["StatusUnknown"] = "StatusUnknown";
|
|
1280
1280
|
})(exports.MobileCredentialVerificationReasonType || (exports.MobileCredentialVerificationReasonType = {}));
|
|
1281
1281
|
exports.ClaimType = void 0;
|
|
1282
1282
|
(function(ClaimType) {
|
|
@@ -1302,6 +1302,13 @@
|
|
|
1302
1302
|
(function(OpenidPresentationCredentialProfileSupported) {
|
|
1303
1303
|
OpenidPresentationCredentialProfileSupported["MOBILE"] = "mobile";
|
|
1304
1304
|
})(exports.OpenidPresentationCredentialProfileSupported || (exports.OpenidPresentationCredentialProfileSupported = {}));
|
|
1305
|
+
var PresentationStatusCode;
|
|
1306
|
+
(function(PresentationStatusCode) {
|
|
1307
|
+
PresentationStatusCode["AwaitingRequestRetrieval"] = "AwaitingRequestRetrieval";
|
|
1308
|
+
PresentationStatusCode["AwaitingResponse"] = "AwaitingResponse";
|
|
1309
|
+
PresentationStatusCode["ResponseSubmitted"] = "ResponseSubmitted";
|
|
1310
|
+
PresentationStatusCode["ResultReady"] = "ResultReady";
|
|
1311
|
+
})(PresentationStatusCode || (PresentationStatusCode = {}));
|
|
1305
1312
|
const CredentialQueryValidator = object({
|
|
1306
1313
|
profile: picklist([ exports.OpenidPresentationCredentialProfileSupported.MOBILE ]),
|
|
1307
1314
|
docType: string(),
|
|
@@ -1325,69 +1332,138 @@
|
|
|
1325
1332
|
credentialErrors: optional(unknown()),
|
|
1326
1333
|
error: optional(unknown())
|
|
1327
1334
|
});
|
|
1335
|
+
exports.Mode = void 0;
|
|
1336
|
+
(function(Mode) {
|
|
1337
|
+
Mode["SameDevice"] = "sameDevice";
|
|
1338
|
+
Mode["CrossDevice"] = "crossDevice";
|
|
1339
|
+
})(exports.Mode || (exports.Mode = {}));
|
|
1340
|
+
var SessionType;
|
|
1341
|
+
(function(SessionType) {
|
|
1342
|
+
SessionType["DigitalCredentialsApi"] = "digital-credentials-api";
|
|
1343
|
+
SessionType["Openid4vp"] = "openid4vp";
|
|
1344
|
+
})(SessionType || (SessionType = {}));
|
|
1328
1345
|
object({
|
|
1329
1346
|
credentialQuery: array(CredentialQueryValidator),
|
|
1330
1347
|
challenge: string(),
|
|
1331
1348
|
redirectUri: optional(string()),
|
|
1332
|
-
walletProviderId: optional(string())
|
|
1349
|
+
walletProviderId: optional(string()),
|
|
1350
|
+
dcApiSupported: optional(_boolean())
|
|
1333
1351
|
});
|
|
1334
|
-
const
|
|
1352
|
+
const CreateSessionDigitalCredentialsValidator = object({
|
|
1353
|
+
type: literal(SessionType.DigitalCredentialsApi),
|
|
1335
1354
|
sessionId: string(),
|
|
1355
|
+
sessionKey: string(),
|
|
1356
|
+
sessionTtl: number(),
|
|
1357
|
+
request: record(string(), any())
|
|
1358
|
+
});
|
|
1359
|
+
const CreateSessionOpenId4vpResponseValidator = object({
|
|
1360
|
+
type: optional(literal(SessionType.Openid4vp)),
|
|
1361
|
+
sessionId: string(),
|
|
1362
|
+
sessionKey: string(),
|
|
1336
1363
|
sessionUrl: string()
|
|
1337
1364
|
});
|
|
1365
|
+
const CreateSessionResponseValidator = union([ CreateSessionDigitalCredentialsValidator, CreateSessionOpenId4vpResponseValidator ]);
|
|
1366
|
+
const GetSessionStatusResponseValidator = union([ object({
|
|
1367
|
+
status: picklist([ PresentationStatusCode.ResultReady ]),
|
|
1368
|
+
responseCode: optional(string())
|
|
1369
|
+
}), object({
|
|
1370
|
+
status: string()
|
|
1371
|
+
}) ]);
|
|
1338
1372
|
var LocalStorageKey;
|
|
1339
1373
|
(function(LocalStorageKey) {
|
|
1340
1374
|
LocalStorageKey["challenge"] = "mattr_chg";
|
|
1341
1375
|
LocalStorageKey["sessionId"] = "mattr_sid";
|
|
1342
1376
|
})(LocalStorageKey || (LocalStorageKey = {}));
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
Mode["sameDevice"] = "sameDevice";
|
|
1346
|
-
Mode["crossDevice"] = "crossDevice";
|
|
1347
|
-
})(exports.Mode || (exports.Mode = {}));
|
|
1377
|
+
const MATTR_SDK_VERSION_HEADER = "x-mattr-sdk-version";
|
|
1378
|
+
const MATTR_SDK_VERSION_VALUE = "2.0.0";
|
|
1348
1379
|
var MessageEventDataType;
|
|
1349
1380
|
(function(MessageEventDataType) {
|
|
1350
1381
|
MessageEventDataType["PresentationCompleted"] = "PresentationCompleted";
|
|
1351
1382
|
MessageEventDataType["PresentationTimeout"] = "PresentationTimeout";
|
|
1352
1383
|
MessageEventDataType["PresentationAbort"] = "PresentationAbort";
|
|
1353
1384
|
})(MessageEventDataType || (MessageEventDataType = {}));
|
|
1354
|
-
const
|
|
1355
|
-
credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
|
|
1356
|
-
redirectUri: string(),
|
|
1357
|
-
challenge: optional(string()),
|
|
1385
|
+
const OpenId4vpConfigSameDeviceOptionsValidator = object({
|
|
1358
1386
|
walletProviderId: optional(string()),
|
|
1359
|
-
mode:
|
|
1387
|
+
mode: literal(exports.Mode.SameDevice),
|
|
1388
|
+
redirectUri: string()
|
|
1360
1389
|
});
|
|
1361
|
-
const
|
|
1362
|
-
credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
|
|
1363
|
-
crossDeviceCallback: object({
|
|
1364
|
-
onComplete: function_(),
|
|
1365
|
-
onFailure: function_()
|
|
1366
|
-
}),
|
|
1367
|
-
challenge: optional(string()),
|
|
1390
|
+
const OpenId4vpConfigCrossDeviceOptionsValidator = object({
|
|
1368
1391
|
walletProviderId: optional(string()),
|
|
1369
|
-
mode:
|
|
1392
|
+
mode: literal(exports.Mode.CrossDevice)
|
|
1370
1393
|
});
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1373
|
-
crossDeviceCallback: object({
|
|
1374
|
-
onComplete: function_(),
|
|
1375
|
-
onFailure: function_()
|
|
1376
|
-
}),
|
|
1394
|
+
const OpenId4vpConfigAutoDetectOptionsValidator = object({
|
|
1395
|
+
walletProviderId: optional(string()),
|
|
1377
1396
|
redirectUri: string(),
|
|
1397
|
+
mode: optional(picklist([ exports.Mode.CrossDevice, exports.Mode.SameDevice ]))
|
|
1398
|
+
});
|
|
1399
|
+
const RequestCredentialsOptionsValidator = object({
|
|
1400
|
+
credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
|
|
1378
1401
|
challenge: optional(string()),
|
|
1379
|
-
|
|
1380
|
-
mode: optional(picklist([ exports.Mode.crossDevice, exports.Mode.sameDevice ]))
|
|
1402
|
+
openid4vpConfiguration: optional(union([ OpenId4vpConfigSameDeviceOptionsValidator, OpenId4vpConfigCrossDeviceOptionsValidator, OpenId4vpConfigAutoDetectOptionsValidator ]))
|
|
1381
1403
|
});
|
|
1382
|
-
const RequestCredentialsOptionsValidator = union([ RequestCredentialsSameDeviceOptionsValidator, RequestCredentialsCrossDeviceOptionsValidator, RequestCredentialsAutoDetectDeviceOptionsValidator ]);
|
|
1383
1404
|
exports.RequestCredentialsErrorType = void 0;
|
|
1384
1405
|
(function(RequestCredentialsErrorType) {
|
|
1385
1406
|
RequestCredentialsErrorType["RequestCredentialsFailed"] = "RequestCredentialsFailed";
|
|
1407
|
+
RequestCredentialsErrorType["Timeout"] = "Timeout";
|
|
1408
|
+
RequestCredentialsErrorType["Abort"] = "Abort";
|
|
1386
1409
|
})(exports.RequestCredentialsErrorType || (exports.RequestCredentialsErrorType = {}));
|
|
1410
|
+
var RequestCredentialsErrorMessage;
|
|
1411
|
+
(function(RequestCredentialsErrorMessage) {
|
|
1412
|
+
RequestCredentialsErrorMessage["FailedToGetSessionResult"] = "Failed to get session result";
|
|
1413
|
+
RequestCredentialsErrorMessage["FailedToGetSessionStatus"] = "Failed to get session status";
|
|
1414
|
+
RequestCredentialsErrorMessage["FailedToCreateSession"] = "Failed to create session";
|
|
1415
|
+
RequestCredentialsErrorMessage["FailedToVerifyCredentialResponse"] = "Failed to verify credential response";
|
|
1416
|
+
RequestCredentialsErrorMessage["MissingOpenId4vpConfig"] = "Identified openid4vp session, but missing openId4vpConfiguration on `requestCredentials`";
|
|
1417
|
+
RequestCredentialsErrorMessage["DcApiError"] = "Failed to request credentials with Digital Credentials API";
|
|
1418
|
+
RequestCredentialsErrorMessage["DcApiResponseParseError"] = "Failed to parse response from Digital Credentials API";
|
|
1419
|
+
RequestCredentialsErrorMessage["Abort"] = "User aborted the session";
|
|
1420
|
+
RequestCredentialsErrorMessage["Timeout"] = "User session timeout";
|
|
1421
|
+
})(RequestCredentialsErrorMessage || (RequestCredentialsErrorMessage = {}));
|
|
1422
|
+
exports.AbortSessionErrorType = void 0;
|
|
1423
|
+
(function(AbortSessionErrorType) {
|
|
1424
|
+
AbortSessionErrorType["AbortSessionFailed"] = "AbortSessionFailed";
|
|
1425
|
+
})(exports.AbortSessionErrorType || (exports.AbortSessionErrorType = {}));
|
|
1426
|
+
var AbortSessionErrorMessage;
|
|
1427
|
+
(function(AbortSessionErrorMessage) {
|
|
1428
|
+
AbortSessionErrorMessage["FailedToAbortSession"] = "Failed to abort session";
|
|
1429
|
+
})(AbortSessionErrorMessage || (AbortSessionErrorMessage = {}));
|
|
1387
1430
|
const InitialiseOptionsValidator = object({
|
|
1388
|
-
apiBaseUrl: string(),
|
|
1389
|
-
applicationId:
|
|
1431
|
+
apiBaseUrl: pipe(string(), nonEmpty("Must not be empty")),
|
|
1432
|
+
applicationId: pipe(string(), nonEmpty("Must not be empty"))
|
|
1390
1433
|
});
|
|
1434
|
+
var SafeFetchCommonResponseErrorType;
|
|
1435
|
+
(function(SafeFetchCommonResponseErrorType) {
|
|
1436
|
+
SafeFetchCommonResponseErrorType["UnexpectedResponse"] = "UnexpectedResponse";
|
|
1437
|
+
})(SafeFetchCommonResponseErrorType || (SafeFetchCommonResponseErrorType = {}));
|
|
1438
|
+
var SafeFetchErrorType;
|
|
1439
|
+
(function(SafeFetchErrorType) {
|
|
1440
|
+
SafeFetchErrorType["HttpError"] = "HttpError";
|
|
1441
|
+
SafeFetchErrorType["UnknownError"] = "UnknownError";
|
|
1442
|
+
})(SafeFetchErrorType || (SafeFetchErrorType = {}));
|
|
1443
|
+
const safeFetch = async (input, init) => {
|
|
1444
|
+
try {
|
|
1445
|
+
const headers = Object.assign(Object.assign({}, init === null || init === void 0 ? void 0 : init.headers), {
|
|
1446
|
+
[MATTR_SDK_VERSION_HEADER]: `verifier-sdk-web/${MATTR_SDK_VERSION_VALUE}`
|
|
1447
|
+
});
|
|
1448
|
+
const response = await fetch(input, Object.assign(Object.assign({}, init), {
|
|
1449
|
+
headers: headers
|
|
1450
|
+
}));
|
|
1451
|
+
if (response.status > 299 || response.status < 200) {
|
|
1452
|
+
return err({
|
|
1453
|
+
type: SafeFetchErrorType.HttpError,
|
|
1454
|
+
message: `HTTP error, status = ${response.status}`,
|
|
1455
|
+
status: response.status
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
return ok(response);
|
|
1459
|
+
} catch (error) {
|
|
1460
|
+
return err({
|
|
1461
|
+
type: SafeFetchErrorType.UnknownError,
|
|
1462
|
+
message: "Unknown error",
|
|
1463
|
+
cause: error
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1391
1467
|
let initialiseOptions = undefined;
|
|
1392
1468
|
var InitialiseErrorMessage;
|
|
1393
1469
|
(function(InitialiseErrorMessage) {
|
|
@@ -1398,6 +1474,42 @@
|
|
|
1398
1474
|
initialiseOptions = options;
|
|
1399
1475
|
};
|
|
1400
1476
|
const getInitialiseOptions = () => initialiseOptions;
|
|
1477
|
+
let sessionAbortController = undefined;
|
|
1478
|
+
let _sessionId = undefined;
|
|
1479
|
+
let _sessionKey = undefined;
|
|
1480
|
+
let _sessionTimeoutId = undefined;
|
|
1481
|
+
const getActiveSession = () => {
|
|
1482
|
+
const sessionId = _sessionId;
|
|
1483
|
+
const sessionKey = _sessionKey;
|
|
1484
|
+
const sessionTimeoutId = _sessionTimeoutId;
|
|
1485
|
+
if (sessionId) {
|
|
1486
|
+
return {
|
|
1487
|
+
sessionId: sessionId,
|
|
1488
|
+
sessionKey: sessionKey,
|
|
1489
|
+
sessionTimeoutId: sessionTimeoutId
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
return undefined;
|
|
1493
|
+
};
|
|
1494
|
+
const setActiveSession = session => {
|
|
1495
|
+
const {sessionId: sessionId, sessionKey: sessionKey, sessionTimeoutId: sessionTimeoutId} = session;
|
|
1496
|
+
_sessionId = sessionId;
|
|
1497
|
+
_sessionKey = sessionKey;
|
|
1498
|
+
_sessionTimeoutId = sessionTimeoutId;
|
|
1499
|
+
const abortController = new AbortController;
|
|
1500
|
+
sessionAbortController = abortController;
|
|
1501
|
+
return abortController;
|
|
1502
|
+
};
|
|
1503
|
+
const removeActiveSession = () => {
|
|
1504
|
+
sessionAbortController === null || sessionAbortController === void 0 ? void 0 : sessionAbortController.abort();
|
|
1505
|
+
if (_sessionTimeoutId) {
|
|
1506
|
+
window.clearTimeout(_sessionTimeoutId);
|
|
1507
|
+
}
|
|
1508
|
+
sessionAbortController = undefined;
|
|
1509
|
+
_sessionKey = undefined;
|
|
1510
|
+
_sessionId = undefined;
|
|
1511
|
+
_sessionTimeoutId = undefined;
|
|
1512
|
+
};
|
|
1401
1513
|
var isMobile_1 = isMobile;
|
|
1402
1514
|
var isMobile_2 = isMobile;
|
|
1403
1515
|
var default_1 = isMobile;
|
|
@@ -1422,6 +1534,23 @@
|
|
|
1422
1534
|
isMobile_1["default"] = default_1;
|
|
1423
1535
|
const defaultRetryDelay = attempt => Math.pow(2, attempt) * 1e3;
|
|
1424
1536
|
const defaultRetry = 2;
|
|
1537
|
+
const withRetry = async (fn, options) => {
|
|
1538
|
+
const {retries: retries = defaultRetry, retryDelay: retryDelay = defaultRetryDelay, attempt: attempt = 0} = options;
|
|
1539
|
+
try {
|
|
1540
|
+
return await fn();
|
|
1541
|
+
} catch (err) {
|
|
1542
|
+
if (retries > 0) {
|
|
1543
|
+
const delay = typeof retryDelay === "function" ? retryDelay(attempt) : retryDelay;
|
|
1544
|
+
await new Promise((resolve => setTimeout(resolve, delay)));
|
|
1545
|
+
return await withRetry(fn, Object.assign(Object.assign({}, options), {
|
|
1546
|
+
retries: retries - 1,
|
|
1547
|
+
retryDelay: retryDelay,
|
|
1548
|
+
attempt: attempt + 1
|
|
1549
|
+
}));
|
|
1550
|
+
}
|
|
1551
|
+
throw err;
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1425
1554
|
const withRetrySafeFetch = async (fn, options) => {
|
|
1426
1555
|
const {retries: retries = defaultRetry, retryDelay: retryDelay = defaultRetryDelay, attempt: attempt = 0, retryHttpStatus: retryHttpStatus} = options;
|
|
1427
1556
|
const result = await fn();
|
|
@@ -1447,17 +1576,15 @@
|
|
|
1447
1576
|
const urlParams = new URLSearchParams(hash.split("#")[1]);
|
|
1448
1577
|
return urlParams.get(param);
|
|
1449
1578
|
};
|
|
1450
|
-
const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl,
|
|
1451
|
-
const postData =
|
|
1579
|
+
const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId, dcApiSupported: dcApiSupported, applicationId: applicationId}) => {
|
|
1580
|
+
const postData = {
|
|
1452
1581
|
credentialQuery: credentialQuery,
|
|
1453
|
-
challenge: challenge
|
|
1454
|
-
|
|
1455
|
-
redirectUri: redirectUri
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
}
|
|
1459
|
-
walletProviderId: walletProviderId
|
|
1460
|
-
} : {});
|
|
1582
|
+
challenge: challenge,
|
|
1583
|
+
applicationId: applicationId,
|
|
1584
|
+
redirectUri: redirectUri,
|
|
1585
|
+
walletProviderId: walletProviderId,
|
|
1586
|
+
dcApiSupported: dcApiSupported
|
|
1587
|
+
};
|
|
1461
1588
|
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions`, {
|
|
1462
1589
|
method: "POST",
|
|
1463
1590
|
headers: {
|
|
@@ -1471,8 +1598,40 @@
|
|
|
1471
1598
|
const data = await responseResult.value.json();
|
|
1472
1599
|
if (!isType(CreateSessionResponseValidator)(data)) {
|
|
1473
1600
|
return err({
|
|
1474
|
-
type:
|
|
1475
|
-
message: "Create session
|
|
1601
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1602
|
+
message: "Create session returned unsupported response"
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
return ok(data);
|
|
1606
|
+
};
|
|
1607
|
+
const abortSession = async ({apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey}) => {
|
|
1608
|
+
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/abort`, {
|
|
1609
|
+
method: "POST",
|
|
1610
|
+
headers: {
|
|
1611
|
+
"Content-Type": "application/json",
|
|
1612
|
+
Authorization: `Bearer ${sessionKey}`
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
if (responseResult.isErr()) {
|
|
1616
|
+
return err(responseResult.error);
|
|
1617
|
+
}
|
|
1618
|
+
return ok(undefined);
|
|
1619
|
+
};
|
|
1620
|
+
const getSessionStatus = async ({apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey}) => {
|
|
1621
|
+
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/status`, {
|
|
1622
|
+
method: "GET",
|
|
1623
|
+
headers: {
|
|
1624
|
+
Authorization: `Bearer ${sessionKey}`
|
|
1625
|
+
}
|
|
1626
|
+
});
|
|
1627
|
+
if (responseResult.isErr()) {
|
|
1628
|
+
return err(responseResult.error);
|
|
1629
|
+
}
|
|
1630
|
+
const data = await responseResult.value.json();
|
|
1631
|
+
if (!isType(GetSessionStatusResponseValidator)(data)) {
|
|
1632
|
+
return err({
|
|
1633
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1634
|
+
message: "Get session status return unsupported response"
|
|
1476
1635
|
});
|
|
1477
1636
|
}
|
|
1478
1637
|
return ok(data);
|
|
@@ -1499,7 +1658,7 @@
|
|
|
1499
1658
|
const data = await responseResult.value.json();
|
|
1500
1659
|
if (!isType(PresentationResultRelaxValidator)(data)) {
|
|
1501
1660
|
return err({
|
|
1502
|
-
type:
|
|
1661
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1503
1662
|
message: "Exchange session result return unsupported response",
|
|
1504
1663
|
details: {
|
|
1505
1664
|
data: data
|
|
@@ -1512,26 +1671,17 @@
|
|
|
1512
1671
|
ua: userAgent,
|
|
1513
1672
|
tablet: false
|
|
1514
1673
|
});
|
|
1515
|
-
|
|
1516
|
-
(function(CrossDeviceCallbackErrorType) {
|
|
1517
|
-
CrossDeviceCallbackErrorType["Timeout"] = "Timeout";
|
|
1518
|
-
CrossDeviceCallbackErrorType["Abort"] = "Abort";
|
|
1519
|
-
CrossDeviceCallbackErrorType["RequestCredentialsFailed"] = "RequestCredentialsFailed";
|
|
1520
|
-
})(exports.CrossDeviceCallbackErrorType || (exports.CrossDeviceCallbackErrorType = {}));
|
|
1521
|
-
var CrossDeviceRequestCredentialsErrorMessage;
|
|
1522
|
-
(function(CrossDeviceRequestCredentialsErrorMessage) {
|
|
1523
|
-
CrossDeviceRequestCredentialsErrorMessage["FailedToGetSessionResult"] = "Failed to get session result";
|
|
1524
|
-
CrossDeviceRequestCredentialsErrorMessage["FailedToCreateSession"] = "Failed to create session";
|
|
1525
|
-
CrossDeviceRequestCredentialsErrorMessage["Abort"] = "User aborted the session";
|
|
1526
|
-
CrossDeviceRequestCredentialsErrorMessage["Timeout"] = "User session timeout";
|
|
1527
|
-
})(CrossDeviceRequestCredentialsErrorMessage || (CrossDeviceRequestCredentialsErrorMessage = {}));
|
|
1674
|
+
const getVersion = () => MATTR_SDK_VERSION_VALUE;
|
|
1528
1675
|
var WindowEventListenerType;
|
|
1529
1676
|
(function(WindowEventListenerType) {
|
|
1530
1677
|
WindowEventListenerType["message"] = "message";
|
|
1531
1678
|
})(WindowEventListenerType || (WindowEventListenerType = {}));
|
|
1532
|
-
let listener;
|
|
1679
|
+
let listener = undefined;
|
|
1533
1680
|
const removeWindowMessageEventListener = () => {
|
|
1534
|
-
|
|
1681
|
+
if (listener) {
|
|
1682
|
+
window.removeEventListener(WindowEventListenerType.message, listener, false);
|
|
1683
|
+
}
|
|
1684
|
+
listener = undefined;
|
|
1535
1685
|
};
|
|
1536
1686
|
const closeCrossDeviceModal = options => {
|
|
1537
1687
|
const {container: container} = options;
|
|
@@ -1541,8 +1691,7 @@
|
|
|
1541
1691
|
removeWindowMessageEventListener();
|
|
1542
1692
|
};
|
|
1543
1693
|
const receiveMessageHandler = options => async event => {
|
|
1544
|
-
const {
|
|
1545
|
-
const {onComplete: onComplete, onFailure: onFailure} = crossDeviceCallback;
|
|
1694
|
+
const {onComplete: onComplete, onFailure: onFailure, container: container, sessionId: sessionId, apiBaseUrl: apiBaseUrl, challenge: challenge} = options;
|
|
1546
1695
|
if (event.origin !== apiBaseUrl) {
|
|
1547
1696
|
return;
|
|
1548
1697
|
}
|
|
@@ -1556,8 +1705,8 @@
|
|
|
1556
1705
|
});
|
|
1557
1706
|
if (result.isErr()) {
|
|
1558
1707
|
onFailure({
|
|
1559
|
-
type: exports.
|
|
1560
|
-
message:
|
|
1708
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1709
|
+
message: RequestCredentialsErrorMessage.FailedToGetSessionResult
|
|
1561
1710
|
});
|
|
1562
1711
|
closeCrossDeviceModal({
|
|
1563
1712
|
container: container
|
|
@@ -1565,8 +1714,9 @@
|
|
|
1565
1714
|
return;
|
|
1566
1715
|
}
|
|
1567
1716
|
onComplete({
|
|
1568
|
-
result: result.value,
|
|
1569
|
-
sessionId: result.value.sessionId
|
|
1717
|
+
result: "challenge" in result.value ? result.value : undefined,
|
|
1718
|
+
sessionId: result.value.sessionId,
|
|
1719
|
+
sessionCompletedInRedirect: false
|
|
1570
1720
|
});
|
|
1571
1721
|
closeCrossDeviceModal({
|
|
1572
1722
|
container: container
|
|
@@ -1575,8 +1725,8 @@
|
|
|
1575
1725
|
}
|
|
1576
1726
|
if (event.data.type === MessageEventDataType.PresentationTimeout) {
|
|
1577
1727
|
onFailure({
|
|
1578
|
-
type: exports.
|
|
1579
|
-
message:
|
|
1728
|
+
type: exports.RequestCredentialsErrorType.Timeout,
|
|
1729
|
+
message: RequestCredentialsErrorMessage.Timeout
|
|
1580
1730
|
});
|
|
1581
1731
|
closeCrossDeviceModal({
|
|
1582
1732
|
container: container
|
|
@@ -1585,8 +1735,8 @@
|
|
|
1585
1735
|
}
|
|
1586
1736
|
if (event.data.type === MessageEventDataType.PresentationAbort) {
|
|
1587
1737
|
onFailure({
|
|
1588
|
-
type: exports.
|
|
1589
|
-
message:
|
|
1738
|
+
type: exports.RequestCredentialsErrorType.Abort,
|
|
1739
|
+
message: RequestCredentialsErrorMessage.Abort
|
|
1590
1740
|
});
|
|
1591
1741
|
closeCrossDeviceModal({
|
|
1592
1742
|
container: container
|
|
@@ -1609,104 +1759,320 @@
|
|
|
1609
1759
|
modalContainer.setAttribute("class", "mattr-verifier-modal-container");
|
|
1610
1760
|
return modalContainer;
|
|
1611
1761
|
};
|
|
1612
|
-
const
|
|
1613
|
-
const {challenge: challenge,
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1762
|
+
const requestCredentialsWithCrossDevice = async options => {
|
|
1763
|
+
const {challenge: challenge, apiBaseUrl: apiBaseUrl, sessionUrl: sessionUrl, sessionId: sessionId, sessionKey: sessionKey} = options;
|
|
1764
|
+
const container = openCrossDeviceModal({
|
|
1765
|
+
sessionUrl: sessionUrl
|
|
1766
|
+
});
|
|
1767
|
+
return await new Promise((resolve => {
|
|
1768
|
+
const abortController = setActiveSession({
|
|
1769
|
+
sessionId: sessionId,
|
|
1770
|
+
sessionKey: sessionKey
|
|
1771
|
+
});
|
|
1772
|
+
abortController.signal.addEventListener("abort", (() => {
|
|
1773
|
+
closeCrossDeviceModal({
|
|
1774
|
+
container: container
|
|
1775
|
+
});
|
|
1776
|
+
resolve(err({
|
|
1777
|
+
type: exports.RequestCredentialsErrorType.Abort,
|
|
1778
|
+
message: RequestCredentialsErrorMessage.Abort
|
|
1779
|
+
}));
|
|
1780
|
+
}));
|
|
1781
|
+
removeWindowMessageEventListener();
|
|
1782
|
+
listener = receiveMessageHandler({
|
|
1783
|
+
container: container,
|
|
1784
|
+
sessionId: sessionId,
|
|
1785
|
+
apiBaseUrl: apiBaseUrl,
|
|
1786
|
+
challenge: challenge,
|
|
1787
|
+
onComplete: data => resolve(ok(data)),
|
|
1788
|
+
onFailure: error => resolve(err(error))
|
|
1789
|
+
});
|
|
1790
|
+
window.addEventListener(WindowEventListenerType.message, listener, false);
|
|
1791
|
+
}));
|
|
1792
|
+
};
|
|
1793
|
+
const abortCredentialRequest = async () => {
|
|
1794
|
+
const initialiseOptions = getInitialiseOptions();
|
|
1795
|
+
if (!initialiseOptions) {
|
|
1796
|
+
throw new Exception(InitialiseErrorMessage.SdkNotInitialised);
|
|
1797
|
+
}
|
|
1798
|
+
const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
|
|
1799
|
+
const session = getActiveSession();
|
|
1800
|
+
if (!session || !session.sessionKey) {
|
|
1801
|
+
return ok(undefined);
|
|
1802
|
+
}
|
|
1803
|
+
const {sessionId: sessionId, sessionKey: sessionKey} = session;
|
|
1804
|
+
removeActiveSession();
|
|
1805
|
+
const abortSessionResult = await abortSession({
|
|
1618
1806
|
apiBaseUrl: apiBaseUrl,
|
|
1619
|
-
|
|
1620
|
-
|
|
1807
|
+
sessionId: sessionId,
|
|
1808
|
+
sessionKey: sessionKey
|
|
1621
1809
|
});
|
|
1622
|
-
if (
|
|
1810
|
+
if (abortSessionResult.isErr()) {
|
|
1623
1811
|
return err({
|
|
1624
|
-
type: exports.
|
|
1625
|
-
message:
|
|
1626
|
-
cause:
|
|
1812
|
+
type: exports.AbortSessionErrorType.AbortSessionFailed,
|
|
1813
|
+
message: AbortSessionErrorMessage.FailedToAbortSession,
|
|
1814
|
+
cause: abortSessionResult.error
|
|
1627
1815
|
});
|
|
1628
1816
|
}
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
crossDeviceCallback: crossDeviceCallback,
|
|
1636
|
-
container: container,
|
|
1817
|
+
return ok(undefined);
|
|
1818
|
+
};
|
|
1819
|
+
const requestCredentialsWithDigitalCredentialsApi = async options => {
|
|
1820
|
+
const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, request: request, sessionTtl: sessionTtl} = options;
|
|
1821
|
+
const sessionTimeoutId = window.setTimeout((() => removeActiveSession()), sessionTtl * 1e3);
|
|
1822
|
+
const abortController = setActiveSession({
|
|
1637
1823
|
sessionId: sessionId,
|
|
1824
|
+
sessionKey: sessionKey,
|
|
1825
|
+
sessionTimeoutId: sessionTimeoutId
|
|
1826
|
+
});
|
|
1827
|
+
const credentialResponseResult = await getCredentials(request, abortController);
|
|
1828
|
+
if (credentialResponseResult.isErr()) {
|
|
1829
|
+
await abortCredentialRequest();
|
|
1830
|
+
return err(credentialResponseResult.error);
|
|
1831
|
+
}
|
|
1832
|
+
const credentialResponse = credentialResponseResult.value;
|
|
1833
|
+
const parsedCredentialResponseResult = parseCredentialResponse(credentialResponse);
|
|
1834
|
+
if (parsedCredentialResponseResult.isErr()) {
|
|
1835
|
+
await abortCredentialRequest();
|
|
1836
|
+
return err(parsedCredentialResponseResult.error);
|
|
1837
|
+
}
|
|
1838
|
+
const parsedCredentialResponse = parsedCredentialResponseResult.value;
|
|
1839
|
+
const credentialVerificationResult = await verifyCredentialResponse({
|
|
1638
1840
|
apiBaseUrl: apiBaseUrl,
|
|
1639
|
-
|
|
1841
|
+
sessionId: sessionId,
|
|
1842
|
+
sessionKey: sessionKey,
|
|
1843
|
+
challenge: challenge,
|
|
1844
|
+
protocol: parsedCredentialResponse.protocol,
|
|
1845
|
+
data: parsedCredentialResponse.data
|
|
1640
1846
|
});
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1847
|
+
if (credentialVerificationResult.isErr()) {
|
|
1848
|
+
return err({
|
|
1849
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1850
|
+
message: RequestCredentialsErrorMessage.FailedToVerifyCredentialResponse,
|
|
1851
|
+
cause: credentialVerificationResult.error
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
return ok(credentialVerificationResult.value);
|
|
1855
|
+
};
|
|
1856
|
+
const getCredentials = async (request, abortController) => {
|
|
1857
|
+
try {
|
|
1858
|
+
const credentialResponse = await navigator.credentials.get(Object.assign(Object.assign({}, request), {
|
|
1859
|
+
signal: abortController.signal
|
|
1860
|
+
}));
|
|
1861
|
+
return ok(credentialResponse);
|
|
1862
|
+
} catch (exception) {
|
|
1863
|
+
return err({
|
|
1864
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1865
|
+
message: RequestCredentialsErrorMessage.DcApiError,
|
|
1866
|
+
cause: exception
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
const parseCredentialResponse = credentialResponse => {
|
|
1871
|
+
if (!credentialResponse) {
|
|
1872
|
+
return err({
|
|
1873
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1874
|
+
message: RequestCredentialsErrorMessage.DcApiResponseParseError,
|
|
1875
|
+
details: {
|
|
1876
|
+
response: credentialResponse
|
|
1877
|
+
}
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
if (typeof credentialResponse === "object") {
|
|
1881
|
+
return ok(credentialResponse);
|
|
1882
|
+
}
|
|
1883
|
+
if (typeof credentialResponse === "string") {
|
|
1884
|
+
try {
|
|
1885
|
+
const parsed = JSON.parse(credentialResponse);
|
|
1886
|
+
return ok(parsed);
|
|
1887
|
+
} catch (_a) {
|
|
1888
|
+
return err({
|
|
1889
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1890
|
+
message: RequestCredentialsErrorMessage.DcApiResponseParseError,
|
|
1891
|
+
details: {
|
|
1892
|
+
response: credentialResponse
|
|
1893
|
+
}
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
return err({
|
|
1898
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1899
|
+
message: RequestCredentialsErrorMessage.DcApiResponseParseError,
|
|
1900
|
+
details: {
|
|
1901
|
+
response: credentialResponse
|
|
1902
|
+
}
|
|
1903
|
+
});
|
|
1904
|
+
};
|
|
1905
|
+
const verifyCredentialResponse = async options => {
|
|
1906
|
+
const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, protocol: protocol, data: data} = options;
|
|
1907
|
+
const requestBody = {
|
|
1908
|
+
protocol: protocol,
|
|
1909
|
+
data: data,
|
|
1910
|
+
challenge: challenge
|
|
1911
|
+
};
|
|
1912
|
+
const credentialVerificationResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/dc-api/response`, {
|
|
1913
|
+
method: "POST",
|
|
1914
|
+
headers: {
|
|
1915
|
+
"Content-Type": "application/json",
|
|
1916
|
+
Authorization: `Bearer ${sessionKey}`
|
|
1917
|
+
},
|
|
1918
|
+
body: JSON.stringify(requestBody)
|
|
1644
1919
|
});
|
|
1920
|
+
if (credentialVerificationResult.isErr()) {
|
|
1921
|
+
return err(credentialVerificationResult.error);
|
|
1922
|
+
}
|
|
1923
|
+
const credentialVerificationResponse = await credentialVerificationResult.value.json();
|
|
1924
|
+
if (!isType(PresentationResultRelaxValidator)(credentialVerificationResponse)) {
|
|
1925
|
+
return err({
|
|
1926
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1927
|
+
message: "Verify credential returned unsupported response",
|
|
1928
|
+
details: {
|
|
1929
|
+
response: credentialVerificationResponse
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
return ok(credentialVerificationResponse);
|
|
1934
|
+
};
|
|
1935
|
+
const isDigitalCredentialsApiSupported = () => {
|
|
1936
|
+
var _a;
|
|
1937
|
+
return "DigitalCredential" in window && typeof window.DigitalCredential === "function" && typeof ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.credentials) === null || _a === void 0 ? void 0 : _a.get) === "function";
|
|
1645
1938
|
};
|
|
1939
|
+
const sleep = ms => new Promise((resolve => setTimeout(resolve, ms)));
|
|
1940
|
+
const SESSION_STATUS_POLLING_MAX_RETRY = 1e3;
|
|
1941
|
+
const SESSION_STATUS_POLLING_INTERVAL_MS = 3e3;
|
|
1942
|
+
const SESSION_STATUS_POLLING_INITIAL_DELAY_MS = 3e3;
|
|
1646
1943
|
var SameDeviceRequestCredentialsErrorMessage;
|
|
1647
1944
|
(function(SameDeviceRequestCredentialsErrorMessage) {
|
|
1648
1945
|
SameDeviceRequestCredentialsErrorMessage["FailedToStoreChallenge"] = "Failed to store challenge";
|
|
1649
1946
|
SameDeviceRequestCredentialsErrorMessage["FailedToCreateSession"] = "Failed to create session";
|
|
1650
1947
|
})(SameDeviceRequestCredentialsErrorMessage || (SameDeviceRequestCredentialsErrorMessage = {}));
|
|
1651
1948
|
const requestCredentialsSameDevice = async options => {
|
|
1652
|
-
const {challenge: challenge,
|
|
1653
|
-
const
|
|
1949
|
+
const {challenge: challenge, apiBaseUrl: apiBaseUrl, applicationId: applicationId, sessionUrl: sessionUrl, sessionKey: sessionKey, sessionId: sessionId} = options;
|
|
1950
|
+
const abortController = setActiveSession({
|
|
1951
|
+
sessionId: sessionId,
|
|
1952
|
+
sessionKey: sessionKey
|
|
1953
|
+
});
|
|
1954
|
+
window.localStorage.setItem(LocalStorageKey.sessionId, sessionId);
|
|
1654
1955
|
window.localStorage.setItem(LocalStorageKey.challenge, challenge);
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1956
|
+
window.location.assign(sessionUrl);
|
|
1957
|
+
await sleep(SESSION_STATUS_POLLING_INITIAL_DELAY_MS);
|
|
1958
|
+
const checkResult = await withRetry((async () => {
|
|
1959
|
+
const statusResult = await getSessionStatus({
|
|
1960
|
+
apiBaseUrl: apiBaseUrl,
|
|
1961
|
+
applicationId: applicationId,
|
|
1962
|
+
sessionId: sessionId,
|
|
1963
|
+
sessionKey: sessionKey
|
|
1660
1964
|
});
|
|
1965
|
+
if (abortController.signal.aborted) {
|
|
1966
|
+
return err({
|
|
1967
|
+
type: exports.RequestCredentialsErrorType.Abort,
|
|
1968
|
+
message: RequestCredentialsErrorMessage.Abort
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
if (statusResult.isErr()) {
|
|
1972
|
+
if (statusResult.error.status === 404) {
|
|
1973
|
+
return err({
|
|
1974
|
+
type: exports.RequestCredentialsErrorType.Timeout,
|
|
1975
|
+
message: RequestCredentialsErrorMessage.Timeout
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
throw Error("Unexpected status response. Retry");
|
|
1979
|
+
}
|
|
1980
|
+
if (statusResult.value.status !== PresentationStatusCode.ResultReady) {
|
|
1981
|
+
throw Error("Result is not ready. Retry");
|
|
1982
|
+
}
|
|
1983
|
+
return ok(undefined);
|
|
1984
|
+
}), {
|
|
1985
|
+
retries: SESSION_STATUS_POLLING_MAX_RETRY,
|
|
1986
|
+
retryDelay: SESSION_STATUS_POLLING_INTERVAL_MS
|
|
1987
|
+
});
|
|
1988
|
+
if (checkResult.isErr()) {
|
|
1989
|
+
return err(checkResult.error);
|
|
1990
|
+
}
|
|
1991
|
+
window.close();
|
|
1992
|
+
return ok({
|
|
1993
|
+
sessionId: sessionId,
|
|
1994
|
+
sessionCompletedInRedirect: true
|
|
1995
|
+
});
|
|
1996
|
+
};
|
|
1997
|
+
const requestCredentials = async options => {
|
|
1998
|
+
var _a;
|
|
1999
|
+
const initialiseOptions = getInitialiseOptions();
|
|
2000
|
+
if (!initialiseOptions) {
|
|
2001
|
+
throw new Exception(InitialiseErrorMessage.SdkNotInitialised);
|
|
1661
2002
|
}
|
|
2003
|
+
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
2004
|
+
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
|
|
2005
|
+
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration} = options;
|
|
2006
|
+
const dcApiSupported = isDigitalCredentialsApiSupported();
|
|
2007
|
+
const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
|
|
1662
2008
|
const createSessionResult = await createSession({
|
|
1663
2009
|
credentialQuery: credentialQuery,
|
|
1664
|
-
challenge:
|
|
1665
|
-
redirectUri:
|
|
2010
|
+
challenge: challenge,
|
|
2011
|
+
redirectUri: openId4VpRedirectUri,
|
|
2012
|
+
walletProviderId: (_a = openid4vpConfiguration === null || openid4vpConfiguration === void 0 ? void 0 : openid4vpConfiguration.walletProviderId) !== null && _a !== void 0 ? _a : undefined,
|
|
1666
2013
|
apiBaseUrl: apiBaseUrl,
|
|
1667
2014
|
applicationId: applicationId,
|
|
1668
|
-
|
|
2015
|
+
dcApiSupported: dcApiSupported
|
|
1669
2016
|
});
|
|
1670
2017
|
if (createSessionResult.isErr()) {
|
|
1671
2018
|
return err({
|
|
1672
2019
|
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1673
|
-
message:
|
|
2020
|
+
message: RequestCredentialsErrorMessage.FailedToCreateSession,
|
|
1674
2021
|
cause: createSessionResult.error
|
|
1675
2022
|
});
|
|
1676
2023
|
}
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
2024
|
+
const session = createSessionResult.value;
|
|
2025
|
+
const {sessionKey: sessionKey, sessionId: sessionId} = session;
|
|
2026
|
+
if (session.type === SessionType.DigitalCredentialsApi) {
|
|
2027
|
+
const {request: request, sessionTtl: sessionTtl} = session;
|
|
2028
|
+
return await requestCredentialsWithDigitalCredentialsApi({
|
|
2029
|
+
apiBaseUrl: apiBaseUrl,
|
|
2030
|
+
request: request,
|
|
2031
|
+
sessionId: sessionId,
|
|
2032
|
+
sessionKey: sessionKey,
|
|
2033
|
+
challenge: challenge,
|
|
2034
|
+
sessionTtl: sessionTtl
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
if (!openid4vpConfiguration) {
|
|
2038
|
+
return err({
|
|
2039
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
2040
|
+
message: RequestCredentialsErrorMessage.MissingOpenId4vpConfig
|
|
2041
|
+
});
|
|
2042
|
+
}
|
|
2043
|
+
const {sessionUrl: sessionUrl} = session;
|
|
2044
|
+
if (openId4VpRedirectUri) {
|
|
2045
|
+
return await requestCredentialsSameDevice({
|
|
2046
|
+
challenge: challenge,
|
|
2047
|
+
apiBaseUrl: apiBaseUrl,
|
|
2048
|
+
applicationId: applicationId,
|
|
2049
|
+
sessionUrl: sessionUrl,
|
|
2050
|
+
sessionKey: sessionKey,
|
|
2051
|
+
sessionId: sessionId
|
|
2052
|
+
});
|
|
2053
|
+
}
|
|
2054
|
+
return await requestCredentialsWithCrossDevice({
|
|
2055
|
+
challenge: challenge,
|
|
2056
|
+
apiBaseUrl: apiBaseUrl,
|
|
2057
|
+
sessionUrl: sessionUrl,
|
|
2058
|
+
sessionKey: sessionKey,
|
|
1681
2059
|
sessionId: sessionId
|
|
1682
2060
|
});
|
|
1683
2061
|
};
|
|
1684
|
-
const
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
if (!initialiseOptions) {
|
|
1688
|
-
throw new Exception(InitialiseErrorMessage.SdkNotInitialised);
|
|
2062
|
+
const deriveOpenId4vpRedirectUri = openid4vpConfiguration => {
|
|
2063
|
+
if (!openid4vpConfiguration) {
|
|
2064
|
+
return undefined;
|
|
1689
2065
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
initialiseOptions: initialiseOptions,
|
|
1696
|
-
challenge: challenge,
|
|
1697
|
-
mode: mode
|
|
1698
|
-
}));
|
|
2066
|
+
let detectedMode;
|
|
2067
|
+
if (openid4vpConfiguration && openid4vpConfiguration.mode) {
|
|
2068
|
+
detectedMode = openid4vpConfiguration.mode;
|
|
2069
|
+
} else {
|
|
2070
|
+
detectedMode = isMobileDetect(navigator.userAgent) ? exports.Mode.SameDevice : exports.Mode.CrossDevice;
|
|
1699
2071
|
}
|
|
1700
|
-
if (
|
|
1701
|
-
return
|
|
1702
|
-
initialiseOptions: initialiseOptions,
|
|
1703
|
-
challenge: challenge,
|
|
1704
|
-
mode: mode
|
|
1705
|
-
}));
|
|
2072
|
+
if (detectedMode === exports.Mode.SameDevice && !isType(OpenId4vpConfigCrossDeviceOptionsValidator)(openid4vpConfiguration) && openid4vpConfiguration.redirectUri) {
|
|
2073
|
+
return openid4vpConfiguration.redirectUri;
|
|
1706
2074
|
}
|
|
1707
|
-
|
|
1708
|
-
data: options
|
|
1709
|
-
});
|
|
2075
|
+
return undefined;
|
|
1710
2076
|
};
|
|
1711
2077
|
exports.HandleRedirectCallbackErrorType = void 0;
|
|
1712
2078
|
(function(HandleRedirectCallbackErrorType) {
|
|
@@ -1716,7 +2082,7 @@
|
|
|
1716
2082
|
(function(HandleRedirectCallbackErrorMessage) {
|
|
1717
2083
|
HandleRedirectCallbackErrorMessage["FailedToFindResponseCode"] = "Failed to find response code";
|
|
1718
2084
|
HandleRedirectCallbackErrorMessage["FailedToFindChallenge"] = "Failed to find challenge";
|
|
1719
|
-
HandleRedirectCallbackErrorMessage["
|
|
2085
|
+
HandleRedirectCallbackErrorMessage["FailedToFindActiveSession"] = "Failed to find active session";
|
|
1720
2086
|
HandleRedirectCallbackErrorMessage["FailedToGetSessionResult"] = "Failed to get session result";
|
|
1721
2087
|
})(HandleRedirectCallbackErrorMessage || (HandleRedirectCallbackErrorMessage = {}));
|
|
1722
2088
|
const handleRedirectCallback = async () => {
|
|
@@ -1732,18 +2098,12 @@
|
|
|
1732
2098
|
message: HandleRedirectCallbackErrorMessage.FailedToFindResponseCode
|
|
1733
2099
|
});
|
|
1734
2100
|
}
|
|
1735
|
-
const challenge = window.localStorage.getItem(LocalStorageKey.challenge);
|
|
1736
|
-
if (!challenge) {
|
|
1737
|
-
return err({
|
|
1738
|
-
type: exports.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,
|
|
1739
|
-
message: HandleRedirectCallbackErrorMessage.FailedToFindChallenge
|
|
1740
|
-
});
|
|
1741
|
-
}
|
|
1742
2101
|
const sessionId = window.localStorage.getItem(LocalStorageKey.sessionId);
|
|
1743
|
-
|
|
2102
|
+
const challenge = window.localStorage.getItem(LocalStorageKey.challenge);
|
|
2103
|
+
if (!sessionId || !challenge) {
|
|
1744
2104
|
return err({
|
|
1745
2105
|
type: exports.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,
|
|
1746
|
-
message: HandleRedirectCallbackErrorMessage.
|
|
2106
|
+
message: HandleRedirectCallbackErrorMessage.FailedToFindActiveSession
|
|
1747
2107
|
});
|
|
1748
2108
|
}
|
|
1749
2109
|
const result = await exchangeSessionResult({
|
|
@@ -1760,16 +2120,19 @@
|
|
|
1760
2120
|
});
|
|
1761
2121
|
}
|
|
1762
2122
|
return ok({
|
|
1763
|
-
result: result.value,
|
|
2123
|
+
result: "challenge" in result.value ? result.value : undefined,
|
|
1764
2124
|
sessionId: result.value.sessionId
|
|
1765
2125
|
});
|
|
1766
2126
|
};
|
|
1767
2127
|
const utils = {
|
|
1768
2128
|
generateChallenge: generateChallenge,
|
|
2129
|
+
getVersion: getVersion,
|
|
1769
2130
|
unwrap: unwrap
|
|
1770
2131
|
};
|
|
2132
|
+
exports.abortCredentialRequest = abortCredentialRequest;
|
|
1771
2133
|
exports.handleRedirectCallback = handleRedirectCallback;
|
|
1772
2134
|
exports.initialise = initialise;
|
|
2135
|
+
exports.isDigitalCredentialsApiSupported = isDigitalCredentialsApiSupported;
|
|
1773
2136
|
exports.requestCredentials = requestCredentials;
|
|
1774
2137
|
exports.utils = utils;
|
|
1775
2138
|
Object.defineProperty(exports, "__esModule", {
|