@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
@@ -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 _defineProperty(obj, key, value) {
459
- key = _toPropertyKey(key);
460
- if (key in obj) {
461
- Object.defineProperty(obj, key, {
462
- value: value,
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) {
@@ -1274,6 +1263,9 @@
1274
1263
  (function(MobileCredentialVerificationReasonType) {
1275
1264
  MobileCredentialVerificationReasonType["Expired"] = "expired";
1276
1265
  MobileCredentialVerificationReasonType["Inactive"] = "inactive";
1266
+ MobileCredentialVerificationReasonType["StatusRevoked"] = "invalid";
1267
+ MobileCredentialVerificationReasonType["StatusSuspended"] = "suspended";
1268
+ MobileCredentialVerificationReasonType["StatusUnknown"] = "unknown";
1277
1269
  })(exports.MobileCredentialVerificationReasonType || (exports.MobileCredentialVerificationReasonType = {}));
1278
1270
  exports.ClaimType = void 0;
1279
1271
  (function(ClaimType) {
@@ -1306,6 +1298,21 @@
1306
1298
  intentToRetain: optional(_boolean())
1307
1299
  })))
1308
1300
  });
1301
+ const DcqlCredentialQueryValidator = object({
1302
+ credentials: array(object({
1303
+ id: string(),
1304
+ format: string(),
1305
+ meta: optional(unknown()),
1306
+ claims: array(object({
1307
+ path: array(string())
1308
+ }))
1309
+ })),
1310
+ credential_sets: optional(array(object({
1311
+ options: array(array(string())),
1312
+ required: optional(_boolean()),
1313
+ purpose: optional(unknown())
1314
+ })))
1315
+ });
1309
1316
  var PresentationErrorType;
1310
1317
  (function(PresentationErrorType) {
1311
1318
  PresentationErrorType["SessionAborted"] = "SessionAborted";
@@ -1323,7 +1330,7 @@
1323
1330
  error: optional(unknown())
1324
1331
  });
1325
1332
  object({
1326
- credentialQuery: array(CredentialQueryValidator),
1333
+ credentialQuery: union([ array(CredentialQueryValidator), DcqlCredentialQueryValidator ]),
1327
1334
  challenge: string(),
1328
1335
  redirectUri: optional(string()),
1329
1336
  walletProviderId: optional(string())
@@ -1353,14 +1360,14 @@
1353
1360
  MessageEventDataType["PresentationAbort"] = "PresentationAbort";
1354
1361
  })(MessageEventDataType || (MessageEventDataType = {}));
1355
1362
  const RequestCredentialsSameDeviceOptionsValidator = object({
1356
- credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
1363
+ credentialQuery: union([ pipe(array(CredentialQueryValidator), nonEmpty()), DcqlCredentialQueryValidator ]),
1357
1364
  redirectUri: string(),
1358
1365
  challenge: optional(string()),
1359
1366
  walletProviderId: optional(string()),
1360
1367
  mode: picklist([ exports.Mode.sameDevice ])
1361
1368
  });
1362
1369
  const RequestCredentialsCrossDeviceOptionsValidator = object({
1363
- credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
1370
+ credentialQuery: union([ pipe(array(CredentialQueryValidator), nonEmpty()), DcqlCredentialQueryValidator ]),
1364
1371
  crossDeviceCallback: object({
1365
1372
  onComplete: function_(),
1366
1373
  onFailure: function_()
@@ -1370,7 +1377,7 @@
1370
1377
  mode: picklist([ exports.Mode.crossDevice ])
1371
1378
  });
1372
1379
  const RequestCredentialsAutoDetectDeviceOptionsValidator = object({
1373
- credentialQuery: pipe(array(CredentialQueryValidator), nonEmpty()),
1380
+ credentialQuery: union([ pipe(array(CredentialQueryValidator), nonEmpty()), DcqlCredentialQueryValidator ]),
1374
1381
  crossDeviceCallback: object({
1375
1382
  onComplete: function_(),
1376
1383
  onFailure: function_()
@@ -1387,6 +1394,7 @@
1387
1394
  })(exports.RequestCredentialsErrorType || (exports.RequestCredentialsErrorType = {}));
1388
1395
  const InitialiseOptionsValidator = object({
1389
1396
  apiBaseUrl: string(),
1397
+ applicationId: optional(string()),
1390
1398
  enableDigitalCredentialsApiSameDeviceFlow: optional(_boolean()),
1391
1399
  enableDigitalCredentialsApiCrossDeviceFlow: optional(_boolean())
1392
1400
  });
@@ -1449,12 +1457,14 @@
1449
1457
  const urlParams = new URLSearchParams(hash.split("#")[1]);
1450
1458
  return urlParams.get(param);
1451
1459
  };
1452
- const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId}) => {
1453
- const postData = Object.assign(Object.assign({
1460
+ const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, applicationId: applicationId, walletProviderId: walletProviderId}) => {
1461
+ const postData = Object.assign(Object.assign(Object.assign({
1454
1462
  credentialQuery: credentialQuery,
1455
1463
  challenge: challenge
1456
1464
  }, redirectUri ? {
1457
1465
  redirectUri: redirectUri
1466
+ } : {}), applicationId ? {
1467
+ applicationId: applicationId
1458
1468
  } : {}), walletProviderId ? {
1459
1469
  walletProviderId: walletProviderId
1460
1470
  } : {});
@@ -1527,7 +1537,7 @@
1527
1537
  }, protocol && {
1528
1538
  protocol: protocol
1529
1539
  });
1530
- const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/browserApi/request`, {
1540
+ const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/web/request`, {
1531
1541
  method: "POST",
1532
1542
  headers: {
1533
1543
  "Content-Type": "application/json"
@@ -1546,13 +1556,14 @@
1546
1556
  }
1547
1557
  return ok(data);
1548
1558
  };
1549
- const getDigitalCredentialsApiSessionResult = async ({challenge: challenge, sessionId: sessionId, response: response, apiBaseUrl: apiBaseUrl}) => {
1559
+ const getDigitalCredentialsApiSessionResult = async ({challenge: challenge, sessionId: sessionId, response: response, apiBaseUrl: apiBaseUrl, protocol: protocol}) => {
1550
1560
  const postData = {
1551
1561
  challenge: challenge,
1552
1562
  sessionId: sessionId,
1553
- response: response
1563
+ response: response,
1564
+ protocol: protocol
1554
1565
  };
1555
- const fetchResultFn = async () => await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/browserApi/response`, {
1566
+ const fetchResultFn = async () => await safeFetch(`${apiBaseUrl}/v2/presentations/sessions/web/response`, {
1556
1567
  method: "POST",
1557
1568
  headers: {
1558
1569
  "Content-Type": "application/json"
@@ -1662,16 +1673,18 @@
1662
1673
  modalContainer.appendChild(style);
1663
1674
  modalContainer.appendChild(iframe);
1664
1675
  document.body.appendChild(modalContainer);
1665
- 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;");
1676
+ 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;");
1677
+ modalContainer.setAttribute("class", "mattr-verifier-modal-container");
1666
1678
  return modalContainer;
1667
1679
  };
1668
1680
  const requestCredentialsCrossDevice = async options => {
1669
1681
  const {challenge: challenge, walletProviderId: walletProviderId, credentialQuery: credentialQuery, crossDeviceCallback: crossDeviceCallback, initialiseOptions: initialiseOptions} = options;
1670
- const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
1682
+ const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
1671
1683
  const createSessionResult = await createSession({
1672
1684
  credentialQuery: credentialQuery,
1673
1685
  challenge: challenge,
1674
1686
  apiBaseUrl: apiBaseUrl,
1687
+ applicationId: applicationId,
1675
1688
  walletProviderId: walletProviderId
1676
1689
  });
1677
1690
  if (createSessionResult.isErr()) {
@@ -1705,7 +1718,7 @@
1705
1718
  })(SameDeviceRequestCredentialsErrorMessage$1 || (SameDeviceRequestCredentialsErrorMessage$1 = {}));
1706
1719
  const requestCredentialsSameDevice = async options => {
1707
1720
  const {challenge: challenge, credentialQuery: credentialQuery, redirectUri: redirectUri, walletProviderId: walletProviderId, initialiseOptions: initialiseOptions} = options;
1708
- const {apiBaseUrl: apiBaseUrl} = initialiseOptions;
1721
+ const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initialiseOptions;
1709
1722
  window.localStorage.setItem(LocalStorageKey.challenge, challenge);
1710
1723
  const storedChallenge = window.localStorage.getItem(LocalStorageKey.challenge);
1711
1724
  if (!storedChallenge) {
@@ -1719,6 +1732,7 @@
1719
1732
  challenge: storedChallenge,
1720
1733
  redirectUri: redirectUri,
1721
1734
  apiBaseUrl: apiBaseUrl,
1735
+ applicationId: applicationId,
1722
1736
  walletProviderId: walletProviderId
1723
1737
  });
1724
1738
  if (createSessionResult.isErr()) {
@@ -1785,7 +1799,8 @@
1785
1799
  challenge: challenge,
1786
1800
  sessionId: sessionId,
1787
1801
  response: response,
1788
- apiBaseUrl: apiBaseUrl
1802
+ apiBaseUrl: apiBaseUrl,
1803
+ protocol: digitalCredentialsApiProtocol !== null && digitalCredentialsApiProtocol !== void 0 ? digitalCredentialsApiProtocol : "preview"
1789
1804
  });
1790
1805
  if (result.isOk()) {
1791
1806
  return ok({