@mattrglobal/verifier-sdk-web 2.0.0-preview-digital-credential-api.3 → 2.0.0-preview-digital-credential-api.5

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.
@@ -7,8 +7,8 @@
7
7
  * Do Not Translate or Localize
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
- * Generated: 2025-02-18
11
- * Version: 2.0.0-preview-digital-credential-api.3
10
+ * Generated: 2025-04-28
11
+ * Version: 2.0.0-preview-digital-credential-api.5
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;
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;
458
453
  }
459
454
 
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;
455
+ function _arrayWithoutHoles(r) {
456
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
470
457
  }
471
458
 
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);
506
- }
507
-
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);
586
558
  }
587
559
 
588
- function _toPropertyKey(arg) {
589
- var key = _toPrimitive(arg, "string");
590
- return typeof key === "symbol" ? key : String(key);
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;
@@ -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;
@@ -1387,6 +1379,22 @@ const CredentialQueryValidator = object({
1387
1379
  })))
1388
1380
  });
1389
1381
 
1382
+ const DcqlCredentialQueryValidator = object({
1383
+ credentials: array(object({
1384
+ id: string(),
1385
+ format: string(),
1386
+ meta: optional(unknown()),
1387
+ claims: array(object({
1388
+ path: array(string())
1389
+ }))
1390
+ })),
1391
+ credential_sets: optional(array(object({
1392
+ options: array(array(string())),
1393
+ required: optional(_boolean()),
1394
+ purpose: optional(unknown())
1395
+ })))
1396
+ });
1397
+
1390
1398
  var PresentationErrorType;
1391
1399
 
1392
1400
  (function(PresentationErrorType) {
@@ -1407,7 +1415,7 @@ const PresentationResultRelaxValidator = object({
1407
1415
  });
1408
1416
 
1409
1417
  object({
1410
- credentialQuery: array(CredentialQueryValidator),
1418
+ credentialQuery: union([ array(CredentialQueryValidator), DcqlCredentialQueryValidator ]),
1411
1419
  challenge: string(),
1412
1420
  redirectUri: optional(string()),
1413
1421
  walletProviderId: optional(string())
@@ -1446,7 +1454,7 @@ var MessageEventDataType;
1446
1454
  })(MessageEventDataType || (MessageEventDataType = {}));
1447
1455
 
1448
1456
  const RequestCredentialsSameDeviceOptionsValidator = object({
1449
- credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
1457
+ credentialQuery: union([ pipe(array(CredentialQueryValidator), nonEmpty()), DcqlCredentialQueryValidator ]),
1450
1458
  redirectUri: string(),
1451
1459
  challenge: optional(string()),
1452
1460
  walletProviderId: optional(string()),
@@ -1454,7 +1462,7 @@ const RequestCredentialsSameDeviceOptionsValidator = object({
1454
1462
  });
1455
1463
 
1456
1464
  const RequestCredentialsCrossDeviceOptionsValidator = object({
1457
- credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
1465
+ credentialQuery: union([ pipe(array(CredentialQueryValidator), nonEmpty()), DcqlCredentialQueryValidator ]),
1458
1466
  crossDeviceCallback: object({
1459
1467
  onComplete: function_(),
1460
1468
  onFailure: function_()
@@ -1465,7 +1473,7 @@ const RequestCredentialsCrossDeviceOptionsValidator = object({
1465
1473
  });
1466
1474
 
1467
1475
  const RequestCredentialsAutoDetectDeviceOptionsValidator = object({
1468
- credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
1476
+ credentialQuery: union([ pipe(array(CredentialQueryValidator), nonEmpty()), DcqlCredentialQueryValidator ]),
1469
1477
  crossDeviceCallback: object({
1470
1478
  onComplete: function_(),
1471
1479
  onFailure: function_()
@@ -1486,6 +1494,7 @@ exports.RequestCredentialsErrorType = void 0;
1486
1494
 
1487
1495
  const InitialiseOptionsValidator = object({
1488
1496
  apiBaseUrl: string(),
1497
+ applicationId: optional(string()),
1489
1498
  enableDigitalCredentialsApiSameDeviceFlow: optional(_boolean()),
1490
1499
  enableDigitalCredentialsApiCrossDeviceFlow: optional(_boolean())
1491
1500
  });
@@ -1568,12 +1577,14 @@ const getHashParamValue = (hash, param) => {
1568
1577
  return urlParams.get(param);
1569
1578
  };
1570
1579
 
1571
- const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId}) => {
1572
- const postData = Object.assign(Object.assign({
1580
+ const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, applicationId: applicationId, walletProviderId: walletProviderId}) => {
1581
+ const postData = Object.assign(Object.assign(Object.assign({
1573
1582
  credentialQuery: credentialQuery,
1574
1583
  challenge: challenge
1575
1584
  }, redirectUri ? {
1576
1585
  redirectUri: redirectUri
1586
+ } : {}), applicationId ? {
1587
+ applicationId: applicationId
1577
1588
  } : {}), walletProviderId ? {
1578
1589
  walletProviderId: walletProviderId
1579
1590
  } : {});
@@ -1650,7 +1661,7 @@ const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQu
1650
1661
  }, protocol && {
1651
1662
  protocol: protocol
1652
1663
  });
1653
- const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/browserApi/request`, {
1664
+ const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/web/request`, {
1654
1665
  method: "POST",
1655
1666
  headers: {
1656
1667
  "Content-Type": "application/json"
@@ -1670,13 +1681,14 @@ const createDigitalCredentialsApiSession = async ({credentialQuery: credentialQu
1670
1681
  return ok(data);
1671
1682
  };
1672
1683
 
1673
- const getDigitalCredentialsApiSessionResult = async ({challenge: challenge, sessionId: sessionId, response: response, apiBaseUrl: apiBaseUrl}) => {
1684
+ const getDigitalCredentialsApiSessionResult = async ({challenge: challenge, sessionId: sessionId, response: response, apiBaseUrl: apiBaseUrl, protocol: protocol}) => {
1674
1685
  const postData = {
1675
1686
  challenge: challenge,
1676
1687
  sessionId: sessionId,
1677
- response: response
1688
+ response: response,
1689
+ protocol: protocol
1678
1690
  };
1679
- const fetchResultFn = async () => await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/browserApi/response`, {
1691
+ const fetchResultFn = async () => await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/web/response`, {
1680
1692
  method: "POST",
1681
1693
  headers: {
1682
1694
  "Content-Type": "application/json"
@@ -1797,17 +1809,19 @@ const openCrossDeviceModal = options => {
1797
1809
  modalContainer.appendChild(style);
1798
1810
  modalContainer.appendChild(iframe);
1799
1811
  document.body.appendChild(modalContainer);
1800
- 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;");
1812
+ 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;");
1813
+ modalContainer.setAttribute("class", "mattr-verifier-modal-container");
1801
1814
  return modalContainer;
1802
1815
  };
1803
1816
 
1804
1817
  const requestCredentialsCrossDevice = async options => {
1805
1818
  const {challenge: challenge, walletProviderId: walletProviderId, credentialQuery: credentialQuery, crossDeviceCallback: crossDeviceCallback, initialiseOptions: initialiseOptions} = options;
1806
- const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
1819
+ const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
1807
1820
  const createSessionResult = await createSession({
1808
1821
  credentialQuery: credentialQuery,
1809
1822
  challenge: challenge,
1810
1823
  apiBaseUrl: apiBaseUrl,
1824
+ applicationId: applicationId,
1811
1825
  walletProviderId: walletProviderId
1812
1826
  });
1813
1827
  if (createSessionResult.isErr()) {
@@ -1844,7 +1858,7 @@ var SameDeviceRequestCredentialsErrorMessage$1;
1844
1858
 
1845
1859
  const requestCredentialsSameDevice = async options => {
1846
1860
  const {challenge: challenge, credentialQuery: credentialQuery, redirectUri: redirectUri, walletProviderId: walletProviderId, initialiseOptions: initialiseOptions} = options;
1847
- const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
1861
+ const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
1848
1862
  window.localStorage.setItem(LocalStorageKey.challenge, challenge);
1849
1863
  const storedChallenge = window.localStorage.getItem(LocalStorageKey.challenge);
1850
1864
  if (!storedChallenge) {
@@ -1858,6 +1872,7 @@ const requestCredentialsSameDevice = async options => {
1858
1872
  challenge: storedChallenge,
1859
1873
  redirectUri: redirectUri,
1860
1874
  apiBaseUrl: apiBaseUrl,
1875
+ applicationId: applicationId,
1861
1876
  walletProviderId: walletProviderId
1862
1877
  });
1863
1878
  if (createSessionResult.isErr()) {
@@ -1927,7 +1942,8 @@ const requestCredentialsDigitalCredentialsApi = async options => {
1927
1942
  challenge: challenge,
1928
1943
  sessionId: sessionId,
1929
1944
  response: response,
1930
- apiBaseUrl: apiBaseUrl
1945
+ apiBaseUrl: apiBaseUrl,
1946
+ protocol: digitalCredentialsApiProtocol !== null && digitalCredentialsApiProtocol !== void 0 ? digitalCredentialsApiProtocol : "preview"
1931
1947
  });
1932
1948
  if (result.isOk()) {
1933
1949
  return ok({