@mattrglobal/verifier-sdk-web 2.3.1-unstable.26 → 2.3.1-unstable.27

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,7 +7,7 @@
7
7
  * Do Not Translate or Localize
8
8
  *
9
9
  * Bundle of @mattrglobal/verifier-sdk-web
10
- * Generated: 2026-09-24
10
+ * Generated: 2026-09-28
11
11
  * Version: 2.3.0
12
12
  * Dependencies:
13
13
  */
@@ -199,12 +199,19 @@ var SessionType;
199
199
  SessionType["Openid4vp"] = "openid4vp";
200
200
  })(SessionType || (SessionType = {}));
201
201
 
202
+ const VerifierConfigurationValidator = v__namespace.object({
203
+ dcApi: v__namespace.object({
204
+ protocols: v__namespace.array(v__namespace.string())
205
+ })
206
+ });
207
+
202
208
  v__namespace.object({
203
209
  credentialQuery: v__namespace.array(CredentialQueryValidator),
204
210
  challenge: v__namespace.string(),
205
211
  redirectUri: v__namespace.optional(v__namespace.string()),
206
212
  walletProviderId: v__namespace.optional(v__namespace.string()),
207
213
  dcApiSupported: v__namespace.optional(v__namespace.boolean()),
214
+ dcApiProtocols: v__namespace.optional(v__namespace.array(v__namespace.string())),
208
215
  state: v__namespace.optional(v__namespace.pipe(v__namespace.string(), v__namespace.minLength(1)))
209
216
  });
210
217
 
@@ -502,18 +509,41 @@ const getHashParamValue = (hash, param) => {
502
509
  return urlParams.get(param);
503
510
  };
504
511
 
505
- const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId, dcApiSupported: dcApiSupported, applicationId: applicationId, state: state}) => {
512
+ const getVerifierConfiguration = async uri => {
513
+ const responseResult = await safeFetch(`${uri}/v2/presentations/web/configuration`, {
514
+ method: "GET",
515
+ headers: {
516
+ "Content-Type": "application/json"
517
+ }
518
+ });
519
+ if (responseResult.isErr()) {
520
+ return neverthrow.err(responseResult.error);
521
+ }
522
+ const body = await responseResult.value.json().catch((() => undefined));
523
+ if (!isType(VerifierConfigurationValidator)(body)) {
524
+ return neverthrow.err({
525
+ type: SafeFetchCommonResponseErrorType.UnexpectedResponse,
526
+ message: "Verifier configuration returned unsupported response"
527
+ });
528
+ }
529
+ return neverthrow.ok(body);
530
+ };
531
+
532
+ const createSession = async ({credentialQuery: credentialQuery, challenge: challenge, redirectUri: redirectUri, apiBaseUrl: apiBaseUrl, walletProviderId: walletProviderId, dcApiSupported: dcApiSupported, dcApiProtocols: dcApiProtocols, applicationId: applicationId, state: state}) => {
506
533
  const openid4vpConfiguration = !!walletProviderId || !!redirectUri ? {
507
534
  redirectUri: redirectUri,
508
535
  walletProviderId: walletProviderId
509
536
  } : undefined;
510
- const postData = Object.assign({
537
+ const postData = Object.assign(Object.assign(Object.assign({
511
538
  credentialQuery: credentialQuery,
512
539
  challenge: challenge,
513
540
  applicationId: applicationId,
514
- dcApiSupported: dcApiSupported,
541
+ dcApiSupported: dcApiSupported
542
+ }, dcApiProtocols !== undefined ? {
543
+ dcApiProtocols: dcApiProtocols
544
+ } : {}), {
515
545
  openid4vpConfiguration: openid4vpConfiguration
516
- }, state !== undefined ? {
546
+ }), state !== undefined ? {
517
547
  state: state
518
548
  } : {});
519
549
  const responseResult = await safeFetch(`${apiBaseUrl}/v2/presentations/web/sessions`, {
@@ -958,9 +988,45 @@ const verifyCredentialResponse = async options => {
958
988
  return neverthrow.ok(credentialVerificationResponse);
959
989
  };
960
990
 
961
- const isDigitalCredentialsApiSupported = () => {
962
- var _a;
963
- 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";
991
+ const digitalCredentialsApiSupported = target => {
992
+ var _a, _b;
993
+ return "DigitalCredential" in target && typeof ((_b = (_a = target.navigator) === null || _a === void 0 ? void 0 : _a.credentials) === null || _b === void 0 ? void 0 : _b.get) === "function" && typeof target.DigitalCredential === "function" && (!("userAgentAllowsProtocol" in target.DigitalCredential) || typeof target.DigitalCredential.userAgentAllowsProtocol === "function");
994
+ };
995
+
996
+ const isDigitalCredentialsApiSupported = () => digitalCredentialsApiSupported(window);
997
+
998
+ const getDigitalCredentialsApiSupport = async apiBaseUrl => {
999
+ if (!digitalCredentialsApiSupported(window)) {
1000
+ return {
1001
+ supported: false
1002
+ };
1003
+ }
1004
+ const {DigitalCredential: digitalCredential} = window;
1005
+ if (!digitalCredential.userAgentAllowsProtocol) {
1006
+ return {
1007
+ supported: true
1008
+ };
1009
+ }
1010
+ const configurationResult = await getVerifierConfiguration(apiBaseUrl);
1011
+ if (configurationResult.isErr()) {
1012
+ return {
1013
+ supported: true
1014
+ };
1015
+ }
1016
+ const protocols = configurationResult.value.dcApi.protocols.filter((protocol => {
1017
+ var _a;
1018
+ try {
1019
+ return ((_a = digitalCredential.userAgentAllowsProtocol) === null || _a === void 0 ? void 0 : _a.call(digitalCredential, protocol)) === true;
1020
+ } catch (_b) {
1021
+ return false;
1022
+ }
1023
+ }));
1024
+ return protocols.length > 0 ? {
1025
+ supported: true,
1026
+ protocols: protocols
1027
+ } : {
1028
+ supported: false
1029
+ };
964
1030
  };
965
1031
 
966
1032
  const sleep = ms => new Promise((resolve => setTimeout(resolve, ms)));
@@ -1042,7 +1108,7 @@ const requestCredentials = async options => {
1042
1108
  assertType(RequestCredentialsOptionsValidator, "Invalid request credential options")(options);
1043
1109
  const {apiBaseUrl: apiBaseUrl, applicationId: applicationId} = initializeOptions;
1044
1110
  const {challenge: challenge = generateChallenge(), credentialQuery: credentialQuery, openid4vpConfiguration: openid4vpConfiguration, state: state, onPresentationRequest: onPresentationRequest} = options;
1045
- const dcApiSupported = isDigitalCredentialsApiSupported();
1111
+ const dcApiSupport = await getDigitalCredentialsApiSupport(apiBaseUrl);
1046
1112
  const openId4VpRedirectUri = deriveOpenId4vpRedirectUri(openid4vpConfiguration);
1047
1113
  const createSessionResult = await createSession({
1048
1114
  credentialQuery: credentialQuery,
@@ -1051,7 +1117,8 @@ const requestCredentials = async options => {
1051
1117
  walletProviderId: (_a = openid4vpConfiguration === null || openid4vpConfiguration === void 0 ? void 0 : openid4vpConfiguration.walletProviderId) !== null && _a !== void 0 ? _a : undefined,
1052
1118
  apiBaseUrl: apiBaseUrl,
1053
1119
  applicationId: applicationId,
1054
- dcApiSupported: dcApiSupported,
1120
+ dcApiSupported: dcApiSupport.supported,
1121
+ dcApiProtocols: dcApiSupport.protocols,
1055
1122
  state: state
1056
1123
  });
1057
1124
  if (createSessionResult.isErr()) {