@openid4vc/openid4vci 0.4.6-alpha-20260201172333 → 0.5.0-alpha-20260202155954

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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, 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,41 @@ 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 zCredentialRequestCommon = z.object({
1570
+ const zCredentialResponseEncryption = z$1.object({
1571
+ jwk: zJwk,
1572
+ alg: z$1.string(),
1573
+ enc: z$1.string()
1574
+ }).loose();
1575
+ const zCredentialRequestCommon = z$1.object({
1118
1576
  proof: zCredentialRequestProof.optional(),
1119
- 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` })),
1120
- credential_response_encryption: z.object({
1121
- jwk: zJwk,
1122
- alg: z.string(),
1123
- enc: z.string()
1124
- }).loose().optional()
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` })),
1578
+ credential_response_encryption: zCredentialResponseEncryption.optional()
1125
1579
  }).loose().refine(({ proof, proofs }) => !(proof !== void 0 && proofs !== void 0), { message: `Both 'proof' and 'proofs' are defined. Only one is allowed` });
1126
1580
 
1127
1581
  //#endregion
@@ -1135,31 +1589,31 @@ const allCredentialRequestFormats = [
1135
1589
  zLegacySdJwtVcCredentialRequestFormatDraft14
1136
1590
  ];
1137
1591
  const allCredentialRequestFormatIdentifiers = allCredentialRequestFormats.map((format) => format.shape.format.value);
1138
- const zCredentialRequestCredentialConfigurationId = z.object({
1139
- credential_configuration_id: z.string(),
1140
- 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()
1141
1595
  });
1142
- const zAuthorizationDetailsCredentialRequest = z.object({
1143
- credential_identifier: z.string(),
1144
- 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()
1145
1599
  });
1146
- const zCredentialRequestFormat = z.object({
1147
- format: z.string(),
1148
- credential_identifier: z.never({ message: "'credential_identifier' cannot be defined when 'format' is set." }).optional(),
1149
- 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()
1150
1604
  }).loose();
1151
1605
  const zCredentialRequestDraft14WithFormat = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
1152
1606
  if (!allCredentialRequestFormatIdentifiers.includes(data.format)) return data;
1153
- 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);
1154
1608
  if (result.success) return result.data;
1155
1609
  for (const issue of result.error.issues) ctx.addIssue({
1156
1610
  ...issue,
1157
1611
  code: issue.code
1158
1612
  });
1159
- return z.NEVER;
1613
+ return z$1.NEVER;
1160
1614
  });
1161
- const zCredentialRequestDraft15 = z.union([zCredentialRequestCommon.and(zAuthorizationDetailsCredentialRequest), zCredentialRequestCommon.and(zCredentialRequestCredentialConfigurationId)]);
1162
- 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)]);
1163
1617
  const zCredentialRequestDraft11To14 = zCredentialRequestCommon.and(zCredentialRequestFormat).transform((data, ctx) => {
1164
1618
  const formatSpecificTransformations = {
1165
1619
  [zLdpVcFormatIdentifier.value]: zLdpVcCredentialRequestDraft11To14,
@@ -1173,7 +1627,7 @@ const zCredentialRequestDraft11To14 = zCredentialRequestCommon.and(zCredentialRe
1173
1627
  ...issue,
1174
1628
  code: issue.code
1175
1629
  });
1176
- return z.NEVER;
1630
+ return z$1.NEVER;
1177
1631
  }).pipe(zCredentialRequestDraft14);
1178
1632
  const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.transform((data, ctx) => {
1179
1633
  if (data.credential_identifier !== void 0) {
@@ -1183,7 +1637,7 @@ const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.transform((data,
1183
1637
  message: `'credential_identifier' is not supported in OpenID4VCI draft 11`,
1184
1638
  path: ["credential_identifier"]
1185
1639
  });
1186
- return z.NEVER;
1640
+ return z$1.NEVER;
1187
1641
  }
1188
1642
  const formatSpecificTransformations = {
1189
1643
  [zLdpVcFormatIdentifier.value]: zLdpVcCredentialRequestDraft14To11,
@@ -1197,20 +1651,16 @@ const zCredentialRequestDraft14To11 = zCredentialRequestDraft14.transform((data,
1197
1651
  ...issue,
1198
1652
  code: issue.code
1199
1653
  });
1200
- return z.NEVER;
1654
+ return z$1.NEVER;
1201
1655
  });
1202
- const zCredentialRequest = z.union([
1656
+ const zCredentialRequest = z$1.union([
1203
1657
  zCredentialRequestDraft15,
1204
1658
  zCredentialRequestDraft14,
1205
1659
  zCredentialRequestDraft11To14
1206
1660
  ]);
1207
- const zDeferredCredentialRequest = z.object({
1208
- transaction_id: z.string().nonempty(),
1209
- credential_response_encryption: z.object({
1210
- jwk: zJwk,
1211
- alg: z.string(),
1212
- enc: z.string()
1213
- }).loose().optional()
1661
+ const zDeferredCredentialRequest = z$1.object({
1662
+ transaction_id: z$1.string().nonempty(),
1663
+ credential_response_encryption: zCredentialResponseEncryption.optional()
1214
1664
  });
1215
1665
 
1216
1666
  //#endregion
@@ -1241,6 +1691,7 @@ let Oauth2ErrorCodes$1 = /* @__PURE__ */ function(Oauth2ErrorCodes$2) {
1241
1691
  Oauth2ErrorCodes$2["InvalidTransactionId"] = "invalid_transaction_id";
1242
1692
  Oauth2ErrorCodes$2["UnsupportedCredentialType"] = "unsupported_credential_type";
1243
1693
  Oauth2ErrorCodes$2["UnsupportedCredentialFormat"] = "unsupported_credential_format";
1694
+ Oauth2ErrorCodes$2["MissingInteractionType"] = "missing_interaction_type";
1244
1695
  Oauth2ErrorCodes$2["InvalidRequestUri"] = "invalid_request_uri";
1245
1696
  Oauth2ErrorCodes$2["InvalidRequestObject"] = "invalid_request_object";
1246
1697
  Oauth2ErrorCodes$2["RequestNotSupported"] = "request_not_supported";
@@ -1254,25 +1705,25 @@ let Oauth2ErrorCodes$1 = /* @__PURE__ */ function(Oauth2ErrorCodes$2) {
1254
1705
  Oauth2ErrorCodes$2["WalletUnavailable"] = "wallet_unavailable";
1255
1706
  return Oauth2ErrorCodes$2;
1256
1707
  }({});
1257
- const zOauth2ErrorResponse = z.object({
1258
- error: z.union([z.enum(Oauth2ErrorCodes$1), z.string()]),
1259
- error_description: z.string().optional(),
1260
- 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()
1261
1712
  }).loose();
1262
1713
 
1263
1714
  //#endregion
1264
1715
  //#region src/credential-request/z-credential-response.ts
1265
- const zCredentialEncoding = z.union([z.string(), z.record(z.string(), z.any())]);
1266
- const zBaseCredentialResponse = z.object({
1267
- credentials: z.union([z.array(z.object({ credential: zCredentialEncoding })), z.array(zCredentialEncoding)]).optional(),
1268
- notification_id: z.string().optional(),
1269
- transaction_id: z.string().optional(),
1270
- 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()
1271
1722
  }).loose();
1272
1723
  const zCredentialResponse = zBaseCredentialResponse.extend({
1273
- credential: z.optional(zCredentialEncoding),
1274
- c_nonce: z.string().optional(),
1275
- 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()
1276
1727
  }).loose().superRefine((value, ctx) => {
1277
1728
  const { credential, credentials, transaction_id, interval, notification_id } = value;
1278
1729
  if ([credential || credentials, transaction_id].filter((i) => i !== void 0).length !== 1) ctx.addIssue({
@@ -1288,10 +1739,10 @@ const zCredentialResponse = zBaseCredentialResponse.extend({
1288
1739
  message: `'notification_id' MUST NOT be defined when 'credential' or 'credentials' are not defined.`
1289
1740
  });
1290
1741
  });
1291
- const zCredentialErrorResponse = z.object({
1292
- ...zOauth2ErrorResponse.shape,
1293
- c_nonce: z.string().optional(),
1294
- 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()
1295
1746
  }).loose();
1296
1747
  const zDeferredCredentialResponse = zBaseCredentialResponse.superRefine((value, ctx) => {
1297
1748
  const { credentials, transaction_id, interval, notification_id } = value;
@@ -1311,6 +1762,39 @@ const zDeferredCredentialResponse = zBaseCredentialResponse.superRefine((value,
1311
1762
 
1312
1763
  //#endregion
1313
1764
  //#region src/credential-request/retrieve-credentials.ts
1765
+ /**
1766
+ * Handles credential response by detecting content type, decrypting if needed, and parsing.
1767
+ */
1768
+ async function handleCredentialResponse(options) {
1769
+ const { response, decryptJwe, credentialResponseEncryption, schema, responseType } = options;
1770
+ if (isResponseContentType(ContentType.Jwt, response)) {
1771
+ const decryptResult = await decryptJwe(await response.clone().text());
1772
+ if (!decryptResult.decrypted) return {
1773
+ ok: false,
1774
+ parseResult: void 0
1775
+ };
1776
+ const jsonPayload = stringToJsonWithErrorHandling(decryptResult.payload, `Unable to parse decrypted ${responseType} as JSON`);
1777
+ const parseResult$1 = schema.safeParse(jsonPayload);
1778
+ if (!parseResult$1.success) return {
1779
+ ok: false,
1780
+ parseResult: parseResult$1
1781
+ };
1782
+ return {
1783
+ ok: true,
1784
+ data: parseResult$1.data
1785
+ };
1786
+ }
1787
+ if (credentialResponseEncryption) throw new Openid4vciError(`Encryption was requested via 'credential_response_encryption' but the ${responseType} was not encrypted. Expected Content-Type 'application/jwt' but received '${response.headers.get("Content-Type")}'.`);
1788
+ const parseResult = isResponseContentType(ContentType.Json, response) ? schema.safeParse(await response.clone().json()) : void 0;
1789
+ if (!parseResult?.success) return {
1790
+ ok: false,
1791
+ parseResult
1792
+ };
1793
+ return {
1794
+ ok: true,
1795
+ data: parseResult.data
1796
+ };
1797
+ }
1314
1798
  async function retrieveCredentialsWithCredentialConfigurationId(options) {
1315
1799
  if (options.issuerMetadata.originalDraftVersion !== Openid4vciVersion.Draft15 && options.issuerMetadata.originalDraftVersion !== Openid4vciVersion.V1) throw new Openid4vciError("Requesting credentials based on credential configuration ID is not supported in OpenID4VCI below draft 15. Make sure to provide the format and format specific claims in the request.");
1316
1800
  getKnownCredentialConfigurationSupportedById(options.issuerMetadata, options.credentialConfigurationId);
@@ -1318,14 +1802,16 @@ async function retrieveCredentialsWithCredentialConfigurationId(options) {
1318
1802
  ...options.additionalRequestPayload,
1319
1803
  credential_configuration_id: options.credentialConfigurationId,
1320
1804
  proof: options.proof,
1321
- proofs: options.proofs
1805
+ proofs: options.proofs,
1806
+ credential_response_encryption: options.credentialResponseEncryption
1322
1807
  };
1323
1808
  return retrieveCredentials({
1324
1809
  callbacks: options.callbacks,
1325
1810
  credentialRequest,
1326
1811
  issuerMetadata: options.issuerMetadata,
1327
1812
  accessToken: options.accessToken,
1328
- dpop: options.dpop
1813
+ dpop: options.dpop,
1814
+ credentialResponseEncryption: options.credentialResponseEncryption
1329
1815
  });
1330
1816
  }
1331
1817
  async function retrieveCredentialsWithFormat(options) {
@@ -1334,14 +1820,16 @@ async function retrieveCredentialsWithFormat(options) {
1334
1820
  ...options.formatPayload,
1335
1821
  ...options.additionalRequestPayload,
1336
1822
  proof: options.proof,
1337
- proofs: options.proofs
1823
+ proofs: options.proofs,
1824
+ credential_response_encryption: options.credentialResponseEncryption
1338
1825
  };
1339
1826
  return retrieveCredentials({
1340
1827
  callbacks: options.callbacks,
1341
1828
  credentialRequest,
1342
1829
  issuerMetadata: options.issuerMetadata,
1343
1830
  accessToken: options.accessToken,
1344
- dpop: options.dpop
1831
+ dpop: options.dpop,
1832
+ credentialResponseEncryption: options.credentialResponseEncryption
1345
1833
  });
1346
1834
  }
1347
1835
  /**
@@ -1375,15 +1863,21 @@ async function retrieveCredentials(options) {
1375
1863
  credentialErrorResponseResult
1376
1864
  };
1377
1865
  }
1378
- const credentialResponseResult = isResponseContentType(ContentType.Json, resourceResponse.response) ? zCredentialResponse.safeParse(await resourceResponse.response.clone().json()) : void 0;
1379
- if (!credentialResponseResult?.success) return {
1866
+ const result = await handleCredentialResponse({
1867
+ response: resourceResponse.response,
1868
+ decryptJwe: options.callbacks.decryptJwe,
1869
+ credentialResponseEncryption: options.credentialResponseEncryption,
1870
+ schema: zCredentialResponse,
1871
+ responseType: "credential response"
1872
+ });
1873
+ if (!result.ok) return {
1380
1874
  ...resourceResponse,
1381
1875
  ok: false,
1382
- credentialResponseResult
1876
+ credentialResponseResult: result.parseResult
1383
1877
  };
1384
1878
  return {
1385
1879
  ...resourceResponse,
1386
- credentialResponse: credentialResponseResult.data
1880
+ credentialResponse: result.data
1387
1881
  };
1388
1882
  }
1389
1883
  async function retrieveDeferredCredentials(options) {
@@ -1391,6 +1885,7 @@ async function retrieveDeferredCredentials(options) {
1391
1885
  if (!credentialEndpoint) throw new Openid4vciError(`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' does not support deferred credential retrieval.`);
1392
1886
  const deferredCredentialRequest = parseWithErrorHandling(zDeferredCredentialRequest, {
1393
1887
  transaction_id: options.transactionId,
1888
+ credential_response_encryption: options.credentialResponseEncryption,
1394
1889
  ...options.additionalRequestPayload
1395
1890
  }, "Error validating deferred credential request");
1396
1891
  const resourceResponse = await resourceRequest({
@@ -1411,15 +1906,22 @@ async function retrieveDeferredCredentials(options) {
1411
1906
  deferredCredentialErrorResponseResult
1412
1907
  };
1413
1908
  }
1414
- const deferredCredentialResponseResult = isResponseContentType(ContentType.Json, resourceResponse.response) ? zDeferredCredentialResponse.refine((response) => response.credentials || response.transaction_id === options.transactionId, { error: `Transaction id in deferred credential response does not match transaction id in deferred credential request '${options.transactionId}'` }).safeParse(await resourceResponse.response.clone().json()) : void 0;
1415
- if (!deferredCredentialResponseResult?.success) return {
1909
+ const deferredResponseSchema = zDeferredCredentialResponse.refine((response) => response.credentials || response.transaction_id === options.transactionId, { message: `Transaction id in deferred credential response does not match transaction id in deferred credential request '${options.transactionId}'` });
1910
+ const result = await handleCredentialResponse({
1911
+ response: resourceResponse.response,
1912
+ decryptJwe: options.callbacks.decryptJwe,
1913
+ credentialResponseEncryption: options.credentialResponseEncryption,
1914
+ schema: deferredResponseSchema,
1915
+ responseType: "deferred credential response"
1916
+ });
1917
+ if (!result.ok) return {
1416
1918
  ...resourceResponse,
1417
1919
  ok: false,
1418
- deferredCredentialResponseResult
1920
+ deferredCredentialResponseResult: result.parseResult
1419
1921
  };
1420
1922
  return {
1421
1923
  ...resourceResponse,
1422
- deferredCredentialResponse: deferredCredentialResponseResult.data
1924
+ deferredCredentialResponse: result.data
1423
1925
  };
1424
1926
  }
1425
1927
 
@@ -1531,9 +2033,9 @@ async function resolveIssuerMetadata(credentialIssuer, options) {
1531
2033
 
1532
2034
  //#endregion
1533
2035
  //#region src/nonce/z-nonce.ts
1534
- const zNonceResponse = z.object({
1535
- c_nonce: z.string(),
1536
- 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)
1537
2039
  }).loose();
1538
2040
 
1539
2041
  //#endregion
@@ -1550,7 +2052,7 @@ async function requestNonce(options) {
1550
2052
  const nonceEndpoint = options.issuerMetadata.credentialIssuer.nonce_endpoint;
1551
2053
  if (!nonceEndpoint) throw new Openid4vciError(`Credential issuer '${options.issuerMetadata.credentialIssuer.credential_issuer}' does not have a nonce endpoint.`);
1552
2054
  const { response, result } = await fetchWithZod(zNonceResponse, ContentType.Json, nonceEndpoint, { method: "POST" });
1553
- 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);
1554
2056
  if (!result.success) throw new ValidationError("Error parsing nonce response", result.error);
1555
2057
  return result.data;
1556
2058
  }
@@ -1564,17 +2066,17 @@ function createNonceResponse(options) {
1564
2066
 
1565
2067
  //#endregion
1566
2068
  //#region src/notification/z-notification.ts
1567
- const zNotificationEvent = z.enum([
2069
+ const zNotificationEvent = z$1.enum([
1568
2070
  "credential_accepted",
1569
2071
  "credential_failure",
1570
2072
  "credential_deleted"
1571
2073
  ]);
1572
- const zNotificationRequest = z.object({
1573
- notification_id: z.string(),
2074
+ const zNotificationRequest = z$1.object({
2075
+ notification_id: z$1.string(),
1574
2076
  event: zNotificationEvent,
1575
- event_description: z.optional(z.string())
2077
+ event_description: z$1.optional(z$1.string())
1576
2078
  }).loose();
1577
- 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();
1578
2080
 
1579
2081
  //#endregion
1580
2082
  //#region src/notification/notification.ts
@@ -1609,11 +2111,6 @@ async function sendNotification(options) {
1609
2111
 
1610
2112
  //#endregion
1611
2113
  //#region src/Openid4vciClient.ts
1612
- let AuthorizationFlow = /* @__PURE__ */ function(AuthorizationFlow$1) {
1613
- AuthorizationFlow$1["Oauth2Redirect"] = "Oauth2Redirect";
1614
- AuthorizationFlow$1["PresentationDuringIssuance"] = "PresentationDuringIssuance";
1615
- return AuthorizationFlow$1;
1616
- }({});
1617
2114
  var Openid4vciClient = class {
1618
2115
  constructor(options) {
1619
2116
  this.options = options;
@@ -1630,7 +2127,9 @@ var Openid4vciClient = class {
1630
2127
  return resolveIssuerMetadata(credentialIssuer, { callbacks: this.options.callbacks });
1631
2128
  }
1632
2129
  /**
1633
- * 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}.
1634
2133
  *
1635
2134
  * This can only be called if an authorization challenge was performed before and returned a
1636
2135
  * `presentation` parameter along with an `auth_session`. If the presentation response included
@@ -1656,18 +2155,53 @@ var Openid4vciClient = class {
1656
2155
  };
1657
2156
  }
1658
2157
  /**
1659
- * Initiates authorization for credential issuance. It handles the following cases:
1660
- * - 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
1661
2193
  * - Pushed Authorization Request
1662
2194
  * - Regular Authorization url
1663
2195
  *
1664
- * In case the authorization challenge request returns an error with `insufficient_authorization`
1665
- * with a `presentation` field it means the authorization server expects presentation of credentials
1666
- * before issuance of credentials. If this is the case, the value in `presentation` should be treated
1667
- * as an openid4vp authorization request and submitted to the verifier. Once the presentation response
1668
- * has been submitted, the RP will respond with a `presentation_during_issuance_session` parameter.
1669
- * Together with the `auth_session` parameter returned in this call you can retrieve an `authorization_code`
1670
- * 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}.
1671
2205
  */
1672
2206
  async initiateAuthorization(options) {
1673
2207
  if (!options.credentialOffer.grants?.[authorizationCodeGrantIdentifier]) throw new Oauth2Error(`Provided credential offer does not include the 'authorization_code' grant.`);
@@ -1679,6 +2213,53 @@ var Openid4vciClient = class {
1679
2213
  const authorizationServerMetadata = getAuthorizationServerMetadataFromList(options.issuerMetadata.authorizationServers, authorizationServer);
1680
2214
  const oauth2Client = new Oauth2Client({ callbacks: this.options.callbacks });
1681
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
+ }
1682
2263
  return {
1683
2264
  ...await oauth2Client.initiateAuthorization({
1684
2265
  clientId: options.clientId,
@@ -1845,7 +2426,7 @@ var Openid4vciClient = class {
1845
2426
  * @throws ValidationError - if validation of the credential request failed
1846
2427
  * @throws Openid4vciError - if the `credentialConfigurationId` couldn't be found, or if the the format specific request couldn't be constructed
1847
2428
  */
1848
- async retrieveCredentials({ issuerMetadata, proof, proofs, credentialConfigurationId, additionalRequestPayload, accessToken, dpop }) {
2429
+ async retrieveCredentials({ issuerMetadata, proof, proofs, credentialConfigurationId, additionalRequestPayload, accessToken, dpop, credentialResponseEncryption }) {
1849
2430
  let credentialResponse;
1850
2431
  if (issuerMetadata.originalDraftVersion === Openid4vciVersion.Draft15 || issuerMetadata.originalDraftVersion === Openid4vciVersion.V1) credentialResponse = await retrieveCredentialsWithCredentialConfigurationId({
1851
2432
  accessToken,
@@ -1855,7 +2436,8 @@ var Openid4vciClient = class {
1855
2436
  proof,
1856
2437
  proofs,
1857
2438
  callbacks: this.options.callbacks,
1858
- dpop
2439
+ dpop,
2440
+ credentialResponseEncryption
1859
2441
  });
1860
2442
  else credentialResponse = await retrieveCredentialsWithFormat({
1861
2443
  accessToken,
@@ -1868,7 +2450,8 @@ var Openid4vciClient = class {
1868
2450
  proof,
1869
2451
  proofs,
1870
2452
  callbacks: this.options.callbacks,
1871
- dpop
2453
+ dpop,
2454
+ credentialResponseEncryption
1872
2455
  });
1873
2456
  if (!credentialResponse.ok) throw new Openid4vciRetrieveCredentialsError(`Error retrieving credentials from '${issuerMetadata.credentialIssuer.credential_issuer}'`, credentialResponse, await credentialResponse.response.clone().text());
1874
2457
  return credentialResponse;
@@ -1901,12 +2484,27 @@ var Openid4vciClient = class {
1901
2484
  if (!notificationResponse.ok) throw new Openid4vciSendNotificationError(`Error sending notification to '${issuerMetadata.credentialIssuer.credential_issuer}'`, notificationResponse);
1902
2485
  return notificationResponse;
1903
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
+ }
1904
2502
  };
1905
2503
 
1906
2504
  //#endregion
1907
2505
  //#region src/credential-request/credential-response.ts
1908
- function createCredentialResponse(options) {
1909
- return parseWithErrorHandling(zCredentialResponse, {
2506
+ async function createCredentialResponse(options) {
2507
+ const credentialResponse = parseWithErrorHandling(zCredentialResponse, {
1910
2508
  c_nonce: options.cNonce,
1911
2509
  c_nonce_expires_in: options.cNonceExpiresInSeconds,
1912
2510
  credential: options.credential,
@@ -1917,15 +2515,45 @@ function createCredentialResponse(options) {
1917
2515
  format: options.credentialRequest.format?.format,
1918
2516
  ...options.additionalPayload
1919
2517
  });
2518
+ if (options.credentialResponseEncryption) {
2519
+ if (!options.callbacks?.encryptJwe) throw new Openid4vciError("'credentialResponseEncryption' was provided but 'callbacks.encryptJwe' is not defined. Provide the 'encryptJwe' callback to encrypt the credential response.");
2520
+ const jweEncryptor = {
2521
+ method: "jwk",
2522
+ publicJwk: options.credentialResponseEncryption.jwk,
2523
+ alg: options.credentialResponseEncryption.alg,
2524
+ enc: options.credentialResponseEncryption.enc
2525
+ };
2526
+ const { jwe } = await options.callbacks.encryptJwe(jweEncryptor, JSON.stringify(credentialResponse));
2527
+ return {
2528
+ credentialResponse,
2529
+ credentialResponseJwt: jwe
2530
+ };
2531
+ }
2532
+ return { credentialResponse };
1920
2533
  }
1921
- function createDeferredCredentialResponse(options) {
1922
- return parseWithErrorHandling(zDeferredCredentialResponse, {
2534
+ async function createDeferredCredentialResponse(options) {
2535
+ const deferredCredentialResponse = parseWithErrorHandling(zDeferredCredentialResponse, {
1923
2536
  credentials: options.credentials,
1924
2537
  notification_id: options.notificationId,
1925
2538
  transaction_id: options.transactionId,
1926
2539
  interval: options.interval,
1927
2540
  ...options.additionalPayload
1928
2541
  });
2542
+ if (options.credentialResponseEncryption) {
2543
+ if (!options.callbacks?.encryptJwe) throw new Openid4vciError("'credentialResponseEncryption' was provided but 'callbacks.encryptJwe' is not defined. Provide the 'encryptJwe' callback to encrypt the deferred credential response.");
2544
+ const jweEncryptor = {
2545
+ method: "jwk",
2546
+ publicJwk: options.credentialResponseEncryption.jwk,
2547
+ alg: options.credentialResponseEncryption.alg,
2548
+ enc: options.credentialResponseEncryption.enc
2549
+ };
2550
+ const { jwe } = await options.callbacks.encryptJwe(jweEncryptor, JSON.stringify(deferredCredentialResponse));
2551
+ return {
2552
+ deferredCredentialResponse,
2553
+ deferredCredentialResponseJwt: jwe
2554
+ };
2555
+ }
2556
+ return { deferredCredentialResponse };
1929
2557
  }
1930
2558
 
1931
2559
  //#endregion
@@ -1935,31 +2563,36 @@ function parseCredentialRequest(options) {
1935
2563
  let proofs;
1936
2564
  const knownProofs = zCredentialRequestProofs.strict().safeParse(credentialRequest.proofs);
1937
2565
  if (knownProofs.success) proofs = knownProofs.data;
1938
- const knownProof = z.union(allCredentialRequestProofs).safeParse(credentialRequest.proof);
2566
+ const knownProof = z$1.union(allCredentialRequestProofs).safeParse(credentialRequest.proof);
1939
2567
  if (knownProof.success && knownProof.data.proof_type === jwtProofTypeIdentifier) proofs = { [jwtProofTypeIdentifier]: [knownProof.data.jwt] };
1940
2568
  else if (knownProof.success && knownProof.data.proof_type === attestationProofTypeIdentifier) proofs = { [attestationProofTypeIdentifier]: [knownProof.data.attestation] };
2569
+ const credentialResponseEncryption = credentialRequest.credential_response_encryption;
1941
2570
  if (credentialRequest.credential_configuration_id) {
1942
2571
  getKnownCredentialConfigurationSupportedById(options.issuerMetadata, credentialRequest.credential_configuration_id);
1943
2572
  return {
1944
2573
  credentialConfiguration: options.issuerMetadata.knownCredentialConfigurations[credentialRequest.credential_configuration_id],
1945
2574
  credentialConfigurationId: credentialRequest.credential_configuration_id,
1946
2575
  credentialRequest,
1947
- proofs
2576
+ proofs,
2577
+ credentialResponseEncryption
1948
2578
  };
1949
2579
  }
1950
2580
  if (credentialRequest.credential_identifier) return {
1951
2581
  credentialIdentifier: credentialRequest.credential_identifier,
1952
2582
  credentialRequest,
1953
- proofs
2583
+ proofs,
2584
+ credentialResponseEncryption
1954
2585
  };
1955
2586
  if (credentialRequest.format && allCredentialRequestFormatIdentifiers.includes(credentialRequest.format)) return {
1956
- 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"),
1957
2588
  credentialRequest,
1958
- proofs
2589
+ proofs,
2590
+ credentialResponseEncryption
1959
2591
  };
1960
2592
  return {
1961
2593
  credentialRequest,
1962
- proofs
2594
+ proofs,
2595
+ credentialResponseEncryption
1963
2596
  };
1964
2597
  }
1965
2598
 
@@ -2121,15 +2754,23 @@ var Openid4vciIssuer = class {
2121
2754
  }
2122
2755
  /**
2123
2756
  * @throws ValidationError - when validation of the credential response fails
2757
+ * @throws Openid4vciError - when encryption is requested but no encryptJwe callback is available
2124
2758
  */
2125
2759
  createCredentialResponse(options) {
2126
- return createCredentialResponse(options);
2760
+ return createCredentialResponse({
2761
+ ...options,
2762
+ callbacks: options.credentialResponseEncryption ? { encryptJwe: this.options.callbacks.encryptJwe } : void 0
2763
+ });
2127
2764
  }
2128
2765
  /**
2129
2766
  * @throws ValidationError - when validation of the credential response fails
2767
+ * @throws Openid4vciError - when encryption is requested but no encryptJwe callback is available
2130
2768
  */
2131
2769
  createDeferredCredentialResponse(options) {
2132
- return createDeferredCredentialResponse(options);
2770
+ return createDeferredCredentialResponse({
2771
+ ...options,
2772
+ callbacks: options.credentialResponseEncryption ? { encryptJwe: this.options.callbacks.encryptJwe } : void 0
2773
+ });
2133
2774
  }
2134
2775
  /**
2135
2776
  * @throws ValidationError - when validation of the nonce response fails
@@ -2140,6 +2781,71 @@ var Openid4vciIssuer = class {
2140
2781
  async verifyWalletAttestation(options) {
2141
2782
  return new Oauth2AuthorizationServer({ callbacks: this.options.callbacks }).verifyClientAttestation(options);
2142
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
+ }
2143
2849
  };
2144
2850
 
2145
2851
  //#endregion
@@ -2172,5 +2878,5 @@ var Openid4vciWalletProvider = class {
2172
2878
  };
2173
2879
 
2174
2880
  //#endregion
2175
- 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 };
2176
2882
  //# sourceMappingURL=index.mjs.map