@openid4vc/openid4vp 0.3.0-alpha-20250707121837 → 0.3.0-alpha-20250711140312

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/dist/index.js CHANGED
@@ -38,6 +38,7 @@ __export(index_exports, {
38
38
  getOpenid4vpClientId: () => getOpenid4vpClientId,
39
39
  isJarmResponseMode: () => isJarmResponseMode,
40
40
  isOpenid4vpAuthorizationRequestDcApi: () => isOpenid4vpAuthorizationRequestDcApi,
41
+ parseAuthorizationRequestVersion: () => parseAuthorizationRequestVersion,
41
42
  parseDcqlVpToken: () => parseDcqlVpToken,
42
43
  parseJarmAuthorizationResponse: () => parseJarmAuthorizationResponse,
43
44
  parseOpenid4VpAuthorizationResponsePayload: () => parseOpenid4VpAuthorizationResponsePayload,
@@ -783,12 +784,116 @@ async function verifyJarmAuthorizationResponse(options) {
783
784
  return { jarmAuthorizationResponse, type, issuer };
784
785
  }
785
786
 
787
+ // src/version.ts
788
+ var import_oauth28 = require("@openid4vc/oauth2");
789
+ function parseAuthorizationRequestVersion(request) {
790
+ const requirements = [];
791
+ if (request.verifier_info) {
792
+ requirements.push([">=", 100]);
793
+ }
794
+ if (request.verifier_attestations) {
795
+ requirements.push(["<", 100]);
796
+ }
797
+ if (request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values || request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values) {
798
+ requirements.push([">=", 28]);
799
+ }
800
+ if (request.client_metadata?.vp_formats_supported?.mso_mdoc?.issuer_signed_alg_values || request.client_metadata?.vp_formats_supported?.mso_mdoc?.device_signed_alg_values) {
801
+ requirements.push(["<", 28]);
802
+ }
803
+ if (request.client_metadata?.vp_formats) {
804
+ requirements.push([">=", 27]);
805
+ }
806
+ if (request.client_metadata?.vp_formats_supported) {
807
+ requirements.push(["<", 27]);
808
+ }
809
+ if (request.client_id?.startsWith("openid_federation:") || request.client_id?.startsWith("decentralized_identifier:")) {
810
+ requirements.push([">=", 26]);
811
+ }
812
+ if (request.client_id?.startsWith("did:")) {
813
+ requirements.push(["<", 26]);
814
+ }
815
+ if (request.presentation_definition || request.presentation_definition_uri) {
816
+ requirements.push([">=", 26]);
817
+ }
818
+ if (request.verifier_attestations) {
819
+ requirements.push([">=", 26]);
820
+ }
821
+ if (request.client_id?.startsWith("x509_san_uri:")) {
822
+ requirements.push(["<", 25]);
823
+ }
824
+ if (request.client_id?.startsWith("x509_hash:")) {
825
+ requirements.push([">=", 25]);
826
+ }
827
+ if (request.client_id?.startsWith("web-origin:")) {
828
+ requirements.push(["<", 25]);
829
+ }
830
+ if (request.client_id?.startsWith("origin:")) {
831
+ requirements.push([">=", 25]);
832
+ }
833
+ if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "w3c_dc_api" || request.response_mode === "w3c_dc_api.jwt")) {
834
+ requirements.push(["<", 23]);
835
+ requirements.push([">=", 21]);
836
+ }
837
+ if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "dc_api" || request.response_mode === "dc_api.jwt")) {
838
+ requirements.push([">=", 23]);
839
+ }
840
+ if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.transaction_data || request.dcql_query)) {
841
+ requirements.push([">=", 23]);
842
+ }
843
+ if (request.transaction_data) {
844
+ requirements.push([">=", 22]);
845
+ }
846
+ if (request.client_id_scheme) {
847
+ requirements.push(["<", 22]);
848
+ }
849
+ if (request.client_id) {
850
+ const colonIndex = request.client_id.indexOf(":");
851
+ const schemePart = request.client_id.substring(0, colonIndex);
852
+ const parsedScheme = zClientIdPrefix.safeParse(schemePart);
853
+ if (parsedScheme.success && parsedScheme.data !== "did" && parsedScheme.data !== "https") {
854
+ requirements.push([">=", 22]);
855
+ }
856
+ }
857
+ if (!request.client_id) {
858
+ requirements.push([">=", 21]);
859
+ }
860
+ if (request.dcql_query) {
861
+ requirements.push([">=", 21]);
862
+ }
863
+ if (request.client_metadata_uri) {
864
+ requirements.push(["<", 21]);
865
+ }
866
+ if (isOpenid4vpAuthorizationRequestDcApi(request)) {
867
+ requirements.push([">=", 21]);
868
+ }
869
+ if (request.request_uri_method || request.wallet_nonce) {
870
+ requirements.push([">=", 21]);
871
+ }
872
+ if (request.client_id_scheme === "verifier_attestation") {
873
+ requirements.push([">=", 20]);
874
+ }
875
+ if (request.client_id_scheme === "x509_san_dns" || request.client_id_scheme === "x509_san_uri") {
876
+ requirements.push([">=", 19]);
877
+ }
878
+ const lessThanVersions = requirements.filter(([operator]) => operator === "<").map(([_, version]) => version);
879
+ const greaterThanVersions = requirements.filter(([operator]) => operator === ">=").map(([_, version]) => version);
880
+ const highestPossibleVersion = lessThanVersions.length > 0 ? Math.max(Math.min(...lessThanVersions) - 1, 18) : 100;
881
+ const lowestRequiredVersion = greaterThanVersions.length > 0 ? Math.max(...greaterThanVersions) : 18;
882
+ if (lowestRequiredVersion > highestPossibleVersion) {
883
+ throw new import_oauth28.Oauth2ServerErrorResponseError({
884
+ error: import_oauth28.Oauth2ErrorCodes.InvalidRequest,
885
+ error_description: `Could not infer openid4vp version from the openid4vp request payload. Based on specification requirements, lowest required version is ${lowestRequiredVersion} and highest possible version is ${highestPossibleVersion}`
886
+ });
887
+ }
888
+ return highestPossibleVersion;
889
+ }
890
+
786
891
  // src/authorization-request/create-authorization-request.ts
787
- var import_oauth211 = require("@openid4vc/oauth2");
892
+ var import_oauth212 = require("@openid4vc/oauth2");
788
893
  var import_utils9 = require("@openid4vc/utils");
789
894
 
790
895
  // src/jar/create-jar-authorization-request.ts
791
- var import_oauth28 = require("@openid4vc/oauth2");
896
+ var import_oauth29 = require("@openid4vc/oauth2");
792
897
  var import_utils7 = require("@openid4vc/utils");
793
898
  async function createJarAuthorizationRequest(options) {
794
899
  const { jwtSigner, jweEncryptor, authorizationRequestPayload, requestUri, callbacks } = options;
@@ -796,7 +901,7 @@ async function createJarAuthorizationRequest(options) {
796
901
  let encryptionJwk;
797
902
  const now = options.now ?? /* @__PURE__ */ new Date();
798
903
  const { jwt, signerJwk } = await callbacks.signJwt(jwtSigner, {
799
- header: { ...(0, import_oauth28.jwtHeaderFromJwtSigner)(jwtSigner), typ: "oauth-authz-req+jwt" },
904
+ header: { ...(0, import_oauth29.jwtHeaderFromJwtSigner)(jwtSigner), typ: "oauth-authz-req+jwt" },
800
905
  payload: {
801
906
  iat: (0, import_utils7.dateToSeconds)(now),
802
907
  exp: (0, import_utils7.dateToSeconds)((0, import_utils7.addSecondsToDate)(now, options.expiresInSeconds)),
@@ -816,94 +921,94 @@ async function createJarAuthorizationRequest(options) {
816
921
  }
817
922
 
818
923
  // src/authorization-request/validate-authorization-request.ts
819
- var import_oauth29 = require("@openid4vc/oauth2");
924
+ var import_oauth210 = require("@openid4vc/oauth2");
820
925
  var import_utils8 = require("@openid4vc/utils");
821
926
  var validateOpenid4vpAuthorizationRequestPayload = (options) => {
822
927
  const { params, walletVerificationOptions } = options;
823
928
  if (!params.redirect_uri && !params.response_uri) {
824
- throw new import_oauth29.Oauth2ServerErrorResponseError({
825
- error: import_oauth29.Oauth2ErrorCodes.InvalidRequest,
929
+ throw new import_oauth210.Oauth2ServerErrorResponseError({
930
+ error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
826
931
  error_description: `Missing required 'redirect_uri' or 'response_uri' in openid4vp authorization request.`
827
932
  });
828
933
  }
829
934
  if (params.response_uri && !["direct_post", "direct_post.jwt"].find((mode) => mode === params.response_mode)) {
830
- throw new import_oauth29.Oauth2ServerErrorResponseError({
831
- error: import_oauth29.Oauth2ErrorCodes.InvalidRequest,
935
+ throw new import_oauth210.Oauth2ServerErrorResponseError({
936
+ error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
832
937
  error_description: `The 'response_mode' parameter MUST be 'direct_post' or 'direct_post.jwt' when 'response_uri' is provided. Current: ${params.response_mode}`
833
938
  });
834
939
  }
835
940
  if ([params.presentation_definition_uri, params.presentation_definition, params.dcql_query, params.scope].filter(
836
941
  Boolean
837
942
  ).length > 1) {
838
- throw new import_oauth29.Oauth2ServerErrorResponseError({
839
- error: import_oauth29.Oauth2ErrorCodes.InvalidRequest,
943
+ throw new import_oauth210.Oauth2ServerErrorResponseError({
944
+ error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
840
945
  error_description: "Exactly one of the following parameters MUST be present in the authorization request: dcql_query, presentation_definition, presentation_definition_uri, or a scope value representing a Presentation Definition."
841
946
  });
842
947
  }
843
948
  if (params.request_uri_method && !params.request_uri) {
844
- throw new import_oauth29.Oauth2ServerErrorResponseError({
845
- error: import_oauth29.Oauth2ErrorCodes.InvalidRequest,
949
+ throw new import_oauth210.Oauth2ServerErrorResponseError({
950
+ error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
846
951
  error_description: 'The "request_uri_method" parameter MUST NOT be present in the authorization request if the "request_uri" parameter is not present.'
847
952
  });
848
953
  }
849
954
  if (params.request_uri_method && !["GET", "POST"].includes(params.request_uri_method)) {
850
- throw new import_oauth29.Oauth2ServerErrorResponseError({
851
- error: import_oauth29.Oauth2ErrorCodes.InvalidRequestUriMethod,
955
+ throw new import_oauth210.Oauth2ServerErrorResponseError({
956
+ error: import_oauth210.Oauth2ErrorCodes.InvalidRequestUriMethod,
852
957
  error_description: `The 'request_uri_method' parameter MUST be 'GET' or 'POST'. Current: ${params.request_uri_method}`
853
958
  });
854
959
  }
855
960
  if (params.trust_chain && !import_utils8.zHttpsUrl.safeParse(params.client_id).success) {
856
- throw new import_oauth29.Oauth2ServerErrorResponseError({
857
- error: import_oauth29.Oauth2ErrorCodes.InvalidRequest,
961
+ throw new import_oauth210.Oauth2ServerErrorResponseError({
962
+ error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
858
963
  error_description: 'The "trust_chain" parameter MUST NOT be present in the authorization request if the "client_id" is not an OpenId Federation Entity Identifier starting with http:// or https://.'
859
964
  });
860
965
  }
861
966
  if (walletVerificationOptions?.expectedNonce && !params.wallet_nonce) {
862
- throw new import_oauth29.Oauth2ServerErrorResponseError({
863
- error: import_oauth29.Oauth2ErrorCodes.InvalidRequest,
967
+ throw new import_oauth210.Oauth2ServerErrorResponseError({
968
+ error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
864
969
  error_description: 'The "wallet_nonce" parameter MUST be present in the authorization request when the "expectedNonce" parameter is provided.'
865
970
  });
866
971
  }
867
972
  if (walletVerificationOptions?.expectedNonce !== params.wallet_nonce) {
868
- throw new import_oauth29.Oauth2ServerErrorResponseError({
869
- error: import_oauth29.Oauth2ErrorCodes.InvalidRequest,
973
+ throw new import_oauth210.Oauth2ServerErrorResponseError({
974
+ error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
870
975
  error_description: 'The "wallet_nonce" parameter MUST match the "expectedNonce" parameter when the "expectedNonce" parameter is provided.'
871
976
  });
872
977
  }
873
978
  if (params.client_id.startsWith("web-origin:") || params.client_id.startsWith("origin:")) {
874
- throw new import_oauth29.Oauth2ServerErrorResponseError({
875
- error: import_oauth29.Oauth2ErrorCodes.InvalidRequest,
979
+ throw new import_oauth210.Oauth2ServerErrorResponseError({
980
+ error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
876
981
  error_description: `The 'client_id' parameter MUST NOT use client identifier scheme '${params.client_id.split(":")[0]}' when not using the dc_api response mode. Current: ${params.client_id}`
877
982
  });
878
983
  }
879
984
  };
880
985
 
881
986
  // src/authorization-request/validate-authorization-request-dc-api.ts
882
- var import_oauth210 = require("@openid4vc/oauth2");
987
+ var import_oauth211 = require("@openid4vc/oauth2");
883
988
  var validateOpenid4vpAuthorizationRequestDcApiPayload = (options) => {
884
989
  const { params, isJarRequest, disableOriginValidation, origin } = options;
885
990
  if (isJarRequest && !params.expected_origins) {
886
- throw new import_oauth210.Oauth2ServerErrorResponseError({
887
- error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
991
+ throw new import_oauth211.Oauth2ServerErrorResponseError({
992
+ error: import_oauth211.Oauth2ErrorCodes.InvalidRequest,
888
993
  error_description: `The 'expected_origins' parameter MUST be present when using the dc_api response mode in combinaction with jar.`
889
994
  });
890
995
  }
891
996
  if ([params.presentation_definition, params.dcql_query].filter(Boolean).length !== 1) {
892
- throw new import_oauth210.Oauth2ServerErrorResponseError({
893
- error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
997
+ throw new import_oauth211.Oauth2ServerErrorResponseError({
998
+ error: import_oauth211.Oauth2ErrorCodes.InvalidRequest,
894
999
  error_description: "Exactly one of the following parameters MUST be present in the Authorization Request: dcql_query or presentation_definition"
895
1000
  });
896
1001
  }
897
1002
  if (params.expected_origins && !disableOriginValidation) {
898
1003
  if (!origin) {
899
- throw new import_oauth210.Oauth2ServerErrorResponseError({
900
- error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
1004
+ throw new import_oauth211.Oauth2ServerErrorResponseError({
1005
+ error: import_oauth211.Oauth2ErrorCodes.InvalidRequest,
901
1006
  error_description: `Failed to validate the 'origin' of the authorization request. The 'origin' was not provided.`
902
1007
  });
903
1008
  }
904
1009
  if (params.expected_origins && !params.expected_origins.includes(origin)) {
905
- throw new import_oauth210.Oauth2ServerErrorResponseError({
906
- error: import_oauth210.Oauth2ErrorCodes.InvalidRequest,
1010
+ throw new import_oauth211.Oauth2ServerErrorResponseError({
1011
+ error: import_oauth211.Oauth2ErrorCodes.InvalidRequest,
907
1012
  error_description: `The 'expected_origins' parameter MUST include the origin of the authorization request. Current: ${params.expected_origins.join(", ")}`
908
1013
  });
909
1014
  }
@@ -922,7 +1027,7 @@ async function createOpenid4vpAuthorizationRequest(options) {
922
1027
  "Invalid authorization request. Could not parse openid4vp dc_api authorization request."
923
1028
  );
924
1029
  if (jar && !authorizationRequestPayload.expected_origins) {
925
- throw new import_oauth211.Oauth2Error(
1030
+ throw new import_oauth212.Oauth2Error(
926
1031
  `The 'expected_origins' parameter MUST be present when using the dc_api response mode in combination with jar.`
927
1032
  );
928
1033
  }
@@ -980,12 +1085,12 @@ async function createOpenid4vpAuthorizationRequest(options) {
980
1085
  }
981
1086
 
982
1087
  // src/authorization-request/parse-authorization-request-params.ts
983
- var import_oauth213 = require("@openid4vc/oauth2");
1088
+ var import_oauth214 = require("@openid4vc/oauth2");
984
1089
  var import_utils11 = require("@openid4vc/utils");
985
1090
  var import_zod11 = __toESM(require("zod"));
986
1091
 
987
1092
  // src/jar/z-jar-authorization-request.ts
988
- var import_oauth212 = require("@openid4vc/oauth2");
1093
+ var import_oauth213 = require("@openid4vc/oauth2");
989
1094
  var import_utils10 = require("@openid4vc/utils");
990
1095
  var import_zod10 = require("zod");
991
1096
  var zJarAuthorizationRequest = import_zod10.z.object({
@@ -997,13 +1102,13 @@ var zJarAuthorizationRequest = import_zod10.z.object({
997
1102
  function validateJarRequestParams(options) {
998
1103
  const { jarRequestParams } = options;
999
1104
  if (jarRequestParams.request && jarRequestParams.request_uri) {
1000
- throw new import_oauth212.Oauth2ServerErrorResponseError({
1105
+ throw new import_oauth213.Oauth2ServerErrorResponseError({
1001
1106
  error: "invalid_request_object",
1002
1107
  error_description: "request and request_uri cannot both be present in a JAR request"
1003
1108
  });
1004
1109
  }
1005
1110
  if (!jarRequestParams.request && !jarRequestParams.request_uri) {
1006
- throw new import_oauth212.Oauth2ServerErrorResponseError({
1111
+ throw new import_oauth213.Oauth2ServerErrorResponseError({
1007
1112
  error: "invalid_request_object",
1008
1113
  error_description: "request or request_uri must be present"
1009
1114
  });
@@ -1028,7 +1133,7 @@ function parseOpenid4vpAuthorizationRequest(options) {
1028
1133
  );
1029
1134
  provided = "uri";
1030
1135
  } else {
1031
- const decoded = (0, import_oauth213.decodeJwt)({ jwt: authorizationRequest });
1136
+ const decoded = (0, import_oauth214.decodeJwt)({ jwt: authorizationRequest });
1032
1137
  params = decoded.payload;
1033
1138
  provided = "jwt";
1034
1139
  }
@@ -1066,7 +1171,7 @@ var import_utils15 = require("@openid4vc/utils");
1066
1171
  var import_zod15 = __toESM(require("zod"));
1067
1172
 
1068
1173
  // src/fetch-client-metadata.ts
1069
- var import_oauth214 = require("@openid4vc/oauth2");
1174
+ var import_oauth215 = require("@openid4vc/oauth2");
1070
1175
  var import_utils12 = require("@openid4vc/utils");
1071
1176
  async function fetchClientMetadata(options) {
1072
1177
  const { fetch, clientMetadataUri } = options;
@@ -1078,15 +1183,15 @@ async function fetchClientMetadata(options) {
1078
1183
  }
1079
1184
  });
1080
1185
  if (!response.ok) {
1081
- throw new import_oauth214.Oauth2ServerErrorResponseError({
1186
+ throw new import_oauth215.Oauth2ServerErrorResponseError({
1082
1187
  error_description: `Fetching client metadata from '${clientMetadataUri}' failed with status code '${response.status}'.`,
1083
- error: import_oauth214.Oauth2ErrorCodes.InvalidRequestUri
1188
+ error: import_oauth215.Oauth2ErrorCodes.InvalidRequestUri
1084
1189
  });
1085
1190
  }
1086
1191
  if (!result || !result.success) {
1087
- throw new import_oauth214.Oauth2ServerErrorResponseError({
1192
+ throw new import_oauth215.Oauth2ServerErrorResponseError({
1088
1193
  error_description: `Parsing client metadata from '${clientMetadataUri}' failed.`,
1089
- error: import_oauth214.Oauth2ErrorCodes.InvalidRequestObject
1194
+ error: import_oauth215.Oauth2ErrorCodes.InvalidRequestObject
1090
1195
  });
1091
1196
  }
1092
1197
  return result.data;
@@ -1096,110 +1201,6 @@ async function fetchClientMetadata(options) {
1096
1201
  var import_oauth218 = require("@openid4vc/oauth2");
1097
1202
  var import_zod13 = __toESM(require("zod"));
1098
1203
 
1099
- // src/version.ts
1100
- var import_oauth215 = require("@openid4vc/oauth2");
1101
- function parseAuthorizationRequestVersion(request) {
1102
- const requirements = [];
1103
- if (request.verifier_info) {
1104
- requirements.push([">=", 29]);
1105
- }
1106
- if (request.verifier_attestations) {
1107
- requirements.push(["<", 29]);
1108
- }
1109
- if (request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values || request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values) {
1110
- requirements.push([">=", 28]);
1111
- }
1112
- if (request.client_metadata?.vp_formats_supported?.mso_mdoc?.issuer_signed_alg_values || request.client_metadata?.vp_formats_supported?.mso_mdoc?.device_signed_alg_values) {
1113
- requirements.push(["<", 28]);
1114
- }
1115
- if (request.client_metadata?.vp_formats) {
1116
- requirements.push([">=", 27]);
1117
- }
1118
- if (request.client_metadata?.vp_formats_supported) {
1119
- requirements.push(["<", 27]);
1120
- }
1121
- if (request.client_id?.startsWith("openid_federation:") || request.client_id?.startsWith("decentralized_identifier:")) {
1122
- requirements.push([">=", 26]);
1123
- }
1124
- if (request.client_id?.startsWith("did:")) {
1125
- requirements.push(["<", 26]);
1126
- }
1127
- if (request.presentation_definition || request.presentation_definition_uri) {
1128
- requirements.push([">=", 26]);
1129
- }
1130
- if (request.verifier_attestations) {
1131
- requirements.push([">=", 26]);
1132
- }
1133
- if (request.client_id?.startsWith("x509_san_uri:")) {
1134
- requirements.push(["<", 25]);
1135
- }
1136
- if (request.client_id?.startsWith("x509_hash:")) {
1137
- requirements.push([">=", 25]);
1138
- }
1139
- if (request.client_id?.startsWith("web-origin:")) {
1140
- requirements.push(["<", 25]);
1141
- }
1142
- if (request.client_id?.startsWith("origin:")) {
1143
- requirements.push([">=", 25]);
1144
- }
1145
- if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "w3c_dc_api" || request.response_mode === "w3c_dc_api.jwt")) {
1146
- requirements.push(["<", 23]);
1147
- requirements.push([">=", 21]);
1148
- }
1149
- if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "dc_api" || request.response_mode === "dc_api.jwt")) {
1150
- requirements.push([">=", 23]);
1151
- }
1152
- if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.transaction_data || request.dcql_query)) {
1153
- requirements.push([">=", 23]);
1154
- }
1155
- if (request.transaction_data) {
1156
- requirements.push([">=", 22]);
1157
- }
1158
- if (request.client_id_scheme) {
1159
- requirements.push(["<", 22]);
1160
- }
1161
- if (request.client_id) {
1162
- const colonIndex = request.client_id.indexOf(":");
1163
- const schemePart = request.client_id.substring(0, colonIndex);
1164
- const parsedScheme = zClientIdPrefix.safeParse(schemePart);
1165
- if (parsedScheme.success && parsedScheme.data !== "did" && parsedScheme.data !== "https") {
1166
- requirements.push([">=", 22]);
1167
- }
1168
- }
1169
- if (!request.client_id) {
1170
- requirements.push([">=", 21]);
1171
- }
1172
- if (request.dcql_query) {
1173
- requirements.push([">=", 21]);
1174
- }
1175
- if (request.client_metadata_uri) {
1176
- requirements.push(["<", 21]);
1177
- }
1178
- if (isOpenid4vpAuthorizationRequestDcApi(request)) {
1179
- requirements.push([">=", 21]);
1180
- }
1181
- if (request.request_uri_method || request.wallet_nonce) {
1182
- requirements.push([">=", 21]);
1183
- }
1184
- if (request.client_id_scheme === "verifier_attestation") {
1185
- requirements.push([">=", 20]);
1186
- }
1187
- if (request.client_id_scheme === "x509_san_dns" || request.client_id_scheme === "x509_san_uri") {
1188
- requirements.push([">=", 19]);
1189
- }
1190
- const lessThanVersions = requirements.filter(([operator]) => operator === "<").map(([_, version]) => version);
1191
- const greaterThanVersions = requirements.filter(([operator]) => operator === ">=").map(([_, version]) => version);
1192
- const highestPossibleVersion = lessThanVersions.length > 0 ? Math.max(Math.min(...lessThanVersions) - 1, 18) : 29;
1193
- const lowestRequiredVersion = greaterThanVersions.length > 0 ? Math.max(...greaterThanVersions) : 18;
1194
- if (lowestRequiredVersion > highestPossibleVersion) {
1195
- throw new import_oauth215.Oauth2ServerErrorResponseError({
1196
- error: import_oauth215.Oauth2ErrorCodes.InvalidRequest,
1197
- error_description: "Could not infer openid4vp version from the openid4vp request payload."
1198
- });
1199
- }
1200
- return highestPossibleVersion;
1201
- }
1202
-
1203
1204
  // src/jar/jar-request-object/fetch-jar-request-object.ts
1204
1205
  var import_oauth216 = require("@openid4vc/oauth2");
1205
1206
  var import_utils13 = require("@openid4vc/utils");
@@ -1783,18 +1784,24 @@ var import_utils20 = require("@openid4vc/utils");
1783
1784
 
1784
1785
  // src/vp-token/z-vp-token.ts
1785
1786
  var import_zod17 = require("zod");
1786
- var zVpTokenPexEntry = import_zod17.z.union([import_zod17.z.string(), import_zod17.z.record(import_zod17.z.any())], {
1787
- message: "pex vp_token entry must be a string or object"
1787
+ var zVpTokenPresentationEntry = import_zod17.z.union([import_zod17.z.string(), import_zod17.z.record(import_zod17.z.any())], {
1788
+ message: "vp_token presentation entry must be string or object"
1788
1789
  });
1789
1790
  var zVpTokenPex = import_zod17.z.union(
1790
- [zVpTokenPexEntry, import_zod17.z.array(zVpTokenPexEntry).nonempty("Must have at least entry in vp_token array")],
1791
+ [
1792
+ zVpTokenPresentationEntry,
1793
+ import_zod17.z.array(zVpTokenPresentationEntry).nonempty("Must have at least entry in vp_token array")
1794
+ ],
1791
1795
  {
1792
- message: "pex vp_token must be a string, object or array of strings and objects"
1796
+ message: "pex vp_token must be a string, object or non-empty array of strings and objects"
1797
+ }
1798
+ );
1799
+ var zVpTokenDcql = import_zod17.z.record(
1800
+ import_zod17.z.union([import_zod17.z.array(zVpTokenPresentationEntry).nonempty(), zVpTokenPresentationEntry]),
1801
+ {
1802
+ message: "dcql vp_token must be an object with keys referencing the dcql credential query id, and values a non-empty array of strings and objects, or string, or object"
1793
1803
  }
1794
1804
  );
1795
- var zVpTokenDcql = import_zod17.z.record(import_zod17.z.union([import_zod17.z.string(), import_zod17.z.record(import_zod17.z.any())]), {
1796
- message: "dcql vp_token must be an object with keys referencing the dcql credential query id, and values the encoded (string or object) presentation"
1797
- });
1798
1805
  var zVpToken = zVpTokenDcql.or(zVpTokenPex);
1799
1806
 
1800
1807
  // src/vp-token/parse-vp-token.ts
@@ -1807,11 +1814,17 @@ function parsePexVpToken(vpToken) {
1807
1814
  return Array.isArray(parsedVpToken) ? parsedVpToken : [parsedVpToken];
1808
1815
  }
1809
1816
  function parseDcqlVpToken(vpToken) {
1810
- return (0, import_utils20.parseWithErrorHandling)(
1817
+ const parsedVpToken = (0, import_utils20.parseWithErrorHandling)(
1811
1818
  zVpTokenDcql,
1812
1819
  (0, import_utils20.parseIfJson)(vpToken),
1813
1820
  "Could not parse dcql vp_token. Expected an object where the values are encoded presentations"
1814
1821
  );
1822
+ return Object.fromEntries(
1823
+ Object.entries(parsedVpToken).map(([queryId, presentations]) => [
1824
+ queryId,
1825
+ Array.isArray(presentations) ? presentations : [presentations]
1826
+ ])
1827
+ );
1815
1828
  }
1816
1829
 
1817
1830
  // src/authorization-response/validate-authorization-response.ts
@@ -2127,6 +2140,7 @@ var zWalletMetadata = import_zod23.z.object({
2127
2140
  getOpenid4vpClientId,
2128
2141
  isJarmResponseMode,
2129
2142
  isOpenid4vpAuthorizationRequestDcApi,
2143
+ parseAuthorizationRequestVersion,
2130
2144
  parseDcqlVpToken,
2131
2145
  parseJarmAuthorizationResponse,
2132
2146
  parseOpenid4VpAuthorizationResponsePayload,