@openid4vc/openid4vp 0.3.0-alpha-20250322171044 → 0.3.0-alpha-20250324183425

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
@@ -62,7 +62,7 @@ module.exports = __toCommonJS(src_exports);
62
62
 
63
63
  // src/client-identifier-scheme/parse-client-identifier-scheme.ts
64
64
  var import_oauth23 = require("@openid4vc/oauth2");
65
- var import_utils4 = require("@openid4vc/utils");
65
+ var import_utils5 = require("@openid4vc/utils");
66
66
 
67
67
  // src/authorization-request/z-authorization-request-dc-api.ts
68
68
  var import_zod5 = require("zod");
@@ -182,7 +182,7 @@ var zOpenid4vpAuthorizationRequest = import_zod4.z.object({
182
182
  client_metadata_uri: import_utils3.zHttpsUrl.optional(),
183
183
  state: import_zod4.z.string().optional(),
184
184
  transaction_data: import_zod4.z.array(import_zod4.z.string().base64url()).optional(),
185
- trust_chain: import_zod4.z.unknown().optional(),
185
+ trust_chain: import_zod4.z.array(import_zod4.z.string()).nonempty().optional(),
186
186
  client_id_scheme: import_zod4.z.enum([
187
187
  "pre-registered",
188
188
  "redirect_uri",
@@ -222,13 +222,15 @@ var zOpenid4vpAuthorizationRequestDcApi = zOpenid4vpAuthorizationRequest.pick({
222
222
  scope: import_zod5.z.never().optional()
223
223
  // TODO: should we disallow any properties specifically, such as redirect_uri and response_uri?
224
224
  });
225
+ function isOpenid4vpResponseModeDcApi(responseMode) {
226
+ return responseMode !== void 0 && zOpenid4vpResponseModeDcApi.options.includes(responseMode);
227
+ }
225
228
  function isOpenid4vpAuthorizationRequestDcApi(request) {
226
- return request.response_mode !== void 0 && zOpenid4vpResponseModeDcApi.options.includes(
227
- request.response_mode
228
- );
229
+ return isOpenid4vpResponseModeDcApi(request.response_mode);
229
230
  }
230
231
 
231
232
  // src/client-identifier-scheme/z-client-id-scheme.ts
233
+ var import_utils4 = require("@openid4vc/utils");
232
234
  var import_zod6 = require("zod");
233
235
  var zClientIdScheme = import_zod6.z.enum([
234
236
  "pre-registered",
@@ -240,6 +242,18 @@ var zClientIdScheme = import_zod6.z.enum([
240
242
  "x509_san_uri",
241
243
  "web-origin"
242
244
  ]);
245
+ var zClientIdToClientIdScheme = import_zod6.z.union(
246
+ [
247
+ import_zod6.z.string({ message: "client_id MUST be a string" }).includes(":").transform((clientId) => {
248
+ const clientIdScheme = clientId.split(":")[0];
249
+ return clientIdScheme === "http" && (0, import_utils4.getGlobalConfig)().allowInsecureUrls ? "https" : clientIdScheme;
250
+ }).pipe(zClientIdScheme.exclude(["pre-registered"])),
251
+ import_zod6.z.string().refine((clientId) => clientId.includes(":") === false).transform(() => "pre-registered")
252
+ ],
253
+ {
254
+ message: `client_id must either start with a known prefix followed by ':' or contain no ':'. Known prefixes are ${zClientIdScheme.exclude(["pre-registered"]).options.join(", ")}`
255
+ }
256
+ );
243
257
  var zLegacyClientIdScheme = import_zod6.z.enum([
244
258
  "pre-registered",
245
259
  "redirect_uri",
@@ -249,58 +263,80 @@ var zLegacyClientIdScheme = import_zod6.z.enum([
249
263
  "x509_san_dns",
250
264
  "x509_san_uri"
251
265
  ]);
266
+ var zLegacyClientIdSchemeToClientIdScheme = zLegacyClientIdScheme.optional().default("pre-registered").transform((clientIdScheme) => clientIdScheme === "entity_id" ? "https" : clientIdScheme);
252
267
 
253
268
  // src/client-identifier-scheme/parse-client-identifier-scheme.ts
254
269
  function getOpenid4vpClientId(options) {
255
- if (isOpenid4vpAuthorizationRequestDcApi(options.authorizationRequestPayload)) {
256
- if (!options.origin) {
270
+ if (isOpenid4vpResponseModeDcApi(options.responseMode)) {
271
+ if (!options.clientId) {
272
+ if (!options.origin) {
273
+ throw new import_oauth23.Oauth2ServerErrorResponseError({
274
+ error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
275
+ error_description: "Failed to parse client identifier. 'origin' is required for requests without a client_id and response_mode 'dc_api' and 'dc_api.jwt'"
276
+ });
277
+ }
278
+ return {
279
+ clientIdScheme: "web-origin",
280
+ clientId: `web-origin:${options.origin}`
281
+ };
282
+ }
283
+ const parsedClientIdScheme2 = zClientIdToClientIdScheme.safeParse(options.clientId);
284
+ if (!parsedClientIdScheme2.success) {
257
285
  throw new import_oauth23.Oauth2ServerErrorResponseError({
258
286
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
259
- error_description: "Failed to parse client identifier. 'origin' is required for requests with response_mode 'dc_api' and 'dc_api.jwt'"
287
+ error_description: `Failed to parse client identifier. Unsupported client_id '${options.clientId}'.`
260
288
  });
261
289
  }
262
290
  return {
263
- clientId: options.authorizationRequestPayload.client_id ?? `web-origin:${options.origin}`
291
+ clientId: options.clientId,
292
+ clientIdScheme: parsedClientIdScheme2.data
264
293
  };
265
294
  }
266
- if (!options.authorizationRequestPayload.client_id) {
295
+ if (!options.clientId) {
267
296
  throw new import_oauth23.Oauth2ServerErrorResponseError({
268
297
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
269
- error_description: `Failed to parse client identifier. Missing required client_id parameter for response_mode '${options.authorizationRequestPayload.response_mode}'.`
298
+ error_description: `Failed to parse client identifier. Missing required client_id parameter for response_mode '${options.responseMode}'.`
270
299
  });
271
300
  }
272
- if (options.authorizationRequestPayload.client_id_scheme) {
273
- const parsedClientIdScheme = zLegacyClientIdScheme.safeParse(options.authorizationRequestPayload.client_id_scheme);
274
- if (!parsedClientIdScheme.success) {
301
+ if (options.legacyClientIdScheme) {
302
+ const parsedClientIdScheme2 = zLegacyClientIdSchemeToClientIdScheme.safeParse(options.legacyClientIdScheme);
303
+ if (!parsedClientIdScheme2.success) {
275
304
  throw new import_oauth23.Oauth2ServerErrorResponseError({
276
305
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
277
- error_description: `Failed to parse client identifier. Unsupported client_id_scheme value '${options.authorizationRequestPayload.client_id_scheme}'.`
306
+ error_description: `Failed to parse client identifier. Unsupported client_id_scheme value '${options.legacyClientIdScheme}'.`
278
307
  });
279
308
  }
280
- const clientIdScheme = parsedClientIdScheme.data === "entity_id" ? "https" : parsedClientIdScheme.data;
281
- if (clientIdScheme === "https" || clientIdScheme === "did" || clientIdScheme === "pre-registered") {
282
- return { clientId: options.authorizationRequestPayload.client_id };
283
- }
309
+ const clientIdScheme = parsedClientIdScheme2.data;
284
310
  return {
285
- clientId: `${clientIdScheme}:${options.authorizationRequestPayload.client_id}`,
286
- legacyClientId: options.authorizationRequestPayload.client_id
311
+ clientId: clientIdScheme === "https" || clientIdScheme === "did" || clientIdScheme === "pre-registered" ? options.clientId : `${parsedClientIdScheme2.data}:${options.clientId}`,
312
+ clientIdScheme: parsedClientIdScheme2.data,
313
+ legacyClientId: options.clientId
287
314
  };
288
315
  }
316
+ const parsedClientIdScheme = zClientIdToClientIdScheme.safeParse(options.clientId);
317
+ if (!parsedClientIdScheme.success) {
318
+ throw new import_oauth23.Oauth2ServerErrorResponseError({
319
+ error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
320
+ error_description: `Failed to parse client identifier. Unsupported client_id '${options.clientId}'.`
321
+ });
322
+ }
289
323
  return {
290
- clientId: options.authorizationRequestPayload.client_id
324
+ clientId: options.clientId,
325
+ clientIdScheme: parsedClientIdScheme.data
291
326
  };
292
327
  }
293
- function parseClientIdentifier(options, parserConfig) {
328
+ function validateOpenid4vpClientId(options, parserConfig) {
294
329
  const { authorizationRequestPayload, jar, origin } = options;
295
330
  const parserConfigWithDefaults = {
296
331
  supportedSchemes: parserConfig?.supportedSchemes || Object.values(zClientIdScheme.options)
297
332
  };
298
- const { clientId, legacyClientId } = getOpenid4vpClientId({
299
- authorizationRequestPayload,
333
+ const { clientId, legacyClientId, clientIdScheme } = getOpenid4vpClientId({
334
+ clientId: authorizationRequestPayload.client_id,
335
+ legacyClientIdScheme: authorizationRequestPayload.client_id_scheme,
336
+ responseMode: authorizationRequestPayload.response_mode,
300
337
  origin
301
338
  });
302
- const colonIndex = clientId.indexOf(":");
303
- if (colonIndex === -1) {
339
+ if (clientIdScheme === "pre-registered") {
304
340
  return {
305
341
  scheme: "pre-registered",
306
342
  identifier: clientId,
@@ -309,17 +345,16 @@ function parseClientIdentifier(options, parserConfig) {
309
345
  clientMetadata: authorizationRequestPayload.client_metadata
310
346
  };
311
347
  }
312
- const schemePart = clientId.substring(0, colonIndex);
348
+ const colonIndex = clientId.indexOf(":");
313
349
  const identifierPart = clientId.substring(colonIndex + 1);
314
- if (!parserConfigWithDefaults.supportedSchemes.includes(schemePart)) {
350
+ if (!parserConfigWithDefaults.supportedSchemes.includes(clientIdScheme)) {
315
351
  throw new import_oauth23.Oauth2ServerErrorResponseError({
316
352
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
317
- error_description: `Unsupported client identifier scheme. ${schemePart} is not supported.`
353
+ error_description: `Unsupported client identifier scheme. ${clientIdScheme} is not supported.`
318
354
  });
319
355
  }
320
- const scheme = schemePart;
321
- if (scheme === "https") {
322
- if (!import_utils4.zHttpsUrl.safeParse(clientId).success) {
356
+ if (clientIdScheme === "https") {
357
+ if (!import_utils5.zHttpsUrl.safeParse(clientId).success) {
323
358
  throw new import_oauth23.Oauth2ServerErrorResponseError(
324
359
  {
325
360
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
@@ -330,15 +365,27 @@ function parseClientIdentifier(options, parserConfig) {
330
365
  }
331
366
  );
332
367
  }
368
+ if (!jar) {
369
+ throw new import_oauth23.Oauth2ServerErrorResponseError({
370
+ error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
371
+ error_description: 'Using client identifier scheme "https" requires a signed JAR request.'
372
+ });
373
+ }
374
+ if (jar.signer.method !== "federation") {
375
+ throw new import_oauth23.Oauth2ServerErrorResponseError({
376
+ error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
377
+ error_description: "Something went wrong. The JWT signer method is not federation but the client identifier scheme is https."
378
+ });
379
+ }
333
380
  return {
334
- scheme,
381
+ scheme: clientIdScheme,
335
382
  identifier: clientId,
336
383
  originalValue: clientId,
337
384
  legacyClientId,
338
385
  trustChain: authorizationRequestPayload.trust_chain
339
386
  };
340
387
  }
341
- if (scheme === "redirect_uri") {
388
+ if (clientIdScheme === "redirect_uri") {
342
389
  if (jar) {
343
390
  throw new import_oauth23.Oauth2ServerErrorResponseError({
344
391
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
@@ -352,20 +399,26 @@ function parseClientIdentifier(options, parserConfig) {
352
399
  });
353
400
  }
354
401
  return {
355
- scheme,
402
+ scheme: clientIdScheme,
356
403
  identifier: identifierPart,
357
404
  originalValue: clientId,
358
405
  legacyClientId,
359
406
  redirectUri: authorizationRequestPayload.redirect_uri ?? authorizationRequestPayload.response_uri
360
407
  };
361
408
  }
362
- if (scheme === "did") {
409
+ if (clientIdScheme === "did") {
363
410
  if (!jar) {
364
411
  throw new import_oauth23.Oauth2ServerErrorResponseError({
365
412
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
366
413
  error_description: 'Using client identifier scheme "did" requires a signed JAR request.'
367
414
  });
368
415
  }
416
+ if (jar.signer.method !== "did") {
417
+ throw new import_oauth23.Oauth2ServerErrorResponseError({
418
+ error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
419
+ error_description: "Something went wrong. The JWT signer method is not did but the client identifier scheme is did."
420
+ });
421
+ }
369
422
  if (!clientId.startsWith("did:")) {
370
423
  throw new import_oauth23.Oauth2ServerErrorResponseError({
371
424
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
@@ -385,14 +438,14 @@ function parseClientIdentifier(options, parserConfig) {
385
438
  });
386
439
  }
387
440
  return {
388
- scheme,
441
+ scheme: clientIdScheme,
389
442
  identifier: clientId,
390
443
  originalValue: clientId,
391
444
  legacyClientId,
392
445
  didUrl: jar.signer.publicJwk.kid
393
446
  };
394
447
  }
395
- if (scheme === "x509_san_dns" || scheme === "x509_san_uri") {
448
+ if (clientIdScheme === "x509_san_dns" || clientIdScheme === "x509_san_uri") {
396
449
  if (!jar) {
397
450
  throw new import_oauth23.Oauth2ServerErrorResponseError({
398
451
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
@@ -405,7 +458,7 @@ function parseClientIdentifier(options, parserConfig) {
405
458
  error_description: "Something went wrong. The JWT signer method is not x5c but the client identifier scheme is x509_san_dns."
406
459
  });
407
460
  }
408
- if (scheme === "x509_san_dns") {
461
+ if (clientIdScheme === "x509_san_dns") {
409
462
  if (!options.callbacks.getX509CertificateMetadata) {
410
463
  throw new import_oauth23.Oauth2ServerErrorResponseError(
411
464
  {
@@ -425,14 +478,14 @@ function parseClientIdentifier(options, parserConfig) {
425
478
  }
426
479
  if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload)) {
427
480
  const uri = authorizationRequestPayload.redirect_uri ?? authorizationRequestPayload.response_uri;
428
- if (!uri || new import_utils4.URL(uri).hostname !== identifierPart) {
481
+ if (!uri || new import_utils5.URL(uri).hostname !== identifierPart) {
429
482
  throw new import_oauth23.Oauth2ServerErrorResponseError({
430
483
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
431
484
  error_description: "Invalid client identifier. The fully qualified domain name of the redirect_uri value MUST match the Client Identifier without the prefix x509_san_dns."
432
485
  });
433
486
  }
434
487
  }
435
- } else if (scheme === "x509_san_uri") {
488
+ } else if (clientIdScheme === "x509_san_uri") {
436
489
  if (!options.callbacks.getX509CertificateMetadata) {
437
490
  throw new import_oauth23.Oauth2ServerErrorResponseError(
438
491
  {
@@ -461,23 +514,23 @@ function parseClientIdentifier(options, parserConfig) {
461
514
  }
462
515
  }
463
516
  return {
464
- scheme,
517
+ scheme: clientIdScheme,
465
518
  identifier: identifierPart,
466
519
  originalValue: clientId,
467
520
  legacyClientId,
468
521
  x5c: jar.signer.x5c
469
522
  };
470
523
  }
471
- if (scheme === "web-origin") {
524
+ if (clientIdScheme === "web-origin") {
472
525
  return {
473
- scheme,
526
+ scheme: clientIdScheme,
474
527
  identifier: identifierPart,
475
528
  originalValue: clientId,
476
529
  legacyClientId,
477
530
  clientMetadata: authorizationRequestPayload.client_metadata
478
531
  };
479
532
  }
480
- if (scheme === "verifier_attestation") {
533
+ if (clientIdScheme === "verifier_attestation") {
481
534
  if (!jar) {
482
535
  throw new import_oauth23.Oauth2ServerErrorResponseError({
483
536
  error: import_oauth23.Oauth2ErrorCodes.InvalidRequest,
@@ -486,7 +539,7 @@ function parseClientIdentifier(options, parserConfig) {
486
539
  }
487
540
  }
488
541
  return {
489
- scheme,
542
+ scheme: clientIdScheme,
490
543
  identifier: identifierPart,
491
544
  legacyClientId,
492
545
  originalValue: clientId
@@ -511,7 +564,7 @@ function extractJwksFromClientMetadata(clientMetadata) {
511
564
 
512
565
  // src/jarm/jarm-authorization-response/jarm-validate-authorization-response.ts
513
566
  var import_oauth25 = require("@openid4vc/oauth2");
514
- var import_utils5 = require("@openid4vc/utils");
567
+ var import_utils6 = require("@openid4vc/utils");
515
568
 
516
569
  // src/jarm/jarm-authorization-response/z-jarm-authorization-response.ts
517
570
  var import_oauth24 = require("@openid4vc/oauth2");
@@ -543,7 +596,7 @@ var jarmAuthorizationResponseValidate = (options) => {
543
596
  `Invalid 'aud' claim in JARM authorization response. Expected '${expectedClientId}' received '${JSON.stringify(authorizationResponse.aud)}'.`
544
597
  );
545
598
  }
546
- if (authorizationResponse.exp !== void 0 && authorizationResponse.exp < (0, import_utils5.dateToSeconds)()) {
599
+ if (authorizationResponse.exp !== void 0 && authorizationResponse.exp < (0, import_utils6.dateToSeconds)()) {
547
600
  throw new import_oauth25.Oauth2Error("Jarm auth response is expired.");
548
601
  }
549
602
  };
@@ -611,11 +664,11 @@ async function verifyJarmAuthorizationResponse(options) {
611
664
 
612
665
  // src/authorization-request/create-authorization-request.ts
613
666
  var import_oauth210 = require("@openid4vc/oauth2");
614
- var import_utils8 = require("@openid4vc/utils");
667
+ var import_utils9 = require("@openid4vc/utils");
615
668
 
616
669
  // src/jar/create-jar-authorization-request.ts
617
670
  var import_oauth27 = require("@openid4vc/oauth2");
618
- var import_utils6 = require("@openid4vc/utils");
671
+ var import_utils7 = require("@openid4vc/utils");
619
672
  async function createJarAuthorizationRequest(options) {
620
673
  const { jwtSigner, jweEncryptor, authorizationRequestPayload, requestUri, callbacks } = options;
621
674
  let authorizationRequestJwt;
@@ -624,8 +677,8 @@ async function createJarAuthorizationRequest(options) {
624
677
  const { jwt, signerJwk } = await callbacks.signJwt(jwtSigner, {
625
678
  header: { ...(0, import_oauth27.jwtHeaderFromJwtSigner)(jwtSigner), typ: "oauth-authz-req+jwt" },
626
679
  payload: {
627
- iat: (0, import_utils6.dateToSeconds)(now),
628
- exp: (0, import_utils6.dateToSeconds)((0, import_utils6.addSecondsToDate)(now, options.expiresInSeconds)),
680
+ iat: (0, import_utils7.dateToSeconds)(now),
681
+ exp: (0, import_utils7.dateToSeconds)((0, import_utils7.addSecondsToDate)(now, options.expiresInSeconds)),
629
682
  ...options.additionalJwtPayload,
630
683
  ...authorizationRequestPayload
631
684
  }
@@ -643,7 +696,7 @@ async function createJarAuthorizationRequest(options) {
643
696
 
644
697
  // src/authorization-request/validate-authorization-request.ts
645
698
  var import_oauth28 = require("@openid4vc/oauth2");
646
- var import_utils7 = require("@openid4vc/utils");
699
+ var import_utils8 = require("@openid4vc/utils");
647
700
  var validateOpenid4vpAuthorizationRequestPayload = (options) => {
648
701
  const { params, walletVerificationOptions } = options;
649
702
  if (!params.redirect_uri && !params.response_uri) {
@@ -678,7 +731,7 @@ var validateOpenid4vpAuthorizationRequestPayload = (options) => {
678
731
  error_description: `The 'request_uri_method' parameter MUST be 'GET' or 'POST'. Current: ${params.request_uri_method}`
679
732
  });
680
733
  }
681
- if (params.trust_chain && !import_utils7.zHttpsUrl.safeParse(params.client_id).success) {
734
+ if (params.trust_chain && !import_utils8.zHttpsUrl.safeParse(params.client_id).success) {
682
735
  throw new import_oauth28.Oauth2ServerErrorResponseError({
683
736
  error: import_oauth28.Oauth2ErrorCodes.InvalidRequest,
684
737
  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://.'
@@ -742,7 +795,7 @@ async function createOpenid4vpAuthorizationRequest(options) {
742
795
  let additionalJwtPayload;
743
796
  let authorizationRequestPayload;
744
797
  if (isOpenid4vpAuthorizationRequestDcApi(options.authorizationRequestPayload)) {
745
- authorizationRequestPayload = (0, import_utils8.parseWithErrorHandling)(
798
+ authorizationRequestPayload = (0, import_utils9.parseWithErrorHandling)(
746
799
  zOpenid4vpAuthorizationRequestDcApi,
747
800
  options.authorizationRequestPayload,
748
801
  "Invalid authorization request. Could not parse openid4vp dc_api authorization request."
@@ -758,7 +811,7 @@ async function createOpenid4vpAuthorizationRequest(options) {
758
811
  disableOriginValidation: true
759
812
  });
760
813
  } else {
761
- authorizationRequestPayload = (0, import_utils8.parseWithErrorHandling)(
814
+ authorizationRequestPayload = (0, import_utils9.parseWithErrorHandling)(
762
815
  zOpenid4vpAuthorizationRequest,
763
816
  options.authorizationRequestPayload,
764
817
  "Invalid authorization request. Could not parse openid4vp authorization request."
@@ -778,10 +831,10 @@ async function createOpenid4vpAuthorizationRequest(options) {
778
831
  additionalJwtPayload,
779
832
  callbacks
780
833
  });
781
- const url2 = new import_utils8.URL(scheme);
782
- url2.search = `?${new import_utils8.URLSearchParams([
834
+ const url2 = new import_utils9.URL(scheme);
835
+ url2.search = `?${new import_utils9.URLSearchParams([
783
836
  ...url2.searchParams.entries(),
784
- ...(0, import_utils8.objectToQueryParams)(jarResult.jarAuthorizationRequest).entries(),
837
+ ...(0, import_utils9.objectToQueryParams)(jarResult.jarAuthorizationRequest).entries(),
785
838
  // Add client_id_scheme if defined for backwards compat
786
839
  ...authorizationRequestPayload.client_id_scheme ? [["client_id_scheme", authorizationRequestPayload.client_id_scheme]] : []
787
840
  ]).toString()}`;
@@ -792,10 +845,10 @@ async function createOpenid4vpAuthorizationRequest(options) {
792
845
  jar: { ...jar, ...jarResult }
793
846
  };
794
847
  }
795
- const url = new import_utils8.URL(scheme);
796
- url.search = `?${new import_utils8.URLSearchParams([
848
+ const url = new import_utils9.URL(scheme);
849
+ url.search = `?${new import_utils9.URLSearchParams([
797
850
  ...url.searchParams.entries(),
798
- ...(0, import_utils8.objectToQueryParams)(authorizationRequestPayload).entries()
851
+ ...(0, import_utils9.objectToQueryParams)(authorizationRequestPayload).entries()
799
852
  ]).toString()}`;
800
853
  return {
801
854
  authorizationRequestPayload,
@@ -807,16 +860,16 @@ async function createOpenid4vpAuthorizationRequest(options) {
807
860
 
808
861
  // src/authorization-request/parse-authorization-request-params.ts
809
862
  var import_oauth212 = require("@openid4vc/oauth2");
810
- var import_utils10 = require("@openid4vc/utils");
863
+ var import_utils11 = require("@openid4vc/utils");
811
864
  var import_zod10 = __toESM(require("zod"));
812
865
 
813
866
  // src/jar/z-jar-authorization-request.ts
814
867
  var import_oauth211 = require("@openid4vc/oauth2");
815
- var import_utils9 = require("@openid4vc/utils");
868
+ var import_utils10 = require("@openid4vc/utils");
816
869
  var import_zod9 = require("zod");
817
870
  var zJarAuthorizationRequest = import_zod9.z.object({
818
871
  request: import_zod9.z.optional(import_zod9.z.string()),
819
- request_uri: import_zod9.z.optional(import_utils9.zHttpsUrl),
872
+ request_uri: import_zod9.z.optional(import_utils10.zHttpsUrl),
820
873
  request_uri_method: import_zod9.z.optional(import_zod9.z.string()),
821
874
  client_id: import_zod9.z.optional(import_zod9.z.string())
822
875
  }).passthrough();
@@ -847,7 +900,7 @@ function parseOpenid4vpAuthorizationRequest(options) {
847
900
  let params;
848
901
  if (typeof authorizationRequest === "string") {
849
902
  if (authorizationRequest.includes("://")) {
850
- params = (0, import_utils10.parseWithErrorHandling)(
903
+ params = (0, import_utils11.parseWithErrorHandling)(
851
904
  zOpenid4vpAuthorizationRequestFromUriParams,
852
905
  authorizationRequest,
853
906
  "Unable to parse openid4vp authorization request uri to a valid object"
@@ -861,7 +914,7 @@ function parseOpenid4vpAuthorizationRequest(options) {
861
914
  } else {
862
915
  params = authorizationRequest;
863
916
  }
864
- const parsedRequest = (0, import_utils10.parseWithErrorHandling)(
917
+ const parsedRequest = (0, import_utils11.parseWithErrorHandling)(
865
918
  import_zod10.default.union([zOpenid4vpAuthorizationRequest, zJarAuthorizationRequest, zOpenid4vpAuthorizationRequestDcApi]),
866
919
  params
867
920
  );
@@ -888,19 +941,19 @@ function parseOpenid4vpAuthorizationRequest(options) {
888
941
 
889
942
  // src/authorization-request/resolve-authorization-request.ts
890
943
  var import_oauth219 = require("@openid4vc/oauth2");
891
- var import_utils14 = require("@openid4vc/utils");
892
- var import_zod13 = __toESM(require("zod"));
944
+ var import_utils15 = require("@openid4vc/utils");
945
+ var import_zod14 = __toESM(require("zod"));
893
946
 
894
947
  // src/fetch-client-metadata.ts
895
948
  var import_oauth213 = require("@openid4vc/oauth2");
896
- var import_utils11 = require("@openid4vc/utils");
949
+ var import_utils12 = require("@openid4vc/utils");
897
950
  async function fetchClientMetadata(options) {
898
951
  const { fetch, clientMetadataUri } = options;
899
- const fetcher = (0, import_utils11.createZodFetcher)(fetch);
900
- const { result, response } = await fetcher(zClientMetadata, import_utils11.ContentType.Json, clientMetadataUri, {
952
+ const fetcher = (0, import_utils12.createZodFetcher)(fetch);
953
+ const { result, response } = await fetcher(zClientMetadata, import_utils12.ContentType.Json, clientMetadataUri, {
901
954
  method: "GET",
902
955
  headers: {
903
- Accept: import_utils11.ContentType.Json
956
+ Accept: import_utils12.ContentType.Json
904
957
  }
905
958
  });
906
959
  if (!response.ok) {
@@ -920,6 +973,7 @@ async function fetchClientMetadata(options) {
920
973
 
921
974
  // src/jar/handle-jar-request/verify-jar-request.ts
922
975
  var import_oauth217 = require("@openid4vc/oauth2");
976
+ var import_zod12 = __toESM(require("zod"));
923
977
 
924
978
  // src/version.ts
925
979
  var import_oauth214 = require("@openid4vc/oauth2");
@@ -985,7 +1039,7 @@ function parseAuthorizationRequestVersion(request) {
985
1039
 
986
1040
  // src/jar/jar-request-object/fetch-jar-request-object.ts
987
1041
  var import_oauth215 = require("@openid4vc/oauth2");
988
- var import_utils12 = require("@openid4vc/utils");
1042
+ var import_utils13 = require("@openid4vc/utils");
989
1043
  async function fetchJarRequestObject(options) {
990
1044
  const { requestUri, clientIdentifierScheme, method, wallet, fetch } = options;
991
1045
  let requestBody = wallet.metadata ? { wallet_metadata: wallet.metadata, wallet_nonce: wallet.nonce } : void 0;
@@ -993,12 +1047,12 @@ async function fetchJarRequestObject(options) {
993
1047
  const { request_object_signing_alg_values_supported, ...rest } = requestBody.wallet_metadata;
994
1048
  requestBody = { ...requestBody, wallet_metadata: { ...rest } };
995
1049
  }
996
- const response = await (0, import_utils12.createFetcher)(fetch)(requestUri, {
1050
+ const response = await (0, import_utils13.createFetcher)(fetch)(requestUri, {
997
1051
  method,
998
- body: method === "POST" ? (0, import_utils12.objectToQueryParams)(wallet.metadata ?? {}) : void 0,
1052
+ body: method === "POST" ? (0, import_utils13.objectToQueryParams)(wallet.metadata ?? {}) : void 0,
999
1053
  headers: {
1000
- Accept: `${import_utils12.ContentType.OAuthAuthorizationRequestJwt}, ${import_utils12.ContentType.Jwt};q=0.9, text/plain`,
1001
- "Content-Type": import_utils12.ContentType.XWwwFormUrlencoded
1054
+ Accept: `${import_utils13.ContentType.OAuthAuthorizationRequestJwt}, ${import_utils13.ContentType.Jwt};q=0.9, text/plain`,
1055
+ "Content-Type": import_utils13.ContentType.XWwwFormUrlencoded
1002
1056
  }
1003
1057
  }).catch(() => {
1004
1058
  throw new import_oauth215.Oauth2ServerErrorResponseError({
@@ -1024,6 +1078,8 @@ var zJarRequestObjectPayload = import_zod11.z.object({
1024
1078
  }).passthrough();
1025
1079
 
1026
1080
  // src/jar/handle-jar-request/verify-jar-request.ts
1081
+ var zSignedAuthorizationRequestJwtHeaderTyp = import_zod12.default.literal("oauth-authz-req+jwt");
1082
+ var signedAuthorizationRequestJwtHeaderTyp = zSignedAuthorizationRequestJwtHeaderTyp.value;
1027
1083
  async function verifyJarRequest(options) {
1028
1084
  const { callbacks, wallet = {} } = options;
1029
1085
  const jarRequestParams = validateJarRequestParams(options);
@@ -1103,7 +1159,41 @@ async function decryptJarRequest(options) {
1103
1159
  async function verifyJarRequestObject(options) {
1104
1160
  const { decryptedRequestObject, callbacks } = options;
1105
1161
  const jwt = (0, import_oauth217.decodeJwt)({ jwt: decryptedRequestObject, payloadSchema: zJarRequestObjectPayload });
1106
- const jwtSigner = (0, import_oauth217.jwtSignerFromJwt)(jwt);
1162
+ let jwtSigner;
1163
+ const { clientIdScheme } = getOpenid4vpClientId({
1164
+ responseMode: jwt.payload.response_mode,
1165
+ clientId: jwt.payload.client_id,
1166
+ legacyClientIdScheme: jwt.payload.client_id_scheme
1167
+ });
1168
+ const clientIdToSignerMethod = {
1169
+ did: ["did"],
1170
+ "pre-registered": ["custom", "did", "jwk"],
1171
+ "web-origin": [],
1172
+ // no signing allowed
1173
+ redirect_uri: [],
1174
+ // no signing allowed
1175
+ // Not 100% sure which one are allowed?
1176
+ verifier_attestation: ["did", "federation", "jwk", "x5c", "custom"],
1177
+ x509_san_dns: ["x5c"],
1178
+ x509_san_uri: ["x5c"],
1179
+ // Handled separately
1180
+ https: []
1181
+ };
1182
+ if (clientIdScheme === "https") {
1183
+ if (!jwt.header.kid) {
1184
+ throw new import_oauth217.Oauth2Error(
1185
+ `When OpenID Federation is used for signed authorization request, the 'kid' parameter is required.`
1186
+ );
1187
+ }
1188
+ jwtSigner = {
1189
+ method: "federation",
1190
+ alg: jwt.header.alg,
1191
+ trustChain: jwt.payload.trust_chain,
1192
+ kid: jwt.header.kid
1193
+ };
1194
+ } else {
1195
+ jwtSigner = (0, import_oauth217.jwtSignerFromJwt)({ ...jwt, allowedSignerMethods: clientIdToSignerMethod[clientIdScheme] });
1196
+ }
1107
1197
  const { signer } = await (0, import_oauth217.verifyJwt)({
1108
1198
  verifyJwtCallback: callbacks.verifyJwt,
1109
1199
  compact: decryptedRequestObject,
@@ -1127,21 +1217,21 @@ async function verifyJarRequestObject(options) {
1127
1217
 
1128
1218
  // src/transaction-data/parse-transaction-data.ts
1129
1219
  var import_oauth218 = require("@openid4vc/oauth2");
1130
- var import_utils13 = require("@openid4vc/utils");
1220
+ var import_utils14 = require("@openid4vc/utils");
1131
1221
 
1132
1222
  // src/transaction-data/z-transaction-data.ts
1133
- var import_zod12 = require("zod");
1134
- var zTransactionEntry = import_zod12.z.object({
1135
- type: import_zod12.z.string(),
1136
- credential_ids: import_zod12.z.array(import_zod12.z.string()).nonempty(),
1137
- transaction_data_hashes_alg: import_zod12.z.array(import_zod12.z.string()).optional()
1223
+ var import_zod13 = require("zod");
1224
+ var zTransactionEntry = import_zod13.z.object({
1225
+ type: import_zod13.z.string(),
1226
+ credential_ids: import_zod13.z.array(import_zod13.z.string()).nonempty(),
1227
+ transaction_data_hashes_alg: import_zod13.z.array(import_zod13.z.string()).optional()
1138
1228
  }).passthrough();
1139
- var zTransactionData = import_zod12.z.array(zTransactionEntry);
1229
+ var zTransactionData = import_zod13.z.array(zTransactionEntry);
1140
1230
 
1141
1231
  // src/transaction-data/parse-transaction-data.ts
1142
1232
  function parseTransactionData(options) {
1143
1233
  const { transactionData } = options;
1144
- const decoded = transactionData.map((tdEntry) => (0, import_utils13.parseIfJson)((0, import_utils13.encodeToUtf8String)((0, import_utils13.decodeBase64)(tdEntry))));
1234
+ const decoded = transactionData.map((tdEntry) => (0, import_utils14.parseIfJson)((0, import_utils14.encodeToUtf8String)((0, import_utils14.decodeBase64)(tdEntry))));
1145
1235
  const parsedResult = zTransactionData.safeParse(decoded);
1146
1236
  if (!parsedResult.success) {
1147
1237
  throw new import_oauth218.Oauth2ServerErrorResponseError({
@@ -1160,16 +1250,16 @@ function parseTransactionData(options) {
1160
1250
  async function resolveOpenid4vpAuthorizationRequest(options) {
1161
1251
  const { wallet, callbacks, origin, disableOriginValidation } = options;
1162
1252
  let authorizationRequestPayload;
1163
- const parsed = (0, import_utils14.parseWithErrorHandling)(
1164
- import_zod13.default.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest, zJarAuthorizationRequest]),
1253
+ const parsed = (0, import_utils15.parseWithErrorHandling)(
1254
+ import_zod14.default.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest, zJarAuthorizationRequest]),
1165
1255
  options.authorizationRequestPayload,
1166
1256
  "Invalid authorization request. Could not parse openid4vp authorization request as openid4vp or jar auth request."
1167
1257
  );
1168
1258
  let jar;
1169
1259
  if (isJarAuthorizationRequest(parsed)) {
1170
1260
  jar = await verifyJarRequest({ jarRequestParams: parsed, callbacks, wallet });
1171
- const parsedJarAuthorizationRequestPayload = (0, import_utils14.parseWithErrorHandling)(
1172
- import_zod13.default.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest]),
1261
+ const parsedJarAuthorizationRequestPayload = (0, import_utils15.parseWithErrorHandling)(
1262
+ import_zod14.default.union([zOpenid4vpAuthorizationRequestDcApi, zOpenid4vpAuthorizationRequest]),
1173
1263
  jar.authorizationRequestPayload,
1174
1264
  "Invalid authorization request. Could not parse jar request payload as openid4vp auth request."
1175
1265
  );
@@ -1193,7 +1283,7 @@ async function resolveOpenid4vpAuthorizationRequest(options) {
1193
1283
  if (!isOpenid4vpAuthorizationRequestDcApi(authorizationRequestPayload) && !clientMetadata && authorizationRequestPayload.client_metadata_uri) {
1194
1284
  clientMetadata = await fetchClientMetadata({ clientMetadataUri: authorizationRequestPayload.client_metadata_uri });
1195
1285
  }
1196
- const clientMeta = parseClientIdentifier({
1286
+ const clientMeta = validateOpenid4vpClientId({
1197
1287
  authorizationRequestPayload: {
1198
1288
  ...authorizationRequestPayload,
1199
1289
  client_metadata: clientMetadata
@@ -1249,7 +1339,7 @@ function validateOpenId4vpAuthorizationRequestPayload(options) {
1249
1339
 
1250
1340
  // src/authorization-response/create-authorization-response.ts
1251
1341
  var import_oauth222 = require("@openid4vc/oauth2");
1252
- var import_utils15 = require("@openid4vc/utils");
1342
+ var import_utils16 = require("@openid4vc/utils");
1253
1343
 
1254
1344
  // ../utils/src/date.ts
1255
1345
  function addSecondsToDate2(date, seconds) {
@@ -1283,7 +1373,7 @@ async function createJarmAuthorizationResponse(options) {
1283
1373
  }
1284
1374
 
1285
1375
  // src/jarm/jarm-response-mode.ts
1286
- var import_zod14 = require("zod");
1376
+ var import_zod15 = require("zod");
1287
1377
  var jarmResponseMode = [
1288
1378
  "jwt",
1289
1379
  "query.jwt",
@@ -1292,7 +1382,7 @@ var jarmResponseMode = [
1292
1382
  "direct_post.jwt",
1293
1383
  "dc_api.jwt"
1294
1384
  ];
1295
- var zJarmResponseMode = import_zod14.z.enum(jarmResponseMode);
1385
+ var zJarmResponseMode = import_zod15.z.enum(jarmResponseMode);
1296
1386
  var isJarmResponseMode = (responseMode) => {
1297
1387
  return jarmResponseMode.includes(responseMode);
1298
1388
  };
@@ -1398,7 +1488,7 @@ async function createOpenid4vpAuthorizationResponse(options) {
1398
1488
  additionalJwtPayload = {
1399
1489
  iss: jarm.authorizationServer,
1400
1490
  aud: jarm.audience,
1401
- exp: jarm.expiresInSeconds ?? (0, import_utils15.dateToSeconds)(addSecondsToDate2(/* @__PURE__ */ new Date(), 60 * 10))
1491
+ exp: jarm.expiresInSeconds ?? (0, import_utils16.dateToSeconds)(addSecondsToDate2(/* @__PURE__ */ new Date(), 60 * 10))
1402
1492
  // default: 10 minutes
1403
1493
  };
1404
1494
  }
@@ -1430,25 +1520,25 @@ async function createOpenid4vpAuthorizationResponse(options) {
1430
1520
 
1431
1521
  // src/authorization-response/submit-authorization-response.ts
1432
1522
  var import_oauth224 = require("@openid4vc/oauth2");
1433
- var import_utils17 = require("@openid4vc/utils");
1434
1523
  var import_utils18 = require("@openid4vc/utils");
1524
+ var import_utils19 = require("@openid4vc/utils");
1435
1525
 
1436
1526
  // src/jarm/jarm-authorizatino-response-send.ts
1437
1527
  var import_oauth223 = require("@openid4vc/oauth2");
1438
- var import_utils16 = require("@openid4vc/utils");
1528
+ var import_utils17 = require("@openid4vc/utils");
1439
1529
  var jarmAuthorizationResponseSend = (options) => {
1440
1530
  const { authorizationRequestPayload, jarmAuthorizationResponseJwt, callbacks } = options;
1441
1531
  const responseEndpoint = authorizationRequestPayload.response_uri ?? authorizationRequestPayload.redirect_uri;
1442
1532
  if (!responseEndpoint) {
1443
1533
  throw new import_oauth223.Oauth2Error(`Either 'response_uri' or 'redirect_uri' MUST be present in the authorization request`);
1444
1534
  }
1445
- const responseEndpointUrl = new import_utils16.URL(responseEndpoint);
1535
+ const responseEndpointUrl = new import_utils17.URL(responseEndpoint);
1446
1536
  return handleDirectPostJwt(responseEndpointUrl, jarmAuthorizationResponseJwt, callbacks);
1447
1537
  };
1448
1538
  async function handleDirectPostJwt(responseEndpoint, responseJwt, callbacks) {
1449
- const response = await (0, import_utils16.createFetcher)(callbacks.fetch)(responseEndpoint, {
1539
+ const response = await (0, import_utils17.createFetcher)(callbacks.fetch)(responseEndpoint, {
1450
1540
  method: "POST",
1451
- headers: { "Content-Type": import_utils16.ContentType.XWwwFormUrlencoded },
1541
+ headers: { "Content-Type": import_utils17.ContentType.XWwwFormUrlencoded },
1452
1542
  body: `response=${responseJwt}`
1453
1543
  });
1454
1544
  return {
@@ -1473,13 +1563,13 @@ async function submitOpenid4vpAuthorizationResponse(options) {
1473
1563
  "Failed to submit OpenId4Vp Authorization Response. No redirect_uri or response_uri provided."
1474
1564
  );
1475
1565
  }
1476
- const fetch = (0, import_utils17.createFetcher)(callbacks.fetch);
1477
- const encodedResponse = (0, import_utils18.objectToQueryParams)(authorizationResponsePayload);
1566
+ const fetch = (0, import_utils18.createFetcher)(callbacks.fetch);
1567
+ const encodedResponse = (0, import_utils19.objectToQueryParams)(authorizationResponsePayload);
1478
1568
  const submissionResponse = await fetch(url, {
1479
1569
  method: "POST",
1480
1570
  body: encodedResponse.toString(),
1481
1571
  headers: {
1482
- "Content-Type": import_utils17.ContentType.XWwwFormUrlencoded
1572
+ "Content-Type": import_utils18.ContentType.XWwwFormUrlencoded
1483
1573
  }
1484
1574
  });
1485
1575
  return {
@@ -1492,37 +1582,37 @@ async function submitOpenid4vpAuthorizationResponse(options) {
1492
1582
  var import_oauth225 = require("@openid4vc/oauth2");
1493
1583
 
1494
1584
  // src/vp-token/parse-vp-token.ts
1495
- var import_utils19 = require("@openid4vc/utils");
1585
+ var import_utils20 = require("@openid4vc/utils");
1496
1586
 
1497
1587
  // src/vp-token/z-vp-token.ts
1498
- var import_zod15 = require("zod");
1499
- var zVpTokenPexEntry = import_zod15.z.union([import_zod15.z.string(), import_zod15.z.record(import_zod15.z.any())], {
1588
+ var import_zod16 = require("zod");
1589
+ var zVpTokenPexEntry = import_zod16.z.union([import_zod16.z.string(), import_zod16.z.record(import_zod16.z.any())], {
1500
1590
  message: "pex vp_token entry must be a string or object"
1501
1591
  });
1502
- var zVpTokenPex = import_zod15.z.union(
1503
- [zVpTokenPexEntry, import_zod15.z.array(zVpTokenPexEntry).nonempty("Must have at least entry in vp_token array")],
1592
+ var zVpTokenPex = import_zod16.z.union(
1593
+ [zVpTokenPexEntry, import_zod16.z.array(zVpTokenPexEntry).nonempty("Must have at least entry in vp_token array")],
1504
1594
  {
1505
1595
  message: "pex vp_token must be a string, object or array of strings and objects"
1506
1596
  }
1507
1597
  );
1508
- var zVpTokenDcql = import_zod15.z.record(import_zod15.z.union([import_zod15.z.string(), import_zod15.z.record(import_zod15.z.any())]), {
1598
+ var zVpTokenDcql = import_zod16.z.record(import_zod16.z.union([import_zod16.z.string(), import_zod16.z.record(import_zod16.z.any())]), {
1509
1599
  message: "dcql vp_token must be an object with keys referencing the dcql credential query id, and values the encoded (string or object) presentation"
1510
1600
  });
1511
1601
  var zVpToken = zVpTokenDcql.or(zVpTokenPex);
1512
1602
 
1513
1603
  // src/vp-token/parse-vp-token.ts
1514
1604
  function parsePexVpToken(vpToken) {
1515
- const parsedVpToken = (0, import_utils19.parseWithErrorHandling)(
1605
+ const parsedVpToken = (0, import_utils20.parseWithErrorHandling)(
1516
1606
  zVpTokenPex,
1517
- (0, import_utils19.parseIfJson)(vpToken),
1607
+ (0, import_utils20.parseIfJson)(vpToken),
1518
1608
  "Could not parse presentation exchange vp_token. Expected a string or an array of strings"
1519
1609
  );
1520
1610
  return Array.isArray(parsedVpToken) ? parsedVpToken : [parsedVpToken];
1521
1611
  }
1522
1612
  function parseDcqlVpToken(vpToken) {
1523
- return (0, import_utils19.parseWithErrorHandling)(
1613
+ return (0, import_utils20.parseWithErrorHandling)(
1524
1614
  zVpTokenDcql,
1525
- (0, import_utils19.parseIfJson)(vpToken),
1615
+ (0, import_utils20.parseIfJson)(vpToken),
1526
1616
  "Could not parse dcql vp_token. Expected an object where the values are encoded presentations"
1527
1617
  );
1528
1618
  }
@@ -1575,32 +1665,32 @@ function validateOpenid4vpAuthorizationResponsePayload(options) {
1575
1665
  var import_oauth227 = require("@openid4vc/oauth2");
1576
1666
 
1577
1667
  // src/authorization-response/parse-authorization-response-payload.ts
1578
- var import_utils21 = require("@openid4vc/utils");
1668
+ var import_utils22 = require("@openid4vc/utils");
1579
1669
 
1580
1670
  // src/authorization-response/z-authorization-response.ts
1581
- var import_utils20 = require("@openid4vc/utils");
1582
- var import_zod17 = require("zod");
1671
+ var import_utils21 = require("@openid4vc/utils");
1672
+ var import_zod18 = require("zod");
1583
1673
 
1584
1674
  // src/models/z-pex.ts
1585
- var import_zod16 = require("zod");
1586
- var zPexPresentationDefinition = import_zod16.z.record(import_zod16.z.any());
1587
- var zPexPresentationSubmission = import_zod16.z.record(import_zod16.z.any());
1675
+ var import_zod17 = require("zod");
1676
+ var zPexPresentationDefinition = import_zod17.z.record(import_zod17.z.any());
1677
+ var zPexPresentationSubmission = import_zod17.z.record(import_zod17.z.any());
1588
1678
 
1589
1679
  // src/authorization-response/z-authorization-response.ts
1590
- var zOpenid4vpAuthorizationResponse = import_zod17.z.object({
1591
- state: import_zod17.z.string().optional(),
1592
- id_token: import_zod17.z.string().optional(),
1680
+ var zOpenid4vpAuthorizationResponse = import_zod18.z.object({
1681
+ state: import_zod18.z.string().optional(),
1682
+ id_token: import_zod18.z.string().optional(),
1593
1683
  vp_token: zVpToken,
1594
- presentation_submission: zPexPresentationSubmission.or(import_utils20.zStringToJson).optional(),
1595
- refresh_token: import_zod17.z.string().optional(),
1596
- token_type: import_zod17.z.string().optional(),
1597
- access_token: import_zod17.z.string().optional(),
1598
- expires_in: import_zod17.z.number().optional()
1684
+ presentation_submission: zPexPresentationSubmission.or(import_utils21.zStringToJson).optional(),
1685
+ refresh_token: import_zod18.z.string().optional(),
1686
+ token_type: import_zod18.z.string().optional(),
1687
+ access_token: import_zod18.z.string().optional(),
1688
+ expires_in: import_zod18.z.number().optional()
1599
1689
  }).passthrough();
1600
1690
 
1601
1691
  // src/authorization-response/parse-authorization-response-payload.ts
1602
1692
  function parseOpenid4VpAuthorizationResponsePayload(payload) {
1603
- return (0, import_utils21.parseWithErrorHandling)(
1693
+ return (0, import_utils22.parseWithErrorHandling)(
1604
1694
  zOpenid4vpAuthorizationResponse,
1605
1695
  payload,
1606
1696
  "Failed to parse openid4vp authorization response."
@@ -1609,12 +1699,12 @@ function parseOpenid4VpAuthorizationResponsePayload(payload) {
1609
1699
 
1610
1700
  // src/authorization-response/parse-jarm-authorization-response.ts
1611
1701
  var import_oauth226 = require("@openid4vc/oauth2");
1612
- var import_utils22 = require("@openid4vc/utils");
1613
- var import_zod18 = __toESM(require("zod"));
1702
+ var import_utils23 = require("@openid4vc/utils");
1703
+ var import_zod19 = __toESM(require("zod"));
1614
1704
  async function parseJarmAuthorizationResponse(options) {
1615
1705
  const { jarmResponseJwt, callbacks, authorizationRequestPayload, expectedClientId } = options;
1616
- const jarmAuthorizationResponseJwt = (0, import_utils22.parseWithErrorHandling)(
1617
- import_zod18.default.union([import_oauth226.zCompactJwt, import_oauth226.zCompactJwe]),
1706
+ const jarmAuthorizationResponseJwt = (0, import_utils23.parseWithErrorHandling)(
1707
+ import_zod19.default.union([import_oauth226.zCompactJwt, import_oauth226.zCompactJwe]),
1618
1708
  jarmResponseJwt,
1619
1709
  "Invalid jarm authorization response jwt."
1620
1710
  );
@@ -1653,7 +1743,9 @@ async function parseOpenid4vpAuthorizationResponse(options) {
1653
1743
  const { authorizationResponse, callbacks, authorizationRequestPayload, origin } = options;
1654
1744
  const expectedClientId = getOpenid4vpClientId({
1655
1745
  origin,
1656
- authorizationRequestPayload
1746
+ responseMode: authorizationRequestPayload.response_mode,
1747
+ clientId: authorizationRequestPayload.client_id,
1748
+ legacyClientIdScheme: authorizationRequestPayload.client_id_scheme
1657
1749
  });
1658
1750
  if (authorizationResponse.response) {
1659
1751
  return parseJarmAuthorizationResponse({
@@ -1710,7 +1802,7 @@ var Openid4vpClient = class {
1710
1802
 
1711
1803
  // src/transaction-data/verify-transaction-data.ts
1712
1804
  var import_oauth228 = require("@openid4vc/oauth2");
1713
- var import_utils23 = require("@openid4vc/utils");
1805
+ var import_utils24 = require("@openid4vc/utils");
1714
1806
  async function verifyTransactionData(options) {
1715
1807
  const parsedTransactionData = parseTransactionData({
1716
1808
  transactionData: options.transactionData
@@ -1737,7 +1829,7 @@ async function verifyTransactionDataEntry({
1737
1829
  );
1738
1830
  const hashes = {};
1739
1831
  for (const alg of supportedAlgs) {
1740
- hashes[alg] = (0, import_utils23.encodeToBase64Url)(await callbacks.hash((0, import_utils23.decodeUtf8String)(entry.encoded), alg));
1832
+ hashes[alg] = (0, import_utils24.encodeToBase64Url)(await callbacks.hash((0, import_utils24.decodeUtf8String)(entry.encoded), alg));
1741
1833
  }
1742
1834
  for (const credentialId of entry.transactionData.credential_ids) {
1743
1835
  const transactionDataHashesCredential = credentials[credentialId];
@@ -1808,22 +1900,22 @@ var Openid4vpVerifier = class {
1808
1900
  };
1809
1901
 
1810
1902
  // src/models/z-credential-formats.ts
1811
- var import_zod19 = require("zod");
1812
- var zCredentialFormat = import_zod19.z.enum(["jwt_vc_json", "ldp_vc", "ac_vc", "mso_mdoc", "dc+sd-jwt", "vc+sd-jwt"]);
1903
+ var import_zod20 = require("zod");
1904
+ var zCredentialFormat = import_zod20.z.enum(["jwt_vc_json", "ldp_vc", "ac_vc", "mso_mdoc", "dc+sd-jwt", "vc+sd-jwt"]);
1813
1905
 
1814
1906
  // src/models/z-proof-formats.ts
1815
- var import_zod20 = require("zod");
1816
- var zProofFormat = import_zod20.z.enum(["jwt_vp_json", "ldc_vp", "ac_vp", "dc+sd-jwt", "vc+sd-jwt", "mso_mdoc"]);
1907
+ var import_zod21 = require("zod");
1908
+ var zProofFormat = import_zod21.z.enum(["jwt_vp_json", "ldc_vp", "ac_vp", "dc+sd-jwt", "vc+sd-jwt", "mso_mdoc"]);
1817
1909
 
1818
1910
  // src/models/z-wallet-metadata.ts
1819
- var import_zod21 = require("zod");
1820
- var zWalletMetadata = import_zod21.z.object({
1821
- presentation_definition_uri_supported: import_zod21.z.optional(import_zod21.z.boolean()),
1911
+ var import_zod22 = require("zod");
1912
+ var zWalletMetadata = import_zod22.z.object({
1913
+ presentation_definition_uri_supported: import_zod22.z.optional(import_zod22.z.boolean()),
1822
1914
  vp_formats_supported: zVpFormatsSupported,
1823
- client_id_schemes_supported: import_zod21.z.optional(import_zod21.z.array(zClientIdScheme)),
1824
- request_object_signing_alg_values_supported: import_zod21.z.optional(import_zod21.z.array(import_zod21.z.string())),
1825
- authorization_encryption_alg_values_supported: import_zod21.z.optional(import_zod21.z.array(import_zod21.z.string())),
1826
- authorization_encryption_enc_values_supported: import_zod21.z.optional(import_zod21.z.array(import_zod21.z.string()))
1915
+ client_id_schemes_supported: import_zod22.z.optional(import_zod22.z.array(zClientIdScheme)),
1916
+ request_object_signing_alg_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string())),
1917
+ authorization_encryption_alg_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string())),
1918
+ authorization_encryption_enc_values_supported: import_zod22.z.optional(import_zod22.z.array(import_zod22.z.string()))
1827
1919
  });
1828
1920
  // Annotate the CommonJS export names for ESM import in node:
1829
1921
  0 && (module.exports = {