@mattrglobal/verifier-sdk-web 2.0.0-preview-digital-credential-api.2 → 2.0.0-preview-digital-credential-api.4

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2024 - MATTR Limited
2
+ * Copyright 2025 - MATTR Limited
3
3
  * All rights reserved
4
4
  * Confidential and proprietary
5
5
  *
@@ -7,8 +7,8 @@
7
7
  * Do Not Translate or Localize
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
- * Generated: 2024-10-21
11
- * Version: 2.0.0-preview-digital-credential-api.2
10
+ * Generated: 2025-03-25
11
+ * Version: 2.0.0-preview-digital-credential-api.4
12
12
  * Dependencies:
13
13
  *
14
14
  * neverthrow -- 4.3.0
@@ -446,148 +446,137 @@ ResultAsync.fromPromise;
446
446
 
447
447
  ResultAsync.fromSafePromise;
448
448
 
449
- function ownKeys(e, r) {
450
- var t = Object.keys(e);
451
- if (Object.getOwnPropertySymbols) {
452
- var o = Object.getOwnPropertySymbols(e);
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);
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;
502
453
  }
503
454
 
504
- function _iterableToArray(iter) {
505
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
455
+ function _arrayWithoutHoles(r) {
456
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
506
457
  }
507
458
 
508
- function _unsupportedIterableToArray(o, minLen) {
509
- if (!o) return;
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);
515
- }
516
-
517
- function _arrayLikeToArray(arr, len) {
518
- if (len == null || len > arr.length) len = arr.length;
519
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
520
- return arr2;
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
- if (i >= o.length) return {
538
- done: true
539
- };
540
- return {
541
- done: false,
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(e) {
546
- throw e;
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 normalCompletion = true, didErr = false, err;
483
+ var o, a = !0, u = !1;
554
484
  return {
555
485
  s: function() {
556
- it = it.call(o);
486
+ t = t.call(r);
557
487
  },
558
488
  n: function() {
559
- var step = it.next();
560
- normalCompletion = step.done;
561
- return step;
489
+ var r = t.next();
490
+ return a = r.done, r;
562
491
  },
563
- e: function(e) {
564
- didErr = true;
565
- err = e;
492
+ e: function(r) {
493
+ u = !0, o = r;
566
494
  },
567
495
  f: function() {
568
496
  try {
569
- if (!normalCompletion && it.return != null) it.return();
497
+ a || null == t.return || t.return();
570
498
  } finally {
571
- if (didErr) throw err;
499
+ if (u) throw o;
572
500
  }
573
501
  }
574
502
  };
575
503
  }
576
504
 
577
- function _toPrimitive(input, hint) {
578
- if (typeof input !== "object" || input === null) return input;
579
- var prim = input[Symbol.toPrimitive];
580
- if (prim !== undefined) {
581
- var res = prim.call(input, hint || "default");
582
- if (typeof res !== "object") return res;
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 (hint === "string" ? String : Number)(input);
557
+ return ("string" === r ? String : Number)(t);
558
+ }
559
+
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);
586
572
  }
587
573
 
588
- function _toPropertyKey(arg) {
589
- var key = _toPrimitive(arg, "string");
590
- return typeof key === "symbol" ? key : String(key);
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;
@@ -1345,6 +1334,9 @@ exports.MobileCredentialVerificationReasonType = void 0;
1345
1334
  (function(MobileCredentialVerificationReasonType) {
1346
1335
  MobileCredentialVerificationReasonType["Expired"] = "expired";
1347
1336
  MobileCredentialVerificationReasonType["Inactive"] = "inactive";
1337
+ MobileCredentialVerificationReasonType["StatusRevoked"] = "invalid";
1338
+ MobileCredentialVerificationReasonType["StatusSuspended"] = "suspended";
1339
+ MobileCredentialVerificationReasonType["StatusUnknown"] = "unknown";
1348
1340
  })(exports.MobileCredentialVerificationReasonType || (exports.MobileCredentialVerificationReasonType = {}));
1349
1341
 
1350
1342
  exports.ClaimType = void 0;
@@ -1486,6 +1478,7 @@ exports.RequestCredentialsErrorType = void 0;
1486
1478
 
1487
1479
  const InitialiseOptionsValidator = object({
1488
1480
  apiBaseUrl: string(),
1481
+ applicationId: optional(string()),
1489
1482
  enableDigitalCredentialsApiSameDeviceFlow: optional(_boolean()),
1490
1483
  enableDigitalCredentialsApiCrossDeviceFlow: optional(_boolean())
1491
1484
  });
@@ -1568,12 +1561,14 @@ const getHashParamValue = (hash, param) => {
1568
1561
  return urlParams.get(param);
1569
1562
  };
1570
1563
 
1571
- const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId}) => {
1572
- const postData = Object.assign(Object.assign({
1564
+ const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, applicationId: applicationId, walletProviderId: walletProviderId}) => {
1565
+ const postData = Object.assign(Object.assign(Object.assign({
1573
1566
  credentialQuery: credentialQuery,
1574
1567
  challenge: challenge
1575
1568
  }, redirectUri ? {
1576
1569
  redirectUri: redirectUri
1570
+ } : {}), applicationId ? {
1571
+ applicationId: applicationId
1577
1572
  } : {}), walletProviderId ? {
1578
1573
  walletProviderId: walletProviderId
1579
1574
  } : {});
@@ -1643,12 +1638,14 @@ const isDigitalCredentialsApiSupported = () => {
1643
1638
  }
1644
1639
  };
1645
1640
 
1646
- const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQuery, challenge: challenge, apiBaseUrl: apiBaseUrl}) => {
1647
- const postData = {
1641
+ const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQuery, challenge: challenge, apiBaseUrl: apiBaseUrl, protocol: protocol}) => {
1642
+ const postData = Object.assign({
1648
1643
  credentialQuery: credentialQuery,
1649
1644
  challenge: challenge
1650
- };
1651
- const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/browserApi/request`, {
1645
+ }, protocol && {
1646
+ protocol: protocol
1647
+ });
1648
+ const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/web/request`, {
1652
1649
  method: "POST",
1653
1650
  headers: {
1654
1651
  "Content-Type": "application/json"
@@ -1668,13 +1665,14 @@ const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQu
1668
1665
  return ok(data);
1669
1666
  };
1670
1667
 
1671
- const getDigitalCredentialsApiSessionResult = async ({challenge: challenge, sessionId: sessionId, response: response, apiBaseUrl: apiBaseUrl}) => {
1668
+ const getDigitalCredentialsApiSessionResult = async ({challenge: challenge, sessionId: sessionId, response: response, apiBaseUrl: apiBaseUrl, protocol: protocol}) => {
1672
1669
  const postData = {
1673
1670
  challenge: challenge,
1674
1671
  sessionId: sessionId,
1675
- response: response
1672
+ response: response,
1673
+ protocol: protocol
1676
1674
  };
1677
- const fetchResultFn = async () => await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/browserApi/response`, {
1675
+ const fetchResultFn = async () => await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/web/response`, {
1678
1676
  method: "POST",
1679
1677
  headers: {
1680
1678
  "Content-Type": "application/json"
@@ -1795,17 +1793,19 @@ const openCrossDeviceModal = options => {
1795
1793
  modalContainer.appendChild(style);
1796
1794
  modalContainer.appendChild(iframe);
1797
1795
  document.body.appendChild(modalContainer);
1798
- modalContainer.setAttribute("style", "background: rgba(0, 0, 0, 0.5) !important; position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important;");
1796
+ modalContainer.setAttribute("style", "background: rgba(0, 0, 0, 0.5) !important; position: fixed !important; top: 0 !important; left: 0 !important; width: 100% !important; height: 100% !important; z-index: 999;");
1797
+ modalContainer.setAttribute("class", "mattr-verifier-modal-container");
1799
1798
  return modalContainer;
1800
1799
  };
1801
1800
 
1802
1801
  const requestCredentialsCrossDevice = async options => {
1803
1802
  const {challenge: challenge, walletProviderId: walletProviderId, credentialQuery: credentialQuery, crossDeviceCallback: crossDeviceCallback, initialiseOptions: initialiseOptions} = options;
1804
- const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
1803
+ const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
1805
1804
  const createSessionResult = await createSession({
1806
1805
  credentialQuery: credentialQuery,
1807
1806
  challenge: challenge,
1808
1807
  apiBaseUrl: apiBaseUrl,
1808
+ applicationId: applicationId,
1809
1809
  walletProviderId: walletProviderId
1810
1810
  });
1811
1811
  if (createSessionResult.isErr()) {
@@ -1842,7 +1842,7 @@ var SameDeviceRequestCredentialsErrorMessage$1;
1842
1842
 
1843
1843
  const requestCredentialsSameDevice = async options => {
1844
1844
  const {challenge: challenge, credentialQuery: credentialQuery, redirectUri: redirectUri, walletProviderId: walletProviderId, initialiseOptions: initialiseOptions} = options;
1845
- const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
1845
+ const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
1846
1846
  window.localStorage.setItem(LocalStorageKey.challenge, challenge);
1847
1847
  const storedChallenge = window.localStorage.getItem(LocalStorageKey.challenge);
1848
1848
  if (!storedChallenge) {
@@ -1856,6 +1856,7 @@ const requestCredentialsSameDevice = async options => {
1856
1856
  challenge: storedChallenge,
1857
1857
  redirectUri: redirectUri,
1858
1858
  apiBaseUrl: apiBaseUrl,
1859
+ applicationId: applicationId,
1859
1860
  walletProviderId: walletProviderId
1860
1861
  });
1861
1862
  if (createSessionResult.isErr()) {
@@ -1882,7 +1883,7 @@ var SameDeviceRequestCredentialsErrorMessage;
1882
1883
 
1883
1884
  const requestCredentialsDigitalCredentialsApi = async options => {
1884
1885
  const {challenge: challenge, credentialQuery: credentialQuery, initialiseOptions: initialiseOptions} = options;
1885
- const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
1886
+ const {apiBaseUrl: apiBaseUrl, digitalCredentialsApiProtocol: digitalCredentialsApiProtocol} = initialiseOptions;
1886
1887
  window.localStorage.setItem(LocalStorageKey.challenge, challenge);
1887
1888
  const storedChallenge = window.localStorage.getItem(LocalStorageKey.challenge);
1888
1889
  if (!storedChallenge) {
@@ -1894,7 +1895,8 @@ const requestCredentialsDigitalCredentialsApi = async options => {
1894
1895
  const createSessionResult = await createDigitalCredentialsApiSession({
1895
1896
  credentialQuery: credentialQuery,
1896
1897
  challenge: storedChallenge,
1897
- apiBaseUrl: apiBaseUrl
1898
+ apiBaseUrl: apiBaseUrl,
1899
+ protocol: digitalCredentialsApiProtocol
1898
1900
  });
1899
1901
  if (createSessionResult.isErr()) {
1900
1902
  return err({
@@ -1924,7 +1926,8 @@ const requestCredentialsDigitalCredentialsApi = async options => {
1924
1926
  challenge: challenge,
1925
1927
  sessionId: sessionId,
1926
1928
  response: response,
1927
- apiBaseUrl: apiBaseUrl
1929
+ apiBaseUrl: apiBaseUrl,
1930
+ protocol: digitalCredentialsApiProtocol !== null && digitalCredentialsApiProtocol !== void 0 ? digitalCredentialsApiProtocol : "preview"
1928
1931
  });
1929
1932
  if (result.isOk()) {
1930
1933
  return ok({