@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
|
*
|
|
@@ -446,148 +446,137 @@ ResultAsync.fromPromise;
|
|
|
446
446
|
|
|
447
447
|
ResultAsync.fromSafePromise;
|
|
448
448
|
|
|
449
|
-
function
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
r && (o = o.filter((function(r) {
|
|
454
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
455
|
-
}))), t.push.apply(t, o);
|
|
456
|
-
}
|
|
457
|
-
return t;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function _objectSpread2(e) {
|
|
461
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
462
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
463
|
-
r % 2 ? ownKeys(Object(t), !0).forEach((function(r) {
|
|
464
|
-
_defineProperty(e, r, t[r]);
|
|
465
|
-
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach((function(r) {
|
|
466
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
467
|
-
}));
|
|
468
|
-
}
|
|
469
|
-
return e;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
function _typeof(o) {
|
|
473
|
-
"@babel/helpers - typeof";
|
|
474
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
475
|
-
return typeof o;
|
|
476
|
-
} : function(o) {
|
|
477
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
478
|
-
}, _typeof(o);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
function _defineProperty(obj, key, value) {
|
|
482
|
-
key = _toPropertyKey(key);
|
|
483
|
-
if (key in obj) {
|
|
484
|
-
Object.defineProperty(obj, key, {
|
|
485
|
-
value: value,
|
|
486
|
-
enumerable: true,
|
|
487
|
-
configurable: true,
|
|
488
|
-
writable: true
|
|
489
|
-
});
|
|
490
|
-
} else {
|
|
491
|
-
obj[key] = value;
|
|
492
|
-
}
|
|
493
|
-
return obj;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
function _toConsumableArray(arr) {
|
|
497
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
function _arrayWithoutHoles(arr) {
|
|
501
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
function _iterableToArray(iter) {
|
|
505
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
449
|
+
function _arrayLikeToArray(r, a) {
|
|
450
|
+
(null == a || a > r.length) && (a = r.length);
|
|
451
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
452
|
+
return n;
|
|
506
453
|
}
|
|
507
454
|
|
|
508
|
-
function
|
|
509
|
-
if (
|
|
510
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
511
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
512
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
513
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
514
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
455
|
+
function _arrayWithoutHoles(r) {
|
|
456
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
515
457
|
}
|
|
516
458
|
|
|
517
|
-
function
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
function _nonIterableSpread() {
|
|
524
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
528
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
529
|
-
if (!it) {
|
|
530
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
531
|
-
if (it) o = it;
|
|
532
|
-
var i = 0;
|
|
533
|
-
var F = function() {};
|
|
459
|
+
function _createForOfIteratorHelper(r, e) {
|
|
460
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
461
|
+
if (!t) {
|
|
462
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
463
|
+
t && (r = t);
|
|
464
|
+
var n = 0, F = function() {};
|
|
534
465
|
return {
|
|
535
466
|
s: F,
|
|
536
467
|
n: function() {
|
|
537
|
-
|
|
538
|
-
done:
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
value: o[i++]
|
|
468
|
+
return n >= r.length ? {
|
|
469
|
+
done: !0
|
|
470
|
+
} : {
|
|
471
|
+
done: !1,
|
|
472
|
+
value: r[n++]
|
|
543
473
|
};
|
|
544
474
|
},
|
|
545
|
-
e: function(
|
|
546
|
-
throw
|
|
475
|
+
e: function(r) {
|
|
476
|
+
throw r;
|
|
547
477
|
},
|
|
548
478
|
f: F
|
|
549
479
|
};
|
|
550
480
|
}
|
|
551
481
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
552
482
|
}
|
|
553
|
-
var
|
|
483
|
+
var o, a = !0, u = !1;
|
|
554
484
|
return {
|
|
555
485
|
s: function() {
|
|
556
|
-
|
|
486
|
+
t = t.call(r);
|
|
557
487
|
},
|
|
558
488
|
n: function() {
|
|
559
|
-
var
|
|
560
|
-
|
|
561
|
-
return step;
|
|
489
|
+
var r = t.next();
|
|
490
|
+
return a = r.done, r;
|
|
562
491
|
},
|
|
563
|
-
e: function(
|
|
564
|
-
|
|
565
|
-
err = e;
|
|
492
|
+
e: function(r) {
|
|
493
|
+
u = !0, o = r;
|
|
566
494
|
},
|
|
567
495
|
f: function() {
|
|
568
496
|
try {
|
|
569
|
-
|
|
497
|
+
a || null == t.return || t.return();
|
|
570
498
|
} finally {
|
|
571
|
-
if (
|
|
499
|
+
if (u) throw o;
|
|
572
500
|
}
|
|
573
501
|
}
|
|
574
502
|
};
|
|
575
503
|
}
|
|
576
504
|
|
|
577
|
-
function
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
505
|
+
function _defineProperty(e, r, t) {
|
|
506
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
507
|
+
value: t,
|
|
508
|
+
enumerable: !0,
|
|
509
|
+
configurable: !0,
|
|
510
|
+
writable: !0
|
|
511
|
+
}) : e[r] = t, e;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function _iterableToArray(r) {
|
|
515
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function _nonIterableSpread() {
|
|
519
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function ownKeys(e, r) {
|
|
523
|
+
var t = Object.keys(e);
|
|
524
|
+
if (Object.getOwnPropertySymbols) {
|
|
525
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
526
|
+
r && (o = o.filter((function(r) {
|
|
527
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
528
|
+
}))), t.push.apply(t, o);
|
|
529
|
+
}
|
|
530
|
+
return t;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function _objectSpread2(e) {
|
|
534
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
535
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
536
|
+
r % 2 ? ownKeys(Object(t), !0).forEach((function(r) {
|
|
537
|
+
_defineProperty(e, r, t[r]);
|
|
538
|
+
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach((function(r) {
|
|
539
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
540
|
+
}));
|
|
541
|
+
}
|
|
542
|
+
return e;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function _toConsumableArray(r) {
|
|
546
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function _toPrimitive(t, r) {
|
|
550
|
+
if ("object" != typeof t || !t) return t;
|
|
551
|
+
var e = t[Symbol.toPrimitive];
|
|
552
|
+
if (void 0 !== e) {
|
|
553
|
+
var i = e.call(t, r || "default");
|
|
554
|
+
if ("object" != typeof i) return i;
|
|
583
555
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
584
556
|
}
|
|
585
|
-
return (
|
|
557
|
+
return ("string" === r ? String : Number)(t);
|
|
586
558
|
}
|
|
587
559
|
|
|
588
|
-
function _toPropertyKey(
|
|
589
|
-
var
|
|
590
|
-
return
|
|
560
|
+
function _toPropertyKey(t) {
|
|
561
|
+
var i = _toPrimitive(t, "string");
|
|
562
|
+
return "symbol" == typeof i ? i : i + "";
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function _typeof(o) {
|
|
566
|
+
"@babel/helpers - typeof";
|
|
567
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
568
|
+
return typeof o;
|
|
569
|
+
} : function(o) {
|
|
570
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
571
|
+
}, _typeof(o);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function _unsupportedIterableToArray(r, a) {
|
|
575
|
+
if (r) {
|
|
576
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
577
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
578
|
+
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;
|
|
579
|
+
}
|
|
591
580
|
}
|
|
592
581
|
|
|
593
582
|
var store;
|
|
@@ -708,6 +697,20 @@ function getDefault(schema, dataset, config2) {
|
|
|
708
697
|
return typeof schema["default"] === "function" ? schema["default"](dataset, config2) : schema["default"];
|
|
709
698
|
}
|
|
710
699
|
|
|
700
|
+
function any() {
|
|
701
|
+
return {
|
|
702
|
+
kind: "schema",
|
|
703
|
+
type: "any",
|
|
704
|
+
reference: any,
|
|
705
|
+
expects: "any",
|
|
706
|
+
async: false,
|
|
707
|
+
_run: function _run(dataset) {
|
|
708
|
+
dataset.typed = true;
|
|
709
|
+
return dataset;
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
711
714
|
function array(item, message) {
|
|
712
715
|
return {
|
|
713
716
|
kind: "schema",
|
|
@@ -793,16 +796,36 @@ function _boolean(message) {
|
|
|
793
796
|
};
|
|
794
797
|
}
|
|
795
798
|
|
|
796
|
-
function
|
|
799
|
+
function literal(literal_, message) {
|
|
797
800
|
return {
|
|
798
801
|
kind: "schema",
|
|
799
|
-
type: "
|
|
800
|
-
reference:
|
|
801
|
-
expects:
|
|
802
|
+
type: "literal",
|
|
803
|
+
reference: literal,
|
|
804
|
+
expects: _stringify(literal_),
|
|
802
805
|
async: false,
|
|
806
|
+
literal: literal_,
|
|
803
807
|
message: message,
|
|
804
808
|
_run: function _run(dataset, config2) {
|
|
805
|
-
if (
|
|
809
|
+
if (dataset.value === this.literal) {
|
|
810
|
+
dataset.typed = true;
|
|
811
|
+
} else {
|
|
812
|
+
_addIssue(this, "type", dataset, config2);
|
|
813
|
+
}
|
|
814
|
+
return dataset;
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
function number(message) {
|
|
820
|
+
return {
|
|
821
|
+
kind: "schema",
|
|
822
|
+
type: "number",
|
|
823
|
+
reference: number,
|
|
824
|
+
expects: "number",
|
|
825
|
+
async: false,
|
|
826
|
+
message: message,
|
|
827
|
+
_run: function _run(dataset, config2) {
|
|
828
|
+
if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
|
|
806
829
|
dataset.typed = true;
|
|
807
830
|
} else {
|
|
808
831
|
_addIssue(this, "type", dataset, config2);
|
|
@@ -1307,47 +1330,21 @@ const assertType = (validator, message) => data => {
|
|
|
1307
1330
|
}
|
|
1308
1331
|
};
|
|
1309
1332
|
|
|
1310
|
-
var SafeFetchCommonRespondErrorType;
|
|
1311
|
-
|
|
1312
|
-
(function(SafeFetchCommonRespondErrorType) {
|
|
1313
|
-
SafeFetchCommonRespondErrorType["UnexpectedRespond"] = "UnexpectedRespond";
|
|
1314
|
-
})(SafeFetchCommonRespondErrorType || (SafeFetchCommonRespondErrorType = {}));
|
|
1315
|
-
|
|
1316
|
-
var SafeFetchErrorType;
|
|
1317
|
-
|
|
1318
|
-
(function(SafeFetchErrorType) {
|
|
1319
|
-
SafeFetchErrorType["HttpError"] = "HttpError";
|
|
1320
|
-
SafeFetchErrorType["UnknownError"] = "UnknownError";
|
|
1321
|
-
})(SafeFetchErrorType || (SafeFetchErrorType = {}));
|
|
1322
|
-
|
|
1323
|
-
const safeFetch = async (input, init) => {
|
|
1324
|
-
try {
|
|
1325
|
-
const response = await fetch(input, init);
|
|
1326
|
-
if (response.status > 299 || response.status < 200) {
|
|
1327
|
-
return err({
|
|
1328
|
-
type: SafeFetchErrorType.HttpError,
|
|
1329
|
-
message: `HTTP error, status = ${response.status}`,
|
|
1330
|
-
status: response.status
|
|
1331
|
-
});
|
|
1332
|
-
}
|
|
1333
|
-
return ok(response);
|
|
1334
|
-
} catch (error) {
|
|
1335
|
-
return err({
|
|
1336
|
-
type: SafeFetchErrorType.UnknownError,
|
|
1337
|
-
message: "Unknown error",
|
|
1338
|
-
cause: error
|
|
1339
|
-
});
|
|
1340
|
-
}
|
|
1341
|
-
};
|
|
1342
|
-
|
|
1343
1333
|
exports.MobileCredentialVerificationReasonType = void 0;
|
|
1344
1334
|
|
|
1345
1335
|
(function(MobileCredentialVerificationReasonType) {
|
|
1346
|
-
MobileCredentialVerificationReasonType["
|
|
1347
|
-
MobileCredentialVerificationReasonType["
|
|
1348
|
-
MobileCredentialVerificationReasonType["
|
|
1349
|
-
MobileCredentialVerificationReasonType["
|
|
1350
|
-
MobileCredentialVerificationReasonType["
|
|
1336
|
+
MobileCredentialVerificationReasonType["TrustedIssuerCertificateExpired"] = "TrustedIssuerCertificateExpired";
|
|
1337
|
+
MobileCredentialVerificationReasonType["TrustedIssuerCertificateNotYetValid"] = "TrustedIssuerCertificateNotYetValid";
|
|
1338
|
+
MobileCredentialVerificationReasonType["IssuerNotTrusted"] = "IssuerNotTrusted";
|
|
1339
|
+
MobileCredentialVerificationReasonType["MobileCredentialInvalid"] = "MobileCredentialInvalid";
|
|
1340
|
+
MobileCredentialVerificationReasonType["MobileCredentialExpired"] = "MobileCredentialExpired";
|
|
1341
|
+
MobileCredentialVerificationReasonType["MobileCredentialNotYetValid"] = "MobileCredentialNotYetValid";
|
|
1342
|
+
MobileCredentialVerificationReasonType["InvalidSignerCertificate"] = "InvalidSignerCertificate";
|
|
1343
|
+
MobileCredentialVerificationReasonType["DeviceKeyInvalid"] = "DeviceKeyInvalid";
|
|
1344
|
+
MobileCredentialVerificationReasonType["UnsupportedCurve"] = "UnsupportedCurve";
|
|
1345
|
+
MobileCredentialVerificationReasonType["StatusRevoked"] = "StatusRevoked";
|
|
1346
|
+
MobileCredentialVerificationReasonType["StatusSuspended"] = "StatusSuspended";
|
|
1347
|
+
MobileCredentialVerificationReasonType["StatusUnknown"] = "StatusUnknown";
|
|
1351
1348
|
})(exports.MobileCredentialVerificationReasonType || (exports.MobileCredentialVerificationReasonType = {}));
|
|
1352
1349
|
|
|
1353
1350
|
exports.ClaimType = void 0;
|
|
@@ -1382,6 +1379,15 @@ exports.OpenidPresentationCredentialProfileSupported = void 0;
|
|
|
1382
1379
|
OpenidPresentationCredentialProfileSupported["MOBILE"] = "mobile";
|
|
1383
1380
|
})(exports.OpenidPresentationCredentialProfileSupported || (exports.OpenidPresentationCredentialProfileSupported = {}));
|
|
1384
1381
|
|
|
1382
|
+
var PresentationStatusCode;
|
|
1383
|
+
|
|
1384
|
+
(function(PresentationStatusCode) {
|
|
1385
|
+
PresentationStatusCode["AwaitingRequestRetrieval"] = "AwaitingRequestRetrieval";
|
|
1386
|
+
PresentationStatusCode["AwaitingResponse"] = "AwaitingResponse";
|
|
1387
|
+
PresentationStatusCode["ResponseSubmitted"] = "ResponseSubmitted";
|
|
1388
|
+
PresentationStatusCode["ResultReady"] = "ResultReady";
|
|
1389
|
+
})(PresentationStatusCode || (PresentationStatusCode = {}));
|
|
1390
|
+
|
|
1385
1391
|
const CredentialQueryValidator = object({
|
|
1386
1392
|
profile: picklist([ exports.OpenidPresentationCredentialProfileSupported.MOBILE ]),
|
|
1387
1393
|
docType: string(),
|
|
@@ -1409,18 +1415,52 @@ const PresentationResultRelaxValidator = object({
|
|
|
1409
1415
|
error: optional(unknown())
|
|
1410
1416
|
});
|
|
1411
1417
|
|
|
1418
|
+
exports.Mode = void 0;
|
|
1419
|
+
|
|
1420
|
+
(function(Mode) {
|
|
1421
|
+
Mode["SameDevice"] = "sameDevice";
|
|
1422
|
+
Mode["CrossDevice"] = "crossDevice";
|
|
1423
|
+
})(exports.Mode || (exports.Mode = {}));
|
|
1424
|
+
|
|
1425
|
+
var SessionType;
|
|
1426
|
+
|
|
1427
|
+
(function(SessionType) {
|
|
1428
|
+
SessionType["DigitalCredentialsApi"] = "digital-credentials-api";
|
|
1429
|
+
SessionType["Openid4vp"] = "openid4vp";
|
|
1430
|
+
})(SessionType || (SessionType = {}));
|
|
1431
|
+
|
|
1412
1432
|
object({
|
|
1413
1433
|
credentialQuery: array(CredentialQueryValidator),
|
|
1414
1434
|
challenge: string(),
|
|
1415
1435
|
redirectUri: optional(string()),
|
|
1416
|
-
walletProviderId: optional(string())
|
|
1436
|
+
walletProviderId: optional(string()),
|
|
1437
|
+
dcApiSupported: optional(_boolean())
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1440
|
+
const CreateSessionDigitalCredentialsValidator = object({
|
|
1441
|
+
type: literal(SessionType.DigitalCredentialsApi),
|
|
1442
|
+
sessionId: string(),
|
|
1443
|
+
sessionKey: string(),
|
|
1444
|
+
sessionTtl: number(),
|
|
1445
|
+
request: record(string(), any())
|
|
1417
1446
|
});
|
|
1418
1447
|
|
|
1419
|
-
const
|
|
1448
|
+
const CreateSessionOpenId4vpResponseValidator = object({
|
|
1449
|
+
type: optional(literal(SessionType.Openid4vp)),
|
|
1420
1450
|
sessionId: string(),
|
|
1451
|
+
sessionKey: string(),
|
|
1421
1452
|
sessionUrl: string()
|
|
1422
1453
|
});
|
|
1423
1454
|
|
|
1455
|
+
const CreateSessionResponseValidator = union([ CreateSessionDigitalCredentialsValidator, CreateSessionOpenId4vpResponseValidator ]);
|
|
1456
|
+
|
|
1457
|
+
const GetSessionStatusResponseValidator = union([ object({
|
|
1458
|
+
status: picklist([ PresentationStatusCode.ResultReady ]),
|
|
1459
|
+
responseCode: optional(string())
|
|
1460
|
+
}), object({
|
|
1461
|
+
status: string()
|
|
1462
|
+
}) ]);
|
|
1463
|
+
|
|
1424
1464
|
var LocalStorageKey;
|
|
1425
1465
|
|
|
1426
1466
|
(function(LocalStorageKey) {
|
|
@@ -1428,12 +1468,9 @@ var LocalStorageKey;
|
|
|
1428
1468
|
LocalStorageKey["sessionId"] = "mattr_sid";
|
|
1429
1469
|
})(LocalStorageKey || (LocalStorageKey = {}));
|
|
1430
1470
|
|
|
1431
|
-
|
|
1471
|
+
const MATTR_SDK_VERSION_HEADER = "x-mattr-sdk-version";
|
|
1432
1472
|
|
|
1433
|
-
|
|
1434
|
-
Mode["sameDevice"] = "sameDevice";
|
|
1435
|
-
Mode["crossDevice"] = "crossDevice";
|
|
1436
|
-
})(exports.Mode || (exports.Mode = {}));
|
|
1473
|
+
const MATTR_SDK_VERSION_VALUE = "2.0.0";
|
|
1437
1474
|
|
|
1438
1475
|
var MessageEventDataType;
|
|
1439
1476
|
|
|
@@ -1443,50 +1480,106 @@ var MessageEventDataType;
|
|
|
1443
1480
|
MessageEventDataType["PresentationAbort"] = "PresentationAbort";
|
|
1444
1481
|
})(MessageEventDataType || (MessageEventDataType = {}));
|
|
1445
1482
|
|
|
1446
|
-
const
|
|
1447
|
-
credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
|
|
1448
|
-
redirectUri: string(),
|
|
1449
|
-
challenge: optional(string()),
|
|
1483
|
+
const OpenId4vpConfigSameDeviceOptionsValidator = object({
|
|
1450
1484
|
walletProviderId: optional(string()),
|
|
1451
|
-
mode:
|
|
1485
|
+
mode: literal(exports.Mode.SameDevice),
|
|
1486
|
+
redirectUri: string()
|
|
1452
1487
|
});
|
|
1453
1488
|
|
|
1454
|
-
const
|
|
1455
|
-
credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
|
|
1456
|
-
crossDeviceCallback: object({
|
|
1457
|
-
onComplete: function_(),
|
|
1458
|
-
onFailure: function_()
|
|
1459
|
-
}),
|
|
1460
|
-
challenge: optional(string()),
|
|
1489
|
+
const OpenId4vpConfigCrossDeviceOptionsValidator = object({
|
|
1461
1490
|
walletProviderId: optional(string()),
|
|
1462
|
-
mode:
|
|
1491
|
+
mode: literal(exports.Mode.CrossDevice)
|
|
1463
1492
|
});
|
|
1464
1493
|
|
|
1465
|
-
const
|
|
1466
|
-
credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
|
|
1467
|
-
crossDeviceCallback: object({
|
|
1468
|
-
onComplete: function_(),
|
|
1469
|
-
onFailure: function_()
|
|
1470
|
-
}),
|
|
1471
|
-
redirectUri: string(),
|
|
1472
|
-
challenge: optional(string()),
|
|
1494
|
+
const OpenId4vpConfigAutoDetectOptionsValidator = object({
|
|
1473
1495
|
walletProviderId: optional(string()),
|
|
1474
|
-
|
|
1496
|
+
redirectUri: string(),
|
|
1497
|
+
mode: optional(picklist([ exports.Mode.CrossDevice, exports.Mode.SameDevice ]))
|
|
1475
1498
|
});
|
|
1476
1499
|
|
|
1477
|
-
const RequestCredentialsOptionsValidator =
|
|
1500
|
+
const RequestCredentialsOptionsValidator = object({
|
|
1501
|
+
credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
|
|
1502
|
+
challenge: optional(string()),
|
|
1503
|
+
openid4vpConfiguration: optional(union([ OpenId4vpConfigSameDeviceOptionsValidator, OpenId4vpConfigCrossDeviceOptionsValidator, OpenId4vpConfigAutoDetectOptionsValidator ]))
|
|
1504
|
+
});
|
|
1478
1505
|
|
|
1479
1506
|
exports.RequestCredentialsErrorType = void 0;
|
|
1480
1507
|
|
|
1481
1508
|
(function(RequestCredentialsErrorType) {
|
|
1482
1509
|
RequestCredentialsErrorType["RequestCredentialsFailed"] = "RequestCredentialsFailed";
|
|
1510
|
+
RequestCredentialsErrorType["Timeout"] = "Timeout";
|
|
1511
|
+
RequestCredentialsErrorType["Abort"] = "Abort";
|
|
1483
1512
|
})(exports.RequestCredentialsErrorType || (exports.RequestCredentialsErrorType = {}));
|
|
1484
1513
|
|
|
1514
|
+
var RequestCredentialsErrorMessage;
|
|
1515
|
+
|
|
1516
|
+
(function(RequestCredentialsErrorMessage) {
|
|
1517
|
+
RequestCredentialsErrorMessage["FailedToGetSessionResult"] = "Failed to get session result";
|
|
1518
|
+
RequestCredentialsErrorMessage["FailedToGetSessionStatus"] = "Failed to get session status";
|
|
1519
|
+
RequestCredentialsErrorMessage["FailedToCreateSession"] = "Failed to create session";
|
|
1520
|
+
RequestCredentialsErrorMessage["FailedToVerifyCredentialResponse"] = "Failed to verify credential response";
|
|
1521
|
+
RequestCredentialsErrorMessage["MissingOpenId4vpConfig"] = "Identified openid4vp session, but missing openId4vpConfiguration on `requestCredentials`";
|
|
1522
|
+
RequestCredentialsErrorMessage["DcApiError"] = "Failed to request credentials with Digital Credentials API";
|
|
1523
|
+
RequestCredentialsErrorMessage["DcApiResponseParseError"] = "Failed to parse response from Digital Credentials API";
|
|
1524
|
+
RequestCredentialsErrorMessage["Abort"] = "User aborted the session";
|
|
1525
|
+
RequestCredentialsErrorMessage["Timeout"] = "User session timeout";
|
|
1526
|
+
})(RequestCredentialsErrorMessage || (RequestCredentialsErrorMessage = {}));
|
|
1527
|
+
|
|
1528
|
+
exports.AbortSessionErrorType = void 0;
|
|
1529
|
+
|
|
1530
|
+
(function(AbortSessionErrorType) {
|
|
1531
|
+
AbortSessionErrorType["AbortSessionFailed"] = "AbortSessionFailed";
|
|
1532
|
+
})(exports.AbortSessionErrorType || (exports.AbortSessionErrorType = {}));
|
|
1533
|
+
|
|
1534
|
+
var AbortSessionErrorMessage;
|
|
1535
|
+
|
|
1536
|
+
(function(AbortSessionErrorMessage) {
|
|
1537
|
+
AbortSessionErrorMessage["FailedToAbortSession"] = "Failed to abort session";
|
|
1538
|
+
})(AbortSessionErrorMessage || (AbortSessionErrorMessage = {}));
|
|
1539
|
+
|
|
1485
1540
|
const InitialiseOptionsValidator = object({
|
|
1486
|
-
apiBaseUrl: string(),
|
|
1487
|
-
applicationId:
|
|
1541
|
+
apiBaseUrl: pipe(string(), nonEmpty("Must not be empty")),
|
|
1542
|
+
applicationId: pipe(string(), nonEmpty("Must not be empty"))
|
|
1488
1543
|
});
|
|
1489
1544
|
|
|
1545
|
+
var SafeFetchCommonResponseErrorType;
|
|
1546
|
+
|
|
1547
|
+
(function(SafeFetchCommonResponseErrorType) {
|
|
1548
|
+
SafeFetchCommonResponseErrorType["UnexpectedResponse"] = "UnexpectedResponse";
|
|
1549
|
+
})(SafeFetchCommonResponseErrorType || (SafeFetchCommonResponseErrorType = {}));
|
|
1550
|
+
|
|
1551
|
+
var SafeFetchErrorType;
|
|
1552
|
+
|
|
1553
|
+
(function(SafeFetchErrorType) {
|
|
1554
|
+
SafeFetchErrorType["HttpError"] = "HttpError";
|
|
1555
|
+
SafeFetchErrorType["UnknownError"] = "UnknownError";
|
|
1556
|
+
})(SafeFetchErrorType || (SafeFetchErrorType = {}));
|
|
1557
|
+
|
|
1558
|
+
const safeFetch = async (input, init) => {
|
|
1559
|
+
try {
|
|
1560
|
+
const headers = Object.assign(Object.assign({}, init === null || init === void 0 ? void 0 : init.headers), {
|
|
1561
|
+
[MATTR_SDK_VERSION_HEADER]: `verifier-sdk-web/${MATTR_SDK_VERSION_VALUE}`
|
|
1562
|
+
});
|
|
1563
|
+
const response = await fetch(input, Object.assign(Object.assign({}, init), {
|
|
1564
|
+
headers: headers
|
|
1565
|
+
}));
|
|
1566
|
+
if (response.status > 299 || response.status < 200) {
|
|
1567
|
+
return err({
|
|
1568
|
+
type: SafeFetchErrorType.HttpError,
|
|
1569
|
+
message: `HTTP error, status = ${response.status}`,
|
|
1570
|
+
status: response.status
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
return ok(response);
|
|
1574
|
+
} catch (error) {
|
|
1575
|
+
return err({
|
|
1576
|
+
type: SafeFetchErrorType.UnknownError,
|
|
1577
|
+
message: "Unknown error",
|
|
1578
|
+
cause: error
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1490
1583
|
let initialiseOptions = undefined;
|
|
1491
1584
|
|
|
1492
1585
|
var InitialiseErrorMessage;
|
|
@@ -1502,6 +1595,49 @@ const initialise = options => {
|
|
|
1502
1595
|
|
|
1503
1596
|
const getInitialiseOptions = () => initialiseOptions;
|
|
1504
1597
|
|
|
1598
|
+
let sessionAbortController = undefined;
|
|
1599
|
+
|
|
1600
|
+
let _sessionId = undefined;
|
|
1601
|
+
|
|
1602
|
+
let _sessionKey = undefined;
|
|
1603
|
+
|
|
1604
|
+
let _sessionTimeoutId = undefined;
|
|
1605
|
+
|
|
1606
|
+
const getActiveSession = () => {
|
|
1607
|
+
const sessionId = _sessionId;
|
|
1608
|
+
const sessionKey = _sessionKey;
|
|
1609
|
+
const sessionTimeoutId = _sessionTimeoutId;
|
|
1610
|
+
if (sessionId) {
|
|
1611
|
+
return {
|
|
1612
|
+
sessionId: sessionId,
|
|
1613
|
+
sessionKey: sessionKey,
|
|
1614
|
+
sessionTimeoutId: sessionTimeoutId
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
return undefined;
|
|
1618
|
+
};
|
|
1619
|
+
|
|
1620
|
+
const setActiveSession = session => {
|
|
1621
|
+
const {sessionId: sessionId, sessionKey: sessionKey, sessionTimeoutId: sessionTimeoutId} = session;
|
|
1622
|
+
_sessionId = sessionId;
|
|
1623
|
+
_sessionKey = sessionKey;
|
|
1624
|
+
_sessionTimeoutId = sessionTimeoutId;
|
|
1625
|
+
const abortController = new AbortController;
|
|
1626
|
+
sessionAbortController = abortController;
|
|
1627
|
+
return abortController;
|
|
1628
|
+
};
|
|
1629
|
+
|
|
1630
|
+
const removeActiveSession = () => {
|
|
1631
|
+
sessionAbortController === null || sessionAbortController === void 0 ? void 0 : sessionAbortController.abort();
|
|
1632
|
+
if (_sessionTimeoutId) {
|
|
1633
|
+
window.clearTimeout(_sessionTimeoutId);
|
|
1634
|
+
}
|
|
1635
|
+
sessionAbortController = undefined;
|
|
1636
|
+
_sessionKey = undefined;
|
|
1637
|
+
_sessionId = undefined;
|
|
1638
|
+
_sessionTimeoutId = undefined;
|
|
1639
|
+
};
|
|
1640
|
+
|
|
1505
1641
|
var isMobile_1 = isMobile;
|
|
1506
1642
|
|
|
1507
1643
|
var isMobile_2 = isMobile;
|
|
@@ -1537,6 +1673,24 @@ const defaultRetryDelay = attempt => Math.pow(2, attempt) * 1e3;
|
|
|
1537
1673
|
|
|
1538
1674
|
const defaultRetry = 2;
|
|
1539
1675
|
|
|
1676
|
+
const withRetry = async (fn, options) => {
|
|
1677
|
+
const {retries: retries = defaultRetry, retryDelay: retryDelay = defaultRetryDelay, attempt: attempt = 0} = options;
|
|
1678
|
+
try {
|
|
1679
|
+
return await fn();
|
|
1680
|
+
} catch (err) {
|
|
1681
|
+
if (retries > 0) {
|
|
1682
|
+
const delay = typeof retryDelay === "function" ? retryDelay(attempt) : retryDelay;
|
|
1683
|
+
await new Promise((resolve => setTimeout(resolve, delay)));
|
|
1684
|
+
return await withRetry(fn, Object.assign(Object.assign({}, options), {
|
|
1685
|
+
retries: retries - 1,
|
|
1686
|
+
retryDelay: retryDelay,
|
|
1687
|
+
attempt: attempt + 1
|
|
1688
|
+
}));
|
|
1689
|
+
}
|
|
1690
|
+
throw err;
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
|
|
1540
1694
|
const withRetrySafeFetch = async (fn, options) => {
|
|
1541
1695
|
const {retries: retries = defaultRetry, retryDelay: retryDelay = defaultRetryDelay, attempt: attempt = 0, retryHttpStatus: retryHttpStatus} = options;
|
|
1542
1696
|
const result = await fn();
|
|
@@ -1565,17 +1719,15 @@ const getHashParamValue = (hash, param) => {
|
|
|
1565
1719
|
return urlParams.get(param);
|
|
1566
1720
|
};
|
|
1567
1721
|
|
|
1568
|
-
const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl,
|
|
1569
|
-
const postData =
|
|
1722
|
+
const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId, dcApiSupported: dcApiSupported, applicationId: applicationId}) => {
|
|
1723
|
+
const postData = {
|
|
1570
1724
|
credentialQuery: credentialQuery,
|
|
1571
|
-
challenge: challenge
|
|
1572
|
-
|
|
1573
|
-
redirectUri: redirectUri
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
}
|
|
1577
|
-
walletProviderId: walletProviderId
|
|
1578
|
-
} : {});
|
|
1725
|
+
challenge: challenge,
|
|
1726
|
+
applicationId: applicationId,
|
|
1727
|
+
redirectUri: redirectUri,
|
|
1728
|
+
walletProviderId: walletProviderId,
|
|
1729
|
+
dcApiSupported: dcApiSupported
|
|
1730
|
+
};
|
|
1579
1731
|
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions`, {
|
|
1580
1732
|
method: "POST",
|
|
1581
1733
|
headers: {
|
|
@@ -1589,8 +1741,42 @@ const createSession = async ({credentialQuery: credentialQuery, challenge: chall
|
|
|
1589
1741
|
const data = await responseResult.value.json();
|
|
1590
1742
|
if (!isType(CreateSessionResponseValidator)(data)) {
|
|
1591
1743
|
return err({
|
|
1592
|
-
type:
|
|
1593
|
-
message: "Create session
|
|
1744
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1745
|
+
message: "Create session returned unsupported response"
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
return ok(data);
|
|
1749
|
+
};
|
|
1750
|
+
|
|
1751
|
+
const abortSession = async ({apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey}) => {
|
|
1752
|
+
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/abort`, {
|
|
1753
|
+
method: "POST",
|
|
1754
|
+
headers: {
|
|
1755
|
+
"Content-Type": "application/json",
|
|
1756
|
+
Authorization: `Bearer ${sessionKey}`
|
|
1757
|
+
}
|
|
1758
|
+
});
|
|
1759
|
+
if (responseResult.isErr()) {
|
|
1760
|
+
return err(responseResult.error);
|
|
1761
|
+
}
|
|
1762
|
+
return ok(undefined);
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
const getSessionStatus = async ({apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey}) => {
|
|
1766
|
+
const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/status`, {
|
|
1767
|
+
method: "GET",
|
|
1768
|
+
headers: {
|
|
1769
|
+
Authorization: `Bearer ${sessionKey}`
|
|
1770
|
+
}
|
|
1771
|
+
});
|
|
1772
|
+
if (responseResult.isErr()) {
|
|
1773
|
+
return err(responseResult.error);
|
|
1774
|
+
}
|
|
1775
|
+
const data = await responseResult.value.json();
|
|
1776
|
+
if (!isType(GetSessionStatusResponseValidator)(data)) {
|
|
1777
|
+
return err({
|
|
1778
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1779
|
+
message: "Get session status return unsupported response"
|
|
1594
1780
|
});
|
|
1595
1781
|
}
|
|
1596
1782
|
return ok(data);
|
|
@@ -1618,7 +1804,7 @@ const exchangeSessionResult = async ({challenge: challenge, responseCode: respon
|
|
|
1618
1804
|
const data = await responseResult.value.json();
|
|
1619
1805
|
if (!isType(PresentationResultRelaxValidator)(data)) {
|
|
1620
1806
|
return err({
|
|
1621
|
-
type:
|
|
1807
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1622
1808
|
message: "Exchange session result return unsupported response",
|
|
1623
1809
|
details: {
|
|
1624
1810
|
data: data
|
|
@@ -1633,22 +1819,7 @@ const isMobileDetect = userAgent => isMobile_2({
|
|
|
1633
1819
|
tablet: false
|
|
1634
1820
|
});
|
|
1635
1821
|
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
(function(CrossDeviceCallbackErrorType) {
|
|
1639
|
-
CrossDeviceCallbackErrorType["Timeout"] = "Timeout";
|
|
1640
|
-
CrossDeviceCallbackErrorType["Abort"] = "Abort";
|
|
1641
|
-
CrossDeviceCallbackErrorType["RequestCredentialsFailed"] = "RequestCredentialsFailed";
|
|
1642
|
-
})(exports.CrossDeviceCallbackErrorType || (exports.CrossDeviceCallbackErrorType = {}));
|
|
1643
|
-
|
|
1644
|
-
var CrossDeviceRequestCredentialsErrorMessage;
|
|
1645
|
-
|
|
1646
|
-
(function(CrossDeviceRequestCredentialsErrorMessage) {
|
|
1647
|
-
CrossDeviceRequestCredentialsErrorMessage["FailedToGetSessionResult"] = "Failed to get session result";
|
|
1648
|
-
CrossDeviceRequestCredentialsErrorMessage["FailedToCreateSession"] = "Failed to create session";
|
|
1649
|
-
CrossDeviceRequestCredentialsErrorMessage["Abort"] = "User aborted the session";
|
|
1650
|
-
CrossDeviceRequestCredentialsErrorMessage["Timeout"] = "User session timeout";
|
|
1651
|
-
})(CrossDeviceRequestCredentialsErrorMessage || (CrossDeviceRequestCredentialsErrorMessage = {}));
|
|
1822
|
+
const getVersion = () => MATTR_SDK_VERSION_VALUE;
|
|
1652
1823
|
|
|
1653
1824
|
var WindowEventListenerType;
|
|
1654
1825
|
|
|
@@ -1656,10 +1827,13 @@ var WindowEventListenerType;
|
|
|
1656
1827
|
WindowEventListenerType["message"] = "message";
|
|
1657
1828
|
})(WindowEventListenerType || (WindowEventListenerType = {}));
|
|
1658
1829
|
|
|
1659
|
-
let listener;
|
|
1830
|
+
let listener = undefined;
|
|
1660
1831
|
|
|
1661
1832
|
const removeWindowMessageEventListener = () => {
|
|
1662
|
-
|
|
1833
|
+
if (listener) {
|
|
1834
|
+
window.removeEventListener(WindowEventListenerType.message, listener, false);
|
|
1835
|
+
}
|
|
1836
|
+
listener = undefined;
|
|
1663
1837
|
};
|
|
1664
1838
|
|
|
1665
1839
|
const closeCrossDeviceModal = options => {
|
|
@@ -1671,8 +1845,7 @@ const closeCrossDeviceModal = options => {
|
|
|
1671
1845
|
};
|
|
1672
1846
|
|
|
1673
1847
|
const receiveMessageHandler = options => async event => {
|
|
1674
|
-
const {
|
|
1675
|
-
const {onComplete: onComplete, onFailure: onFailure} = crossDeviceCallback;
|
|
1848
|
+
const {onComplete: onComplete, onFailure: onFailure, container: container, sessionId: sessionId, apiBaseUrl: apiBaseUrl, challenge: challenge} = options;
|
|
1676
1849
|
if (event.origin !== apiBaseUrl) {
|
|
1677
1850
|
return;
|
|
1678
1851
|
}
|
|
@@ -1686,8 +1859,8 @@ const receiveMessageHandler = options => async event => {
|
|
|
1686
1859
|
});
|
|
1687
1860
|
if (result.isErr()) {
|
|
1688
1861
|
onFailure({
|
|
1689
|
-
type: exports.
|
|
1690
|
-
message:
|
|
1862
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1863
|
+
message: RequestCredentialsErrorMessage.FailedToGetSessionResult
|
|
1691
1864
|
});
|
|
1692
1865
|
closeCrossDeviceModal({
|
|
1693
1866
|
container: container
|
|
@@ -1695,8 +1868,9 @@ const receiveMessageHandler = options => async event => {
|
|
|
1695
1868
|
return;
|
|
1696
1869
|
}
|
|
1697
1870
|
onComplete({
|
|
1698
|
-
result: result.value,
|
|
1699
|
-
sessionId: result.value.sessionId
|
|
1871
|
+
result: "challenge" in result.value ? result.value : undefined,
|
|
1872
|
+
sessionId: result.value.sessionId,
|
|
1873
|
+
sessionCompletedInRedirect: false
|
|
1700
1874
|
});
|
|
1701
1875
|
closeCrossDeviceModal({
|
|
1702
1876
|
container: container
|
|
@@ -1705,8 +1879,8 @@ const receiveMessageHandler = options => async event => {
|
|
|
1705
1879
|
}
|
|
1706
1880
|
if (event.data.type === MessageEventDataType.PresentationTimeout) {
|
|
1707
1881
|
onFailure({
|
|
1708
|
-
type: exports.
|
|
1709
|
-
message:
|
|
1882
|
+
type: exports.RequestCredentialsErrorType.Timeout,
|
|
1883
|
+
message: RequestCredentialsErrorMessage.Timeout
|
|
1710
1884
|
});
|
|
1711
1885
|
closeCrossDeviceModal({
|
|
1712
1886
|
container: container
|
|
@@ -1715,8 +1889,8 @@ const receiveMessageHandler = options => async event => {
|
|
|
1715
1889
|
}
|
|
1716
1890
|
if (event.data.type === MessageEventDataType.PresentationAbort) {
|
|
1717
1891
|
onFailure({
|
|
1718
|
-
type: exports.
|
|
1719
|
-
message:
|
|
1892
|
+
type: exports.RequestCredentialsErrorType.Abort,
|
|
1893
|
+
message: RequestCredentialsErrorMessage.Abort
|
|
1720
1894
|
});
|
|
1721
1895
|
closeCrossDeviceModal({
|
|
1722
1896
|
container: container
|
|
@@ -1741,41 +1915,198 @@ const openCrossDeviceModal = options => {
|
|
|
1741
1915
|
return modalContainer;
|
|
1742
1916
|
};
|
|
1743
1917
|
|
|
1744
|
-
const
|
|
1745
|
-
const {challenge: challenge,
|
|
1746
|
-
const
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1918
|
+
const requestCredentialsWithCrossDevice = async options => {
|
|
1919
|
+
const {challenge: challenge, apiBaseUrl: apiBaseUrl, sessionUrl: sessionUrl, sessionId: sessionId, sessionKey: sessionKey} = options;
|
|
1920
|
+
const container = openCrossDeviceModal({
|
|
1921
|
+
sessionUrl: sessionUrl
|
|
1922
|
+
});
|
|
1923
|
+
return await new Promise((resolve => {
|
|
1924
|
+
const abortController = setActiveSession({
|
|
1925
|
+
sessionId: sessionId,
|
|
1926
|
+
sessionKey: sessionKey
|
|
1927
|
+
});
|
|
1928
|
+
abortController.signal.addEventListener("abort", (() => {
|
|
1929
|
+
closeCrossDeviceModal({
|
|
1930
|
+
container: container
|
|
1931
|
+
});
|
|
1932
|
+
resolve(err({
|
|
1933
|
+
type: exports.RequestCredentialsErrorType.Abort,
|
|
1934
|
+
message: RequestCredentialsErrorMessage.Abort
|
|
1935
|
+
}));
|
|
1936
|
+
}));
|
|
1937
|
+
removeWindowMessageEventListener();
|
|
1938
|
+
listener = receiveMessageHandler({
|
|
1939
|
+
container: container,
|
|
1940
|
+
sessionId: sessionId,
|
|
1941
|
+
apiBaseUrl: apiBaseUrl,
|
|
1942
|
+
challenge: challenge,
|
|
1943
|
+
onComplete: data => resolve(ok(data)),
|
|
1944
|
+
onFailure: error => resolve(err(error))
|
|
1945
|
+
});
|
|
1946
|
+
window.addEventListener(WindowEventListenerType.message, listener, false);
|
|
1947
|
+
}));
|
|
1948
|
+
};
|
|
1949
|
+
|
|
1950
|
+
const abortCredentialRequest = async () => {
|
|
1951
|
+
const initialiseOptions = getInitialiseOptions();
|
|
1952
|
+
if (!initialiseOptions) {
|
|
1953
|
+
throw new Exception(InitialiseErrorMessage.SdkNotInitialised);
|
|
1954
|
+
}
|
|
1955
|
+
const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
|
|
1956
|
+
const session = getActiveSession();
|
|
1957
|
+
if (!session || !session.sessionKey) {
|
|
1958
|
+
return ok(undefined);
|
|
1959
|
+
}
|
|
1960
|
+
const {sessionId: sessionId, sessionKey: sessionKey} = session;
|
|
1961
|
+
removeActiveSession();
|
|
1962
|
+
const abortSessionResult = await abortSession({
|
|
1750
1963
|
apiBaseUrl: apiBaseUrl,
|
|
1751
|
-
|
|
1752
|
-
|
|
1964
|
+
sessionId: sessionId,
|
|
1965
|
+
sessionKey: sessionKey
|
|
1753
1966
|
});
|
|
1754
|
-
if (
|
|
1967
|
+
if (abortSessionResult.isErr()) {
|
|
1755
1968
|
return err({
|
|
1756
|
-
type: exports.
|
|
1757
|
-
message:
|
|
1758
|
-
cause:
|
|
1969
|
+
type: exports.AbortSessionErrorType.AbortSessionFailed,
|
|
1970
|
+
message: AbortSessionErrorMessage.FailedToAbortSession,
|
|
1971
|
+
cause: abortSessionResult.error
|
|
1759
1972
|
});
|
|
1760
1973
|
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
container: container,
|
|
1974
|
+
return ok(undefined);
|
|
1975
|
+
};
|
|
1976
|
+
|
|
1977
|
+
const requestCredentialsWithDigitalCredentialsApi = async options => {
|
|
1978
|
+
const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, request: request, sessionTtl: sessionTtl} = options;
|
|
1979
|
+
const sessionTimeoutId = window.setTimeout((() => removeActiveSession()), sessionTtl * 1e3);
|
|
1980
|
+
const abortController = setActiveSession({
|
|
1769
1981
|
sessionId: sessionId,
|
|
1982
|
+
sessionKey: sessionKey,
|
|
1983
|
+
sessionTimeoutId: sessionTimeoutId
|
|
1984
|
+
});
|
|
1985
|
+
const credentialResponseResult = await getCredentials(request, abortController);
|
|
1986
|
+
if (credentialResponseResult.isErr()) {
|
|
1987
|
+
await abortCredentialRequest();
|
|
1988
|
+
return err(credentialResponseResult.error);
|
|
1989
|
+
}
|
|
1990
|
+
const credentialResponse = credentialResponseResult.value;
|
|
1991
|
+
const parsedCredentialResponseResult = parseCredentialResponse(credentialResponse);
|
|
1992
|
+
if (parsedCredentialResponseResult.isErr()) {
|
|
1993
|
+
await abortCredentialRequest();
|
|
1994
|
+
return err(parsedCredentialResponseResult.error);
|
|
1995
|
+
}
|
|
1996
|
+
const parsedCredentialResponse = parsedCredentialResponseResult.value;
|
|
1997
|
+
const credentialVerificationResult = await verifyCredentialResponse({
|
|
1770
1998
|
apiBaseUrl: apiBaseUrl,
|
|
1771
|
-
|
|
1999
|
+
sessionId: sessionId,
|
|
2000
|
+
sessionKey: sessionKey,
|
|
2001
|
+
challenge: challenge,
|
|
2002
|
+
protocol: parsedCredentialResponse.protocol,
|
|
2003
|
+
data: parsedCredentialResponse.data
|
|
1772
2004
|
});
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
2005
|
+
if (credentialVerificationResult.isErr()) {
|
|
2006
|
+
return err({
|
|
2007
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
2008
|
+
message: RequestCredentialsErrorMessage.FailedToVerifyCredentialResponse,
|
|
2009
|
+
cause: credentialVerificationResult.error
|
|
2010
|
+
});
|
|
2011
|
+
}
|
|
2012
|
+
return ok(credentialVerificationResult.value);
|
|
2013
|
+
};
|
|
2014
|
+
|
|
2015
|
+
const getCredentials = async (request, abortController) => {
|
|
2016
|
+
try {
|
|
2017
|
+
const credentialResponse = await navigator.credentials.get(Object.assign(Object.assign({}, request), {
|
|
2018
|
+
signal: abortController.signal
|
|
2019
|
+
}));
|
|
2020
|
+
return ok(credentialResponse);
|
|
2021
|
+
} catch (exception) {
|
|
2022
|
+
return err({
|
|
2023
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
2024
|
+
message: RequestCredentialsErrorMessage.DcApiError,
|
|
2025
|
+
cause: exception
|
|
2026
|
+
});
|
|
2027
|
+
}
|
|
2028
|
+
};
|
|
2029
|
+
|
|
2030
|
+
const parseCredentialResponse = credentialResponse => {
|
|
2031
|
+
if (!credentialResponse) {
|
|
2032
|
+
return err({
|
|
2033
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
2034
|
+
message: RequestCredentialsErrorMessage.DcApiResponseParseError,
|
|
2035
|
+
details: {
|
|
2036
|
+
response: credentialResponse
|
|
2037
|
+
}
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
if (typeof credentialResponse === "object") {
|
|
2041
|
+
return ok(credentialResponse);
|
|
2042
|
+
}
|
|
2043
|
+
if (typeof credentialResponse === "string") {
|
|
2044
|
+
try {
|
|
2045
|
+
const parsed = JSON.parse(credentialResponse);
|
|
2046
|
+
return ok(parsed);
|
|
2047
|
+
} catch (_a) {
|
|
2048
|
+
return err({
|
|
2049
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
2050
|
+
message: RequestCredentialsErrorMessage.DcApiResponseParseError,
|
|
2051
|
+
details: {
|
|
2052
|
+
response: credentialResponse
|
|
2053
|
+
}
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
return err({
|
|
2058
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
2059
|
+
message: RequestCredentialsErrorMessage.DcApiResponseParseError,
|
|
2060
|
+
details: {
|
|
2061
|
+
response: credentialResponse
|
|
2062
|
+
}
|
|
1776
2063
|
});
|
|
1777
2064
|
};
|
|
1778
2065
|
|
|
2066
|
+
const verifyCredentialResponse = async options => {
|
|
2067
|
+
const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, protocol: protocol, data: data} = options;
|
|
2068
|
+
const requestBody = {
|
|
2069
|
+
protocol: protocol,
|
|
2070
|
+
data: data,
|
|
2071
|
+
challenge: challenge
|
|
2072
|
+
};
|
|
2073
|
+
const credentialVerificationResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/dc-api/response`, {
|
|
2074
|
+
method: "POST",
|
|
2075
|
+
headers: {
|
|
2076
|
+
"Content-Type": "application/json",
|
|
2077
|
+
Authorization: `Bearer ${sessionKey}`
|
|
2078
|
+
},
|
|
2079
|
+
body: JSON.stringify(requestBody)
|
|
2080
|
+
});
|
|
2081
|
+
if (credentialVerificationResult.isErr()) {
|
|
2082
|
+
return err(credentialVerificationResult.error);
|
|
2083
|
+
}
|
|
2084
|
+
const credentialVerificationResponse = await credentialVerificationResult.value.json();
|
|
2085
|
+
if (!isType(PresentationResultRelaxValidator)(credentialVerificationResponse)) {
|
|
2086
|
+
return err({
|
|
2087
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
2088
|
+
message: "Verify credential returned unsupported response",
|
|
2089
|
+
details: {
|
|
2090
|
+
response: credentialVerificationResponse
|
|
2091
|
+
}
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
return ok(credentialVerificationResponse);
|
|
2095
|
+
};
|
|
2096
|
+
|
|
2097
|
+
const isDigitalCredentialsApiSupported = () => {
|
|
2098
|
+
var _a;
|
|
2099
|
+
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";
|
|
2100
|
+
};
|
|
2101
|
+
|
|
2102
|
+
const sleep = ms => new Promise((resolve => setTimeout(resolve, ms)));
|
|
2103
|
+
|
|
2104
|
+
const SESSION_STATUS_POLLING_MAX_RETRY = 1e3;
|
|
2105
|
+
|
|
2106
|
+
const SESSION_STATUS_POLLING_INTERVAL_MS = 3e3;
|
|
2107
|
+
|
|
2108
|
+
const SESSION_STATUS_POLLING_INITIAL_DELAY_MS = 3e3;
|
|
2109
|
+
|
|
1779
2110
|
var SameDeviceRequestCredentialsErrorMessage;
|
|
1780
2111
|
|
|
1781
2112
|
(function(SameDeviceRequestCredentialsErrorMessage) {
|
|
@@ -1784,65 +2115,135 @@ var SameDeviceRequestCredentialsErrorMessage;
|
|
|
1784
2115
|
})(SameDeviceRequestCredentialsErrorMessage || (SameDeviceRequestCredentialsErrorMessage = {}));
|
|
1785
2116
|
|
|
1786
2117
|
const requestCredentialsSameDevice = async options => {
|
|
1787
|
-
const {challenge: challenge,
|
|
1788
|
-
const
|
|
2118
|
+
const {challenge: challenge, apiBaseUrl: apiBaseUrl, applicationId: applicationId, sessionUrl: sessionUrl, sessionKey: sessionKey, sessionId: sessionId} = options;
|
|
2119
|
+
const abortController = setActiveSession({
|
|
2120
|
+
sessionId: sessionId,
|
|
2121
|
+
sessionKey: sessionKey
|
|
2122
|
+
});
|
|
2123
|
+
window.localStorage.setItem(LocalStorageKey.sessionId, sessionId);
|
|
1789
2124
|
window.localStorage.setItem(LocalStorageKey.challenge, challenge);
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
2125
|
+
window.location.assign(sessionUrl);
|
|
2126
|
+
await sleep(SESSION_STATUS_POLLING_INITIAL_DELAY_MS);
|
|
2127
|
+
const checkResult = await withRetry((async () => {
|
|
2128
|
+
const statusResult = await getSessionStatus({
|
|
2129
|
+
apiBaseUrl: apiBaseUrl,
|
|
2130
|
+
applicationId: applicationId,
|
|
2131
|
+
sessionId: sessionId,
|
|
2132
|
+
sessionKey: sessionKey
|
|
1795
2133
|
});
|
|
2134
|
+
if (abortController.signal.aborted) {
|
|
2135
|
+
return err({
|
|
2136
|
+
type: exports.RequestCredentialsErrorType.Abort,
|
|
2137
|
+
message: RequestCredentialsErrorMessage.Abort
|
|
2138
|
+
});
|
|
2139
|
+
}
|
|
2140
|
+
if (statusResult.isErr()) {
|
|
2141
|
+
if (statusResult.error.status === 404) {
|
|
2142
|
+
return err({
|
|
2143
|
+
type: exports.RequestCredentialsErrorType.Timeout,
|
|
2144
|
+
message: RequestCredentialsErrorMessage.Timeout
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2147
|
+
throw Error("Unexpected status response. Retry");
|
|
2148
|
+
}
|
|
2149
|
+
if (statusResult.value.status !== PresentationStatusCode.ResultReady) {
|
|
2150
|
+
throw Error("Result is not ready. Retry");
|
|
2151
|
+
}
|
|
2152
|
+
return ok(undefined);
|
|
2153
|
+
}), {
|
|
2154
|
+
retries: SESSION_STATUS_POLLING_MAX_RETRY,
|
|
2155
|
+
retryDelay: SESSION_STATUS_POLLING_INTERVAL_MS
|
|
2156
|
+
});
|
|
2157
|
+
if (checkResult.isErr()) {
|
|
2158
|
+
return err(checkResult.error);
|
|
2159
|
+
}
|
|
2160
|
+
window.close();
|
|
2161
|
+
return ok({
|
|
2162
|
+
sessionId: sessionId,
|
|
2163
|
+
sessionCompletedInRedirect: true
|
|
2164
|
+
});
|
|
2165
|
+
};
|
|
2166
|
+
|
|
2167
|
+
const requestCredentials = async options => {
|
|
2168
|
+
var _a;
|
|
2169
|
+
const initialiseOptions = getInitialiseOptions();
|
|
2170
|
+
if (!initialiseOptions) {
|
|
2171
|
+
throw new Exception(InitialiseErrorMessage.SdkNotInitialised);
|
|
1796
2172
|
}
|
|
2173
|
+
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
2174
|
+
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
|
|
2175
|
+
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration} = options;
|
|
2176
|
+
const dcApiSupported = isDigitalCredentialsApiSupported();
|
|
2177
|
+
const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
|
|
1797
2178
|
const createSessionResult = await createSession({
|
|
1798
2179
|
credentialQuery: credentialQuery,
|
|
1799
|
-
challenge:
|
|
1800
|
-
redirectUri:
|
|
2180
|
+
challenge: challenge,
|
|
2181
|
+
redirectUri: openId4VpRedirectUri,
|
|
2182
|
+
walletProviderId: (_a = openid4vpConfiguration === null || openid4vpConfiguration === void 0 ? void 0 : openid4vpConfiguration.walletProviderId) !== null && _a !== void 0 ? _a : undefined,
|
|
1801
2183
|
apiBaseUrl: apiBaseUrl,
|
|
1802
2184
|
applicationId: applicationId,
|
|
1803
|
-
|
|
2185
|
+
dcApiSupported: dcApiSupported
|
|
1804
2186
|
});
|
|
1805
2187
|
if (createSessionResult.isErr()) {
|
|
1806
2188
|
return err({
|
|
1807
2189
|
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1808
|
-
message:
|
|
2190
|
+
message: RequestCredentialsErrorMessage.FailedToCreateSession,
|
|
1809
2191
|
cause: createSessionResult.error
|
|
1810
2192
|
});
|
|
1811
2193
|
}
|
|
1812
|
-
const
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
2194
|
+
const session = createSessionResult.value;
|
|
2195
|
+
const {sessionKey: sessionKey, sessionId: sessionId} = session;
|
|
2196
|
+
if (session.type === SessionType.DigitalCredentialsApi) {
|
|
2197
|
+
const {request: request, sessionTtl: sessionTtl} = session;
|
|
2198
|
+
return await requestCredentialsWithDigitalCredentialsApi({
|
|
2199
|
+
apiBaseUrl: apiBaseUrl,
|
|
2200
|
+
request: request,
|
|
2201
|
+
sessionId: sessionId,
|
|
2202
|
+
sessionKey: sessionKey,
|
|
2203
|
+
challenge: challenge,
|
|
2204
|
+
sessionTtl: sessionTtl
|
|
2205
|
+
});
|
|
2206
|
+
}
|
|
2207
|
+
if (!openid4vpConfiguration) {
|
|
2208
|
+
return err({
|
|
2209
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
2210
|
+
message: RequestCredentialsErrorMessage.MissingOpenId4vpConfig
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2213
|
+
const {sessionUrl: sessionUrl} = session;
|
|
2214
|
+
if (openId4VpRedirectUri) {
|
|
2215
|
+
return await requestCredentialsSameDevice({
|
|
2216
|
+
challenge: challenge,
|
|
2217
|
+
apiBaseUrl: apiBaseUrl,
|
|
2218
|
+
applicationId: applicationId,
|
|
2219
|
+
sessionUrl: sessionUrl,
|
|
2220
|
+
sessionKey: sessionKey,
|
|
2221
|
+
sessionId: sessionId
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
return await requestCredentialsWithCrossDevice({
|
|
2225
|
+
challenge: challenge,
|
|
2226
|
+
apiBaseUrl: apiBaseUrl,
|
|
2227
|
+
sessionUrl: sessionUrl,
|
|
2228
|
+
sessionKey: sessionKey,
|
|
1816
2229
|
sessionId: sessionId
|
|
1817
2230
|
});
|
|
1818
2231
|
};
|
|
1819
2232
|
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
if (!initialiseOptions) {
|
|
1824
|
-
throw new Exception(InitialiseErrorMessage.SdkNotInitialised);
|
|
2233
|
+
const deriveOpenId4vpRedirectUri = openid4vpConfiguration => {
|
|
2234
|
+
if (!openid4vpConfiguration) {
|
|
2235
|
+
return undefined;
|
|
1825
2236
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
initialiseOptions: initialiseOptions,
|
|
1832
|
-
challenge: challenge,
|
|
1833
|
-
mode: mode
|
|
1834
|
-
}));
|
|
2237
|
+
let detectedMode;
|
|
2238
|
+
if (openid4vpConfiguration && openid4vpConfiguration.mode) {
|
|
2239
|
+
detectedMode = openid4vpConfiguration.mode;
|
|
2240
|
+
} else {
|
|
2241
|
+
detectedMode = isMobileDetect(navigator.userAgent) ? exports.Mode.SameDevice : exports.Mode.CrossDevice;
|
|
1835
2242
|
}
|
|
1836
|
-
if (
|
|
1837
|
-
return
|
|
1838
|
-
initialiseOptions: initialiseOptions,
|
|
1839
|
-
challenge: challenge,
|
|
1840
|
-
mode: mode
|
|
1841
|
-
}));
|
|
2243
|
+
if (detectedMode === exports.Mode.SameDevice && !isType(OpenId4vpConfigCrossDeviceOptionsValidator)(openid4vpConfiguration) && openid4vpConfiguration.redirectUri) {
|
|
2244
|
+
return openid4vpConfiguration.redirectUri;
|
|
1842
2245
|
}
|
|
1843
|
-
|
|
1844
|
-
data: options
|
|
1845
|
-
});
|
|
2246
|
+
return undefined;
|
|
1846
2247
|
};
|
|
1847
2248
|
|
|
1848
2249
|
exports.HandleRedirectCallbackErrorType = void 0;
|
|
@@ -1856,7 +2257,7 @@ var HandleRedirectCallbackErrorMessage;
|
|
|
1856
2257
|
(function(HandleRedirectCallbackErrorMessage) {
|
|
1857
2258
|
HandleRedirectCallbackErrorMessage["FailedToFindResponseCode"] = "Failed to find response code";
|
|
1858
2259
|
HandleRedirectCallbackErrorMessage["FailedToFindChallenge"] = "Failed to find challenge";
|
|
1859
|
-
HandleRedirectCallbackErrorMessage["
|
|
2260
|
+
HandleRedirectCallbackErrorMessage["FailedToFindActiveSession"] = "Failed to find active session";
|
|
1860
2261
|
HandleRedirectCallbackErrorMessage["FailedToGetSessionResult"] = "Failed to get session result";
|
|
1861
2262
|
})(HandleRedirectCallbackErrorMessage || (HandleRedirectCallbackErrorMessage = {}));
|
|
1862
2263
|
|
|
@@ -1873,18 +2274,12 @@ const handleRedirectCallback = async () => {
|
|
|
1873
2274
|
message: HandleRedirectCallbackErrorMessage.FailedToFindResponseCode
|
|
1874
2275
|
});
|
|
1875
2276
|
}
|
|
1876
|
-
const challenge = window.localStorage.getItem(LocalStorageKey.challenge);
|
|
1877
|
-
if (!challenge) {
|
|
1878
|
-
return err({
|
|
1879
|
-
type: exports.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,
|
|
1880
|
-
message: HandleRedirectCallbackErrorMessage.FailedToFindChallenge
|
|
1881
|
-
});
|
|
1882
|
-
}
|
|
1883
2277
|
const sessionId = window.localStorage.getItem(LocalStorageKey.sessionId);
|
|
1884
|
-
|
|
2278
|
+
const challenge = window.localStorage.getItem(LocalStorageKey.challenge);
|
|
2279
|
+
if (!sessionId || !challenge) {
|
|
1885
2280
|
return err({
|
|
1886
2281
|
type: exports.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,
|
|
1887
|
-
message: HandleRedirectCallbackErrorMessage.
|
|
2282
|
+
message: HandleRedirectCallbackErrorMessage.FailedToFindActiveSession
|
|
1888
2283
|
});
|
|
1889
2284
|
}
|
|
1890
2285
|
const result = await exchangeSessionResult({
|
|
@@ -1901,20 +2296,25 @@ const handleRedirectCallback = async () => {
|
|
|
1901
2296
|
});
|
|
1902
2297
|
}
|
|
1903
2298
|
return ok({
|
|
1904
|
-
result: result.value,
|
|
2299
|
+
result: "challenge" in result.value ? result.value : undefined,
|
|
1905
2300
|
sessionId: result.value.sessionId
|
|
1906
2301
|
});
|
|
1907
2302
|
};
|
|
1908
2303
|
|
|
1909
2304
|
const utils = {
|
|
1910
2305
|
generateChallenge: generateChallenge,
|
|
2306
|
+
getVersion: getVersion,
|
|
1911
2307
|
unwrap: unwrap
|
|
1912
2308
|
};
|
|
1913
2309
|
|
|
2310
|
+
exports.abortCredentialRequest = abortCredentialRequest;
|
|
2311
|
+
|
|
1914
2312
|
exports.handleRedirectCallback = handleRedirectCallback;
|
|
1915
2313
|
|
|
1916
2314
|
exports.initialise = initialise;
|
|
1917
2315
|
|
|
2316
|
+
exports.isDigitalCredentialsApiSupported = isDigitalCredentialsApiSupported;
|
|
2317
|
+
|
|
1918
2318
|
exports.requestCredentials = requestCredentials;
|
|
1919
2319
|
|
|
1920
2320
|
exports.utils = utils;
|