@mattrglobal/verifier-sdk-web 1.1.1-unstable.16 → 1.1.1-unstable.161
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 +63 -42
- package/dist/lib/verifier-js-no-deps.cjs.js +590 -198
- package/dist/lib/verifier-js-no-deps.cjs.js.map +1 -1
- package/dist/lib/verifier-js.cjs.js +716 -312
- 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 +3 -1
- package/dist/typings/verifier/initialize.d.ts +12 -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 +129 -21
- package/dist/typings/verifier/types/verifier-web-sdk.d.ts +129 -186
- package/dist/typings/verifier/utils.d.ts +25 -5
- package/dist/verifier-js.development.js +661 -294
- 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
- package/dist/typings/verifier/initialise.d.ts +0 -12
|
@@ -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-20
|
|
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;
|
|
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;
|
|
469
547
|
}
|
|
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.");
|
|
553
|
-
}
|
|
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) {
|
|
748
750
|
return {
|
|
749
751
|
kind: "schema",
|
|
750
|
-
type: "
|
|
751
|
-
reference:
|
|
752
|
-
expects:
|
|
752
|
+
type: "literal",
|
|
753
|
+
reference: literal,
|
|
754
|
+
expects: _stringify(literal_),
|
|
753
755
|
async: false,
|
|
756
|
+
literal: literal_,
|
|
754
757
|
message: message,
|
|
755
758
|
_run: function _run(dataset, config2) {
|
|
756
|
-
if (
|
|
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) {
|
|
769
|
+
return {
|
|
770
|
+
kind: "schema",
|
|
771
|
+
type: "number",
|
|
772
|
+
reference: number,
|
|
773
|
+
expects: "number",
|
|
774
|
+
async: false,
|
|
775
|
+
message: message,
|
|
776
|
+
_run: function _run(dataset, config2) {
|
|
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,79 +1332,184 @@
|
|
|
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 = {}));
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
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 = {}));
|
|
1430
|
+
const InitializeOptionsValidator = object({
|
|
1431
|
+
apiBaseUrl: pipe(string(), nonEmpty("Must not be empty")),
|
|
1432
|
+
applicationId: pipe(string(), nonEmpty("Must not be empty"))
|
|
1390
1433
|
});
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
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
|
+
};
|
|
1467
|
+
let initializeOptions = undefined;
|
|
1468
|
+
var InitializeErrorMessage;
|
|
1469
|
+
(function(InitializeErrorMessage) {
|
|
1470
|
+
InitializeErrorMessage["SdkNotInitialized"] = "SDK not initialized";
|
|
1471
|
+
})(InitializeErrorMessage || (InitializeErrorMessage = {}));
|
|
1472
|
+
const initialize = options => {
|
|
1473
|
+
assertType(InitializeOptionsValidator, "Invalid initialize options")(options);
|
|
1474
|
+
initializeOptions = options;
|
|
1475
|
+
};
|
|
1476
|
+
const getInitializeOptions = () => initializeOptions;
|
|
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;
|
|
1399
1512
|
};
|
|
1400
|
-
const getInitialiseOptions = () => initialiseOptions;
|
|
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,324 @@
|
|
|
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 initializeOptions = getInitializeOptions();
|
|
1795
|
+
if (!initializeOptions) {
|
|
1796
|
+
throw new Exception(InitializeErrorMessage.SdkNotInitialized);
|
|
1797
|
+
}
|
|
1798
|
+
const {apiBaseUrl: apiBaseUrl} = initializeOptions;
|
|
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
|
-
|
|
1847
|
+
if (credentialVerificationResult.isErr()) {
|
|
1848
|
+
return err({
|
|
1849
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1850
|
+
message: RequestCredentialsErrorMessage.FailedToVerifyCredentialResponse,
|
|
1851
|
+
cause: credentialVerificationResult.error
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
const verificationResult = credentialVerificationResult.value;
|
|
1642
1855
|
return ok({
|
|
1856
|
+
result: "challenge" in verificationResult ? verificationResult : undefined,
|
|
1643
1857
|
sessionId: sessionId
|
|
1644
1858
|
});
|
|
1645
1859
|
};
|
|
1860
|
+
const getCredentials = async (request, abortController) => {
|
|
1861
|
+
try {
|
|
1862
|
+
const credentialResponse = await navigator.credentials.get(Object.assign(Object.assign({}, request), {
|
|
1863
|
+
signal: abortController.signal
|
|
1864
|
+
}));
|
|
1865
|
+
return ok(credentialResponse);
|
|
1866
|
+
} catch (exception) {
|
|
1867
|
+
return err({
|
|
1868
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1869
|
+
message: RequestCredentialsErrorMessage.DcApiError,
|
|
1870
|
+
cause: exception
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
};
|
|
1874
|
+
const parseCredentialResponse = credentialResponse => {
|
|
1875
|
+
if (!credentialResponse) {
|
|
1876
|
+
return err({
|
|
1877
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1878
|
+
message: RequestCredentialsErrorMessage.DcApiResponseParseError,
|
|
1879
|
+
details: {
|
|
1880
|
+
response: credentialResponse
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
if (typeof credentialResponse === "object") {
|
|
1885
|
+
return ok(credentialResponse);
|
|
1886
|
+
}
|
|
1887
|
+
if (typeof credentialResponse === "string") {
|
|
1888
|
+
try {
|
|
1889
|
+
const parsed = JSON.parse(credentialResponse);
|
|
1890
|
+
return ok(parsed);
|
|
1891
|
+
} catch (_a) {
|
|
1892
|
+
return err({
|
|
1893
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1894
|
+
message: RequestCredentialsErrorMessage.DcApiResponseParseError,
|
|
1895
|
+
details: {
|
|
1896
|
+
response: credentialResponse
|
|
1897
|
+
}
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return err({
|
|
1902
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1903
|
+
message: RequestCredentialsErrorMessage.DcApiResponseParseError,
|
|
1904
|
+
details: {
|
|
1905
|
+
response: credentialResponse
|
|
1906
|
+
}
|
|
1907
|
+
});
|
|
1908
|
+
};
|
|
1909
|
+
const verifyCredentialResponse = async options => {
|
|
1910
|
+
const {apiBaseUrl: apiBaseUrl, sessionId: sessionId, sessionKey: sessionKey, challenge: challenge, protocol: protocol, data: data} = options;
|
|
1911
|
+
const requestBody = {
|
|
1912
|
+
protocol: protocol,
|
|
1913
|
+
data: data,
|
|
1914
|
+
challenge: challenge
|
|
1915
|
+
};
|
|
1916
|
+
const credentialVerificationResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/${sessionId}/dc-api/response`, {
|
|
1917
|
+
method: "POST",
|
|
1918
|
+
headers: {
|
|
1919
|
+
"Content-Type": "application/json",
|
|
1920
|
+
Authorization: `Bearer ${sessionKey}`
|
|
1921
|
+
},
|
|
1922
|
+
body: JSON.stringify(requestBody)
|
|
1923
|
+
});
|
|
1924
|
+
if (credentialVerificationResult.isErr()) {
|
|
1925
|
+
return err(credentialVerificationResult.error);
|
|
1926
|
+
}
|
|
1927
|
+
const credentialVerificationResponse = await credentialVerificationResult.value.json();
|
|
1928
|
+
if (!isType(PresentationResultRelaxValidator)(credentialVerificationResponse)) {
|
|
1929
|
+
return err({
|
|
1930
|
+
type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
|
|
1931
|
+
message: "Verify credential returned unsupported response",
|
|
1932
|
+
details: {
|
|
1933
|
+
response: credentialVerificationResponse
|
|
1934
|
+
}
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1937
|
+
return ok(credentialVerificationResponse);
|
|
1938
|
+
};
|
|
1939
|
+
const isDigitalCredentialsApiSupported = () => {
|
|
1940
|
+
var _a;
|
|
1941
|
+
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";
|
|
1942
|
+
};
|
|
1943
|
+
const sleep = ms => new Promise((resolve => setTimeout(resolve, ms)));
|
|
1944
|
+
const SESSION_STATUS_POLLING_MAX_RETRY = 1e3;
|
|
1945
|
+
const SESSION_STATUS_POLLING_INTERVAL_MS = 3e3;
|
|
1946
|
+
const SESSION_STATUS_POLLING_INITIAL_DELAY_MS = 3e3;
|
|
1646
1947
|
var SameDeviceRequestCredentialsErrorMessage;
|
|
1647
1948
|
(function(SameDeviceRequestCredentialsErrorMessage) {
|
|
1648
1949
|
SameDeviceRequestCredentialsErrorMessage["FailedToStoreChallenge"] = "Failed to store challenge";
|
|
1649
1950
|
SameDeviceRequestCredentialsErrorMessage["FailedToCreateSession"] = "Failed to create session";
|
|
1650
1951
|
})(SameDeviceRequestCredentialsErrorMessage || (SameDeviceRequestCredentialsErrorMessage = {}));
|
|
1651
1952
|
const requestCredentialsSameDevice = async options => {
|
|
1652
|
-
const {challenge: challenge,
|
|
1653
|
-
const
|
|
1953
|
+
const {challenge: challenge, apiBaseUrl: apiBaseUrl, applicationId: applicationId, sessionUrl: sessionUrl, sessionKey: sessionKey, sessionId: sessionId} = options;
|
|
1954
|
+
const abortController = setActiveSession({
|
|
1955
|
+
sessionId: sessionId,
|
|
1956
|
+
sessionKey: sessionKey
|
|
1957
|
+
});
|
|
1958
|
+
window.localStorage.setItem(LocalStorageKey.sessionId, sessionId);
|
|
1654
1959
|
window.localStorage.setItem(LocalStorageKey.challenge, challenge);
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1960
|
+
window.location.assign(sessionUrl);
|
|
1961
|
+
await sleep(SESSION_STATUS_POLLING_INITIAL_DELAY_MS);
|
|
1962
|
+
const checkResult = await withRetry((async () => {
|
|
1963
|
+
const statusResult = await getSessionStatus({
|
|
1964
|
+
apiBaseUrl: apiBaseUrl,
|
|
1965
|
+
applicationId: applicationId,
|
|
1966
|
+
sessionId: sessionId,
|
|
1967
|
+
sessionKey: sessionKey
|
|
1660
1968
|
});
|
|
1969
|
+
if (abortController.signal.aborted) {
|
|
1970
|
+
return err({
|
|
1971
|
+
type: exports.RequestCredentialsErrorType.Abort,
|
|
1972
|
+
message: RequestCredentialsErrorMessage.Abort
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
if (statusResult.isErr()) {
|
|
1976
|
+
if (statusResult.error.status === 404) {
|
|
1977
|
+
return err({
|
|
1978
|
+
type: exports.RequestCredentialsErrorType.Timeout,
|
|
1979
|
+
message: RequestCredentialsErrorMessage.Timeout
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
throw Error("Unexpected status response. Retry");
|
|
1983
|
+
}
|
|
1984
|
+
if (statusResult.value.status !== PresentationStatusCode.ResultReady) {
|
|
1985
|
+
throw Error("Result is not ready. Retry");
|
|
1986
|
+
}
|
|
1987
|
+
return ok(undefined);
|
|
1988
|
+
}), {
|
|
1989
|
+
retries: SESSION_STATUS_POLLING_MAX_RETRY,
|
|
1990
|
+
retryDelay: SESSION_STATUS_POLLING_INTERVAL_MS
|
|
1991
|
+
});
|
|
1992
|
+
if (checkResult.isErr()) {
|
|
1993
|
+
return err(checkResult.error);
|
|
1661
1994
|
}
|
|
1995
|
+
window.close();
|
|
1996
|
+
return ok({
|
|
1997
|
+
sessionId: sessionId,
|
|
1998
|
+
sessionCompletedInRedirect: true
|
|
1999
|
+
});
|
|
2000
|
+
};
|
|
2001
|
+
const requestCredentials = async options => {
|
|
2002
|
+
var _a;
|
|
2003
|
+
const initializeOptions = getInitializeOptions();
|
|
2004
|
+
if (!initializeOptions) {
|
|
2005
|
+
throw new Exception(InitializeErrorMessage.SdkNotInitialized);
|
|
2006
|
+
}
|
|
2007
|
+
assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
|
|
2008
|
+
const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initializeOptions;
|
|
2009
|
+
const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration} = options;
|
|
2010
|
+
const dcApiSupported = isDigitalCredentialsApiSupported();
|
|
2011
|
+
const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
|
|
1662
2012
|
const createSessionResult = await createSession({
|
|
1663
2013
|
credentialQuery: credentialQuery,
|
|
1664
|
-
challenge:
|
|
1665
|
-
redirectUri:
|
|
2014
|
+
challenge: challenge,
|
|
2015
|
+
redirectUri: openId4VpRedirectUri,
|
|
2016
|
+
walletProviderId: (_a = openid4vpConfiguration === null || openid4vpConfiguration === void 0 ? void 0 : openid4vpConfiguration.walletProviderId) !== null && _a !== void 0 ? _a : undefined,
|
|
1666
2017
|
apiBaseUrl: apiBaseUrl,
|
|
1667
2018
|
applicationId: applicationId,
|
|
1668
|
-
|
|
2019
|
+
dcApiSupported: dcApiSupported
|
|
1669
2020
|
});
|
|
1670
2021
|
if (createSessionResult.isErr()) {
|
|
1671
2022
|
return err({
|
|
1672
2023
|
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
1673
|
-
message:
|
|
2024
|
+
message: RequestCredentialsErrorMessage.FailedToCreateSession,
|
|
1674
2025
|
cause: createSessionResult.error
|
|
1675
2026
|
});
|
|
1676
2027
|
}
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
2028
|
+
const session = createSessionResult.value;
|
|
2029
|
+
const {sessionKey: sessionKey, sessionId: sessionId} = session;
|
|
2030
|
+
if (session.type === SessionType.DigitalCredentialsApi) {
|
|
2031
|
+
const {request: request, sessionTtl: sessionTtl} = session;
|
|
2032
|
+
return await requestCredentialsWithDigitalCredentialsApi({
|
|
2033
|
+
apiBaseUrl: apiBaseUrl,
|
|
2034
|
+
request: request,
|
|
2035
|
+
sessionId: sessionId,
|
|
2036
|
+
sessionKey: sessionKey,
|
|
2037
|
+
challenge: challenge,
|
|
2038
|
+
sessionTtl: sessionTtl
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
if (!openid4vpConfiguration) {
|
|
2042
|
+
return err({
|
|
2043
|
+
type: exports.RequestCredentialsErrorType.RequestCredentialsFailed,
|
|
2044
|
+
message: RequestCredentialsErrorMessage.MissingOpenId4vpConfig
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
const {sessionUrl: sessionUrl} = session;
|
|
2048
|
+
if (openId4VpRedirectUri) {
|
|
2049
|
+
return await requestCredentialsSameDevice({
|
|
2050
|
+
challenge: challenge,
|
|
2051
|
+
apiBaseUrl: apiBaseUrl,
|
|
2052
|
+
applicationId: applicationId,
|
|
2053
|
+
sessionUrl: sessionUrl,
|
|
2054
|
+
sessionKey: sessionKey,
|
|
2055
|
+
sessionId: sessionId
|
|
2056
|
+
});
|
|
2057
|
+
}
|
|
2058
|
+
return await requestCredentialsWithCrossDevice({
|
|
2059
|
+
challenge: challenge,
|
|
2060
|
+
apiBaseUrl: apiBaseUrl,
|
|
2061
|
+
sessionUrl: sessionUrl,
|
|
2062
|
+
sessionKey: sessionKey,
|
|
1681
2063
|
sessionId: sessionId
|
|
1682
2064
|
});
|
|
1683
2065
|
};
|
|
1684
|
-
const
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
if (!initialiseOptions) {
|
|
1688
|
-
throw new Exception(InitialiseErrorMessage.SdkNotInitialised);
|
|
2066
|
+
const deriveOpenId4vpRedirectUri = openid4vpConfiguration => {
|
|
2067
|
+
if (!openid4vpConfiguration) {
|
|
2068
|
+
return undefined;
|
|
1689
2069
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
initialiseOptions: initialiseOptions,
|
|
1696
|
-
challenge: challenge,
|
|
1697
|
-
mode: mode
|
|
1698
|
-
}));
|
|
2070
|
+
let detectedMode;
|
|
2071
|
+
if (openid4vpConfiguration && openid4vpConfiguration.mode) {
|
|
2072
|
+
detectedMode = openid4vpConfiguration.mode;
|
|
2073
|
+
} else {
|
|
2074
|
+
detectedMode = isMobileDetect(navigator.userAgent) ? exports.Mode.SameDevice : exports.Mode.CrossDevice;
|
|
1699
2075
|
}
|
|
1700
|
-
if (
|
|
1701
|
-
return
|
|
1702
|
-
initialiseOptions: initialiseOptions,
|
|
1703
|
-
challenge: challenge,
|
|
1704
|
-
mode: mode
|
|
1705
|
-
}));
|
|
2076
|
+
if (detectedMode === exports.Mode.SameDevice && !isType(OpenId4vpConfigCrossDeviceOptionsValidator)(openid4vpConfiguration) && openid4vpConfiguration.redirectUri) {
|
|
2077
|
+
return openid4vpConfiguration.redirectUri;
|
|
1706
2078
|
}
|
|
1707
|
-
|
|
1708
|
-
data: options
|
|
1709
|
-
});
|
|
2079
|
+
return undefined;
|
|
1710
2080
|
};
|
|
1711
2081
|
exports.HandleRedirectCallbackErrorType = void 0;
|
|
1712
2082
|
(function(HandleRedirectCallbackErrorType) {
|
|
@@ -1716,15 +2086,15 @@
|
|
|
1716
2086
|
(function(HandleRedirectCallbackErrorMessage) {
|
|
1717
2087
|
HandleRedirectCallbackErrorMessage["FailedToFindResponseCode"] = "Failed to find response code";
|
|
1718
2088
|
HandleRedirectCallbackErrorMessage["FailedToFindChallenge"] = "Failed to find challenge";
|
|
1719
|
-
HandleRedirectCallbackErrorMessage["
|
|
2089
|
+
HandleRedirectCallbackErrorMessage["FailedToFindActiveSession"] = "Failed to find active session";
|
|
1720
2090
|
HandleRedirectCallbackErrorMessage["FailedToGetSessionResult"] = "Failed to get session result";
|
|
1721
2091
|
})(HandleRedirectCallbackErrorMessage || (HandleRedirectCallbackErrorMessage = {}));
|
|
1722
2092
|
const handleRedirectCallback = async () => {
|
|
1723
|
-
const
|
|
1724
|
-
if (!
|
|
1725
|
-
throw new Exception(
|
|
2093
|
+
const initializeOptions = getInitializeOptions();
|
|
2094
|
+
if (!initializeOptions) {
|
|
2095
|
+
throw new Exception(InitializeErrorMessage.SdkNotInitialized);
|
|
1726
2096
|
}
|
|
1727
|
-
const {apiBaseUrl: apiBaseUrl} =
|
|
2097
|
+
const {apiBaseUrl: apiBaseUrl} = initializeOptions;
|
|
1728
2098
|
const responseCode = getHashParamValue(window.location.hash, "response_code");
|
|
1729
2099
|
if (!responseCode) {
|
|
1730
2100
|
return err({
|
|
@@ -1732,18 +2102,12 @@
|
|
|
1732
2102
|
message: HandleRedirectCallbackErrorMessage.FailedToFindResponseCode
|
|
1733
2103
|
});
|
|
1734
2104
|
}
|
|
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
2105
|
const sessionId = window.localStorage.getItem(LocalStorageKey.sessionId);
|
|
1743
|
-
|
|
2106
|
+
const challenge = window.localStorage.getItem(LocalStorageKey.challenge);
|
|
2107
|
+
if (!sessionId || !challenge) {
|
|
1744
2108
|
return err({
|
|
1745
2109
|
type: exports.HandleRedirectCallbackErrorType.HandleRedirectCallbackFailed,
|
|
1746
|
-
message: HandleRedirectCallbackErrorMessage.
|
|
2110
|
+
message: HandleRedirectCallbackErrorMessage.FailedToFindActiveSession
|
|
1747
2111
|
});
|
|
1748
2112
|
}
|
|
1749
2113
|
const result = await exchangeSessionResult({
|
|
@@ -1760,16 +2124,19 @@
|
|
|
1760
2124
|
});
|
|
1761
2125
|
}
|
|
1762
2126
|
return ok({
|
|
1763
|
-
result: result.value,
|
|
2127
|
+
result: "challenge" in result.value ? result.value : undefined,
|
|
1764
2128
|
sessionId: result.value.sessionId
|
|
1765
2129
|
});
|
|
1766
2130
|
};
|
|
1767
2131
|
const utils = {
|
|
1768
2132
|
generateChallenge: generateChallenge,
|
|
2133
|
+
getVersion: getVersion,
|
|
1769
2134
|
unwrap: unwrap
|
|
1770
2135
|
};
|
|
2136
|
+
exports.abortCredentialRequest = abortCredentialRequest;
|
|
1771
2137
|
exports.handleRedirectCallback = handleRedirectCallback;
|
|
1772
|
-
exports.
|
|
2138
|
+
exports.initialize = initialize;
|
|
2139
|
+
exports.isDigitalCredentialsApiSupported = isDigitalCredentialsApiSupported;
|
|
1773
2140
|
exports.requestCredentials = requestCredentials;
|
|
1774
2141
|
exports.utils = utils;
|
|
1775
2142
|
Object.defineProperty(exports, "__esModule", {
|