@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.d.mts +26 -18
- package/dist/index.d.ts +26 -18
- package/dist/index.js +168 -154
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +161 -148
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -728,6 +728,110 @@ async function verifyJarmAuthorizationResponse(options) {
|
|
|
728
728
|
return { jarmAuthorizationResponse, type, issuer };
|
|
729
729
|
}
|
|
730
730
|
|
|
731
|
+
// src/version.ts
|
|
732
|
+
import { Oauth2ErrorCodes as Oauth2ErrorCodes2, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError2 } from "@openid4vc/oauth2";
|
|
733
|
+
function parseAuthorizationRequestVersion(request) {
|
|
734
|
+
const requirements = [];
|
|
735
|
+
if (request.verifier_info) {
|
|
736
|
+
requirements.push([">=", 100]);
|
|
737
|
+
}
|
|
738
|
+
if (request.verifier_attestations) {
|
|
739
|
+
requirements.push(["<", 100]);
|
|
740
|
+
}
|
|
741
|
+
if (request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values || request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values) {
|
|
742
|
+
requirements.push([">=", 28]);
|
|
743
|
+
}
|
|
744
|
+
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) {
|
|
745
|
+
requirements.push(["<", 28]);
|
|
746
|
+
}
|
|
747
|
+
if (request.client_metadata?.vp_formats) {
|
|
748
|
+
requirements.push([">=", 27]);
|
|
749
|
+
}
|
|
750
|
+
if (request.client_metadata?.vp_formats_supported) {
|
|
751
|
+
requirements.push(["<", 27]);
|
|
752
|
+
}
|
|
753
|
+
if (request.client_id?.startsWith("openid_federation:") || request.client_id?.startsWith("decentralized_identifier:")) {
|
|
754
|
+
requirements.push([">=", 26]);
|
|
755
|
+
}
|
|
756
|
+
if (request.client_id?.startsWith("did:")) {
|
|
757
|
+
requirements.push(["<", 26]);
|
|
758
|
+
}
|
|
759
|
+
if (request.presentation_definition || request.presentation_definition_uri) {
|
|
760
|
+
requirements.push([">=", 26]);
|
|
761
|
+
}
|
|
762
|
+
if (request.verifier_attestations) {
|
|
763
|
+
requirements.push([">=", 26]);
|
|
764
|
+
}
|
|
765
|
+
if (request.client_id?.startsWith("x509_san_uri:")) {
|
|
766
|
+
requirements.push(["<", 25]);
|
|
767
|
+
}
|
|
768
|
+
if (request.client_id?.startsWith("x509_hash:")) {
|
|
769
|
+
requirements.push([">=", 25]);
|
|
770
|
+
}
|
|
771
|
+
if (request.client_id?.startsWith("web-origin:")) {
|
|
772
|
+
requirements.push(["<", 25]);
|
|
773
|
+
}
|
|
774
|
+
if (request.client_id?.startsWith("origin:")) {
|
|
775
|
+
requirements.push([">=", 25]);
|
|
776
|
+
}
|
|
777
|
+
if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "w3c_dc_api" || request.response_mode === "w3c_dc_api.jwt")) {
|
|
778
|
+
requirements.push(["<", 23]);
|
|
779
|
+
requirements.push([">=", 21]);
|
|
780
|
+
}
|
|
781
|
+
if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "dc_api" || request.response_mode === "dc_api.jwt")) {
|
|
782
|
+
requirements.push([">=", 23]);
|
|
783
|
+
}
|
|
784
|
+
if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.transaction_data || request.dcql_query)) {
|
|
785
|
+
requirements.push([">=", 23]);
|
|
786
|
+
}
|
|
787
|
+
if (request.transaction_data) {
|
|
788
|
+
requirements.push([">=", 22]);
|
|
789
|
+
}
|
|
790
|
+
if (request.client_id_scheme) {
|
|
791
|
+
requirements.push(["<", 22]);
|
|
792
|
+
}
|
|
793
|
+
if (request.client_id) {
|
|
794
|
+
const colonIndex = request.client_id.indexOf(":");
|
|
795
|
+
const schemePart = request.client_id.substring(0, colonIndex);
|
|
796
|
+
const parsedScheme = zClientIdPrefix.safeParse(schemePart);
|
|
797
|
+
if (parsedScheme.success && parsedScheme.data !== "did" && parsedScheme.data !== "https") {
|
|
798
|
+
requirements.push([">=", 22]);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
if (!request.client_id) {
|
|
802
|
+
requirements.push([">=", 21]);
|
|
803
|
+
}
|
|
804
|
+
if (request.dcql_query) {
|
|
805
|
+
requirements.push([">=", 21]);
|
|
806
|
+
}
|
|
807
|
+
if (request.client_metadata_uri) {
|
|
808
|
+
requirements.push(["<", 21]);
|
|
809
|
+
}
|
|
810
|
+
if (isOpenid4vpAuthorizationRequestDcApi(request)) {
|
|
811
|
+
requirements.push([">=", 21]);
|
|
812
|
+
}
|
|
813
|
+
if (request.request_uri_method || request.wallet_nonce) {
|
|
814
|
+
requirements.push([">=", 21]);
|
|
815
|
+
}
|
|
816
|
+
if (request.client_id_scheme === "verifier_attestation") {
|
|
817
|
+
requirements.push([">=", 20]);
|
|
818
|
+
}
|
|
819
|
+
if (request.client_id_scheme === "x509_san_dns" || request.client_id_scheme === "x509_san_uri") {
|
|
820
|
+
requirements.push([">=", 19]);
|
|
821
|
+
}
|
|
822
|
+
const lessThanVersions = requirements.filter(([operator]) => operator === "<").map(([_, version]) => version);
|
|
823
|
+
const greaterThanVersions = requirements.filter(([operator]) => operator === ">=").map(([_, version]) => version);
|
|
824
|
+
const highestPossibleVersion = lessThanVersions.length > 0 ? Math.max(Math.min(...lessThanVersions) - 1, 18) : 100;
|
|
825
|
+
const lowestRequiredVersion = greaterThanVersions.length > 0 ? Math.max(...greaterThanVersions) : 18;
|
|
826
|
+
if (lowestRequiredVersion > highestPossibleVersion) {
|
|
827
|
+
throw new Oauth2ServerErrorResponseError2({
|
|
828
|
+
error: Oauth2ErrorCodes2.InvalidRequest,
|
|
829
|
+
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}`
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
return highestPossibleVersion;
|
|
833
|
+
}
|
|
834
|
+
|
|
731
835
|
// src/authorization-request/create-authorization-request.ts
|
|
732
836
|
import { Oauth2Error as Oauth2Error4 } from "@openid4vc/oauth2";
|
|
733
837
|
import { URL as URL3, URLSearchParams, objectToQueryParams, parseWithErrorHandling as parseWithErrorHandling2 } from "@openid4vc/utils";
|
|
@@ -763,94 +867,94 @@ async function createJarAuthorizationRequest(options) {
|
|
|
763
867
|
}
|
|
764
868
|
|
|
765
869
|
// src/authorization-request/validate-authorization-request.ts
|
|
766
|
-
import { Oauth2ErrorCodes as
|
|
870
|
+
import { Oauth2ErrorCodes as Oauth2ErrorCodes3, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError3 } from "@openid4vc/oauth2";
|
|
767
871
|
import { zHttpsUrl as zHttpsUrl4 } from "@openid4vc/utils";
|
|
768
872
|
var validateOpenid4vpAuthorizationRequestPayload = (options) => {
|
|
769
873
|
const { params, walletVerificationOptions } = options;
|
|
770
874
|
if (!params.redirect_uri && !params.response_uri) {
|
|
771
|
-
throw new
|
|
772
|
-
error:
|
|
875
|
+
throw new Oauth2ServerErrorResponseError3({
|
|
876
|
+
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
773
877
|
error_description: `Missing required 'redirect_uri' or 'response_uri' in openid4vp authorization request.`
|
|
774
878
|
});
|
|
775
879
|
}
|
|
776
880
|
if (params.response_uri && !["direct_post", "direct_post.jwt"].find((mode) => mode === params.response_mode)) {
|
|
777
|
-
throw new
|
|
778
|
-
error:
|
|
881
|
+
throw new Oauth2ServerErrorResponseError3({
|
|
882
|
+
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
779
883
|
error_description: `The 'response_mode' parameter MUST be 'direct_post' or 'direct_post.jwt' when 'response_uri' is provided. Current: ${params.response_mode}`
|
|
780
884
|
});
|
|
781
885
|
}
|
|
782
886
|
if ([params.presentation_definition_uri, params.presentation_definition, params.dcql_query, params.scope].filter(
|
|
783
887
|
Boolean
|
|
784
888
|
).length > 1) {
|
|
785
|
-
throw new
|
|
786
|
-
error:
|
|
889
|
+
throw new Oauth2ServerErrorResponseError3({
|
|
890
|
+
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
787
891
|
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."
|
|
788
892
|
});
|
|
789
893
|
}
|
|
790
894
|
if (params.request_uri_method && !params.request_uri) {
|
|
791
|
-
throw new
|
|
792
|
-
error:
|
|
895
|
+
throw new Oauth2ServerErrorResponseError3({
|
|
896
|
+
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
793
897
|
error_description: 'The "request_uri_method" parameter MUST NOT be present in the authorization request if the "request_uri" parameter is not present.'
|
|
794
898
|
});
|
|
795
899
|
}
|
|
796
900
|
if (params.request_uri_method && !["GET", "POST"].includes(params.request_uri_method)) {
|
|
797
|
-
throw new
|
|
798
|
-
error:
|
|
901
|
+
throw new Oauth2ServerErrorResponseError3({
|
|
902
|
+
error: Oauth2ErrorCodes3.InvalidRequestUriMethod,
|
|
799
903
|
error_description: `The 'request_uri_method' parameter MUST be 'GET' or 'POST'. Current: ${params.request_uri_method}`
|
|
800
904
|
});
|
|
801
905
|
}
|
|
802
906
|
if (params.trust_chain && !zHttpsUrl4.safeParse(params.client_id).success) {
|
|
803
|
-
throw new
|
|
804
|
-
error:
|
|
907
|
+
throw new Oauth2ServerErrorResponseError3({
|
|
908
|
+
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
805
909
|
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://.'
|
|
806
910
|
});
|
|
807
911
|
}
|
|
808
912
|
if (walletVerificationOptions?.expectedNonce && !params.wallet_nonce) {
|
|
809
|
-
throw new
|
|
810
|
-
error:
|
|
913
|
+
throw new Oauth2ServerErrorResponseError3({
|
|
914
|
+
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
811
915
|
error_description: 'The "wallet_nonce" parameter MUST be present in the authorization request when the "expectedNonce" parameter is provided.'
|
|
812
916
|
});
|
|
813
917
|
}
|
|
814
918
|
if (walletVerificationOptions?.expectedNonce !== params.wallet_nonce) {
|
|
815
|
-
throw new
|
|
816
|
-
error:
|
|
919
|
+
throw new Oauth2ServerErrorResponseError3({
|
|
920
|
+
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
817
921
|
error_description: 'The "wallet_nonce" parameter MUST match the "expectedNonce" parameter when the "expectedNonce" parameter is provided.'
|
|
818
922
|
});
|
|
819
923
|
}
|
|
820
924
|
if (params.client_id.startsWith("web-origin:") || params.client_id.startsWith("origin:")) {
|
|
821
|
-
throw new
|
|
822
|
-
error:
|
|
925
|
+
throw new Oauth2ServerErrorResponseError3({
|
|
926
|
+
error: Oauth2ErrorCodes3.InvalidRequest,
|
|
823
927
|
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}`
|
|
824
928
|
});
|
|
825
929
|
}
|
|
826
930
|
};
|
|
827
931
|
|
|
828
932
|
// src/authorization-request/validate-authorization-request-dc-api.ts
|
|
829
|
-
import { Oauth2ErrorCodes as
|
|
933
|
+
import { Oauth2ErrorCodes as Oauth2ErrorCodes4, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError4 } from "@openid4vc/oauth2";
|
|
830
934
|
var validateOpenid4vpAuthorizationRequestDcApiPayload = (options) => {
|
|
831
935
|
const { params, isJarRequest, disableOriginValidation, origin } = options;
|
|
832
936
|
if (isJarRequest && !params.expected_origins) {
|
|
833
|
-
throw new
|
|
834
|
-
error:
|
|
937
|
+
throw new Oauth2ServerErrorResponseError4({
|
|
938
|
+
error: Oauth2ErrorCodes4.InvalidRequest,
|
|
835
939
|
error_description: `The 'expected_origins' parameter MUST be present when using the dc_api response mode in combinaction with jar.`
|
|
836
940
|
});
|
|
837
941
|
}
|
|
838
942
|
if ([params.presentation_definition, params.dcql_query].filter(Boolean).length !== 1) {
|
|
839
|
-
throw new
|
|
840
|
-
error:
|
|
943
|
+
throw new Oauth2ServerErrorResponseError4({
|
|
944
|
+
error: Oauth2ErrorCodes4.InvalidRequest,
|
|
841
945
|
error_description: "Exactly one of the following parameters MUST be present in the Authorization Request: dcql_query or presentation_definition"
|
|
842
946
|
});
|
|
843
947
|
}
|
|
844
948
|
if (params.expected_origins && !disableOriginValidation) {
|
|
845
949
|
if (!origin) {
|
|
846
|
-
throw new
|
|
847
|
-
error:
|
|
950
|
+
throw new Oauth2ServerErrorResponseError4({
|
|
951
|
+
error: Oauth2ErrorCodes4.InvalidRequest,
|
|
848
952
|
error_description: `Failed to validate the 'origin' of the authorization request. The 'origin' was not provided.`
|
|
849
953
|
});
|
|
850
954
|
}
|
|
851
955
|
if (params.expected_origins && !params.expected_origins.includes(origin)) {
|
|
852
|
-
throw new
|
|
853
|
-
error:
|
|
956
|
+
throw new Oauth2ServerErrorResponseError4({
|
|
957
|
+
error: Oauth2ErrorCodes4.InvalidRequest,
|
|
854
958
|
error_description: `The 'expected_origins' parameter MUST include the origin of the authorization request. Current: ${params.expected_origins.join(", ")}`
|
|
855
959
|
});
|
|
856
960
|
}
|
|
@@ -932,7 +1036,7 @@ import { parseWithErrorHandling as parseWithErrorHandling3 } from "@openid4vc/ut
|
|
|
932
1036
|
import z11 from "zod";
|
|
933
1037
|
|
|
934
1038
|
// src/jar/z-jar-authorization-request.ts
|
|
935
|
-
import { Oauth2ServerErrorResponseError as
|
|
1039
|
+
import { Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError5 } from "@openid4vc/oauth2";
|
|
936
1040
|
import { zHttpsUrl as zHttpsUrl5 } from "@openid4vc/utils";
|
|
937
1041
|
import { z as z10 } from "zod";
|
|
938
1042
|
var zJarAuthorizationRequest = z10.object({
|
|
@@ -944,13 +1048,13 @@ var zJarAuthorizationRequest = z10.object({
|
|
|
944
1048
|
function validateJarRequestParams(options) {
|
|
945
1049
|
const { jarRequestParams } = options;
|
|
946
1050
|
if (jarRequestParams.request && jarRequestParams.request_uri) {
|
|
947
|
-
throw new
|
|
1051
|
+
throw new Oauth2ServerErrorResponseError5({
|
|
948
1052
|
error: "invalid_request_object",
|
|
949
1053
|
error_description: "request and request_uri cannot both be present in a JAR request"
|
|
950
1054
|
});
|
|
951
1055
|
}
|
|
952
1056
|
if (!jarRequestParams.request && !jarRequestParams.request_uri) {
|
|
953
|
-
throw new
|
|
1057
|
+
throw new Oauth2ServerErrorResponseError5({
|
|
954
1058
|
error: "invalid_request_object",
|
|
955
1059
|
error_description: "request or request_uri must be present"
|
|
956
1060
|
});
|
|
@@ -1013,7 +1117,7 @@ import { parseWithErrorHandling as parseWithErrorHandling4 } from "@openid4vc/ut
|
|
|
1013
1117
|
import z15 from "zod";
|
|
1014
1118
|
|
|
1015
1119
|
// src/fetch-client-metadata.ts
|
|
1016
|
-
import { Oauth2ErrorCodes as
|
|
1120
|
+
import { Oauth2ErrorCodes as Oauth2ErrorCodes5, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError6 } from "@openid4vc/oauth2";
|
|
1017
1121
|
import { ContentType, createZodFetcher } from "@openid4vc/utils";
|
|
1018
1122
|
async function fetchClientMetadata(options) {
|
|
1019
1123
|
const { fetch, clientMetadataUri } = options;
|
|
@@ -1025,15 +1129,15 @@ async function fetchClientMetadata(options) {
|
|
|
1025
1129
|
}
|
|
1026
1130
|
});
|
|
1027
1131
|
if (!response.ok) {
|
|
1028
|
-
throw new
|
|
1132
|
+
throw new Oauth2ServerErrorResponseError6({
|
|
1029
1133
|
error_description: `Fetching client metadata from '${clientMetadataUri}' failed with status code '${response.status}'.`,
|
|
1030
|
-
error:
|
|
1134
|
+
error: Oauth2ErrorCodes5.InvalidRequestUri
|
|
1031
1135
|
});
|
|
1032
1136
|
}
|
|
1033
1137
|
if (!result || !result.success) {
|
|
1034
|
-
throw new
|
|
1138
|
+
throw new Oauth2ServerErrorResponseError6({
|
|
1035
1139
|
error_description: `Parsing client metadata from '${clientMetadataUri}' failed.`,
|
|
1036
|
-
error:
|
|
1140
|
+
error: Oauth2ErrorCodes5.InvalidRequestObject
|
|
1037
1141
|
});
|
|
1038
1142
|
}
|
|
1039
1143
|
return result.data;
|
|
@@ -1052,110 +1156,6 @@ import {
|
|
|
1052
1156
|
} from "@openid4vc/oauth2";
|
|
1053
1157
|
import z13 from "zod";
|
|
1054
1158
|
|
|
1055
|
-
// src/version.ts
|
|
1056
|
-
import { Oauth2ErrorCodes as Oauth2ErrorCodes5, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError6 } from "@openid4vc/oauth2";
|
|
1057
|
-
function parseAuthorizationRequestVersion(request) {
|
|
1058
|
-
const requirements = [];
|
|
1059
|
-
if (request.verifier_info) {
|
|
1060
|
-
requirements.push([">=", 29]);
|
|
1061
|
-
}
|
|
1062
|
-
if (request.verifier_attestations) {
|
|
1063
|
-
requirements.push(["<", 29]);
|
|
1064
|
-
}
|
|
1065
|
-
if (request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values || request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values) {
|
|
1066
|
-
requirements.push([">=", 28]);
|
|
1067
|
-
}
|
|
1068
|
-
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) {
|
|
1069
|
-
requirements.push(["<", 28]);
|
|
1070
|
-
}
|
|
1071
|
-
if (request.client_metadata?.vp_formats) {
|
|
1072
|
-
requirements.push([">=", 27]);
|
|
1073
|
-
}
|
|
1074
|
-
if (request.client_metadata?.vp_formats_supported) {
|
|
1075
|
-
requirements.push(["<", 27]);
|
|
1076
|
-
}
|
|
1077
|
-
if (request.client_id?.startsWith("openid_federation:") || request.client_id?.startsWith("decentralized_identifier:")) {
|
|
1078
|
-
requirements.push([">=", 26]);
|
|
1079
|
-
}
|
|
1080
|
-
if (request.client_id?.startsWith("did:")) {
|
|
1081
|
-
requirements.push(["<", 26]);
|
|
1082
|
-
}
|
|
1083
|
-
if (request.presentation_definition || request.presentation_definition_uri) {
|
|
1084
|
-
requirements.push([">=", 26]);
|
|
1085
|
-
}
|
|
1086
|
-
if (request.verifier_attestations) {
|
|
1087
|
-
requirements.push([">=", 26]);
|
|
1088
|
-
}
|
|
1089
|
-
if (request.client_id?.startsWith("x509_san_uri:")) {
|
|
1090
|
-
requirements.push(["<", 25]);
|
|
1091
|
-
}
|
|
1092
|
-
if (request.client_id?.startsWith("x509_hash:")) {
|
|
1093
|
-
requirements.push([">=", 25]);
|
|
1094
|
-
}
|
|
1095
|
-
if (request.client_id?.startsWith("web-origin:")) {
|
|
1096
|
-
requirements.push(["<", 25]);
|
|
1097
|
-
}
|
|
1098
|
-
if (request.client_id?.startsWith("origin:")) {
|
|
1099
|
-
requirements.push([">=", 25]);
|
|
1100
|
-
}
|
|
1101
|
-
if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "w3c_dc_api" || request.response_mode === "w3c_dc_api.jwt")) {
|
|
1102
|
-
requirements.push(["<", 23]);
|
|
1103
|
-
requirements.push([">=", 21]);
|
|
1104
|
-
}
|
|
1105
|
-
if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.response_mode === "dc_api" || request.response_mode === "dc_api.jwt")) {
|
|
1106
|
-
requirements.push([">=", 23]);
|
|
1107
|
-
}
|
|
1108
|
-
if (isOpenid4vpAuthorizationRequestDcApi(request) && (request.transaction_data || request.dcql_query)) {
|
|
1109
|
-
requirements.push([">=", 23]);
|
|
1110
|
-
}
|
|
1111
|
-
if (request.transaction_data) {
|
|
1112
|
-
requirements.push([">=", 22]);
|
|
1113
|
-
}
|
|
1114
|
-
if (request.client_id_scheme) {
|
|
1115
|
-
requirements.push(["<", 22]);
|
|
1116
|
-
}
|
|
1117
|
-
if (request.client_id) {
|
|
1118
|
-
const colonIndex = request.client_id.indexOf(":");
|
|
1119
|
-
const schemePart = request.client_id.substring(0, colonIndex);
|
|
1120
|
-
const parsedScheme = zClientIdPrefix.safeParse(schemePart);
|
|
1121
|
-
if (parsedScheme.success && parsedScheme.data !== "did" && parsedScheme.data !== "https") {
|
|
1122
|
-
requirements.push([">=", 22]);
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
if (!request.client_id) {
|
|
1126
|
-
requirements.push([">=", 21]);
|
|
1127
|
-
}
|
|
1128
|
-
if (request.dcql_query) {
|
|
1129
|
-
requirements.push([">=", 21]);
|
|
1130
|
-
}
|
|
1131
|
-
if (request.client_metadata_uri) {
|
|
1132
|
-
requirements.push(["<", 21]);
|
|
1133
|
-
}
|
|
1134
|
-
if (isOpenid4vpAuthorizationRequestDcApi(request)) {
|
|
1135
|
-
requirements.push([">=", 21]);
|
|
1136
|
-
}
|
|
1137
|
-
if (request.request_uri_method || request.wallet_nonce) {
|
|
1138
|
-
requirements.push([">=", 21]);
|
|
1139
|
-
}
|
|
1140
|
-
if (request.client_id_scheme === "verifier_attestation") {
|
|
1141
|
-
requirements.push([">=", 20]);
|
|
1142
|
-
}
|
|
1143
|
-
if (request.client_id_scheme === "x509_san_dns" || request.client_id_scheme === "x509_san_uri") {
|
|
1144
|
-
requirements.push([">=", 19]);
|
|
1145
|
-
}
|
|
1146
|
-
const lessThanVersions = requirements.filter(([operator]) => operator === "<").map(([_, version]) => version);
|
|
1147
|
-
const greaterThanVersions = requirements.filter(([operator]) => operator === ">=").map(([_, version]) => version);
|
|
1148
|
-
const highestPossibleVersion = lessThanVersions.length > 0 ? Math.max(Math.min(...lessThanVersions) - 1, 18) : 29;
|
|
1149
|
-
const lowestRequiredVersion = greaterThanVersions.length > 0 ? Math.max(...greaterThanVersions) : 18;
|
|
1150
|
-
if (lowestRequiredVersion > highestPossibleVersion) {
|
|
1151
|
-
throw new Oauth2ServerErrorResponseError6({
|
|
1152
|
-
error: Oauth2ErrorCodes5.InvalidRequest,
|
|
1153
|
-
error_description: "Could not infer openid4vp version from the openid4vp request payload."
|
|
1154
|
-
});
|
|
1155
|
-
}
|
|
1156
|
-
return highestPossibleVersion;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
1159
|
// src/jar/jar-request-object/fetch-jar-request-object.ts
|
|
1160
1160
|
import { Oauth2ErrorCodes as Oauth2ErrorCodes6, Oauth2ServerErrorResponseError as Oauth2ServerErrorResponseError7 } from "@openid4vc/oauth2";
|
|
1161
1161
|
import { ContentType as ContentType2, createFetcher, objectToQueryParams as objectToQueryParams2 } from "@openid4vc/utils";
|
|
@@ -1747,18 +1747,24 @@ import { parseIfJson as parseIfJson2, parseWithErrorHandling as parseWithErrorHa
|
|
|
1747
1747
|
|
|
1748
1748
|
// src/vp-token/z-vp-token.ts
|
|
1749
1749
|
import { z as z17 } from "zod";
|
|
1750
|
-
var
|
|
1751
|
-
message: "
|
|
1750
|
+
var zVpTokenPresentationEntry = z17.union([z17.string(), z17.record(z17.any())], {
|
|
1751
|
+
message: "vp_token presentation entry must be string or object"
|
|
1752
1752
|
});
|
|
1753
1753
|
var zVpTokenPex = z17.union(
|
|
1754
|
-
[
|
|
1754
|
+
[
|
|
1755
|
+
zVpTokenPresentationEntry,
|
|
1756
|
+
z17.array(zVpTokenPresentationEntry).nonempty("Must have at least entry in vp_token array")
|
|
1757
|
+
],
|
|
1755
1758
|
{
|
|
1756
|
-
message: "pex vp_token must be a string, object or array of strings and objects"
|
|
1759
|
+
message: "pex vp_token must be a string, object or non-empty array of strings and objects"
|
|
1760
|
+
}
|
|
1761
|
+
);
|
|
1762
|
+
var zVpTokenDcql = z17.record(
|
|
1763
|
+
z17.union([z17.array(zVpTokenPresentationEntry).nonempty(), zVpTokenPresentationEntry]),
|
|
1764
|
+
{
|
|
1765
|
+
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"
|
|
1757
1766
|
}
|
|
1758
1767
|
);
|
|
1759
|
-
var zVpTokenDcql = z17.record(z17.union([z17.string(), z17.record(z17.any())]), {
|
|
1760
|
-
message: "dcql vp_token must be an object with keys referencing the dcql credential query id, and values the encoded (string or object) presentation"
|
|
1761
|
-
});
|
|
1762
1768
|
var zVpToken = zVpTokenDcql.or(zVpTokenPex);
|
|
1763
1769
|
|
|
1764
1770
|
// src/vp-token/parse-vp-token.ts
|
|
@@ -1771,11 +1777,17 @@ function parsePexVpToken(vpToken) {
|
|
|
1771
1777
|
return Array.isArray(parsedVpToken) ? parsedVpToken : [parsedVpToken];
|
|
1772
1778
|
}
|
|
1773
1779
|
function parseDcqlVpToken(vpToken) {
|
|
1774
|
-
|
|
1780
|
+
const parsedVpToken = parseWithErrorHandling5(
|
|
1775
1781
|
zVpTokenDcql,
|
|
1776
1782
|
parseIfJson2(vpToken),
|
|
1777
1783
|
"Could not parse dcql vp_token. Expected an object where the values are encoded presentations"
|
|
1778
1784
|
);
|
|
1785
|
+
return Object.fromEntries(
|
|
1786
|
+
Object.entries(parsedVpToken).map(([queryId, presentations]) => [
|
|
1787
|
+
queryId,
|
|
1788
|
+
Array.isArray(presentations) ? presentations : [presentations]
|
|
1789
|
+
])
|
|
1790
|
+
);
|
|
1779
1791
|
}
|
|
1780
1792
|
|
|
1781
1793
|
// src/authorization-response/validate-authorization-response.ts
|
|
@@ -2094,6 +2106,7 @@ export {
|
|
|
2094
2106
|
getOpenid4vpClientId,
|
|
2095
2107
|
isJarmResponseMode,
|
|
2096
2108
|
isOpenid4vpAuthorizationRequestDcApi,
|
|
2109
|
+
parseAuthorizationRequestVersion,
|
|
2097
2110
|
parseDcqlVpToken,
|
|
2098
2111
|
parseJarmAuthorizationResponse,
|
|
2099
2112
|
parseOpenid4VpAuthorizationResponsePayload,
|