@openid4vc/openid4vci 0.5.0-alpha-20260202131209 → 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.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { ContentType, OpenId4VcBaseError, URL, URLSearchParams, ValidationError, arrayEqualsIgnoreOrder, createZodFetcher, dateToSeconds, encodeToBase64Url, formatZodError, getGlobalConfig, getQueryParams, isResponseContentType, joinUriParts, objectToQueryParams, parseWithErrorHandling, setGlobalConfig, stringToJsonWithErrorHandling, zDataUrl, zHttpsUrl, zInteger, zIs, zNumericDate } from "@openid4vc/utils";
2
- import { InvalidFetchResponseError, Oauth2AuthorizationServer, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2Error, Oauth2ErrorCodes, Oauth2JwtVerificationError, Oauth2ServerErrorResponseError, authorizationCodeGrantIdentifier, createClientAttestationJwt, decodeJwt, fetchAuthorizationServerMetadata, fetchWellKnownMetadata, fullySpecifiedCoseAlgorithmArrayToJwaSignatureAlgorithmArray, getAuthorizationServerMetadataFromList, isJwkInSet, jwaSignatureAlgorithmArrayToFullySpecifiedCoseAlgorithmArray, jwtHeaderFromJwtSigner, jwtSignerFromJwt, parseAuthorizationResponseRedirectUrl, preAuthorizedCodeGrantIdentifier, resourceRequest, verifyAuthorizationResponse, verifyJwt, zAuthorizationServerMetadata, zCompactJwt, zJwk, zJwtHeader, zJwtPayload } from "@openid4vc/oauth2";
3
- import z from "zod";
1
+ import { ContentType, Headers, InvalidFetchResponseError, OpenId4VcBaseError, URL, URLSearchParams, ValidationError, arrayEqualsIgnoreOrder, createZodFetcher, dateToSeconds, encodeToBase64Url, formatZodError, getGlobalConfig, getQueryParams, isResponseContentType, joinUriParts, objectToQueryParams, parseWithErrorHandling, setGlobalConfig, stringToJsonWithErrorHandling, zDataUrl, zHttpsUrl, zInteger, zIs, zNumericDate } from "@openid4vc/utils";
2
+ import { InvalidFetchResponseError as InvalidFetchResponseError$1, Oauth2AuthorizationServer, Oauth2Client, Oauth2ClientAuthorizationChallengeError, Oauth2ClientErrorResponseError, Oauth2Error, Oauth2ErrorCodes, Oauth2JwtVerificationError, Oauth2ServerErrorResponseError, authorizationCodeGrantIdentifier, authorizationServerRequestWithDpopRetry, createClientAttestationJwt, createDpopHeadersForRequest, createPkce, decodeJwt, extractDpopNonceFromHeaders, fetchAuthorizationServerMetadata, fetchWellKnownMetadata, fullySpecifiedCoseAlgorithmArrayToJwaSignatureAlgorithmArray, getAuthorizationServerMetadataFromList, isJarAuthorizationRequest, isJwkInSet, jwaSignatureAlgorithmArrayToFullySpecifiedCoseAlgorithmArray, jwtHeaderFromJwtSigner, jwtSignerFromJwt, parseAuthorizationRequest, parseAuthorizationResponseRedirectUrl, parseJarRequest, preAuthorizedCodeGrantIdentifier, resourceRequest, verifyAuthorizationRequest, verifyAuthorizationResponse, verifyJarRequest, verifyJwt, zAuthorizationRequest, zAuthorizationServerMetadata, zCompactJwt, zJarAuthorizationRequest, zJwk, zJwtHeader, zJwtPayload, zOauth2ErrorResponse } from "@openid4vc/oauth2";
3
+ import z$1, { z } from "zod";
4
4
 
5
5
  //#region src/version.ts
6
6
  let Openid4vciVersion = /* @__PURE__ */ function(Openid4vciVersion$1) {
@@ -17,35 +17,35 @@ const Openid4vciDraftVersion = Openid4vciVersion;
17
17
 
18
18
  //#endregion
19
19
  //#region src/credential-offer/z-credential-offer.ts
20
- const zTxCode = z.object({
21
- input_mode: z.union([z.literal("numeric"), z.literal("text")]).optional(),
22
- length: z.number().int().optional(),
23
- description: z.string().max(300).optional()
20
+ const zTxCode = z$1.object({
21
+ input_mode: z$1.union([z$1.literal("numeric"), z$1.literal("text")]).optional(),
22
+ length: z$1.number().int().optional(),
23
+ description: z$1.string().max(300).optional()
24
24
  }).loose();
25
- const zCredentialOfferGrants = z.object({
26
- authorization_code: z.object({
27
- issuer_state: z.string().optional(),
25
+ const zCredentialOfferGrants = z$1.object({
26
+ authorization_code: z$1.object({
27
+ issuer_state: z$1.string().optional(),
28
28
  authorization_server: zHttpsUrl.optional()
29
29
  }).loose().optional(),
30
- [preAuthorizedCodeGrantIdentifier]: z.object({
31
- "pre-authorized_code": z.string(),
30
+ [preAuthorizedCodeGrantIdentifier]: z$1.object({
31
+ "pre-authorized_code": z$1.string(),
32
32
  tx_code: zTxCode.optional(),
33
33
  authorization_server: zHttpsUrl.optional()
34
34
  }).loose().optional()
35
35
  }).loose();
36
- const zCredentialOfferObjectDraft14 = z.object({
36
+ const zCredentialOfferObjectDraft14 = z$1.object({
37
37
  credential_issuer: zHttpsUrl,
38
- credential_configuration_ids: z.array(z.string()),
39
- grants: z.optional(zCredentialOfferGrants)
38
+ credential_configuration_ids: z$1.array(z$1.string()),
39
+ grants: z$1.optional(zCredentialOfferGrants)
40
40
  }).loose();
41
- const zCredentialOfferObjectDraft11To14 = z.object({
41
+ const zCredentialOfferObjectDraft11To14 = z$1.object({
42
42
  credential_issuer: zHttpsUrl,
43
- credentials: z.array(z.string({ message: "Only string credential identifiers are supported for draft 11 credential offers" })),
44
- grants: z.optional(z.object({
43
+ credentials: z$1.array(z$1.string({ message: "Only string credential identifiers are supported for draft 11 credential offers" })),
44
+ grants: z$1.optional(z$1.object({
45
45
  authorization_code: zCredentialOfferGrants.shape.authorization_code,
46
- [preAuthorizedCodeGrantIdentifier]: z.object({
47
- "pre-authorized_code": z.string(),
48
- user_pin_required: z.optional(z.boolean())
46
+ [preAuthorizedCodeGrantIdentifier]: z$1.object({
47
+ "pre-authorized_code": z$1.string(),
48
+ user_pin_required: z$1.optional(z$1.boolean())
49
49
  }).loose().optional()
50
50
  }))
51
51
  }).loose().transform(({ credentials, grants, ...rest }) => {
@@ -63,7 +63,7 @@ const zCredentialOfferObjectDraft11To14 = z.object({
63
63
  }
64
64
  return v14;
65
65
  }).pipe(zCredentialOfferObjectDraft14);
66
- const zCredentialOfferObject = z.union([zCredentialOfferObjectDraft14, zCredentialOfferObjectDraft11To14]);
66
+ const zCredentialOfferObject = z$1.union([zCredentialOfferObjectDraft14, zCredentialOfferObjectDraft11To14]);
67
67
 
68
68
  //#endregion
69
69
  //#region src/credential-offer/credential-offer.ts
@@ -75,7 +75,7 @@ async function resolveCredentialOffer(credentialOffer, options) {
75
75
  let credentialOfferParseResult;
76
76
  if (parsedQueryParams.credential_offer_uri) {
77
77
  const { response, result } = await createZodFetcher(options?.fetch)(zCredentialOfferObject, ContentType.Json, parsedQueryParams.credential_offer_uri);
78
- if (!response.ok || !result) throw new InvalidFetchResponseError(`Fetching credential offer from '${parsedQueryParams.credential_offer_uri}' resulted in an unsuccessful response with status '${response.status}'`, await response.clone().text(), response);
78
+ if (!response.ok || !result) throw new InvalidFetchResponseError$1(`Fetching credential offer from '${parsedQueryParams.credential_offer_uri}' resulted in an unsuccessful response with status '${response.status}'`, await response.clone().text(), response);
79
79
  credentialOfferParseResult = result;
80
80
  } else if (parsedQueryParams.credential_offer) {
81
81
  let credentialOfferJson;
@@ -167,6 +167,15 @@ function getCredentialConfigurationsMatchingRequestFormat({ requestFormat, issue
167
167
  }));
168
168
  }
169
169
 
170
+ //#endregion
171
+ //#region src/error/Openid4vciClientInteractiveAuthorizationError.ts
172
+ var Openid4vciClientInteractiveAuthorizationError = class extends Oauth2ClientErrorResponseError {
173
+ constructor(message, errorResponse, response) {
174
+ super(message, errorResponse, response);
175
+ this.errorResponse = errorResponse;
176
+ }
177
+ };
178
+
170
179
  //#endregion
171
180
  //#region src/error/Openid4vciError.ts
172
181
  var Openid4vciError = class extends Error {
@@ -197,31 +206,466 @@ var Openid4vciSendNotificationError = class extends Openid4vciError {
197
206
  }
198
207
  };
199
208
 
209
+ //#endregion
210
+ //#region src/interactive-authorization/z-interactive-authorization.ts
211
+ /**
212
+ * Schema for Interactive Authorization Request (initial request)
213
+ *
214
+ * Based on OpenID4VCI 1.1 Interactive Authorization Endpoint
215
+ * Similar to PAR request but sent to interactive_authorization_endpoint
216
+ */
217
+ const zInteractiveAuthorizationInitialRequest = z.object({
218
+ ...zAuthorizationRequest.omit({ response_type: true }).shape,
219
+ interaction_types_supported: z.string(),
220
+ response_type: z.literal("code").default("code")
221
+ }).loose();
222
+ /**
223
+ * Schema for Follow-up Interactive Authorization Request
224
+ *
225
+ * Follow-up requests include auth_session and interaction-specific parameters
226
+ */
227
+ const zInteractiveAuthorizationFollowUpRequest = z.object({
228
+ auth_session: z.string(),
229
+ openid4vp_response: z.optional(z.string()),
230
+ code_verifier: z.optional(z.string())
231
+ }).loose();
232
+ /**
233
+ * Base schema for Interaction Required Response
234
+ *
235
+ * Contains fields common to all interaction types
236
+ */
237
+ const zInteractiveAuthorizationInteractionRequiredResponseBase = z.object({
238
+ status: z.literal("require_interaction"),
239
+ auth_session: z.string(),
240
+ expires_in: z.optional(zInteger)
241
+ });
242
+ /**
243
+ * Schema for OpenID4VP Presentation Interaction Response
244
+ *
245
+ * Returned when the Authorization Server requires an OpenID4VP presentation
246
+ */
247
+ const zInteractiveAuthorizationOpenid4vpPresentationResponse = zInteractiveAuthorizationInteractionRequiredResponseBase.extend({
248
+ type: z.literal("openid4vp_presentation"),
249
+ openid4vp_request: z.record(z.string(), z.unknown())
250
+ }).loose();
251
+ /**
252
+ * Schema for Redirect to Web Interaction Response
253
+ *
254
+ * Returned when the Authorization Server requires a browser redirect
255
+ */
256
+ const zInteractiveAuthorizationRedirectToWebResponse = zInteractiveAuthorizationInteractionRequiredResponseBase.extend({
257
+ type: z.literal("redirect_to_web"),
258
+ request_uri: z.string()
259
+ }).loose();
260
+ /**
261
+ * Schema for Interaction Required Response (discriminated union)
262
+ *
263
+ * Returned when the Authorization Server requires additional user interaction.
264
+ * Uses discriminated union on 'type' field for better type inference.
265
+ */
266
+ const zInteractiveAuthorizationInteractionRequiredResponse = z.discriminatedUnion("type", [zInteractiveAuthorizationOpenid4vpPresentationResponse, zInteractiveAuthorizationRedirectToWebResponse]);
267
+ /**
268
+ * Schema for Authorization Code Response
269
+ *
270
+ * Returned when authorization is successfully completed
271
+ */
272
+ const zInteractiveAuthorizationCodeResponse = z.object({
273
+ status: z.literal("ok"),
274
+ code: z.string()
275
+ }).loose();
276
+ /**
277
+
278
+
279
+ /**
280
+ * Union type for all possible Interactive Authorization Responses
281
+ */
282
+ const zInteractiveAuthorizationResponse = z.union([zInteractiveAuthorizationInteractionRequiredResponse, zInteractiveAuthorizationCodeResponse]);
283
+ /**
284
+ * Type guard to check if a request is a JAR Interactive Authorization Request
285
+ */
286
+ function isInteractiveAuthorizationFollowUpRequest(request) {
287
+ return request.auth_session !== void 0;
288
+ }
289
+
290
+ //#endregion
291
+ //#region src/interactive-authorization/create-interactive-authorization-response.ts
292
+ /**
293
+ * Create a successful Interactive Authorization Code Response
294
+ *
295
+ * This response indicates that the authorization process is complete
296
+ * and returns an authorization code that can be exchanged for an access token.
297
+ *
298
+ * @param options - Response options
299
+ * @returns The authorization code response
300
+ *
301
+ * @example
302
+ * ```ts
303
+ * const response = createInteractiveAuthorizationCodeResponse({
304
+ * authorizationCode: 'SplxlOBeZQQYbYS6WxSbIA'
305
+ * })
306
+ * ```
307
+ */
308
+ function createInteractiveAuthorizationCodeResponse(options) {
309
+ return parseWithErrorHandling(zInteractiveAuthorizationCodeResponse, {
310
+ status: "ok",
311
+ code: options.authorizationCode,
312
+ ...options.additionalPayload
313
+ });
314
+ }
315
+ /**
316
+ * Create an Interactive Authorization Interaction Required Response
317
+ * requesting an OpenID4VP presentation
318
+ *
319
+ * This response indicates that the wallet must present credentials
320
+ * via OpenID4VP before authorization can be granted.
321
+ *
322
+ * @param options - Response options
323
+ * @returns The interaction required response
324
+ *
325
+ * @example With unsigned request
326
+ * ```ts
327
+ * const response = createInteractiveAuthorizationOpenid4vpInteraction({
328
+ * authSession: 'session-123',
329
+ * openid4vpRequest: {
330
+ * response_type: 'vp_token',
331
+ * response_mode: 'iae_post',
332
+ * nonce: 'n-0S6_WzA2Mj',
333
+ * dcql_query: { ... }
334
+ * }
335
+ * })
336
+ * ```
337
+ *
338
+ * @example With signed request
339
+ * ```ts
340
+ * const response = createInteractiveAuthorizationOpenid4vpInteraction({
341
+ * authSession: 'session-123',
342
+ * openid4vpRequest: {
343
+ * request: 'eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...'
344
+ * }
345
+ * })
346
+ * ```
347
+ */
348
+ function createInteractiveAuthorizationOpenid4vpInteraction(options) {
349
+ return parseWithErrorHandling(zInteractiveAuthorizationInteractionRequiredResponse, {
350
+ status: "require_interaction",
351
+ type: "openid4vp_presentation",
352
+ auth_session: options.authSession,
353
+ openid4vp_request: options.openid4vpRequest,
354
+ ...options.additionalPayload
355
+ });
356
+ }
357
+ /**
358
+ * Create an Interactive Authorization Interaction Required Response
359
+ * requesting a redirect to web
360
+ *
361
+ * This response indicates that the authorization process must continue
362
+ * via interactions with the user in a web browser.
363
+ *
364
+ * @param options - Response options
365
+ * @returns The interaction required response
366
+ *
367
+ * @example
368
+ * ```ts
369
+ * const response = createInteractiveAuthorizationRedirectToWebInteraction({
370
+ * authSession: 'session-123',
371
+ * requestUri: 'urn:ietf:params:oauth:request_uri:6esc_11ACC5bwc014ltc14eY22c',
372
+ * expiresIn: 60
373
+ * })
374
+ * ```
375
+ */
376
+ function createInteractiveAuthorizationRedirectToWebInteraction(options) {
377
+ return parseWithErrorHandling(zInteractiveAuthorizationInteractionRequiredResponse, {
378
+ status: "require_interaction",
379
+ type: "redirect_to_web",
380
+ auth_session: options.authSession,
381
+ request_uri: options.requestUri,
382
+ expires_in: options.expiresIn,
383
+ ...options.additionalPayload
384
+ });
385
+ }
386
+ /**
387
+ * Create an Interactive Authorization Error Response
388
+ *
389
+ * This response indicates that an error occurred during the authorization process.
390
+ *
391
+ * @param options - Error response options
392
+ * @returns The error response
393
+ *
394
+ * @example
395
+ * ```ts
396
+ * const response = createInteractiveAuthorizationErrorResponse({
397
+ * error: 'missing_interaction_type',
398
+ * errorDescription: 'interaction_types_supported is missing openid4vp_presentation'
399
+ * })
400
+ * ```
401
+ */
402
+ function createInteractiveAuthorizationErrorResponse(options) {
403
+ return parseWithErrorHandling(zOauth2ErrorResponse, {
404
+ error: options.error,
405
+ error_description: options.errorDescription,
406
+ error_uri: options.errorUri,
407
+ ...options.additionalPayload
408
+ });
409
+ }
410
+
411
+ //#endregion
412
+ //#region src/interactive-authorization/parse-interactive-authorization-request.ts
413
+ let InteractiveAuthorizationRequestType = /* @__PURE__ */ function(InteractiveAuthorizationRequestType$1) {
414
+ InteractiveAuthorizationRequestType$1["Initial"] = "Initial";
415
+ InteractiveAuthorizationRequestType$1["FollowUp"] = "FollowUp";
416
+ return InteractiveAuthorizationRequestType$1;
417
+ }({});
418
+ /**
419
+ * Parse an Interactive Authorization Request
420
+ *
421
+ * This function parses and validates an Interactive Authorization Endpoint request.
422
+ * It automatically detects whether this is an initial request, a follow-up request,
423
+ * or a JAR (JWT-secured) request based on the parameters present.
424
+ *
425
+ * @param options - Parsing options
426
+ * @returns The parsed request and metadata
427
+ * @throws {Oauth2ServerErrorResponseError} if validation fails
428
+ *
429
+ * @example Parse initial request
430
+ * ```ts
431
+ * const { interactiveAuthorizationRequest, isFollowUpRequest } = await parseInteractiveAuthorizationRequest({
432
+ * request: req,
433
+ * interactiveAuthorizationRequest: req.body,
434
+ * callbacks: { fetch }
435
+ * })
436
+ * // isFollowUpRequest = false
437
+ * ```
438
+ *
439
+ * @example Parse follow-up request
440
+ * ```ts
441
+ * const { interactiveAuthorizationRequest, isFollowUpRequest } = await parseInteractiveAuthorizationRequest({
442
+ * request: req,
443
+ * interactiveAuthorizationRequest: req.body,
444
+ * callbacks: { fetch }
445
+ * })
446
+ * // isFollowUpRequest = true
447
+ * ```
448
+ *
449
+ * @example Parse JAR request
450
+ * ```ts
451
+ * const { interactiveAuthorizationRequest, interactiveAuthorizationRequestJwt } = await parseInteractiveAuthorizationRequest({
452
+ * request: req,
453
+ * interactiveAuthorizationRequest: req.body,
454
+ * callbacks: { fetch }
455
+ * })
456
+ * // interactiveAuthorizationRequestJwt contains the signed JWT
457
+ * ```
458
+ */
459
+ async function parseInteractiveAuthorizationRequest(options) {
460
+ const parsed = parseWithErrorHandling(z$1.union([
461
+ zInteractiveAuthorizationInitialRequest,
462
+ zInteractiveAuthorizationFollowUpRequest,
463
+ zJarAuthorizationRequest
464
+ ]), options.interactiveAuthorizationRequest, "Invalid interactive authorization request. Could not parse as initial request, follow-up request, or JAR request.");
465
+ if (isInteractiveAuthorizationFollowUpRequest(parsed)) return {
466
+ type: InteractiveAuthorizationRequestType.FollowUp,
467
+ interactiveAuthorizationRequest: parsed
468
+ };
469
+ let interactiveAuthorizationRequest;
470
+ let interactiveAuthorizationRequestJwt;
471
+ if (isJarAuthorizationRequest(parsed)) {
472
+ const parsedJar = await parseJarRequest({
473
+ jarRequestParams: parsed,
474
+ callbacks: options.callbacks
475
+ });
476
+ const jwt = decodeJwt({ jwt: parsedJar.authorizationRequestJwt });
477
+ const parsedInteractiveAuthorizationRequest = zInteractiveAuthorizationInitialRequest.safeParse(jwt.payload);
478
+ if (!parsedInteractiveAuthorizationRequest.success) throw new Oauth2ServerErrorResponseError({
479
+ error: Oauth2ErrorCodes.InvalidRequest,
480
+ error_description: `Invalid interactive authorization request. Could not parse JAR request payload.\n${formatZodError(parsedInteractiveAuthorizationRequest.error)}`
481
+ });
482
+ interactiveAuthorizationRequestJwt = parsedJar.authorizationRequestJwt;
483
+ interactiveAuthorizationRequest = parsedInteractiveAuthorizationRequest.data;
484
+ } else interactiveAuthorizationRequest = parsed;
485
+ const { clientAttestation, dpop } = parseAuthorizationRequest({
486
+ authorizationRequest: interactiveAuthorizationRequest,
487
+ request: options.request
488
+ });
489
+ return {
490
+ type: InteractiveAuthorizationRequestType.Initial,
491
+ interactiveAuthorizationRequest,
492
+ interactiveAuthorizationRequestJwt,
493
+ dpop,
494
+ clientAttestation,
495
+ interactionTypesSupported: interactiveAuthorizationRequest.interaction_types_supported.split(",")
496
+ };
497
+ }
498
+
499
+ //#endregion
500
+ //#region src/interactive-authorization/send-interactive-authorization-request.ts
501
+ /**
502
+ * Send an Interactive Authorization Request to the Authorization Server
503
+ *
504
+ * Implements the Interactive Authorization Endpoint flow from OpenID4VCI 1.1.
505
+ * This endpoint enables complex authentication and authorization flows where
506
+ * interaction occurs directly with the Wallet rather than being intermediated
507
+ * by a browser.
508
+ *
509
+ * The request can be either:
510
+ * - Initial request: Contains authorization parameters and interaction_types_supported
511
+ * - Follow-up request: Contains auth_session and interaction-specific parameters
512
+ *
513
+ * @param options - Configuration options for the request
514
+ * @returns The interactive authorization response and updated DPoP config
515
+ * @throws {Oauth2Error} if the authorization server doesn't support interactive authorization
516
+ * @throws {Openid4vciClientInteractiveAuthorizationError} if the request failed and an error response is returned
517
+ * @throws {InvalidFetchResponseError} if the request failed but no error response could be parsed
518
+ * @throws {ValidationError} if a successful response was received but an error occurred during verification
519
+ *
520
+ * @example Initial request
521
+ * ```ts
522
+ * const result = await sendInteractiveAuthorizationRequest({
523
+ * callbacks,
524
+ * authorizationServerMetadata,
525
+ * request: {
526
+ * response_type: 'code',
527
+ * client_id: 'my-client',
528
+ * interaction_types_supported: 'openid4vp_presentation,redirect_to_web',
529
+ * authorization_details: [...]
530
+ * }
531
+ * })
532
+ * ```
533
+ *
534
+ * @example Follow-up request with OpenID4VP response
535
+ * ```ts
536
+ * const result = await sendInteractiveAuthorizationRequest({
537
+ * callbacks,
538
+ * authorizationServerMetadata,
539
+ * request: {
540
+ * auth_session: 'session-123',
541
+ * openid4vp_response: JSON.stringify({ vp_token: '...' })
542
+ * }
543
+ * })
544
+ * ```
545
+ */
546
+ async function sendInteractiveAuthorizationRequest(options) {
547
+ const fetchWithZod = createZodFetcher(options.callbacks.fetch);
548
+ const authorizationServerMetadata = options.authorizationServerMetadata;
549
+ const interactiveAuthorizationEndpoint = authorizationServerMetadata.interactive_authorization_endpoint;
550
+ if (!interactiveAuthorizationEndpoint) throw new Oauth2Error(`Unable to send interactive authorization request. Authorization server '${authorizationServerMetadata.issuer}' has no 'interactive_authorization_endpoint'`);
551
+ const interactiveAuthorizationRequest = options.request.auth_session ? parseWithErrorHandling(zInteractiveAuthorizationFollowUpRequest, options.request, "Invalid interactive authorization follow-up request") : parseWithErrorHandling(zInteractiveAuthorizationInitialRequest, options.request, "Invalid interactive authorization request");
552
+ return authorizationServerRequestWithDpopRetry({
553
+ dpop: options.dpop,
554
+ request: async (dpop) => {
555
+ const headers = new Headers({
556
+ ...dpop ? await createDpopHeadersForRequest({
557
+ request: {
558
+ method: "POST",
559
+ url: interactiveAuthorizationEndpoint
560
+ },
561
+ signer: dpop.signer,
562
+ callbacks: options.callbacks,
563
+ nonce: dpop.nonce
564
+ }) : void 0,
565
+ ...options.additionalHeaders,
566
+ "Content-Type": ContentType.XWwwFormUrlencoded
567
+ });
568
+ const { response, result } = await fetchWithZod(zInteractiveAuthorizationResponse, ContentType.Json, interactiveAuthorizationEndpoint, {
569
+ method: "POST",
570
+ body: objectToQueryParams(interactiveAuthorizationRequest).toString(),
571
+ headers
572
+ });
573
+ if (!response.ok || !result) {
574
+ const interactiveAuthorizationErrorResponse = zOauth2ErrorResponse.safeParse(await response.clone().json().catch(() => null));
575
+ if (interactiveAuthorizationErrorResponse.success) throw new Openid4vciClientInteractiveAuthorizationError(`Error requesting authorization from interactive authorization endpoint '${authorizationServerMetadata.interactive_authorization_endpoint}'. Received response with status ${response.status}`, interactiveAuthorizationErrorResponse.data, response);
576
+ throw new InvalidFetchResponseError(`Error requesting authorization from interactive authorization endpoint '${authorizationServerMetadata.interactive_authorization_endpoint}'. Received response with status ${response.status}`, await response.clone().text(), response);
577
+ }
578
+ if (!result.success) throw new ValidationError("Error validating interactive authorization response", result.error);
579
+ const dpopNonce = extractDpopNonceFromHeaders(response.headers) ?? void 0;
580
+ return {
581
+ interactiveAuthorizationResponse: result.data,
582
+ dpop: dpop ? {
583
+ ...dpop,
584
+ nonce: dpopNonce
585
+ } : void 0
586
+ };
587
+ }
588
+ });
589
+ }
590
+
591
+ //#endregion
592
+ //#region src/interactive-authorization/verify-interactive-authorization-request.ts
593
+ /**
594
+ * Verify an initial (possibly signed) Interactive Authorization Request
595
+ *
596
+ * This function verifies the interactive authorization request including:
597
+ * - JAR (JWT-secured Authorization Request) signature verification (if present)
598
+ * - Client attestation (if present)
599
+ * - DPoP binding (if present)
600
+ * - Authorization request parameters
601
+ *
602
+ * @param options - Verification options
603
+ * @returns Verification result with client attestation and DPoP info
604
+ *
605
+ * @example Verify initial request
606
+ * ```ts
607
+ * const result = await verifyInteractiveAuthorizationInitialRequest({
608
+ * interactiveAuthorizationRequest: request,
609
+ * authorizationServerMetadata,
610
+ * callbacks: { fetch, verifyJwt }
611
+ * })
612
+ * ```
613
+ *
614
+ * @example Verify JAR request
615
+ * ```ts
616
+ * const result = await verifyInteractiveAuthorizationInitialRequest({
617
+ * interactiveAuthorizationRequest: jarRequest,
618
+ * interactiveAuthorizationRequestJwt: jwt,
619
+ * jwtSigner: { ... },
620
+ * authorizationServerMetadata,
621
+ * callbacks: { fetch, verifyJwt }
622
+ * })
623
+ * ```
624
+ */
625
+ async function verifyInteractiveAuthorizationInitialRequest(options) {
626
+ let jar;
627
+ if (options.interactiveAuthorizationRequestJwt) jar = await verifyJarRequest({
628
+ authorizationRequestJwt: options.interactiveAuthorizationRequestJwt.jwt,
629
+ jarRequestParams: options.interactiveAuthorizationRequest,
630
+ callbacks: options.callbacks,
631
+ jwtSigner: options.interactiveAuthorizationRequestJwt.signer
632
+ });
633
+ const { clientAttestation, dpop } = await verifyAuthorizationRequest({
634
+ ...options,
635
+ authorizationRequest: options.interactiveAuthorizationRequest
636
+ });
637
+ return {
638
+ dpop,
639
+ clientAttestation,
640
+ jar
641
+ };
642
+ }
643
+
200
644
  //#endregion
201
645
  //#region src/key-attestation/z-key-attestation.ts
202
- const zKeyAttestationJwtHeader = z.object({
646
+ const zKeyAttestationJwtHeader = z$1.object({
203
647
  ...zJwtHeader.shape,
204
- typ: z.literal("keyattestation+jwt").or(z.literal("key-attestation+jwt"))
648
+ typ: z$1.literal("keyattestation+jwt").or(z$1.literal("key-attestation+jwt"))
205
649
  }).loose().refine(({ kid, jwk }) => jwk === void 0 || kid === void 0, { message: `Both 'jwk' and 'kid' are defined. Only one is allowed` }).refine(({ trust_chain, kid }) => !trust_chain || !kid, { message: `When 'trust_chain' is provided, 'kid' is required` });
206
- const zIso18045 = z.enum([
650
+ const zIso18045 = z$1.enum([
207
651
  "iso_18045_high",
208
652
  "iso_18045_moderate",
209
653
  "iso_18045_enhanced-basic",
210
654
  "iso_18045_basic"
211
655
  ]);
212
- const zIso18045OrStringArray = z.array(z.union([zIso18045, z.string()]));
213
- const zKeyAttestationJwtPayload = z.object({
656
+ const zIso18045OrStringArray = z$1.array(z$1.union([zIso18045, z$1.string()]));
657
+ const zKeyAttestationJwtPayload = z$1.object({
214
658
  ...zJwtPayload.shape,
215
659
  iat: zNumericDate,
216
- attested_keys: z.array(zJwk),
217
- key_storage: z.optional(zIso18045OrStringArray),
218
- user_authentication: z.optional(zIso18045OrStringArray),
219
- certification: z.optional(z.url())
660
+ attested_keys: z$1.array(zJwk),
661
+ key_storage: z$1.optional(zIso18045OrStringArray),
662
+ user_authentication: z$1.optional(zIso18045OrStringArray),
663
+ certification: z$1.optional(z$1.url())
220
664
  }).loose();
221
- const zKeyAttestationJwtPayloadForUse = (use) => z.object({
665
+ const zKeyAttestationJwtPayloadForUse = (use) => z$1.object({
222
666
  ...zKeyAttestationJwtPayload.shape,
223
- nonce: use === "proof_type.attestation" ? z.string({ message: `Nonce must be defined when key attestation is used as 'proof_type.attestation' directly` }) : z.optional(z.string()),
224
- exp: use === "proof_type.jwt" ? zNumericDate : z.optional(zNumericDate)
667
+ nonce: use === "proof_type.attestation" ? z$1.string({ message: `Nonce must be defined when key attestation is used as 'proof_type.attestation' directly` }) : z$1.optional(z$1.string()),
668
+ exp: use === "proof_type.jwt" ? zNumericDate : z$1.optional(zNumericDate)
225
669
  }).loose();
226
670
 
227
671
  //#endregion
@@ -283,124 +727,124 @@ async function verifyKeyAttestationJwt(options) {
283
727
 
284
728
  //#endregion
285
729
  //#region src/metadata/credential-issuer/z-claims-description.ts
286
- const zCredentialConfigurationSupportedClaimsDescriptionDraft14 = z.object({
287
- mandatory: z.boolean().optional(),
288
- value_type: z.string().optional(),
289
- display: z.array(z.object({
290
- name: z.string().optional(),
291
- locale: z.string().optional()
730
+ const zCredentialConfigurationSupportedClaimsDescriptionDraft14 = z$1.object({
731
+ mandatory: z$1.boolean().optional(),
732
+ value_type: z$1.string().optional(),
733
+ display: z$1.array(z$1.object({
734
+ name: z$1.string().optional(),
735
+ locale: z$1.string().optional()
292
736
  }).loose()).optional()
293
737
  }).loose();
294
- const zCredentialConfigurationSupportedClaimsDraft14 = z.record(z.string(), z.union([zCredentialConfigurationSupportedClaimsDescriptionDraft14, z.lazy(() => zCredentialConfigurationSupportedClaimsDraft14)]));
295
- const zClaimDescriptionPathValue = z.union([
296
- z.string(),
297
- z.number().int().nonnegative(),
298
- z.null()
738
+ const zCredentialConfigurationSupportedClaimsDraft14 = z$1.record(z$1.string(), z$1.union([zCredentialConfigurationSupportedClaimsDescriptionDraft14, z$1.lazy(() => zCredentialConfigurationSupportedClaimsDraft14)]));
739
+ const zClaimDescriptionPathValue = z$1.union([
740
+ z$1.string(),
741
+ z$1.number().int().nonnegative(),
742
+ z$1.null()
299
743
  ]);
300
- const zClaimsDescriptionPath = z.tuple([zClaimDescriptionPathValue], zClaimDescriptionPathValue);
301
- const zMsoMdocClaimsDescriptionPath = z.tuple([z.string(), z.string()], zClaimDescriptionPathValue, { message: "mso_mdoc claims description path MUST be an array with at least two string elements, pointing to the namespace and element identifier within an mdoc credential" });
302
- const zIssuerMetadataClaimsDescription = z.object({
744
+ const zClaimsDescriptionPath = z$1.tuple([zClaimDescriptionPathValue], zClaimDescriptionPathValue);
745
+ const zMsoMdocClaimsDescriptionPath = z$1.tuple([z$1.string(), z$1.string()], zClaimDescriptionPathValue, { message: "mso_mdoc claims description path MUST be an array with at least two string elements, pointing to the namespace and element identifier within an mdoc credential" });
746
+ const zIssuerMetadataClaimsDescription = z$1.object({
303
747
  path: zClaimsDescriptionPath,
304
- mandatory: z.boolean().optional(),
305
- display: z.array(z.object({
306
- name: z.string().optional(),
307
- locale: z.string().optional()
748
+ mandatory: z$1.boolean().optional(),
749
+ display: z$1.array(z$1.object({
750
+ name: z$1.string().optional(),
751
+ locale: z$1.string().optional()
308
752
  }).loose()).optional()
309
753
  }).loose();
310
754
  const zMsoMdocIssuerMetadataClaimsDescription = zIssuerMetadataClaimsDescription.extend({ path: zMsoMdocClaimsDescriptionPath });
311
755
 
312
756
  //#endregion
313
757
  //#region src/metadata/credential-issuer/z-credential-configuration-supported-common.ts
314
- const zCredentialConfigurationSupportedDisplayEntry = z.object({
315
- name: z.string(),
316
- locale: z.string().optional(),
317
- logo: z.object({
758
+ const zCredentialConfigurationSupportedDisplayEntry = z$1.object({
759
+ name: z$1.string(),
760
+ locale: z$1.string().optional(),
761
+ logo: z$1.object({
318
762
  uri: zHttpsUrl.or(zDataUrl).optional(),
319
- alt_text: z.string().optional()
763
+ alt_text: z$1.string().optional()
320
764
  }).loose().optional(),
321
- description: z.string().optional(),
322
- background_color: z.string().optional(),
323
- background_image: z.object({ uri: zHttpsUrl.or(zDataUrl).optional() }).loose().optional(),
324
- text_color: z.string().optional()
765
+ description: z$1.string().optional(),
766
+ background_color: z$1.string().optional(),
767
+ background_image: z$1.object({ uri: zHttpsUrl.or(zDataUrl).optional() }).loose().optional(),
768
+ text_color: z$1.string().optional()
325
769
  }).loose();
326
- const zCredentialConfigurationSupportedCommonCredentialMetadata = z.object({ display: z.array(zCredentialConfigurationSupportedDisplayEntry).optional() }).loose();
327
- const zCredentialConfigurationSupportedCommon = z.object({
328
- format: z.string(),
329
- scope: z.string().optional(),
330
- cryptographic_binding_methods_supported: z.array(z.string()).optional(),
331
- credential_signing_alg_values_supported: z.array(z.string()).or(z.array(z.number())).optional(),
332
- proof_types_supported: z.record(z.union([
333
- z.literal("jwt"),
334
- z.literal("attestation"),
335
- z.string()
336
- ]), z.object({
337
- proof_signing_alg_values_supported: z.array(z.string()),
338
- key_attestations_required: z.object({
770
+ const zCredentialConfigurationSupportedCommonCredentialMetadata = z$1.object({ display: z$1.array(zCredentialConfigurationSupportedDisplayEntry).optional() }).loose();
771
+ const zCredentialConfigurationSupportedCommon = z$1.object({
772
+ format: z$1.string(),
773
+ scope: z$1.string().optional(),
774
+ cryptographic_binding_methods_supported: z$1.array(z$1.string()).optional(),
775
+ credential_signing_alg_values_supported: z$1.array(z$1.string()).or(z$1.array(z$1.number())).optional(),
776
+ proof_types_supported: z$1.record(z$1.union([
777
+ z$1.literal("jwt"),
778
+ z$1.literal("attestation"),
779
+ z$1.string()
780
+ ]), z$1.object({
781
+ proof_signing_alg_values_supported: z$1.array(z$1.string()),
782
+ key_attestations_required: z$1.object({
339
783
  key_storage: zIso18045OrStringArray.optional(),
340
784
  user_authentication: zIso18045OrStringArray.optional()
341
785
  }).loose().optional()
342
786
  })).optional(),
343
787
  credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.optional()
344
788
  }).loose();
345
- const zCredentialConfigurationSupportedCommonDraft15 = z.object({
346
- format: z.string(),
347
- scope: z.string().optional(),
348
- cryptographic_binding_methods_supported: z.array(z.string()).optional(),
349
- credential_signing_alg_values_supported: z.array(z.string()).optional(),
350
- proof_types_supported: z.record(z.union([
351
- z.literal("jwt"),
352
- z.literal("attestation"),
353
- z.string()
354
- ]), z.object({
355
- proof_signing_alg_values_supported: z.array(z.string()),
356
- key_attestations_required: z.object({
789
+ const zCredentialConfigurationSupportedCommonDraft15 = z$1.object({
790
+ format: z$1.string(),
791
+ scope: z$1.string().optional(),
792
+ cryptographic_binding_methods_supported: z$1.array(z$1.string()).optional(),
793
+ credential_signing_alg_values_supported: z$1.array(z$1.string()).optional(),
794
+ proof_types_supported: z$1.record(z$1.union([
795
+ z$1.literal("jwt"),
796
+ z$1.literal("attestation"),
797
+ z$1.string()
798
+ ]), z$1.object({
799
+ proof_signing_alg_values_supported: z$1.array(z$1.string()),
800
+ key_attestations_required: z$1.object({
357
801
  key_storage: zIso18045OrStringArray.optional(),
358
802
  user_authentication: zIso18045OrStringArray.optional()
359
803
  }).loose().optional()
360
804
  })).optional(),
361
- display: z.array(zCredentialConfigurationSupportedDisplayEntry).optional(),
362
- credential_metadata: z.optional(z.never())
805
+ display: z$1.array(zCredentialConfigurationSupportedDisplayEntry).optional(),
806
+ credential_metadata: z$1.optional(z$1.never())
363
807
  }).loose();
364
808
 
365
809
  //#endregion
366
810
  //#region src/formats/credential/mso-mdoc/z-mso-mdoc.ts
367
- const zMsoMdocFormatIdentifier = z.literal("mso_mdoc");
811
+ const zMsoMdocFormatIdentifier = z$1.literal("mso_mdoc");
368
812
  const zMsoMdocCredentialIssuerMetadata = zCredentialConfigurationSupportedCommon.extend({
369
813
  format: zMsoMdocFormatIdentifier,
370
- doctype: z.string(),
371
- credential_signing_alg_values_supported: z.array(z.number()).optional(),
372
- credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z.array(zMsoMdocIssuerMetadataClaimsDescription).optional() }).optional()
814
+ doctype: z$1.string(),
815
+ credential_signing_alg_values_supported: z$1.array(z$1.number()).optional(),
816
+ credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z$1.array(zMsoMdocIssuerMetadataClaimsDescription).optional() }).optional()
373
817
  });
374
818
  const zMsoMdocCredentialIssuerMetadataDraft15 = zCredentialConfigurationSupportedCommonDraft15.extend({
375
819
  format: zMsoMdocFormatIdentifier,
376
- doctype: z.string(),
377
- claims: z.array(zMsoMdocIssuerMetadataClaimsDescription).optional()
820
+ doctype: z$1.string(),
821
+ claims: z$1.array(zMsoMdocIssuerMetadataClaimsDescription).optional()
378
822
  });
379
823
  const zMsoMdocCredentialIssuerMetadataDraft14 = zCredentialConfigurationSupportedCommonDraft15.extend({
380
824
  format: zMsoMdocFormatIdentifier,
381
- doctype: z.string(),
825
+ doctype: z$1.string(),
382
826
  claims: zCredentialConfigurationSupportedClaimsDraft14.optional(),
383
- order: z.optional(z.array(z.string()))
827
+ order: z$1.optional(z$1.array(z$1.string()))
384
828
  });
385
- const zMsoMdocCredentialRequestFormatDraft14 = z.object({
829
+ const zMsoMdocCredentialRequestFormatDraft14 = z$1.object({
386
830
  format: zMsoMdocFormatIdentifier,
387
- doctype: z.string(),
831
+ doctype: z$1.string(),
388
832
  claims: zCredentialConfigurationSupportedClaimsDraft14.optional()
389
833
  });
390
834
 
391
835
  //#endregion
392
836
  //#region src/formats/credential/sd-jwt-dc/z-sd-jwt-dc.ts
393
- const zSdJwtDcFormatIdentifier = z.literal("dc+sd-jwt");
837
+ const zSdJwtDcFormatIdentifier = z$1.literal("dc+sd-jwt");
394
838
  const zSdJwtDcCredentialIssuerMetadata = zCredentialConfigurationSupportedCommon.extend({
395
- vct: z.string(),
839
+ vct: z$1.string(),
396
840
  format: zSdJwtDcFormatIdentifier,
397
- credential_signing_alg_values_supported: z.array(z.string()).optional(),
398
- credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z.array(zIssuerMetadataClaimsDescription).optional() }).optional()
841
+ credential_signing_alg_values_supported: z$1.array(z$1.string()).optional(),
842
+ credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z$1.array(zIssuerMetadataClaimsDescription).optional() }).optional()
399
843
  });
400
844
  const zSdJwtDcCredentialIssuerMetadataDraft15 = zCredentialConfigurationSupportedCommonDraft15.extend({
401
- vct: z.string(),
845
+ vct: z$1.string(),
402
846
  format: zSdJwtDcFormatIdentifier,
403
- claims: z.array(zIssuerMetadataClaimsDescription).optional()
847
+ claims: z$1.array(zIssuerMetadataClaimsDescription).optional()
404
848
  });
405
849
 
406
850
  //#endregion
@@ -410,19 +854,19 @@ const zSdJwtDcCredentialIssuerMetadataDraft15 = zCredentialConfigurationSupporte
410
854
  * of the OpenID for Verifiable Presentations specification. Please update your
411
855
  * implementations accordingly.
412
856
  */
413
- const zLegacySdJwtVcFormatIdentifier = z.literal("vc+sd-jwt");
857
+ const zLegacySdJwtVcFormatIdentifier = z$1.literal("vc+sd-jwt");
414
858
  /**
415
859
  * @deprecated format has been deprecated in favor of "dc+sd-jwt" since Draft 23
416
860
  * of the OpenID for Verifiable Presentations specification. Please update your
417
861
  * implementations accordingly.
418
862
  */
419
863
  const zLegacySdJwtVcCredentialIssuerMetadataV1 = zCredentialConfigurationSupportedCommon.extend({
420
- vct: z.string(),
864
+ vct: z$1.string(),
421
865
  format: zLegacySdJwtVcFormatIdentifier,
422
- order: z.optional(z.array(z.string())),
423
- credential_signing_alg_values_supported: z.array(z.string()).optional(),
424
- credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z.array(zIssuerMetadataClaimsDescription).optional() }).optional(),
425
- credential_definition: z.optional(z.never())
866
+ order: z$1.optional(z$1.array(z$1.string())),
867
+ credential_signing_alg_values_supported: z$1.array(z$1.string()).optional(),
868
+ credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z$1.array(zIssuerMetadataClaimsDescription).optional() }).optional(),
869
+ credential_definition: z$1.optional(z$1.never())
426
870
  });
427
871
  /**
428
872
  * @deprecated format has been deprecated in favor of "dc+sd-jwt" since Draft 23
@@ -430,71 +874,71 @@ const zLegacySdJwtVcCredentialIssuerMetadataV1 = zCredentialConfigurationSupport
430
874
  * implementations accordingly.
431
875
  */
432
876
  const zLegacySdJwtVcCredentialIssuerMetadataDraft14 = zCredentialConfigurationSupportedCommonDraft15.extend({
433
- vct: z.string(),
877
+ vct: z$1.string(),
434
878
  format: zLegacySdJwtVcFormatIdentifier,
435
- claims: z.optional(zCredentialConfigurationSupportedClaimsDraft14),
436
- order: z.optional(z.array(z.string())),
437
- credential_definition: z.optional(z.never())
879
+ claims: z$1.optional(zCredentialConfigurationSupportedClaimsDraft14),
880
+ order: z$1.optional(z$1.array(z$1.string())),
881
+ credential_definition: z$1.optional(z$1.never())
438
882
  });
439
883
  /**
440
884
  * @deprecated format has been deprecated in favor of "dc+sd-jwt" since Draft 23
441
885
  * of the OpenID for Verifiable Presentations specification. Please update your
442
886
  * implementations accordingly.
443
887
  */
444
- const zLegacySdJwtVcCredentialRequestFormatDraft14 = z.object({
888
+ const zLegacySdJwtVcCredentialRequestFormatDraft14 = z$1.object({
445
889
  format: zLegacySdJwtVcFormatIdentifier,
446
- vct: z.string(),
447
- claims: z.optional(zCredentialConfigurationSupportedClaimsDraft14),
448
- credential_definition: z.optional(z.never())
890
+ vct: z$1.string(),
891
+ claims: z$1.optional(zCredentialConfigurationSupportedClaimsDraft14),
892
+ credential_definition: z$1.optional(z$1.never())
449
893
  });
450
894
 
451
895
  //#endregion
452
896
  //#region src/formats/credential/w3c-vc/z-w3c-vc-common.ts
453
- const zCredentialSubjectLeafTypeDraft14 = z.object({
454
- mandatory: z.boolean().optional(),
455
- value_type: z.string().optional(),
456
- display: z.array(z.object({
457
- name: z.string().optional(),
458
- locale: z.string().optional()
897
+ const zCredentialSubjectLeafTypeDraft14 = z$1.object({
898
+ mandatory: z$1.boolean().optional(),
899
+ value_type: z$1.string().optional(),
900
+ display: z$1.array(z$1.object({
901
+ name: z$1.string().optional(),
902
+ locale: z$1.string().optional()
459
903
  }).loose()).optional()
460
904
  }).loose();
461
- const zClaimValueSchemaDraft14 = z.union([
462
- z.array(z.any()),
463
- z.record(z.string(), z.any()),
905
+ const zClaimValueSchemaDraft14 = z$1.union([
906
+ z$1.array(z$1.any()),
907
+ z$1.record(z$1.string(), z$1.any()),
464
908
  zCredentialSubjectLeafTypeDraft14
465
909
  ]);
466
- const zW3cVcCredentialSubjectDraft14 = z.record(z.string(), zClaimValueSchemaDraft14);
467
- const zW3cVcJsonLdCredentialDefinition = z.object({
468
- "@context": z.array(z.string()),
469
- type: z.tuple([z.string()], z.string())
910
+ const zW3cVcCredentialSubjectDraft14 = z$1.record(z$1.string(), zClaimValueSchemaDraft14);
911
+ const zW3cVcJsonLdCredentialDefinition = z$1.object({
912
+ "@context": z$1.array(z$1.string()),
913
+ type: z$1.tuple([z$1.string()], z$1.string())
470
914
  }).loose();
471
915
  const zW3cVcJsonLdCredentialDefinitionDraft14 = zW3cVcJsonLdCredentialDefinition.extend({ credentialSubject: zW3cVcCredentialSubjectDraft14.optional() });
472
916
 
473
917
  //#endregion
474
918
  //#region src/formats/credential/w3c-vc/z-w3c-jwt-vc-json.ts
475
- const zJwtVcJsonFormatIdentifier = z.literal("jwt_vc_json");
476
- const zJwtVcJsonCredentialDefinition = z.object({ type: z.tuple([z.string()], z.string()) }).loose();
919
+ const zJwtVcJsonFormatIdentifier = z$1.literal("jwt_vc_json");
920
+ const zJwtVcJsonCredentialDefinition = z$1.object({ type: z$1.tuple([z$1.string()], z$1.string()) }).loose();
477
921
  const zJwtVcJsonCredentialDefinitionDraft14 = zJwtVcJsonCredentialDefinition.extend({ credentialSubject: zW3cVcCredentialSubjectDraft14.optional() });
478
922
  const zJwtVcJsonCredentialIssuerMetadata = zCredentialConfigurationSupportedCommon.extend({
479
923
  format: zJwtVcJsonFormatIdentifier,
480
924
  credential_definition: zJwtVcJsonCredentialDefinition,
481
- credential_signing_alg_values_supported: z.array(z.string()).optional(),
482
- credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z.array(zIssuerMetadataClaimsDescription).optional() }).optional()
925
+ credential_signing_alg_values_supported: z$1.array(z$1.string()).optional(),
926
+ credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z$1.array(zIssuerMetadataClaimsDescription).optional() }).optional()
483
927
  });
484
928
  const zJwtVcJsonCredentialIssuerMetadataDraft15 = zCredentialConfigurationSupportedCommonDraft15.extend({
485
929
  format: zJwtVcJsonFormatIdentifier,
486
930
  credential_definition: zJwtVcJsonCredentialDefinition,
487
- claims: z.array(zIssuerMetadataClaimsDescription).optional()
931
+ claims: z$1.array(zIssuerMetadataClaimsDescription).optional()
488
932
  });
489
933
  const zJwtVcJsonCredentialIssuerMetadataDraft14 = zCredentialConfigurationSupportedCommonDraft15.extend({
490
934
  format: zJwtVcJsonFormatIdentifier,
491
935
  credential_definition: zJwtVcJsonCredentialDefinitionDraft14,
492
- order: z.array(z.string()).optional()
936
+ order: z$1.array(z$1.string()).optional()
493
937
  });
494
- const zJwtVcJsonCredentialIssuerMetadataDraft11 = z.object({
938
+ const zJwtVcJsonCredentialIssuerMetadataDraft11 = z$1.object({
495
939
  format: zJwtVcJsonFormatIdentifier,
496
- order: z.array(z.string()).optional(),
497
- types: z.tuple([z.string()], z.string()),
940
+ order: z$1.array(z$1.string()).optional(),
941
+ types: z$1.tuple([z$1.string()], z$1.string()),
498
942
  credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
499
943
  }).loose();
500
944
  const zJwtVcJsonCredentialIssuerMetadataDraft11To14 = zJwtVcJsonCredentialIssuerMetadataDraft11.transform(({ types, credentialSubject, ...rest }) => ({
@@ -509,14 +953,14 @@ const zJwtVcJsonCredentialIssuerMetadataDraft14To11 = zJwtVcJsonCredentialIssuer
509
953
  types: type,
510
954
  ...credentialDefinition
511
955
  })).pipe(zJwtVcJsonCredentialIssuerMetadataDraft11);
512
- const zJwtVcJsonCredentialRequestFormatDraft14 = z.object({
956
+ const zJwtVcJsonCredentialRequestFormatDraft14 = z$1.object({
513
957
  format: zJwtVcJsonFormatIdentifier,
514
958
  credential_definition: zJwtVcJsonCredentialDefinition
515
959
  });
516
- const zJwtVcJsonCredentialRequestDraft11 = z.object({
960
+ const zJwtVcJsonCredentialRequestDraft11 = z$1.object({
517
961
  format: zJwtVcJsonFormatIdentifier,
518
- types: z.tuple([z.string()], z.string()),
519
- credentialSubject: z.optional(zW3cVcCredentialSubjectDraft14)
962
+ types: z$1.tuple([z$1.string()], z$1.string()),
963
+ credentialSubject: z$1.optional(zW3cVcCredentialSubjectDraft14)
520
964
  }).loose();
521
965
  const zJwtVcJsonCredentialRequestDraft11To14 = zJwtVcJsonCredentialRequestDraft11.transform(({ types, credentialSubject, ...rest }) => {
522
966
  return {
@@ -535,28 +979,28 @@ const zJwtVcJsonCredentialRequestDraft14To11 = zJwtVcJsonCredentialRequestFormat
535
979
 
536
980
  //#endregion
537
981
  //#region src/formats/credential/w3c-vc/z-w3c-jwt-vc-json-ld.ts
538
- const zJwtVcJsonLdFormatIdentifier = z.literal("jwt_vc_json-ld");
982
+ const zJwtVcJsonLdFormatIdentifier = z$1.literal("jwt_vc_json-ld");
539
983
  const zJwtVcJsonLdCredentialIssuerMetadata = zCredentialConfigurationSupportedCommon.extend({
540
984
  format: zJwtVcJsonLdFormatIdentifier,
541
985
  credential_definition: zW3cVcJsonLdCredentialDefinition,
542
- credential_signing_alg_values_supported: z.array(z.string()).optional(),
543
- credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z.array(zIssuerMetadataClaimsDescription).optional() }).optional()
986
+ credential_signing_alg_values_supported: z$1.array(z$1.string()).optional(),
987
+ credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z$1.array(zIssuerMetadataClaimsDescription).optional() }).optional()
544
988
  });
545
989
  const zJwtVcJsonLdCredentialIssuerMetadataDraft15 = zCredentialConfigurationSupportedCommonDraft15.extend({
546
990
  format: zJwtVcJsonLdFormatIdentifier,
547
991
  credential_definition: zW3cVcJsonLdCredentialDefinition,
548
- claims: z.array(zIssuerMetadataClaimsDescription).optional()
992
+ claims: z$1.array(zIssuerMetadataClaimsDescription).optional()
549
993
  });
550
994
  const zJwtVcJsonLdCredentialIssuerMetadataDraft14 = zCredentialConfigurationSupportedCommonDraft15.extend({
551
995
  format: zJwtVcJsonLdFormatIdentifier,
552
996
  credential_definition: zW3cVcJsonLdCredentialDefinitionDraft14,
553
- order: z.optional(z.array(z.string()))
997
+ order: z$1.optional(z$1.array(z$1.string()))
554
998
  });
555
- const zJwtVcJsonLdCredentialIssuerMetadataDraft11 = z.object({
556
- order: z.array(z.string()).optional(),
999
+ const zJwtVcJsonLdCredentialIssuerMetadataDraft11 = z$1.object({
1000
+ order: z$1.array(z$1.string()).optional(),
557
1001
  format: zJwtVcJsonLdFormatIdentifier,
558
- "@context": z.array(z.string()),
559
- types: z.tuple([z.string()], z.string()),
1002
+ "@context": z$1.array(z$1.string()),
1003
+ types: z$1.tuple([z$1.string()], z$1.string()),
560
1004
  credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
561
1005
  }).loose();
562
1006
  const zJwtVcJsonLdCredentialIssuerMetadataDraft11To14 = zJwtVcJsonLdCredentialIssuerMetadataDraft11.transform(({ "@context": context, types, credentialSubject, ...rest }) => ({
@@ -572,16 +1016,16 @@ const zJwtVcJsonLdCredentialIssuerMetadataDraft14To11 = zJwtVcJsonLdCredentialIs
572
1016
  ...credentialDefinition,
573
1017
  types: type
574
1018
  })).pipe(zJwtVcJsonLdCredentialIssuerMetadataDraft11);
575
- const zJwtVcJsonLdCredentialRequestFormatDraft14 = z.object({
1019
+ const zJwtVcJsonLdCredentialRequestFormatDraft14 = z$1.object({
576
1020
  format: zJwtVcJsonLdFormatIdentifier,
577
1021
  credential_definition: zW3cVcJsonLdCredentialDefinition
578
1022
  });
579
- const zJwtVcJsonLdCredentialRequestDraft11 = z.object({
1023
+ const zJwtVcJsonLdCredentialRequestDraft11 = z$1.object({
580
1024
  format: zJwtVcJsonLdFormatIdentifier,
581
- credential_definition: z.object({
582
- "@context": z.array(z.string()),
583
- types: z.tuple([z.string()], z.string()),
584
- credentialSubject: z.optional(zW3cVcCredentialSubjectDraft14)
1025
+ credential_definition: z$1.object({
1026
+ "@context": z$1.array(z$1.string()),
1027
+ types: z$1.tuple([z$1.string()], z$1.string()),
1028
+ credentialSubject: z$1.optional(zW3cVcCredentialSubjectDraft14)
585
1029
  }).loose()
586
1030
  }).loose();
587
1031
  const zJwtVcJsonLdCredentialRequestDraft11To14 = zJwtVcJsonLdCredentialRequestDraft11.transform(({ credential_definition: { types, ...restCredentialDefinition }, ...rest }) => ({
@@ -601,28 +1045,28 @@ const zJwtVcJsonLdCredentialRequestDraft14To11 = zJwtVcJsonLdCredentialRequestFo
601
1045
 
602
1046
  //#endregion
603
1047
  //#region src/formats/credential/w3c-vc/z-w3c-ldp-vc.ts
604
- const zLdpVcFormatIdentifier = z.literal("ldp_vc");
1048
+ const zLdpVcFormatIdentifier = z$1.literal("ldp_vc");
605
1049
  const zLdpVcCredentialIssuerMetadata = zCredentialConfigurationSupportedCommon.extend({
606
1050
  format: zLdpVcFormatIdentifier,
607
1051
  credential_definition: zW3cVcJsonLdCredentialDefinition,
608
- credential_signing_alg_values_supported: z.array(z.string()).optional(),
609
- credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z.array(zIssuerMetadataClaimsDescription).optional() }).optional()
1052
+ credential_signing_alg_values_supported: z$1.array(z$1.string()).optional(),
1053
+ credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z$1.array(zIssuerMetadataClaimsDescription).optional() }).optional()
610
1054
  });
611
1055
  const zLdpVcCredentialIssuerMetadataDraft15 = zCredentialConfigurationSupportedCommonDraft15.extend({
612
1056
  format: zLdpVcFormatIdentifier,
613
1057
  credential_definition: zW3cVcJsonLdCredentialDefinition,
614
- claims: z.array(zIssuerMetadataClaimsDescription).optional()
1058
+ claims: z$1.array(zIssuerMetadataClaimsDescription).optional()
615
1059
  });
616
1060
  const zLdpVcCredentialIssuerMetadataDraft14 = zCredentialConfigurationSupportedCommonDraft15.extend({
617
1061
  format: zLdpVcFormatIdentifier,
618
1062
  credential_definition: zW3cVcJsonLdCredentialDefinitionDraft14,
619
- order: z.array(z.string()).optional()
1063
+ order: z$1.array(z$1.string()).optional()
620
1064
  });
621
- const zLdpVcCredentialIssuerMetadataDraft11 = z.object({
622
- order: z.array(z.string()).optional(),
1065
+ const zLdpVcCredentialIssuerMetadataDraft11 = z$1.object({
1066
+ order: z$1.array(z$1.string()).optional(),
623
1067
  format: zLdpVcFormatIdentifier,
624
- "@context": z.array(z.string()),
625
- types: z.tuple([z.string()], z.string()),
1068
+ "@context": z$1.array(z$1.string()),
1069
+ types: z$1.tuple([z$1.string()], z$1.string()),
626
1070
  credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
627
1071
  }).loose();
628
1072
  const zLdpVcCredentialIssuerMetadataDraft11To14 = zLdpVcCredentialIssuerMetadataDraft11.transform(({ "@context": context, types, credentialSubject, ...rest }) => ({
@@ -638,15 +1082,15 @@ const zLdpVcCredentialIssuerMetadataDraft14To11 = zLdpVcCredentialIssuerMetadata
638
1082
  ...credentialDefinition,
639
1083
  types: type
640
1084
  })).pipe(zLdpVcCredentialIssuerMetadataDraft11);
641
- const zLdpVcCredentialRequestFormatDraft14 = z.object({
1085
+ const zLdpVcCredentialRequestFormatDraft14 = z$1.object({
642
1086
  format: zLdpVcFormatIdentifier,
643
1087
  credential_definition: zW3cVcJsonLdCredentialDefinitionDraft14
644
1088
  });
645
- const zLdpVcCredentialRequestDraft11 = z.object({
1089
+ const zLdpVcCredentialRequestDraft11 = z$1.object({
646
1090
  format: zLdpVcFormatIdentifier,
647
- credential_definition: z.object({
648
- "@context": z.array(z.string()),
649
- types: z.tuple([z.string()], z.string()),
1091
+ credential_definition: z$1.object({
1092
+ "@context": z$1.array(z$1.string()),
1093
+ types: z$1.tuple([z$1.string()], z$1.string()),
650
1094
  credentialSubject: zW3cVcCredentialSubjectDraft14.optional()
651
1095
  })
652
1096
  }).loose();
@@ -667,25 +1111,25 @@ const zLdpVcCredentialRequestDraft14To11 = zLdpVcCredentialRequestFormatDraft14.
667
1111
 
668
1112
  //#endregion
669
1113
  //#region src/formats/credential/w3c-vc/z-w3c-sd-jwt-vc.ts
670
- const zSdJwtW3VcFormatIdentifier = z.literal("vc+sd-jwt");
671
- const zSdJwtW3VcCredentialDefinition = z.object({ type: z.tuple([z.string()], z.string()) }).loose();
1114
+ const zSdJwtW3VcFormatIdentifier = z$1.literal("vc+sd-jwt");
1115
+ const zSdJwtW3VcCredentialDefinition = z$1.object({ type: z$1.tuple([z$1.string()], z$1.string()) }).loose();
672
1116
  const zSdJwtW3VcCredentialIssuerMetadata = zCredentialConfigurationSupportedCommon.extend({
673
1117
  format: zSdJwtW3VcFormatIdentifier,
674
1118
  credential_definition: zSdJwtW3VcCredentialDefinition,
675
- credential_signing_alg_values_supported: z.array(z.string()).optional(),
676
- credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z.array(zIssuerMetadataClaimsDescription).optional() }).optional(),
677
- vct: z.optional(z.never())
1119
+ credential_signing_alg_values_supported: z$1.array(z$1.string()).optional(),
1120
+ credential_metadata: zCredentialConfigurationSupportedCommonCredentialMetadata.extend({ claims: z$1.array(zIssuerMetadataClaimsDescription).optional() }).optional(),
1121
+ vct: z$1.optional(z$1.never())
678
1122
  });
679
1123
  const zSdJwtW3VcCredentialIssuerMetadataDraft15 = zCredentialConfigurationSupportedCommonDraft15.extend({
680
1124
  format: zSdJwtW3VcFormatIdentifier,
681
1125
  credential_definition: zSdJwtW3VcCredentialDefinition,
682
- claims: z.array(zIssuerMetadataClaimsDescription).optional(),
683
- vct: z.optional(z.never())
1126
+ claims: z$1.array(zIssuerMetadataClaimsDescription).optional(),
1127
+ vct: z$1.optional(z$1.never())
684
1128
  });
685
- const zSdJwtW3VcCredentialRequestFormatDraft14 = z.object({
1129
+ const zSdJwtW3VcCredentialRequestFormatDraft14 = z$1.object({
686
1130
  format: zSdJwtW3VcFormatIdentifier,
687
1131
  credential_definition: zSdJwtW3VcCredentialDefinition,
688
- vct: z.optional(z.never())
1132
+ vct: z$1.optional(z$1.never())
689
1133
  });
690
1134
 
691
1135
  //#endregion
@@ -711,50 +1155,50 @@ const allCredentialIssuerMetadataFormats = [
711
1155
  zJwtVcJsonCredentialIssuerMetadataDraft14
712
1156
  ];
713
1157
  const allCredentialIssuerMetadataFormatIdentifiers = allCredentialIssuerMetadataFormats.map((format) => format.shape.format.value);
714
- const zCredentialConfigurationSupportedWithFormats = z.union([zCredentialConfigurationSupportedCommon, zCredentialConfigurationSupportedCommonDraft15]).transform((data, ctx) => {
1158
+ const zCredentialConfigurationSupportedWithFormats = z$1.union([zCredentialConfigurationSupportedCommon, zCredentialConfigurationSupportedCommonDraft15]).transform((data, ctx) => {
715
1159
  if (!allCredentialIssuerMetadataFormatIdentifiers.includes(data.format)) return data;
716
1160
  const validators = allCredentialIssuerMetadataFormats.filter((formatValidator) => formatValidator.shape.format.value === data.format);
717
- const result = z.object({}).loose().and(validators.length > 1 ? z.union(validators) : validators[0]).safeParse(data);
1161
+ const result = z$1.object({}).loose().and(validators.length > 1 ? z$1.union(validators) : validators[0]).safeParse(data);
718
1162
  if (result.success) return result.data;
719
1163
  for (const issue of result.error.issues) ctx.addIssue({
720
1164
  ...issue,
721
1165
  code: issue.code
722
1166
  });
723
- return z.NEVER;
1167
+ return z$1.NEVER;
724
1168
  });
725
- const zCredentialIssuerMetadataDisplayEntry = z.object({
726
- name: z.string().optional(),
727
- locale: z.string().optional(),
728
- logo: z.object({
1169
+ const zCredentialIssuerMetadataDisplayEntry = z$1.object({
1170
+ name: z$1.string().optional(),
1171
+ locale: z$1.string().optional(),
1172
+ logo: z$1.object({
729
1173
  uri: zHttpsUrl.or(zDataUrl).optional(),
730
- alt_text: z.string().optional()
1174
+ alt_text: z$1.string().optional()
731
1175
  }).loose().optional()
732
1176
  }).loose();
733
- const zCredentialIssuerMetadataDraft14Draft15V1 = z.object({
1177
+ const zCredentialIssuerMetadataDraft14Draft15V1 = z$1.object({
734
1178
  credential_issuer: zHttpsUrl,
735
- authorization_servers: z.array(zHttpsUrl).optional(),
1179
+ authorization_servers: z$1.array(zHttpsUrl).optional(),
736
1180
  credential_endpoint: zHttpsUrl,
737
1181
  deferred_credential_endpoint: zHttpsUrl.optional(),
738
1182
  notification_endpoint: zHttpsUrl.optional(),
739
1183
  nonce_endpoint: zHttpsUrl.optional(),
740
- credential_response_encryption: z.object({
741
- alg_values_supported: z.array(z.string()),
742
- enc_values_supported: z.array(z.string()),
743
- encryption_required: z.boolean()
1184
+ credential_response_encryption: z$1.object({
1185
+ alg_values_supported: z$1.array(z$1.string()),
1186
+ enc_values_supported: z$1.array(z$1.string()),
1187
+ encryption_required: z$1.boolean()
744
1188
  }).loose().optional(),
745
- batch_credential_issuance: z.object({ batch_size: z.number().positive() }).loose().optional(),
746
- display: z.array(zCredentialIssuerMetadataDisplayEntry).optional(),
747
- credential_configurations_supported: z.record(z.string(), zCredentialConfigurationSupportedCommon)
1189
+ batch_credential_issuance: z$1.object({ batch_size: z$1.number().positive() }).loose().optional(),
1190
+ display: z$1.array(zCredentialIssuerMetadataDisplayEntry).optional(),
1191
+ credential_configurations_supported: z$1.record(z$1.string(), zCredentialConfigurationSupportedCommon)
748
1192
  }).loose();
749
- const zCredentialConfigurationSupportedDraft11ToV1 = z.object({
750
- id: z.string().optional(),
751
- format: z.string(),
752
- cryptographic_suites_supported: z.array(z.string()).optional(),
753
- display: z.array(z.object({
754
- logo: z.object({ url: zHttpsUrl.or(zDataUrl).optional() }).loose().optional(),
755
- background_image: z.object({ url: zHttpsUrl.or(zDataUrl).optional() }).loose().optional()
1193
+ const zCredentialConfigurationSupportedDraft11ToV1 = z$1.object({
1194
+ id: z$1.string().optional(),
1195
+ format: z$1.string(),
1196
+ cryptographic_suites_supported: z$1.array(z$1.string()).optional(),
1197
+ display: z$1.array(z$1.object({
1198
+ logo: z$1.object({ url: zHttpsUrl.or(zDataUrl).optional() }).loose().optional(),
1199
+ background_image: z$1.object({ url: zHttpsUrl.or(zDataUrl).optional() }).loose().optional()
756
1200
  }).loose()).optional(),
757
- claims: z.any().transform((claims) => claimsObjectToClaimsArray(claims)).optional()
1201
+ claims: z$1.any().transform((claims) => claimsObjectToClaimsArray(claims)).optional()
758
1202
  }).loose().transform(({ cryptographic_suites_supported, display, claims, id, format, ...rest }) => ({
759
1203
  ...rest,
760
1204
  format: format === "vc+sd-jwt" && rest.vct ? "dc+sd-jwt" : format,
@@ -780,7 +1224,7 @@ const zCredentialConfigurationSupportedDraft11ToV1 = z.object({
780
1224
  ...issue,
781
1225
  code: issue.code
782
1226
  });
783
- return z.NEVER;
1227
+ return z$1.NEVER;
784
1228
  }).pipe(zCredentialConfigurationSupportedWithFormats);
785
1229
  const zCredentialConfigurationSupportedV1ToDraft11 = zCredentialConfigurationSupportedWithFormats.transform(({ credential_metadata, ...rest }) => ({
786
1230
  ...credential_metadata,
@@ -794,7 +1238,7 @@ const zCredentialConfigurationSupportedV1ToDraft11 = zCredentialConfigurationSup
794
1238
  path: ["id"],
795
1239
  message: "Missing required id field"
796
1240
  });
797
- return z.NEVER;
1241
+ return z$1.NEVER;
798
1242
  }
799
1243
  return {
800
1244
  ...configuration,
@@ -821,26 +1265,26 @@ const zCredentialConfigurationSupportedV1ToDraft11 = zCredentialConfigurationSup
821
1265
  };
822
1266
  }) } : {},
823
1267
  id
824
- })).pipe(z.union([
1268
+ })).pipe(z$1.union([
825
1269
  zLdpVcCredentialIssuerMetadataDraft14To11,
826
1270
  zJwtVcJsonCredentialIssuerMetadataDraft14To11,
827
1271
  zJwtVcJsonLdCredentialIssuerMetadataDraft14To11,
828
- z.object({ format: z.string().refine((input) => ![
1272
+ z$1.object({ format: z$1.string().refine((input) => ![
829
1273
  zLdpVcFormatIdentifier.value,
830
1274
  zJwtVcJsonFormatIdentifier.value,
831
1275
  zJwtVcJsonLdFormatIdentifier.value
832
1276
  ].includes(input)) }).loose()
833
1277
  ]));
834
- const zCredentialIssuerMetadataDraft11ToV1 = z.object({
835
- authorization_server: z.string().optional(),
836
- credentials_supported: z.array(z.object({ id: z.string().optional() }).loose())
1278
+ const zCredentialIssuerMetadataDraft11ToV1 = z$1.object({
1279
+ authorization_server: z$1.string().optional(),
1280
+ credentials_supported: z$1.array(z$1.object({ id: z$1.string().optional() }).loose())
837
1281
  }).loose().transform(({ authorization_server, credentials_supported, ...rest }) => {
838
1282
  return {
839
1283
  ...rest,
840
1284
  ...authorization_server ? { authorization_servers: [authorization_server] } : {},
841
1285
  credential_configurations_supported: Object.fromEntries(credentials_supported.map((supported) => supported.id ? [supported.id, supported] : void 0).filter((i) => i !== void 0))
842
1286
  };
843
- }).pipe(z.object({ credential_configurations_supported: z.record(z.string(), zCredentialConfigurationSupportedDraft11ToV1) }).loose()).pipe(zCredentialIssuerMetadataDraft14Draft15V1);
1287
+ }).pipe(z$1.object({ credential_configurations_supported: z$1.record(z$1.string(), zCredentialConfigurationSupportedDraft11ToV1) }).loose()).pipe(zCredentialIssuerMetadataDraft14Draft15V1);
844
1288
  const zCredentialIssuerMetadataWithDraft11 = zCredentialIssuerMetadataDraft14Draft15V1.transform((issuerMetadata) => ({
845
1289
  ...issuerMetadata,
846
1290
  ...issuerMetadata.authorization_servers ? { authorization_server: issuerMetadata.authorization_servers[0] } : {},
@@ -848,9 +1292,9 @@ const zCredentialIssuerMetadataWithDraft11 = zCredentialIssuerMetadataDraft14Dra
848
1292
  ...value,
849
1293
  id
850
1294
  }))
851
- })).pipe(zCredentialIssuerMetadataDraft14Draft15V1.extend({ credentials_supported: z.array(zCredentialConfigurationSupportedV1ToDraft11) }));
852
- const zCredentialIssuerMetadata = z.union([zCredentialIssuerMetadataDraft14Draft15V1, zCredentialIssuerMetadataDraft11ToV1]);
853
- const zCredentialIssuerMetadataWithDraftVersion = z.union([zCredentialIssuerMetadataDraft14Draft15V1.transform((credentialIssuerMetadata) => {
1295
+ })).pipe(zCredentialIssuerMetadataDraft14Draft15V1.extend({ credentials_supported: z$1.array(zCredentialConfigurationSupportedV1ToDraft11) }));
1296
+ const zCredentialIssuerMetadata = z$1.union([zCredentialIssuerMetadataDraft14Draft15V1, zCredentialIssuerMetadataDraft11ToV1]);
1297
+ const zCredentialIssuerMetadataWithDraftVersion = z$1.union([zCredentialIssuerMetadataDraft14Draft15V1.transform((credentialIssuerMetadata) => {
854
1298
  const credentialConfigurations = Object.values(credentialIssuerMetadata.credential_configurations_supported);
855
1299
  const isDraft15 = credentialConfigurations.some((configuration) => {
856
1300
  const knownConfiguration = configuration;
@@ -929,16 +1373,25 @@ function claimsObjectToClaimsArray(claims) {
929
1373
  return result;
930
1374
  }
931
1375
 
1376
+ //#endregion
1377
+ //#region src/authorization-flow.ts
1378
+ let AuthorizationFlow = /* @__PURE__ */ function(AuthorizationFlow$1) {
1379
+ AuthorizationFlow$1["Oauth2Redirect"] = "Oauth2Redirect";
1380
+ AuthorizationFlow$1["PresentationDuringIssuance"] = "PresentationDuringIssuance";
1381
+ AuthorizationFlow$1["InteractiveAuthorizationOpenid4vp"] = "InteractiveAuthorizationOpenid4vp";
1382
+ return AuthorizationFlow$1;
1383
+ }({});
1384
+
932
1385
  //#endregion
933
1386
  //#region src/metadata/credential-issuer/z-signed-credential-issuer-metadata.ts
934
- const zSignedCredentialIssuerMetadataHeader = z.object({
1387
+ const zSignedCredentialIssuerMetadataHeader = z$1.object({
935
1388
  ...zJwtHeader.shape,
936
- typ: z.literal("openidvci-issuer-metadata+jwt")
1389
+ typ: z$1.literal("openidvci-issuer-metadata+jwt")
937
1390
  }).loose();
938
- const zSignedCredentialIssuerMetadataPayload = z.object({
1391
+ const zSignedCredentialIssuerMetadataPayload = z$1.object({
939
1392
  ...zJwtPayload.shape,
940
1393
  iat: zNumericDate,
941
- sub: z.string(),
1394
+ sub: z$1.string(),
942
1395
  ...zCredentialIssuerMetadataDraft14Draft15V1.shape
943
1396
  }).loose();
944
1397
 
@@ -1078,9 +1531,9 @@ function getCredentialRequestFormatPayloadForCredentialConfigurationId(options)
1078
1531
 
1079
1532
  //#endregion
1080
1533
  //#region src/formats/proof-type/attestation/z-attestation-proof-type.ts
1081
- const zAttestationProofTypeIdentifier = z.literal("attestation");
1534
+ const zAttestationProofTypeIdentifier = z$1.literal("attestation");
1082
1535
  const attestationProofTypeIdentifier = zAttestationProofTypeIdentifier.value;
1083
- const zCredentialRequestProofAttestation = z.object({
1536
+ const zCredentialRequestProofAttestation = z$1.object({
1084
1537
  proof_type: zAttestationProofTypeIdentifier,
1085
1538
  attestation: zCompactJwt
1086
1539
  });
@@ -1088,40 +1541,40 @@ const zCredentialRequestAttestationProofTypePayload = zKeyAttestationJwtPayloadF
1088
1541
 
1089
1542
  //#endregion
1090
1543
  //#region src/formats/proof-type/jwt/z-jwt-proof-type.ts
1091
- const zJwtProofTypeIdentifier = z.literal("jwt");
1544
+ const zJwtProofTypeIdentifier = z$1.literal("jwt");
1092
1545
  const jwtProofTypeIdentifier = zJwtProofTypeIdentifier.value;
1093
- const zCredentialRequestProofJwt = z.object({
1546
+ const zCredentialRequestProofJwt = z$1.object({
1094
1547
  proof_type: zJwtProofTypeIdentifier,
1095
1548
  jwt: zCompactJwt
1096
1549
  });
1097
1550
  const zCredentialRequestJwtProofTypeHeader = zJwtHeader.extend({
1098
- key_attestation: z.optional(zCompactJwt),
1099
- typ: z.literal("openid4vci-proof+jwt")
1551
+ key_attestation: z$1.optional(zCompactJwt),
1552
+ typ: z$1.literal("openid4vci-proof+jwt")
1100
1553
  }).loose().refine(({ kid, jwk }) => jwk === void 0 || kid === void 0, { message: `Both 'jwk' and 'kid' are defined. Only one is allowed` }).refine(({ trust_chain, kid }) => !trust_chain || !kid, { message: `When 'trust_chain' is provided, 'kid' is required` });
1101
- const zCredentialRequestJwtProofTypePayload = z.object({
1554
+ const zCredentialRequestJwtProofTypePayload = z$1.object({
1102
1555
  ...zJwtPayload.shape,
1103
- aud: z.union([zHttpsUrl, z.array(zHttpsUrl)]),
1556
+ aud: z$1.union([zHttpsUrl, z$1.array(zHttpsUrl)]),
1104
1557
  iat: zNumericDate
1105
1558
  }).loose();
1106
1559
 
1107
1560
  //#endregion
1108
1561
  //#region src/credential-request/z-credential-request-common.ts
1109
- const zCredentialRequestProofCommon = z.object({ proof_type: z.string() }).loose();
1562
+ const zCredentialRequestProofCommon = z$1.object({ proof_type: z$1.string() }).loose();
1110
1563
  const allCredentialRequestProofs = [zCredentialRequestProofJwt, zCredentialRequestProofAttestation];
1111
- const zCredentialRequestProof = z.union([zCredentialRequestProofCommon, z.discriminatedUnion("proof_type", allCredentialRequestProofs)]);
1112
- const zCredentialRequestProofsCommon = z.record(z.string(), z.array(z.unknown()));
1113
- const zCredentialRequestProofs = z.object({
1114
- [zJwtProofTypeIdentifier.value]: z.optional(z.array(zCredentialRequestProofJwt.shape.jwt)),
1115
- [zAttestationProofTypeIdentifier.value]: z.optional(z.array(zCredentialRequestProofAttestation.shape.attestation))
1564
+ const zCredentialRequestProof = z$1.union([zCredentialRequestProofCommon, z$1.discriminatedUnion("proof_type", allCredentialRequestProofs)]);
1565
+ const zCredentialRequestProofsCommon = z$1.record(z$1.string(), z$1.array(z$1.unknown()));
1566
+ const zCredentialRequestProofs = z$1.object({
1567
+ [zJwtProofTypeIdentifier.value]: z$1.optional(z$1.array(zCredentialRequestProofJwt.shape.jwt)),
1568
+ [zAttestationProofTypeIdentifier.value]: z$1.optional(z$1.array(zCredentialRequestProofAttestation.shape.attestation))
1116
1569
  });
1117
- const zCredentialResponseEncryption = z.object({
1570
+ const zCredentialResponseEncryption = z$1.object({
1118
1571
  jwk: zJwk,
1119
- alg: z.string(),
1120
- enc: z.string()
1572
+ alg: z$1.string(),
1573
+ enc: z$1.string()
1121
1574
  }).loose();
1122
- const zCredentialRequestCommon = z.object({
1575
+ const zCredentialRequestCommon = z$1.object({
1123
1576
  proof: zCredentialRequestProof.optional(),
1124
- proofs: z.optional(z.intersection(zCredentialRequestProofsCommon, zCredentialRequestProofs).refine((proofs) => Object.values(proofs).length === 1, { message: `The 'proofs' object in a credential request should contain exactly one attribute` })),
1577
+ proofs: z$1.optional(z$1.intersection(zCredentialRequestProofsCommon, zCredentialRequestProofs).refine((proofs) => Object.values(proofs).length === 1, { message: `The 'proofs' object in a credential request should contain exactly one attribute` })),
1125
1578
  credential_response_encryption: zCredentialResponseEncryption.optional()
1126
1579
  }).loose().refine(({ proof, proofs }) => !(proof !== void 0 && proofs !== void 0), { message: `Both 'proof' and 'proofs' are defined. Only one is allowed` });
1127
1580
 
@@ -1136,31 +1589,31 @@ const allCredentialRequestFormats = [
1136
1589
  zLegacySdJwtVcCredentialRequestFormatDraft14
1137
1590
  ];
1138
1591
  const allCredentialRequestFormatIdentifiers = allCredentialRequestFormats.map((format) => format.shape.format.value);
1139
- const zCredentialRequestCredentialConfigurationId = z.object({
1140
- credential_configuration_id: z.string(),
1141
- credential_identifier: z.never({ message: "'credential_identifier' cannot be defined when 'credential_configuration_id' is set." }).optional()
1592
+ const zCredentialRequestCredentialConfigurationId = z$1.object({
1593
+ credential_configuration_id: z$1.string(),
1594
+ credential_identifier: z$1.never({ message: "'credential_identifier' cannot be defined when 'credential_configuration_id' is set." }).optional()
1142
1595
  });
1143
- const zAuthorizationDetailsCredentialRequest = z.object({
1144
- credential_identifier: z.string(),
1145
- credential_configuration_id: z.never({ message: "'credential_configuration_id' cannot be defined when 'credential_identifier' is set." }).optional()
1596
+ const zAuthorizationDetailsCredentialRequest = z$1.object({
1597
+ credential_identifier: z$1.string(),
1598
+ credential_configuration_id: z$1.never({ message: "'credential_configuration_id' cannot be defined when 'credential_identifier' is set." }).optional()
1146
1599
  });
1147
- const zCredentialRequestFormat = z.object({
1148
- format: z.string(),
1149
- credential_identifier: z.never({ message: "'credential_identifier' cannot be defined when 'format' is set." }).optional(),
1150
- credential_configuration_id: z.never({ message: "'credential_configuration_id' cannot be defined when 'format' is set." }).optional()
1600
+ const zCredentialRequestFormat = z$1.object({
1601
+ format: z$1.string(),
1602
+ credential_identifier: z$1.never({ message: "'credential_identifier' cannot be defined when 'format' is set." }).optional(),
1603
+ credential_configuration_id: z$1.never({ message: "'credential_configuration_id' cannot be defined when 'format' is set." }).optional()
1151
1604
  }).loose();
1152
1605
  const zCredentialRequestDraft14WithFormat = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
1153
1606
  if (!allCredentialRequestFormatIdentifiers.includes(data.format)) return data;
1154
- const result = z.object({}).loose().and(z.union(allCredentialRequestFormats)).safeParse(data);
1607
+ const result = z$1.object({}).loose().and(z$1.union(allCredentialRequestFormats)).safeParse(data);
1155
1608
  if (result.success) return result.data;
1156
1609
  for (const issue of result.error.issues) ctx.addIssue({
1157
1610
  ...issue,
1158
1611
  code: issue.code
1159
1612
  });
1160
- return z.NEVER;
1613
+ return z$1.NEVER;
1161
1614
  });
1162
- const zCredentialRequestDraft15 = z.union([zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest), zCredentialRequestCommon.and(zCredentialRequestCredentialConfigurationId)]);
1163
- const zCredentialRequestDraft14 = z.union([zCredentialRequestDraft14WithFormat, zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest)]);
1615
+ const zCredentialRequestDraft15 = z$1.union([zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest), zCredentialRequestCommon.and(zCredentialRequestCredentialConfigurationId)]);
1616
+ const zCredentialRequestDraft14 = z$1.union([zCredentialRequestDraft14WithFormat, zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest)]);
1164
1617
  const zCredentialRequestDraft11To14 = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
1165
1618
  const formatSpecificTransformations = {
1166
1619
  [zLdpVcFormatIdentifier.value]: zLdpVcCredentialRequestDraft11To14,
@@ -1174,7 +1627,7 @@ const zCredentialRequestDraft11To14 = zCredentialRequestCommon.and(zCredentialRe
1174
1627
  ...issue,
1175
1628
  code: issue.code
1176
1629
  });
1177
- return z.NEVER;
1630
+ return z$1.NEVER;
1178
1631
  }).pipe(zCredentialRequestDraft14);
1179
1632
  const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.transform((data, ctx) => {
1180
1633
  if (data.credential_identifier !== void 0) {
@@ -1184,7 +1637,7 @@ const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.transform((data,
1184
1637
  message: `'credential_identifier' is not supported in OpenID4VCI draft 11`,
1185
1638
  path: ["credential_identifier"]
1186
1639
  });
1187
- return z.NEVER;
1640
+ return z$1.NEVER;
1188
1641
  }
1189
1642
  const formatSpecificTransformations = {
1190
1643
  [zLdpVcFormatIdentifier.value]: zLdpVcCredentialRequestDraft14To11,
@@ -1198,15 +1651,15 @@ const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.transform((data,
1198
1651
  ...issue,
1199
1652
  code: issue.code
1200
1653
  });
1201
- return z.NEVER;
1654
+ return z$1.NEVER;
1202
1655
  });
1203
- const zCredentialRequest = z.union([
1656
+ const zCredentialRequest = z$1.union([
1204
1657
  zCredentialRequestDraft15,
1205
1658
  zCredentialRequestDraft14,
1206
1659
  zCredentialRequestDraft11To14
1207
1660
  ]);
1208
- const zDeferredCredentialRequest = z.object({
1209
- transaction_id: z.string().nonempty(),
1661
+ const zDeferredCredentialRequest = z$1.object({
1662
+ transaction_id: z$1.string().nonempty(),
1210
1663
  credential_response_encryption: zCredentialResponseEncryption.optional()
1211
1664
  });
1212
1665
 
@@ -1238,6 +1691,7 @@ let Oauth2ErrorCodes$1 = /* @__PURE__ */ function(Oauth2ErrorCodes$2) {
1238
1691
  Oauth2ErrorCodes$2["InvalidTransactionId"] = "invalid_transaction_id";
1239
1692
  Oauth2ErrorCodes$2["UnsupportedCredentialType"] = "unsupported_credential_type";
1240
1693
  Oauth2ErrorCodes$2["UnsupportedCredentialFormat"] = "unsupported_credential_format";
1694
+ Oauth2ErrorCodes$2["MissingInteractionType"] = "missing_interaction_type";
1241
1695
  Oauth2ErrorCodes$2["InvalidRequestUri"] = "invalid_request_uri";
1242
1696
  Oauth2ErrorCodes$2["InvalidRequestObject"] = "invalid_request_object";
1243
1697
  Oauth2ErrorCodes$2["RequestNotSupported"] = "request_not_supported";
@@ -1251,25 +1705,25 @@ let Oauth2ErrorCodes$1 = /* @__PURE__ */ function(Oauth2ErrorCodes$2) {
1251
1705
  Oauth2ErrorCodes$2["WalletUnavailable"] = "wallet_unavailable";
1252
1706
  return Oauth2ErrorCodes$2;
1253
1707
  }({});
1254
- const zOauth2ErrorResponse = z.object({
1255
- error: z.union([z.enum(Oauth2ErrorCodes$1), z.string()]),
1256
- error_description: z.string().optional(),
1257
- error_uri: z.string().optional()
1708
+ const zOauth2ErrorResponse$1 = z$1.object({
1709
+ error: z$1.union([z$1.enum(Oauth2ErrorCodes$1), z$1.string()]),
1710
+ error_description: z$1.string().optional(),
1711
+ error_uri: z$1.string().optional()
1258
1712
  }).loose();
1259
1713
 
1260
1714
  //#endregion
1261
1715
  //#region src/credential-request/z-credential-response.ts
1262
- const zCredentialEncoding = z.union([z.string(), z.record(z.string(), z.any())]);
1263
- const zBaseCredentialResponse = z.object({
1264
- credentials: z.union([z.array(z.object({ credential: zCredentialEncoding })), z.array(zCredentialEncoding)]).optional(),
1265
- notification_id: z.string().optional(),
1266
- transaction_id: z.string().optional(),
1267
- interval: z.number().int().positive().optional()
1716
+ const zCredentialEncoding = z$1.union([z$1.string(), z$1.record(z$1.string(), z$1.any())]);
1717
+ const zBaseCredentialResponse = z$1.object({
1718
+ credentials: z$1.union([z$1.array(z$1.object({ credential: zCredentialEncoding })), z$1.array(zCredentialEncoding)]).optional(),
1719
+ notification_id: z$1.string().optional(),
1720
+ transaction_id: z$1.string().optional(),
1721
+ interval: z$1.number().int().positive().optional()
1268
1722
  }).loose();
1269
1723
  const zCredentialResponse = zBaseCredentialResponse.extend({
1270
- credential: z.optional(zCredentialEncoding),
1271
- c_nonce: z.string().optional(),
1272
- c_nonce_expires_in: z.number().int().optional()
1724
+ credential: z$1.optional(zCredentialEncoding),
1725
+ c_nonce: z$1.string().optional(),
1726
+ c_nonce_expires_in: z$1.number().int().optional()
1273
1727
  }).loose().superRefine((value, ctx) => {
1274
1728
  const { credential, credentials, transaction_id, interval, notification_id } = value;
1275
1729
  if ([credential || credentials, transaction_id].filter((i) => i !== void 0).length !== 1) ctx.addIssue({
@@ -1285,10 +1739,10 @@ const zCredentialResponse = zBaseCredentialResponse.extend({
1285
1739
  message: `'notification_id' MUST NOT be defined when 'credential' or 'credentials' are not defined.`
1286
1740
  });
1287
1741
  });
1288
- const zCredentialErrorResponse = z.object({
1289
- ...zOauth2ErrorResponse.shape,
1290
- c_nonce: z.string().optional(),
1291
- c_nonce_expires_in: z.number().int().optional()
1742
+ const zCredentialErrorResponse = z$1.object({
1743
+ ...zOauth2ErrorResponse$1.shape,
1744
+ c_nonce: z$1.string().optional(),
1745
+ c_nonce_expires_in: z$1.number().int().optional()
1292
1746
  }).loose();
1293
1747
  const zDeferredCredentialResponse = zBaseCredentialResponse.superRefine((value, ctx) => {
1294
1748
  const { credentials, transaction_id, interval, notification_id } = value;
@@ -1579,9 +2033,9 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
1579
2033
 
1580
2034
  //#endregion
1581
2035
  //#region src/nonce/z-nonce.ts
1582
- const zNonceResponse = z.object({
1583
- c_nonce: z.string(),
1584
- c_nonce_expires_in: z.optional(zInteger)
2036
+ const zNonceResponse = z$1.object({
2037
+ c_nonce: z$1.string(),
2038
+ c_nonce_expires_in: z$1.optional(zInteger)
1585
2039
  }).loose();
1586
2040
 
1587
2041
  //#endregion
@@ -1598,7 +2052,7 @@ async function requestNonce(options) {
1598
2052
  const nonceEndpoint = options.issuerMetadata.credentialIssuer.nonce_endpoint;
1599
2053
  if (!nonceEndpoint) throw new Openid4vciError(`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' does not have a nonce endpoint.`);
1600
2054
  const { response, result } = await fetchWithZod(zNonceResponse, ContentType.Json, nonceEndpoint, { method: "POST" });
1601
- if (!response.ok || !result) throw new InvalidFetchResponseError(`Requesting nonce from '${nonceEndpoint}' resulted in an unsuccessful response with status '${response.status}'`, await response.clone().text(), response);
2055
+ if (!response.ok || !result) throw new InvalidFetchResponseError$1(`Requesting nonce from '${nonceEndpoint}' resulted in an unsuccessful response with status '${response.status}'`, await response.clone().text(), response);
1602
2056
  if (!result.success) throw new ValidationError("Error parsing nonce response", result.error);
1603
2057
  return result.data;
1604
2058
  }
@@ -1612,17 +2066,17 @@ function createNonceResponse(options) {
1612
2066
 
1613
2067
  //#endregion
1614
2068
  //#region src/notification/z-notification.ts
1615
- const zNotificationEvent = z.enum([
2069
+ const zNotificationEvent = z$1.enum([
1616
2070
  "credential_accepted",
1617
2071
  "credential_failure",
1618
2072
  "credential_deleted"
1619
2073
  ]);
1620
- const zNotificationRequest = z.object({
1621
- notification_id: z.string(),
2074
+ const zNotificationRequest = z$1.object({
2075
+ notification_id: z$1.string(),
1622
2076
  event: zNotificationEvent,
1623
- event_description: z.optional(z.string())
2077
+ event_description: z$1.optional(z$1.string())
1624
2078
  }).loose();
1625
- const zNotificationErrorResponse = z.object({ error: z.enum(["invalid_notification_id", "invalid_notification_request"]) }).loose();
2079
+ const zNotificationErrorResponse = z$1.object({ error: z$1.enum(["invalid_notification_id", "invalid_notification_request"]) }).loose();
1626
2080
 
1627
2081
  //#endregion
1628
2082
  //#region src/notification/notification.ts
@@ -1657,11 +2111,6 @@ async function sendNotification(options) {
1657
2111
 
1658
2112
  //#endregion
1659
2113
  //#region src/Openid4vciClient.ts
1660
- let AuthorizationFlow = /* @__PURE__ */ function(AuthorizationFlow$1) {
1661
- AuthorizationFlow$1["Oauth2Redirect"] = "Oauth2Redirect";
1662
- AuthorizationFlow$1["PresentationDuringIssuance"] = "PresentationDuringIssuance";
1663
- return AuthorizationFlow$1;
1664
- }({});
1665
2114
  var Openid4vciClient = class {
1666
2115
  constructor(options) {
1667
2116
  this.options = options;
@@ -1678,7 +2127,9 @@ var Openid4vciClient = class {
1678
2127
  return resolveIssuerMetadata(credentialIssuer, { callbacks: this.options.callbacks });
1679
2128
  }
1680
2129
  /**
1681
- * Retrieve an authorization code for a presentation during issuance session
2130
+ * Retrieve an authorization code for a legacy presentation during issuance session
2131
+ *
2132
+ * This can only be called if the initiateAuthorization returned {@link AuthorizationFlow.PresentationDuringIssuance}.
1682
2133
  *
1683
2134
  * This can only be called if an authorization challenge was performed before and returned a
1684
2135
  * `presentation` parameter along with an `auth_session`. If the presentation response included
@@ -1704,18 +2155,53 @@ var Openid4vciClient = class {
1704
2155
  };
1705
2156
  }
1706
2157
  /**
1707
- * Initiates authorization for credential issuance. It handles the following cases:
1708
- * - Authorization Challenge
2158
+ * Retrieve authorization code using Interactive Authorization Endpoint after OpenID4VP presentation
2159
+ *
2160
+ * This method is used when the Interactive Authorization Endpoint requires an OpenID4VP presentation.
2161
+ * After completing the presentation, call this method with the auth_session and the openid4vp_response.
2162
+ *
2163
+ * @param options - Options including auth_session and openid4vp_response
2164
+ * @returns The authorization code
2165
+ */
2166
+ async retrieveAuthorizationCodeUsingInteractiveAuthorization(options) {
2167
+ const authorizationCodeGrant = options.credentialOffer.grants?.[authorizationCodeGrantIdentifier];
2168
+ if (!authorizationCodeGrant) throw new Oauth2Error(`Provided credential offer does not include the 'authorization_code' grant.`);
2169
+ const authorizationServer = determineAuthorizationServerForCredentialOffer({
2170
+ issuerMetadata: options.issuerMetadata,
2171
+ grantAuthorizationServer: authorizationCodeGrant.authorization_server
2172
+ });
2173
+ const authorizationServerMetadata = getAuthorizationServerMetadataFromList(options.issuerMetadata.authorizationServers, authorizationServer);
2174
+ if (!authorizationServerMetadata.interactive_authorization_endpoint) throw new Openid4vciError("Authorization server does not support interactive authorization endpoint");
2175
+ const { interactiveAuthorizationResponse, dpop } = await this.sendInteractiveAuthorizationRequest({
2176
+ authorizationServerMetadata,
2177
+ request: {
2178
+ auth_session: options.authSession,
2179
+ openid4vp_response: options.openid4vpResponse
2180
+ },
2181
+ dpop: options.dpop
2182
+ });
2183
+ if (interactiveAuthorizationResponse.status !== "ok") throw new Openid4vciError(`Interactive authorization did not return status 'ok'. Received status '${interactiveAuthorizationResponse.status}'.`);
2184
+ return {
2185
+ authorizationCode: interactiveAuthorizationResponse.code,
2186
+ dpop
2187
+ };
2188
+ }
2189
+ /**
2190
+ * Initiates authorization for credential issuance. It handles the following cases (in order):
2191
+ * - Interactive Authorization Endpoint (OpenID4VCI 1.1) - preferred method
2192
+ * - Authorization Challenge (OAuth 2.0 First-Party Applications) - fallback
1709
2193
  * - Pushed Authorization Request
1710
2194
  * - Regular Authorization url
1711
2195
  *
1712
- * In case the authorization challenge request returns an error with `insufficient_authorization`
1713
- * with a `presentation` field it means the authorization server expects presentation of credentials
1714
- * before issuance of credentials. If this is the case, the value in `presentation` should be treated
1715
- * as an openid4vp authorization request and submitted to the verifier. Once the presentation response
1716
- * has been submitted, the RP will respond with a `presentation_during_issuance_session` parameter.
1717
- * Together with the `auth_session` parameter returned in this call you can retrieve an `authorization_code`
1718
- * using
2196
+ * The Interactive Authorization Endpoint can return:
2197
+ * - `status: 'require_interaction'` with type 'openid4vp_presentation' (requires OpenID4VP presentation)
2198
+ * - `status: 'require_interaction'` with type 'redirect_to_web' (requires browser redirect)
2199
+ *
2200
+ * For Authorization Challenge (legacy), an error with `insufficient_authorization` and `presentation`
2201
+ * field means the AS expects presentation of credentials before issuance. The value in `presentation`
2202
+ * should be treated as an OpenID4VP authorization request. Once submitted, the RP will respond with
2203
+ * a `presentation_during_issuance_session` parameter. Together with the `auth_session` you can
2204
+ * retrieve an authorization code using {@link retrieveAuthorizationCodeUsingPresentation}.
1719
2205
  */
1720
2206
  async initiateAuthorization(options) {
1721
2207
  if (!options.credentialOffer.grants?.[authorizationCodeGrantIdentifier]) throw new Oauth2Error(`Provided credential offer does not include the 'authorization_code' grant.`);
@@ -1727,6 +2213,53 @@ var Openid4vciClient = class {
1727
2213
  const authorizationServerMetadata = getAuthorizationServerMetadataFromList(options.issuerMetadata.authorizationServers, authorizationServer);
1728
2214
  const oauth2Client = new Oauth2Client({ callbacks: this.options.callbacks });
1729
2215
  try {
2216
+ if (authorizationServerMetadata.interactive_authorization_endpoint) {
2217
+ const pkce = authorizationServerMetadata.code_challenge_methods_supported ? await createPkce({
2218
+ allowedCodeChallengeMethods: authorizationServerMetadata.code_challenge_methods_supported,
2219
+ callbacks: this.options.callbacks,
2220
+ codeVerifier: options.pkceCodeVerifier
2221
+ }) : void 0;
2222
+ const result = await this.sendInteractiveAuthorizationRequest({
2223
+ authorizationServerMetadata,
2224
+ request: {
2225
+ response_type: "code",
2226
+ client_id: options.clientId,
2227
+ interaction_types_supported: ["redirect_to_web", "openid4vp_presentation"].join(","),
2228
+ scope: options.scope,
2229
+ redirect_uri: options.redirectUri,
2230
+ resource: options.resource,
2231
+ state: options.state,
2232
+ code_challenge: pkce?.codeChallenge,
2233
+ code_challenge_method: pkce?.codeChallengeMethod,
2234
+ ...options.additionalRequestPayload
2235
+ },
2236
+ dpop: options.dpop
2237
+ });
2238
+ const response = result.interactiveAuthorizationResponse;
2239
+ if (response.status === "ok") throw new Oauth2Error("Received a successful authorization code response from interactive authorization endpoint without authorization");
2240
+ if (response.status === "require_interaction") {
2241
+ if (response.type === "redirect_to_web") {
2242
+ const authorizationRequestUrl = `${authorizationServerMetadata.authorization_endpoint}?${objectToQueryParams({
2243
+ request_uri: response.request_uri,
2244
+ client_id: options.clientId
2245
+ }).toString()}`;
2246
+ return {
2247
+ authorizationFlow: AuthorizationFlow.Oauth2Redirect,
2248
+ authorizationServer,
2249
+ dpop: result.dpop,
2250
+ authorizationRequestUrl,
2251
+ pkce
2252
+ };
2253
+ }
2254
+ if (response.type === "openid4vp_presentation") return {
2255
+ authorizationFlow: AuthorizationFlow.InteractiveAuthorizationOpenid4vp,
2256
+ authorizationServer,
2257
+ dpop: result.dpop,
2258
+ openid4vpRequest: response.openid4vp_request,
2259
+ authSession: response.auth_session
2260
+ };
2261
+ }
2262
+ }
1730
2263
  return {
1731
2264
  ...await oauth2Client.initiateAuthorization({
1732
2265
  clientId: options.clientId,
@@ -1951,6 +2484,21 @@ var Openid4vciClient = class {
1951
2484
  if (!notificationResponse.ok) throw new Openid4vciSendNotificationError(`Error sending notification to '${issuerMetadata.credentialIssuer.credential_issuer}'`, notificationResponse);
1952
2485
  return notificationResponse;
1953
2486
  }
2487
+ /**
2488
+ * Send an Interactive Authorization Request
2489
+ *
2490
+ * This method sends a request to the Interactive Authorization Endpoint.
2491
+ * Supports both initial requests and follow-up requests.
2492
+ *
2493
+ * @param options - Request options
2494
+ * @returns The interactive authorization response and updated DPoP config
2495
+ */
2496
+ async sendInteractiveAuthorizationRequest(options) {
2497
+ return sendInteractiveAuthorizationRequest({
2498
+ ...options,
2499
+ callbacks: this.options.callbacks
2500
+ });
2501
+ }
1954
2502
  };
1955
2503
 
1956
2504
  //#endregion
@@ -2015,7 +2563,7 @@ function parseCredentialRequest(options) {
2015
2563
  let proofs;
2016
2564
  const knownProofs = zCredentialRequestProofs.strict().safeParse(credentialRequest.proofs);
2017
2565
  if (knownProofs.success) proofs = knownProofs.data;
2018
- const knownProof = z.union(allCredentialRequestProofs).safeParse(credentialRequest.proof);
2566
+ const knownProof = z$1.union(allCredentialRequestProofs).safeParse(credentialRequest.proof);
2019
2567
  if (knownProof.success && knownProof.data.proof_type === jwtProofTypeIdentifier) proofs = { [jwtProofTypeIdentifier]: [knownProof.data.jwt] };
2020
2568
  else if (knownProof.success && knownProof.data.proof_type === attestationProofTypeIdentifier) proofs = { [attestationProofTypeIdentifier]: [knownProof.data.attestation] };
2021
2569
  const credentialResponseEncryption = credentialRequest.credential_response_encryption;
@@ -2036,7 +2584,7 @@ function parseCredentialRequest(options) {
2036
2584
  credentialResponseEncryption
2037
2585
  };
2038
2586
  if (credentialRequest.format && allCredentialRequestFormatIdentifiers.includes(credentialRequest.format)) return {
2039
- format: parseWithErrorHandling(z.union(allCredentialRequestFormats), credentialRequest, "Unable to validate format specific properties from credential request"),
2587
+ format: parseWithErrorHandling(z$1.union(allCredentialRequestFormats), credentialRequest, "Unable to validate format specific properties from credential request"),
2040
2588
  credentialRequest,
2041
2589
  proofs,
2042
2590
  credentialResponseEncryption
@@ -2233,6 +2781,71 @@ var Openid4vciIssuer = class {
2233
2781
  async verifyWalletAttestation(options) {
2234
2782
  return new Oauth2AuthorizationServer({ callbacks: this.options.callbacks }).verifyClientAttestation(options);
2235
2783
  }
2784
+ /**
2785
+ * Parse an Interactive Authorization Request
2786
+ *
2787
+ * This method parses and validates an Interactive Authorization Endpoint request.
2788
+ * It automatically detects whether this is an initial request, a follow-up request,
2789
+ * or a JAR (JWT-secured) request based on the parameters present.
2790
+ */
2791
+ async parseInteractiveAuthorizationRequest(options) {
2792
+ return parseInteractiveAuthorizationRequest({
2793
+ callbacks: this.options.callbacks,
2794
+ ...options
2795
+ });
2796
+ }
2797
+ /**
2798
+ * Verify an initial (possibly signed) Interactive Authorization Request
2799
+ *
2800
+ * This method verifies the interactive authorization request including:
2801
+ * - JAR (JWT-secured Authorization Request) signature verification (if present)
2802
+ * - Client attestation (if present)
2803
+ * - DPoP binding (if present)
2804
+ * - Authorization request parameters
2805
+ */
2806
+ async verifyInteractiveAuthorizationInitialRequest(options) {
2807
+ return verifyInteractiveAuthorizationInitialRequest({
2808
+ callbacks: this.options.callbacks,
2809
+ ...options
2810
+ });
2811
+ }
2812
+ /**
2813
+ * Create a successful Interactive Authorization Code Response
2814
+ *
2815
+ * This response indicates that the authorization process is complete
2816
+ * and returns an authorization code that can be exchanged for an access token.
2817
+ */
2818
+ createInteractiveAuthorizationCodeResponse(options) {
2819
+ return createInteractiveAuthorizationCodeResponse(options);
2820
+ }
2821
+ /**
2822
+ * Create an Interactive Authorization Interaction Required Response
2823
+ * requesting an OpenID4VP presentation
2824
+ *
2825
+ * This response indicates that the wallet must present credentials
2826
+ * via OpenID4VP before authorization can be granted.
2827
+ */
2828
+ createInteractiveAuthorizationOpenid4vpInteraction(options) {
2829
+ return createInteractiveAuthorizationOpenid4vpInteraction(options);
2830
+ }
2831
+ /**
2832
+ * Create an Interactive Authorization Interaction Required Response
2833
+ * requesting a redirect to web
2834
+ *
2835
+ * This response indicates that the authorization process must continue
2836
+ * via interactions with the user in a web browser.
2837
+ */
2838
+ createInteractiveAuthorizationRedirectToWebInteraction(options) {
2839
+ return createInteractiveAuthorizationRedirectToWebInteraction(options);
2840
+ }
2841
+ /**
2842
+ * Create an Interactive Authorization Error Response
2843
+ *
2844
+ * This response indicates that an error occurred during the authorization process.
2845
+ */
2846
+ createInteractiveAuthorizationErrorResponse(options) {
2847
+ return createInteractiveAuthorizationErrorResponse(options);
2848
+ }
2236
2849
  };
2237
2850
 
2238
2851
  //#endregion
@@ -2265,5 +2878,5 @@ var Openid4vciWalletProvider = class {
2265
2878
  };
2266
2879
 
2267
2880
  //#endregion
2268
- export { AuthorizationFlow, Openid4vciClient, Openid4vciDraftVersion, Openid4vciError, Openid4vciIssuer, Openid4vciRetrieveCredentialsError, Openid4vciSendNotificationError, Openid4vciVersion, Openid4vciWalletProvider, createKeyAttestationJwt, credentialsSupportedToCredentialConfigurationsSupported, determineAuthorizationServerForCredentialOffer, extractScopesForCredentialConfigurationIds, getCredentialConfigurationsMatchingRequestFormat, getGlobalConfig, parseKeyAttestationJwt, setGlobalConfig, verifyKeyAttestationJwt };
2881
+ export { AuthorizationFlow, InteractiveAuthorizationRequestType, Openid4vciClient, Openid4vciClientInteractiveAuthorizationError, Openid4vciDraftVersion, Openid4vciError, Openid4vciIssuer, Openid4vciRetrieveCredentialsError, Openid4vciSendNotificationError, Openid4vciVersion, Openid4vciWalletProvider, createInteractiveAuthorizationCodeResponse, createInteractiveAuthorizationErrorResponse, createInteractiveAuthorizationOpenid4vpInteraction, createInteractiveAuthorizationRedirectToWebInteraction, createKeyAttestationJwt, credentialsSupportedToCredentialConfigurationsSupported, determineAuthorizationServerForCredentialOffer, extractScopesForCredentialConfigurationIds, getCredentialConfigurationsMatchingRequestFormat, getGlobalConfig, parseInteractiveAuthorizationRequest, parseKeyAttestationJwt, sendInteractiveAuthorizationRequest, setGlobalConfig, verifyInteractiveAuthorizationInitialRequest, verifyKeyAttestationJwt };
2269
2882
  //# sourceMappingURL=index.mjs.map