@openid4vc/openid4vp 0.4.6-alpha-20260201172333 → 0.5.0-alpha-20260202155954
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 +852 -88
- package/dist/index.mjs +144 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -60,7 +60,7 @@ const validateOpenid4vpAuthorizationRequestDcApiPayload = (options) => {
|
|
|
60
60
|
const { params, isJarRequest, disableOriginValidation, origin } = options;
|
|
61
61
|
if (isJarRequest && !params.expected_origins) throw new Oauth2ServerErrorResponseError({
|
|
62
62
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
63
|
-
error_description: `The 'expected_origins' parameter MUST be present when using the dc_api response mode in
|
|
63
|
+
error_description: `The 'expected_origins' parameter MUST be present when using the dc_api response mode in combination with jar.`
|
|
64
64
|
});
|
|
65
65
|
if ([params.presentation_definition, params.dcql_query].filter(Boolean).length !== 1) throw new Oauth2ServerErrorResponseError({
|
|
66
66
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -71,13 +71,48 @@ const validateOpenid4vpAuthorizationRequestDcApiPayload = (options) => {
|
|
|
71
71
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
72
72
|
error_description: `Failed to validate the 'origin' of the authorization request. The 'origin' was not provided.`
|
|
73
73
|
});
|
|
74
|
-
if (
|
|
74
|
+
if (!params.expected_origins.includes(origin)) throw new Oauth2ServerErrorResponseError({
|
|
75
75
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
76
76
|
error_description: `The 'expected_origins' parameter MUST include the origin of the authorization request. Current: ${params.expected_origins.join(", ")}`
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/authorization-request/validate-authorization-request-iae.ts
|
|
83
|
+
/**
|
|
84
|
+
* Validate the OpenId4Vp Authorization Request parameters for the IAE (Interactive Authorization Endpoint) response mode
|
|
85
|
+
*
|
|
86
|
+
* The IAE flow is part of OpenID4VCI 1.1 and is used when the authorization server needs to
|
|
87
|
+
* interact directly with the wallet during the authorization process.
|
|
88
|
+
*
|
|
89
|
+
* Key validation rules:
|
|
90
|
+
* - For signed requests (JAR), expected_url parameter is validated against the actual endpoint URL
|
|
91
|
+
* - expected_url is used instead of expected_origins to prevent replay attacks
|
|
92
|
+
* - dcql_query must be present
|
|
93
|
+
*/
|
|
94
|
+
const validateOpenid4vpAuthorizationRequestIaePayload = (options) => {
|
|
95
|
+
const { params, isJarRequest, expectedUrl, disableExpectedUrlValidation } = options;
|
|
96
|
+
if (isJarRequest && !params.expected_url) throw new Oauth2ServerErrorResponseError({
|
|
97
|
+
error: Oauth2ErrorCodes.InvalidRequest,
|
|
98
|
+
error_description: `The 'expected_url' parameter MUST be present when using the iae_post response mode in combination with jar.`
|
|
99
|
+
});
|
|
100
|
+
if (!params.dcql_query) throw new Oauth2ServerErrorResponseError({
|
|
101
|
+
error: Oauth2ErrorCodes.InvalidRequest,
|
|
102
|
+
error_description: "dcql_query MUST be present when using iae_post response mode."
|
|
103
|
+
});
|
|
104
|
+
if (params.expected_url && !disableExpectedUrlValidation) {
|
|
105
|
+
if (!expectedUrl) throw new Oauth2ServerErrorResponseError({
|
|
106
|
+
error: Oauth2ErrorCodes.InvalidRequest,
|
|
107
|
+
error_description: `Failed to validate the 'expected_url' of the authorization request. The 'expectedUrl' was not provided for validation.`
|
|
108
|
+
});
|
|
109
|
+
if (params.expected_url !== expectedUrl) throw new Oauth2ServerErrorResponseError({
|
|
110
|
+
error: Oauth2ErrorCodes.InvalidRequest,
|
|
111
|
+
error_description: `The 'expected_url' parameter does not match the follow-up request URL. This prevents replay attacks from malicious verifiers.`
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
81
116
|
//#endregion
|
|
82
117
|
//#region src/jarm/metadata/z-jarm-client-metadata.ts
|
|
83
118
|
const zJarmSignOnlyClientMetadata = z.object({
|
|
@@ -255,6 +290,42 @@ function isOpenid4vpAuthorizationRequestDcApi(request) {
|
|
|
255
290
|
return isOpenid4vpResponseModeDcApi(request.response_mode);
|
|
256
291
|
}
|
|
257
292
|
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region src/authorization-request/z-authorization-request-iae.ts
|
|
295
|
+
/**
|
|
296
|
+
* Response modes for Interactive Authorization Endpoint (IAE) flow
|
|
297
|
+
* Part of OpenID4VCI 1.1 specification
|
|
298
|
+
*/
|
|
299
|
+
const zOpenid4vpResponseModeIae = z.enum(["iae_post", "iae_post.jwt"]);
|
|
300
|
+
/**
|
|
301
|
+
* Authorization Request schema for Interactive Authorization Endpoint (IAE) flow
|
|
302
|
+
*
|
|
303
|
+
* IAE is used in OpenID4VCI when the authorization server needs to interact
|
|
304
|
+
* directly with the wallet (e.g., requesting credential presentation) as part
|
|
305
|
+
* of the authorization process.
|
|
306
|
+
*
|
|
307
|
+
* Key differences from DC API:
|
|
308
|
+
* - Uses iae_post/iae_post.jwt response modes
|
|
309
|
+
* - Uses expected_url instead of expected_origins for signed requests
|
|
310
|
+
* - Response is sent back to the Interactive Authorization Endpoint
|
|
311
|
+
*/
|
|
312
|
+
const zOpenid4vpAuthorizationRequestIae = zOpenid4vpAuthorizationRequestDcApi.omit({
|
|
313
|
+
response_mode: true,
|
|
314
|
+
expected_origins: true,
|
|
315
|
+
presentation_definition: true
|
|
316
|
+
}).extend({
|
|
317
|
+
response_mode: zOpenid4vpResponseModeIae,
|
|
318
|
+
dcql_query: z.record(z.string(), z.any()),
|
|
319
|
+
expected_url: z.string().optional(),
|
|
320
|
+
expected_origins: z.never("The 'expected_origins' parameter MUST NOT be present when using Interactive Authorization response mode. ").optional()
|
|
321
|
+
});
|
|
322
|
+
function isOpenid4vpResponseModeIae(responseMode) {
|
|
323
|
+
return responseMode !== void 0 && zOpenid4vpResponseModeIae.options.includes(responseMode);
|
|
324
|
+
}
|
|
325
|
+
function isOpenid4vpAuthorizationRequestIae(request) {
|
|
326
|
+
return isOpenid4vpResponseModeIae(request.response_mode);
|
|
327
|
+
}
|
|
328
|
+
|
|
258
329
|
//#endregion
|
|
259
330
|
//#region src/authorization-request/create-authorization-request.ts
|
|
260
331
|
/**
|
|
@@ -280,12 +351,18 @@ async function createOpenid4vpAuthorizationRequest(options) {
|
|
|
280
351
|
let authorizationRequestPayload;
|
|
281
352
|
if (isOpenid4vpAuthorizationRequestDcApi(options.authorizationRequestPayload)) {
|
|
282
353
|
authorizationRequestPayload = parseWithErrorHandling(zOpenid4vpAuthorizationRequestDcApi, options.authorizationRequestPayload, "Invalid authorization request. Could not parse openid4vp dc_api authorization request.");
|
|
283
|
-
if (jar && !authorizationRequestPayload.expected_origins) throw new Oauth2Error(`The 'expected_origins' parameter MUST be present when using the dc_api response mode in combination with jar.`);
|
|
284
354
|
validateOpenid4vpAuthorizationRequestDcApiPayload({
|
|
285
355
|
params: authorizationRequestPayload,
|
|
286
356
|
isJarRequest: Boolean(jar),
|
|
287
357
|
disableOriginValidation: true
|
|
288
358
|
});
|
|
359
|
+
} else if (isOpenid4vpAuthorizationRequestIae(options.authorizationRequestPayload)) {
|
|
360
|
+
authorizationRequestPayload = parseWithErrorHandling(zOpenid4vpAuthorizationRequestIae, options.authorizationRequestPayload, "Invalid authorization request. Could not parse openid4vp iae_post authorization request.");
|
|
361
|
+
validateOpenid4vpAuthorizationRequestIaePayload({
|
|
362
|
+
params: authorizationRequestPayload,
|
|
363
|
+
isJarRequest: Boolean(jar),
|
|
364
|
+
disableExpectedUrlValidation: true
|
|
365
|
+
});
|
|
289
366
|
} else {
|
|
290
367
|
authorizationRequestPayload = parseWithErrorHandling(zOpenid4vpAuthorizationRequest, options.authorizationRequestPayload, "Invalid authorization request. Could not parse openid4vp authorization request.");
|
|
291
368
|
validateOpenid4vpAuthorizationRequestPayload({
|
|
@@ -354,7 +431,8 @@ function parseOpenid4vpAuthorizationRequest(options) {
|
|
|
354
431
|
const parsedRequest = parseWithErrorHandling(z$1.union([
|
|
355
432
|
zOpenid4vpAuthorizationRequest,
|
|
356
433
|
zOpenid4vpJarAuthorizationRequest,
|
|
357
|
-
zOpenid4vpAuthorizationRequestDcApi
|
|
434
|
+
zOpenid4vpAuthorizationRequestDcApi,
|
|
435
|
+
zOpenid4vpAuthorizationRequestIae
|
|
358
436
|
]), params);
|
|
359
437
|
if (isJarAuthorizationRequest(parsedRequest)) return {
|
|
360
438
|
type: "jar",
|
|
@@ -366,6 +444,11 @@ function parseOpenid4vpAuthorizationRequest(options) {
|
|
|
366
444
|
provided,
|
|
367
445
|
params: parsedRequest
|
|
368
446
|
};
|
|
447
|
+
if (isOpenid4vpAuthorizationRequestIae(parsedRequest)) return {
|
|
448
|
+
type: "openid4vp_iae",
|
|
449
|
+
provided,
|
|
450
|
+
params: parsedRequest
|
|
451
|
+
};
|
|
369
452
|
return {
|
|
370
453
|
type: "openid4vp",
|
|
371
454
|
provided,
|
|
@@ -430,7 +513,7 @@ const zLegacyClientIdSchemeToClientIdPrefix = zLegacyClientIdScheme.optional().d
|
|
|
430
513
|
*/
|
|
431
514
|
function getOpenid4vpClientId(options) {
|
|
432
515
|
const original = { clientId: options.clientId };
|
|
433
|
-
const version = options.version ??
|
|
516
|
+
const version = options.version ?? 101;
|
|
434
517
|
if (isOpenid4vpResponseModeDcApi(options.responseMode)) {
|
|
435
518
|
if (!options.clientId) {
|
|
436
519
|
if (!options.origin) throw new Oauth2ServerErrorResponseError({
|
|
@@ -468,7 +551,7 @@ function getOpenid4vpClientId(options) {
|
|
|
468
551
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
469
552
|
error_description: `Failed to parse client identifier. Missing required client_id parameter for response_mode '${options.responseMode}'.`
|
|
470
553
|
});
|
|
471
|
-
if (options.legacyClientIdScheme) {
|
|
554
|
+
if (options.legacyClientIdScheme && !isOpenid4vpResponseModeIae(options.responseMode)) {
|
|
472
555
|
const parsedClientIdPrefix = zLegacyClientIdSchemeToClientIdPrefix.safeParse(options.legacyClientIdScheme);
|
|
473
556
|
if (!parsedClientIdPrefix.success) throw new Oauth2ServerErrorResponseError({
|
|
474
557
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -517,16 +600,16 @@ async function validateOpenid4vpClientId(options, parserConfig) {
|
|
|
517
600
|
responseMode: authorizationRequestPayload.response_mode,
|
|
518
601
|
origin
|
|
519
602
|
});
|
|
603
|
+
if (!parserConfigWithDefaults.supportedSchemes.includes(clientIdPrefix)) throw new Oauth2ServerErrorResponseError({
|
|
604
|
+
error: Oauth2ErrorCodes.InvalidRequest,
|
|
605
|
+
error_description: `Unsupported client identifier prefix. ${clientIdPrefix} is not supported.`
|
|
606
|
+
});
|
|
520
607
|
if (clientIdPrefix === "pre-registered") return {
|
|
521
608
|
prefix: "pre-registered",
|
|
522
609
|
identifier: clientIdIdentifier,
|
|
523
610
|
effective: effectiveClientId,
|
|
524
611
|
original
|
|
525
612
|
};
|
|
526
|
-
if (!parserConfigWithDefaults.supportedSchemes.includes(clientIdPrefix)) throw new Oauth2ServerErrorResponseError({
|
|
527
|
-
error: Oauth2ErrorCodes.InvalidRequest,
|
|
528
|
-
error_description: `Unsupported client identifier prefix. ${clientIdPrefix} is not supported.`
|
|
529
|
-
});
|
|
530
613
|
if (clientIdPrefix === "openid_federation") {
|
|
531
614
|
if (!zHttpsUrl.safeParse(clientIdIdentifier).success) throw new Oauth2ServerErrorResponseError({
|
|
532
615
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -553,9 +636,9 @@ async function validateOpenid4vpClientId(options, parserConfig) {
|
|
|
553
636
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
554
637
|
error_description: "Using client identifier prefix \"redirect_uri\" the request MUST NOT be signed."
|
|
555
638
|
});
|
|
556
|
-
if (isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) throw new Oauth2ServerErrorResponseError({
|
|
639
|
+
if (isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload) || isOpenid4vpAuthorizationRequestIae(authorizationRequestPayload)) throw new Oauth2ServerErrorResponseError({
|
|
557
640
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
558
|
-
error_description: `The client identifier prefix 'redirect_uri' is not supported when using the
|
|
641
|
+
error_description: `The client identifier prefix 'redirect_uri' is not supported when using the ${authorizationRequestPayload.response_mode} response mode.`
|
|
559
642
|
});
|
|
560
643
|
if (authorizationRequestPayload.redirect_uri && authorizationRequestPayload.redirect_uri !== clientIdIdentifier) throw new Oauth2ServerErrorResponseError({
|
|
561
644
|
error: Oauth2ErrorCodes.InvalidClient,
|
|
@@ -577,7 +660,7 @@ async function validateOpenid4vpClientId(options, parserConfig) {
|
|
|
577
660
|
if (clientIdPrefix === "decentralized_identifier") {
|
|
578
661
|
if (!jar) throw new Oauth2ServerErrorResponseError({
|
|
579
662
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
580
|
-
error_description: "Using client identifier prefix \"
|
|
663
|
+
error_description: "Using client identifier prefix \"decentralized_identifier\" requires a signed JAR request."
|
|
581
664
|
});
|
|
582
665
|
if (jar.signer.method !== "did") throw new Oauth2ServerErrorResponseError({
|
|
583
666
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -617,7 +700,7 @@ async function validateOpenid4vpClientId(options, parserConfig) {
|
|
|
617
700
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
618
701
|
error_description: `Invalid client identifier. One of the leaf certificates san dns names [${sanDnsNames.join(", ")}] must match the client identifier '${clientIdIdentifier}'. `
|
|
619
702
|
});
|
|
620
|
-
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) {
|
|
703
|
+
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload) && !isOpenid4vpAuthorizationRequestIae(authorizationRequestPayload)) {
|
|
621
704
|
const uri = authorizationRequestPayload.redirect_uri ?? authorizationRequestPayload.response_uri;
|
|
622
705
|
if (!uri || new URL(uri).hostname !== clientIdIdentifier) throw new Oauth2ServerErrorResponseError({
|
|
623
706
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -630,7 +713,7 @@ async function validateOpenid4vpClientId(options, parserConfig) {
|
|
|
630
713
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
631
714
|
error_description: `Invalid client identifier. One of the leaf certificates san uri names [${sanUriNames.join(", ")}] must match the client identifier '${clientIdIdentifier}'.`
|
|
632
715
|
});
|
|
633
|
-
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) {
|
|
716
|
+
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload) && !isOpenid4vpAuthorizationRequestIae(authorizationRequestPayload)) {
|
|
634
717
|
const uri = authorizationRequestPayload.redirect_uri || authorizationRequestPayload.response_uri;
|
|
635
718
|
if (!uri || uri !== clientIdIdentifier) throw new Oauth2ServerErrorResponseError({
|
|
636
719
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -656,13 +739,19 @@ async function validateOpenid4vpClientId(options, parserConfig) {
|
|
|
656
739
|
clientMetadata: authorizationRequestPayload.client_metadata
|
|
657
740
|
};
|
|
658
741
|
}
|
|
659
|
-
if (clientIdPrefix === "origin")
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
742
|
+
if (clientIdPrefix === "origin") {
|
|
743
|
+
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) throw new Oauth2ServerErrorResponseError({
|
|
744
|
+
error: Oauth2ErrorCodes.InvalidRequest,
|
|
745
|
+
error_description: `The client identifier prefix 'origin' is only supported when using a DC API response mode.`
|
|
746
|
+
});
|
|
747
|
+
return {
|
|
748
|
+
prefix: clientIdPrefix,
|
|
749
|
+
identifier: clientIdIdentifier,
|
|
750
|
+
effective: effectiveClientId,
|
|
751
|
+
original,
|
|
752
|
+
clientMetadata: authorizationRequestPayload.client_metadata
|
|
753
|
+
};
|
|
754
|
+
}
|
|
666
755
|
if (clientIdPrefix === "verifier_attestation") {
|
|
667
756
|
if (!jar) throw new Oauth2ServerErrorResponseError({
|
|
668
757
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -701,9 +790,10 @@ async function fetchClientMetadata(options) {
|
|
|
701
790
|
//#region src/version.ts
|
|
702
791
|
function parseAuthorizationRequestVersion(request) {
|
|
703
792
|
const requirements = [];
|
|
793
|
+
if (isOpenid4vpAuthorizationRequestIae(request)) requirements.push([">=", 101]);
|
|
704
794
|
if (request.verifier_info) requirements.push([">=", 100]);
|
|
705
795
|
if (request.verifier_attestations) requirements.push(["<", 100]);
|
|
706
|
-
if (request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values || request.client_metadata?.vp_formats_supported?.mso_mdoc?.
|
|
796
|
+
if (request.client_metadata?.vp_formats_supported?.mso_mdoc?.deviceauth_alg_values || request.client_metadata?.vp_formats_supported?.mso_mdoc?.issuerauth_alg_values) requirements.push([">=", 28]);
|
|
707
797
|
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) requirements.push(["<", 28]);
|
|
708
798
|
if (request.client_metadata?.vp_formats_supported) requirements.push([">=", 27]);
|
|
709
799
|
if (request.client_metadata?.vp_formats) requirements.push(["<", 27]);
|
|
@@ -738,7 +828,7 @@ function parseAuthorizationRequestVersion(request) {
|
|
|
738
828
|
if (request.client_id_scheme === "x509_san_dns" || request.client_id_scheme === "x509_san_uri") requirements.push([">=", 19]);
|
|
739
829
|
const lessThanVersions = requirements.filter(([operator]) => operator === "<").map(([_, version]) => version);
|
|
740
830
|
const greaterThanVersions = requirements.filter(([operator]) => operator === ">=").map(([_, version]) => version);
|
|
741
|
-
const highestPossibleVersion = lessThanVersions.length > 0 ? Math.max(Math.min(...lessThanVersions) - 1, 18) :
|
|
831
|
+
const highestPossibleVersion = lessThanVersions.length > 0 ? Math.max(Math.min(...lessThanVersions) - 1, 18) : 101;
|
|
742
832
|
const lowestRequiredVersion = greaterThanVersions.length > 0 ? Math.max(...greaterThanVersions) : 18;
|
|
743
833
|
if (lowestRequiredVersion > highestPossibleVersion) throw new Oauth2ServerErrorResponseError({
|
|
744
834
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
@@ -806,8 +896,8 @@ async function fetchJarRequestObject(options) {
|
|
|
806
896
|
async function verifyJarRequest(options) {
|
|
807
897
|
const { callbacks, wallet = {} } = options;
|
|
808
898
|
const jarRequestParams = {
|
|
809
|
-
...
|
|
810
|
-
...options
|
|
899
|
+
...options.jarRequestParams,
|
|
900
|
+
...validateJarRequestParams(options)
|
|
811
901
|
};
|
|
812
902
|
const sendBy = jarRequestParams.request ? "value" : "reference";
|
|
813
903
|
const clientIdPrefix = jarRequestParams.client_id ? zClientIdPrefix.safeParse(jarRequestParams.client_id.split(":")[0]).data : "origin";
|
|
@@ -842,7 +932,7 @@ async function verifyJarRequest(options) {
|
|
|
842
932
|
error: Oauth2ErrorCodes.InvalidRequestObject,
|
|
843
933
|
error_description: "Jar Request Object is missing the required \"client_id\" field."
|
|
844
934
|
});
|
|
845
|
-
if (!isOpenid4vpResponseModeDcApi(authorizationRequestPayload.response_mode) && jarRequestParams.client_id !== authorizationRequestPayload.client_id) throw new Oauth2ServerErrorResponseError({
|
|
935
|
+
if (!isOpenid4vpResponseModeDcApi(authorizationRequestPayload.response_mode) && !isOpenid4vpResponseModeIae(authorizationRequestPayload.response_mode) && jarRequestParams.client_id !== authorizationRequestPayload.client_id) throw new Oauth2ServerErrorResponseError({
|
|
846
936
|
error: Oauth2ErrorCodes.InvalidRequest,
|
|
847
937
|
error_description: "client_id does not match the request object client_id."
|
|
848
938
|
});
|
|
@@ -965,10 +1055,11 @@ function parseTransactionData(options) {
|
|
|
965
1055
|
//#endregion
|
|
966
1056
|
//#region src/authorization-request/resolve-authorization-request.ts
|
|
967
1057
|
async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
968
|
-
const { wallet, callbacks
|
|
1058
|
+
const { wallet, callbacks } = options;
|
|
969
1059
|
let authorizationRequestPayload;
|
|
970
1060
|
const parsed = parseWithErrorHandling(z$1.union([
|
|
971
1061
|
zOpenid4vpAuthorizationRequestDcApi,
|
|
1062
|
+
zOpenid4vpAuthorizationRequestIae,
|
|
972
1063
|
zOpenid4vpAuthorizationRequest,
|
|
973
1064
|
zOpenid4vpJarAuthorizationRequest
|
|
974
1065
|
]), options.authorizationRequestPayload, "Invalid authorization request. Could not parse openid4vp authorization request as openid4vp or jar auth request.");
|
|
@@ -977,25 +1068,28 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
|
977
1068
|
jar = await verifyJarRequest({
|
|
978
1069
|
jarRequestParams: parsed,
|
|
979
1070
|
callbacks,
|
|
980
|
-
wallet
|
|
1071
|
+
wallet,
|
|
1072
|
+
allowRequestUri: options.responseMode.type === "direct_post"
|
|
981
1073
|
});
|
|
982
1074
|
authorizationRequestPayload = validateOpenId4vpAuthorizationRequestPayload({
|
|
983
|
-
authorizationRequestPayload: parseWithErrorHandling(z$1.union([
|
|
1075
|
+
authorizationRequestPayload: parseWithErrorHandling(z$1.union([
|
|
1076
|
+
zOpenid4vpAuthorizationRequestDcApi,
|
|
1077
|
+
zOpenid4vpAuthorizationRequestIae,
|
|
1078
|
+
zOpenid4vpAuthorizationRequest
|
|
1079
|
+
]), jar.authorizationRequestPayload, "Invalid authorization request. Could not parse jar request payload as openid4vp auth request."),
|
|
984
1080
|
wallet,
|
|
985
1081
|
jar: true,
|
|
986
|
-
|
|
987
|
-
disableOriginValidation
|
|
1082
|
+
responseMode: options.responseMode
|
|
988
1083
|
});
|
|
989
1084
|
} else authorizationRequestPayload = validateOpenId4vpAuthorizationRequestPayload({
|
|
990
1085
|
authorizationRequestPayload: parsed,
|
|
991
1086
|
wallet,
|
|
992
1087
|
jar: false,
|
|
993
|
-
|
|
994
|
-
disableOriginValidation
|
|
1088
|
+
responseMode: options.responseMode
|
|
995
1089
|
});
|
|
996
1090
|
const version = parseAuthorizationRequestVersion(authorizationRequestPayload);
|
|
997
1091
|
let clientMetadata = authorizationRequestPayload.client_metadata;
|
|
998
|
-
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload) && !clientMetadata && authorizationRequestPayload.client_metadata_uri) clientMetadata = await fetchClientMetadata({ clientMetadataUri: authorizationRequestPayload.client_metadata_uri });
|
|
1092
|
+
if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload) && !isOpenid4vpAuthorizationRequestIae(authorizationRequestPayload) && !clientMetadata && authorizationRequestPayload.client_metadata_uri) clientMetadata = await fetchClientMetadata({ clientMetadataUri: authorizationRequestPayload.client_metadata_uri });
|
|
999
1093
|
const clientMeta = await validateOpenid4vpClientId({
|
|
1000
1094
|
authorizationRequestPayload: {
|
|
1001
1095
|
...authorizationRequestPayload,
|
|
@@ -1003,7 +1097,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
|
1003
1097
|
},
|
|
1004
1098
|
jar,
|
|
1005
1099
|
callbacks,
|
|
1006
|
-
origin,
|
|
1100
|
+
origin: options.responseMode.type === "dc_api" ? options.responseMode.expectedOrigin : void 0,
|
|
1007
1101
|
version
|
|
1008
1102
|
});
|
|
1009
1103
|
let pex;
|
|
@@ -1030,16 +1124,26 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
|
|
|
1030
1124
|
};
|
|
1031
1125
|
}
|
|
1032
1126
|
function validateOpenId4vpAuthorizationRequestPayload(options) {
|
|
1033
|
-
const { authorizationRequestPayload, wallet, jar,
|
|
1127
|
+
const { authorizationRequestPayload, wallet, jar, responseMode } = options;
|
|
1034
1128
|
if (isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) {
|
|
1129
|
+
if (responseMode.type !== "dc_api") throw new Oauth2Error(`Authorization request uses response mode ${authorizationRequestPayload.response_mode}, but expected to use a response mode in the ${responseMode.type} category.`);
|
|
1035
1130
|
validateOpenid4vpAuthorizationRequestDcApiPayload({
|
|
1036
1131
|
params: authorizationRequestPayload,
|
|
1037
1132
|
isJarRequest: jar,
|
|
1038
|
-
|
|
1039
|
-
|
|
1133
|
+
origin: responseMode.expectedOrigin
|
|
1134
|
+
});
|
|
1135
|
+
return authorizationRequestPayload;
|
|
1136
|
+
}
|
|
1137
|
+
if (isOpenid4vpAuthorizationRequestIae(authorizationRequestPayload)) {
|
|
1138
|
+
if (responseMode.type !== "iae") throw new Oauth2Error(`Authorization request uses response mode ${authorizationRequestPayload.response_mode}, but expected to use a response mode in the ${responseMode.type} category.`);
|
|
1139
|
+
validateOpenid4vpAuthorizationRequestIaePayload({
|
|
1140
|
+
params: authorizationRequestPayload,
|
|
1141
|
+
isJarRequest: jar,
|
|
1142
|
+
expectedUrl: responseMode.expectedUrl
|
|
1040
1143
|
});
|
|
1041
1144
|
return authorizationRequestPayload;
|
|
1042
1145
|
}
|
|
1146
|
+
if (responseMode.type !== "direct_post") throw new Oauth2Error(`Authorization request uses response mode ${authorizationRequestPayload.response_mode}, but expected to use a response mode in the ${responseMode.type} category.`);
|
|
1043
1147
|
validateOpenid4vpAuthorizationRequestPayload({
|
|
1044
1148
|
params: authorizationRequestPayload,
|
|
1045
1149
|
walletVerificationOptions: wallet
|
|
@@ -1699,5 +1803,5 @@ var Openid4vpVerifier = class {
|
|
|
1699
1803
|
};
|
|
1700
1804
|
|
|
1701
1805
|
//#endregion
|
|
1702
|
-
export { JarmMode, Openid4vpClient, Openid4vpVerifier, calculateX509HashClientIdPrefixValue, createOpenid4vpAuthorizationRequest, createOpenid4vpAuthorizationResponse, extractEncryptionJwkFromJwks, getOpenid4vpClientId, isJarmResponseMode, isOpenid4vpAuthorizationRequestDcApi, parseAuthorizationRequestVersion, parseDcqlVpToken, parseJarmAuthorizationResponse, parseOpenid4VpAuthorizationResponsePayload, parseOpenid4vpAuthorizationRequest, parseOpenid4vpAuthorizationResponse, parsePexVpToken, parseTransactionData, resolveOpenid4vpAuthorizationRequest, submitOpenid4vpAuthorizationResponse, validateOpenid4vpAuthorizationRequestPayload, validateOpenid4vpAuthorizationResponsePayload, verifyJarmAuthorizationResponse, zClientIdPrefix, zClientMetadata, zCredentialFormat, zJarmClientMetadata, zOpenid4vpAuthorizationResponse, zProofFormat, zVerifierAttestations, zWalletMetadata };
|
|
1806
|
+
export { JarmMode, Openid4vpClient, Openid4vpVerifier, calculateX509HashClientIdPrefixValue, createOpenid4vpAuthorizationRequest, createOpenid4vpAuthorizationResponse, extractEncryptionJwkFromJwks, getOpenid4vpClientId, isJarmResponseMode, isOpenid4vpAuthorizationRequestDcApi, isOpenid4vpAuthorizationRequestIae, parseAuthorizationRequestVersion, parseDcqlVpToken, parseJarmAuthorizationResponse, parseOpenid4VpAuthorizationResponsePayload, parseOpenid4vpAuthorizationRequest, parseOpenid4vpAuthorizationResponse, parsePexVpToken, parseTransactionData, resolveOpenid4vpAuthorizationRequest, submitOpenid4vpAuthorizationResponse, validateOpenid4vpAuthorizationRequestDcApiPayload, validateOpenid4vpAuthorizationRequestIaePayload, validateOpenid4vpAuthorizationRequestPayload, validateOpenid4vpAuthorizationResponsePayload, verifyJarmAuthorizationResponse, zClientIdPrefix, zClientMetadata, zCredentialFormat, zJarmClientMetadata, zOpenid4vpAuthorizationResponse, zProofFormat, zVerifierAttestations, zWalletMetadata };
|
|
1703
1807
|
//# sourceMappingURL=index.mjs.map
|