@openid4vc/oauth2 0.2.1-alpha-20250130103023 → 0.3.0-alpha-20250202020720

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,8 +1,8 @@
1
1
  // src/index.ts
2
2
  import { getGlobalConfig, setGlobalConfig } from "@openid4vc/utils";
3
3
 
4
- // src/common/v-oauth2-error.ts
5
- import * as v from "valibot";
4
+ // src/common/z-oauth2-error.ts
5
+ import z from "zod";
6
6
  var Oauth2ErrorCodes = /* @__PURE__ */ ((Oauth2ErrorCodes2) => {
7
7
  Oauth2ErrorCodes2["ServerError"] = "server_error";
8
8
  Oauth2ErrorCodes2["InvalidTarget"] = "invalid_target";
@@ -28,52 +28,54 @@ var Oauth2ErrorCodes = /* @__PURE__ */ ((Oauth2ErrorCodes2) => {
28
28
  Oauth2ErrorCodes2["InvalidEncryptionParameters"] = "invalid_encryption_parameters";
29
29
  return Oauth2ErrorCodes2;
30
30
  })(Oauth2ErrorCodes || {});
31
- var vOauth2ErrorResponse = v.looseObject({
32
- error: v.union([v.enum(Oauth2ErrorCodes), v.string()]),
33
- error_description: v.optional(v.string()),
34
- error_uri: v.optional(v.string())
35
- });
31
+ var zOauth2ErrorResponse = z.object({
32
+ error: z.union([z.nativeEnum(Oauth2ErrorCodes), z.string()]),
33
+ error_description: z.string().optional(),
34
+ error_uri: z.string().optional()
35
+ }).passthrough();
36
36
 
37
37
  // src/common/jwk/jwk-thumbprint.ts
38
- import * as v2 from "valibot";
39
38
  import { decodeUtf8String, encodeToBase64Url, parseWithErrorHandling } from "@openid4vc/utils";
40
- var vJwkThumbprintComponents = v2.variant("kty", [
41
- v2.pipe(
42
- v2.looseObject({
43
- kty: v2.literal("EC"),
44
- crv: v2.string(),
45
- x: v2.string(),
46
- y: v2.string()
47
- }),
48
- v2.transform(({ crv, kty, x, y }) => ({ crv, kty, x, y }))
49
- ),
50
- v2.pipe(
51
- v2.looseObject({
52
- kty: v2.literal("OKP"),
53
- crv: v2.string(),
54
- x: v2.string()
55
- }),
56
- v2.transform(({ crv, kty, x }) => ({ crv, kty, x }))
57
- ),
58
- v2.pipe(
59
- v2.looseObject({
60
- kty: v2.literal("RSA"),
61
- e: v2.string(),
62
- n: v2.string()
63
- }),
64
- v2.transform(({ e, kty, n }) => ({ e, kty, n }))
65
- ),
66
- v2.pipe(
67
- v2.looseObject({
68
- kty: v2.literal("oct"),
69
- k: v2.string()
70
- }),
71
- v2.transform(({ k, kty }) => ({ k, kty }))
72
- )
73
- ]);
39
+ import z2 from "zod";
40
+ var zJwkThumbprintComponents = z2.discriminatedUnion("kty", [
41
+ z2.object({
42
+ kty: z2.literal("EC"),
43
+ crv: z2.string(),
44
+ x: z2.string(),
45
+ y: z2.string()
46
+ }),
47
+ z2.object({
48
+ kty: z2.literal("OKP"),
49
+ crv: z2.string(),
50
+ x: z2.string()
51
+ }),
52
+ z2.object({
53
+ kty: z2.literal("RSA"),
54
+ e: z2.string(),
55
+ n: z2.string()
56
+ }),
57
+ z2.object({
58
+ kty: z2.literal("oct"),
59
+ k: z2.string()
60
+ })
61
+ ]).transform((data) => {
62
+ if (data.kty === "EC") {
63
+ return { crv: data.crv, kty: data.kty, x: data.x, y: data.y };
64
+ }
65
+ if (data.kty === "OKP") {
66
+ return { crv: data.crv, kty: data.kty, x: data.x };
67
+ }
68
+ if (data.kty === "RSA") {
69
+ return { e: data.e, kty: data.kty, n: data.n };
70
+ }
71
+ if (data.kty === "oct") {
72
+ return { k: data.k, kty: data.kty };
73
+ }
74
+ throw new Error("Unsupported kty");
75
+ });
74
76
  async function calculateJwkThumbprint(options) {
75
77
  const jwkThumbprintComponents = parseWithErrorHandling(
76
- vJwkThumbprintComponents,
78
+ zJwkThumbprintComponents,
77
79
  options.jwk,
78
80
  `Provided jwk does not match a supported jwk structure. Either the 'kty' is not supported, or required values are missing.`
79
81
  );
@@ -134,44 +136,42 @@ async function isJwkInSet({
134
136
  return false;
135
137
  }
136
138
 
137
- // src/common/jwk/v-jwk.ts
138
- import * as v3 from "valibot";
139
- var vJwk = v3.looseObject({
140
- kty: v3.string(),
141
- crv: v3.optional(v3.string()),
142
- x: v3.optional(v3.string()),
143
- y: v3.optional(v3.string()),
144
- e: v3.optional(v3.string()),
145
- n: v3.optional(v3.string()),
146
- alg: v3.optional(v3.string()),
147
- d: v3.optional(v3.string()),
148
- dp: v3.optional(v3.string()),
149
- dq: v3.optional(v3.string()),
150
- ext: v3.optional(v3.boolean()),
151
- k: v3.optional(v3.string()),
152
- key_ops: v3.optional(v3.string()),
153
- kid: v3.optional(v3.string()),
154
- oth: v3.optional(
155
- v3.array(
156
- v3.looseObject({
157
- d: v3.optional(v3.string()),
158
- r: v3.optional(v3.string()),
159
- t: v3.optional(v3.string())
160
- })
139
+ // src/common/jwk/z-jwk.ts
140
+ import z3 from "zod";
141
+ var zJwk = z3.object({
142
+ kty: z3.string(),
143
+ crv: z3.optional(z3.string()),
144
+ x: z3.optional(z3.string()),
145
+ y: z3.optional(z3.string()),
146
+ e: z3.optional(z3.string()),
147
+ n: z3.optional(z3.string()),
148
+ alg: z3.optional(z3.string()),
149
+ d: z3.optional(z3.string()),
150
+ dp: z3.optional(z3.string()),
151
+ dq: z3.optional(z3.string()),
152
+ ext: z3.optional(z3.boolean()),
153
+ k: z3.optional(z3.string()),
154
+ key_ops: z3.optional(z3.string()),
155
+ kid: z3.optional(z3.string()),
156
+ oth: z3.optional(
157
+ z3.array(
158
+ z3.object({
159
+ d: z3.optional(z3.string()),
160
+ r: z3.optional(z3.string()),
161
+ t: z3.optional(z3.string())
162
+ }).passthrough()
161
163
  )
162
164
  ),
163
- p: v3.optional(v3.string()),
164
- q: v3.optional(v3.string()),
165
- qi: v3.optional(v3.string()),
166
- use: v3.optional(v3.string()),
167
- x5c: v3.optional(v3.string()),
168
- x5t: v3.optional(v3.string()),
169
- "x5t#S256": v3.optional(v3.string()),
170
- x5u: v3.optional(v3.string())
171
- });
172
- var vJwkSet = v3.looseObject({
173
- keys: v3.array(vJwk)
174
- });
165
+ p: z3.optional(z3.string()),
166
+ q: z3.optional(z3.string()),
167
+ qi: z3.optional(z3.string()),
168
+ use: z3.optional(z3.string()),
169
+ x5c: z3.optional(z3.string()),
170
+ x5t: z3.optional(z3.string()),
171
+ "x5t#S256": z3.optional(z3.string()),
172
+ x5u: z3.optional(z3.string())
173
+ }).passthrough();
174
+ var zJwkSet = z3.object({ keys: z3.array(zJwk) }).passthrough();
175
175
 
176
176
  // src/common/jwt/verify-jwt.ts
177
177
  import { dateToSeconds } from "@openid4vc/utils";
@@ -245,47 +245,43 @@ var Oauth2JwtParseError = class extends Oauth2Error {
245
245
  }
246
246
  };
247
247
 
248
- // src/common/jwt/v-jwt.ts
249
- import { vInteger } from "@openid4vc/utils";
250
- import * as v5 from "valibot";
248
+ // src/common/jwt/z-jwt.ts
249
+ import { zInteger } from "@openid4vc/utils";
250
+ import z5 from "zod";
251
251
 
252
- // src/common/v-common.ts
253
- import * as v4 from "valibot";
254
- var vAlgValueNotNone = v4.pipe(
255
- v4.string(),
256
- v4.check((alg) => alg !== "none", `alg value may not be 'none'`)
257
- );
252
+ // src/common/z-common.ts
253
+ import z4 from "zod";
254
+ var zAlgValueNotNone = z4.string().refine((alg) => alg !== "none", { message: `alg value may not be 'none'` });
258
255
 
259
- // src/common/jwt/v-jwt.ts
260
- var vCompactJwt = v5.pipe(
261
- v5.string(),
262
- v5.regex(/^([a-zA-Z0-9_=]+)\.([a-zA-Z0-9_=]+)\.([a-zA-Z0-9_\-\+\/=]*)$/, "Not a valid compact jwt")
263
- );
264
- var vJwtConfirmationPayload = v5.looseObject({
265
- jwk: v5.optional(vJwk),
266
- // RFC9449. jwk thumbprint of the dpop public key to which the access token is bound
267
- jkt: v5.optional(v5.string())
256
+ // src/common/jwt/z-jwt.ts
257
+ var zCompactJwt = z5.string().regex(/^([a-zA-Z0-9_=]+)\.([a-zA-Z0-9_=]+)\.([a-zA-Z0-9_\-\+\/=]*)$/, {
258
+ message: "Not a valid compact jwt"
268
259
  });
269
- var vJwtPayload = v5.looseObject({
270
- iss: v5.optional(v5.string()),
271
- aud: v5.optional(v5.string()),
272
- iat: v5.optional(vInteger),
273
- exp: v5.optional(vInteger),
274
- nbf: v5.optional(vInteger),
275
- nonce: v5.optional(v5.string()),
276
- jti: v5.optional(v5.string()),
277
- cnf: v5.optional(vJwtConfirmationPayload),
260
+ var zJwtConfirmationPayload = z5.object({
261
+ jwk: zJwk.optional(),
262
+ // RFC9449. jwk thumbprint of the dpop public key to which the access token is bound
263
+ jkt: z5.string().optional()
264
+ }).passthrough();
265
+ var zJwtPayload = z5.object({
266
+ iss: z5.string().optional(),
267
+ aud: z5.string().optional(),
268
+ iat: zInteger.optional(),
269
+ exp: zInteger.optional(),
270
+ nbf: zInteger.optional(),
271
+ nonce: z5.string().optional(),
272
+ jti: z5.string().optional(),
273
+ cnf: zJwtConfirmationPayload.optional(),
278
274
  // Reserved for status parameters
279
- status: v5.optional(v5.looseObject({}))
280
- });
281
- var vJwtHeader = v5.looseObject({
282
- alg: vAlgValueNotNone,
283
- typ: v5.optional(v5.string()),
284
- kid: v5.optional(v5.string()),
285
- jwk: v5.optional(vJwk),
286
- x5c: v5.optional(v5.array(v5.string())),
287
- trust_chain: v5.optional(v5.array(v5.string()))
288
- });
275
+ status: z5.record(z5.string(), z5.any()).optional()
276
+ }).passthrough();
277
+ var zJwtHeader = z5.object({
278
+ alg: zAlgValueNotNone,
279
+ typ: z5.string().optional(),
280
+ kid: z5.string().optional(),
281
+ jwk: zJwk.optional(),
282
+ x5c: z5.array(z5.string()).optional(),
283
+ trust_chain: z5.array(z5.string()).optional()
284
+ }).passthrough();
289
285
 
290
286
  // src/common/jwt/decode-jwt.ts
291
287
  function decodeJwt(options) {
@@ -307,8 +303,8 @@ function decodeJwt(options) {
307
303
  } catch (error) {
308
304
  throw new Oauth2JwtParseError("Error parsing JWT");
309
305
  }
310
- const header = parseWithErrorHandling2(options.headerSchema ?? vJwtHeader, headerJson);
311
- const payload = parseWithErrorHandling2(options.payloadSchema ?? vJwtPayload, payloadJson);
306
+ const header = parseWithErrorHandling2(options.headerSchema ?? zJwtHeader, headerJson);
307
+ const payload = parseWithErrorHandling2(options.payloadSchema ?? zJwtPayload, payloadJson);
312
308
  return {
313
309
  header,
314
310
  payload,
@@ -470,101 +466,133 @@ ${JSON.stringify(errorResponse, null, 2)}`,
470
466
  }
471
467
  };
472
468
 
473
- // src/metadata/authorization-server/v-authorization-server-metadata.ts
474
- import { vHttpsUrl } from "@openid4vc/utils";
475
- import * as v6 from "valibot";
476
- var vAuthorizationServerMetadata = v6.pipe(
477
- v6.looseObject({
478
- issuer: vHttpsUrl,
479
- token_endpoint: vHttpsUrl,
480
- token_endpoint_auth_methods_supported: v6.optional(v6.array(v6.string())),
481
- authorization_endpoint: v6.optional(vHttpsUrl),
482
- jwks_uri: v6.optional(vHttpsUrl),
483
- // RFC7636
484
- code_challenge_methods_supported: v6.optional(v6.array(v6.string())),
485
- // RFC9449
486
- dpop_signing_alg_values_supported: v6.optional(v6.array(v6.string())),
487
- // RFC9126
488
- require_pushed_authorization_requests: v6.optional(v6.boolean()),
489
- pushed_authorization_request_endpoint: v6.optional(vHttpsUrl),
490
- // RFC9068
491
- introspection_endpoint: v6.optional(vHttpsUrl),
492
- introspection_endpoint_auth_methods_supported: v6.optional(
493
- v6.array(v6.union([v6.literal("client_secret_jwt"), v6.literal("private_key_jwt"), v6.string()]))
494
- ),
495
- introspection_endpoint_auth_signing_alg_values_supported: v6.optional(v6.array(vAlgValueNotNone)),
496
- // FiPA (no RFC yet)
497
- authorization_challenge_endpoint: v6.optional(vHttpsUrl),
498
- // From OID4VCI specification
499
- "pre-authorized_grant_anonymous_access_supported": v6.optional(v6.boolean())
500
- }),
501
- v6.check(
502
- ({
503
- introspection_endpoint_auth_methods_supported: methodsSupported,
504
- introspection_endpoint_auth_signing_alg_values_supported: algValuesSupported
505
- }) => {
506
- if (!methodsSupported) return true;
507
- if (!methodsSupported.includes("private_key_jwt") && !methodsSupported.includes("client_secret_jwt")) return true;
508
- return algValuesSupported !== void 0 && algValuesSupported.length > 0;
509
- },
510
- `Metadata value 'introspection_endpoint_auth_signing_alg_values_supported' must be defined if metadata 'introspection_endpoint_auth_methods_supported' value contains values 'private_key_jwt' or 'client_secret_jwt'`
511
- )
469
+ // src/metadata/authorization-server/z-authorization-server-metadata.ts
470
+ import { zHttpsUrl } from "@openid4vc/utils";
471
+ import z6 from "zod";
472
+ var zAuthorizationServerMetadata = z6.object({
473
+ issuer: zHttpsUrl,
474
+ token_endpoint: zHttpsUrl,
475
+ token_endpoint_auth_methods_supported: z6.optional(z6.array(z6.string())),
476
+ authorization_endpoint: z6.optional(zHttpsUrl),
477
+ jwks_uri: z6.optional(zHttpsUrl),
478
+ // RFC7636
479
+ code_challenge_methods_supported: z6.optional(z6.array(z6.string())),
480
+ // RFC9449
481
+ dpop_signing_alg_values_supported: z6.optional(z6.array(z6.string())),
482
+ // RFC9126
483
+ require_pushed_authorization_requests: z6.optional(z6.boolean()),
484
+ pushed_authorization_request_endpoint: z6.optional(zHttpsUrl),
485
+ // RFC9068
486
+ introspection_endpoint: z6.optional(zHttpsUrl),
487
+ introspection_endpoint_auth_methods_supported: z6.optional(
488
+ z6.array(z6.union([z6.literal("client_secret_jwt"), z6.literal("private_key_jwt"), z6.string()]))
489
+ ),
490
+ introspection_endpoint_auth_signing_alg_values_supported: z6.optional(z6.array(zAlgValueNotNone)),
491
+ // FiPA (no RFC yet)
492
+ authorization_challenge_endpoint: z6.optional(zHttpsUrl),
493
+ // From OID4VCI specification
494
+ pre_authorized_grant_anonymous_access_supported: z6.optional(z6.boolean())
495
+ }).passthrough().refine(
496
+ ({
497
+ introspection_endpoint_auth_methods_supported: methodsSupported,
498
+ introspection_endpoint_auth_signing_alg_values_supported: algValuesSupported
499
+ }) => {
500
+ if (!methodsSupported) return true;
501
+ if (!methodsSupported.includes("private_key_jwt") && !methodsSupported.includes("client_secret_jwt")) return true;
502
+ return algValuesSupported !== void 0 && algValuesSupported.length > 0;
503
+ },
504
+ `Metadata value 'introspection_endpoint_auth_signing_alg_values_supported' must be defined if metadata 'introspection_endpoint_auth_methods_supported' value contains values 'private_key_jwt' or 'client_secret_jwt'`
512
505
  );
513
506
 
514
507
  // src/metadata/authorization-server/authorization-server-metadata.ts
515
508
  import { joinUriParts } from "@openid4vc/utils";
516
509
 
517
510
  // src/metadata/fetch-well-known-metadata.ts
518
- import { ContentType, createValibotFetcher } from "@openid4vc/utils";
511
+ import { ContentType, createZodFetcher } from "@openid4vc/utils";
519
512
  import { InvalidFetchResponseError } from "@openid4vc/utils";
520
513
 
521
- // ../utils/src/parse.ts
522
- import * as v7 from "valibot";
523
-
524
- // ../utils/src/object.ts
525
- function isObject(item) {
526
- return item != null && typeof item === "object" && !Array.isArray(item);
527
- }
528
- function mergeDeep(target, ...sources) {
529
- if (!sources.length) return target;
530
- const source = sources.shift();
531
- if (isObject(target) && isObject(source)) {
532
- for (const key in source) {
533
- if (isObject(source[key])) {
534
- if (!target[key]) Object.assign(target, { [key]: {} });
535
- mergeDeep(target[key], source[key]);
536
- } else {
537
- Object.assign(target, { [key]: source[key] });
514
+ // ../utils/src/error/ValidationError.ts
515
+ import { ZodIssueCode } from "zod";
516
+ var constants = {
517
+ // biome-ignore lint/suspicious/noMisleadingCharacterClass: expected
518
+ identifierRegex: /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u,
519
+ unionSeparator: ", or ",
520
+ issueSeparator: "\n - "
521
+ };
522
+ var ValidationError = class extends Error {
523
+ escapeQuotes(str) {
524
+ return str.replace(/"/g, '\\"');
525
+ }
526
+ joinPath(path) {
527
+ if (path.length === 1) {
528
+ return path[0].toString();
529
+ }
530
+ return path.reduce((acc, item) => {
531
+ if (typeof item === "number") {
532
+ return `${acc}[${item.toString()}]`;
533
+ }
534
+ if (item.includes('"')) {
535
+ return `${acc}["${this.escapeQuotes(item)}"]`;
538
536
  }
537
+ if (!constants.identifierRegex.test(item)) {
538
+ return `${acc}["${item}"]`;
539
+ }
540
+ const separator = acc.length === 0 ? "" : ".";
541
+ return acc + separator + item;
542
+ }, "");
543
+ }
544
+ getMessageFromUnionErrors(unionErrors) {
545
+ return unionErrors.reduce((acc, zodError) => {
546
+ const newIssues = zodError.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator);
547
+ if (!acc.includes(newIssues)) acc.push(newIssues);
548
+ return acc;
549
+ }, []).join(constants.unionSeparator);
550
+ }
551
+ getMessageFromZodIssue(issue) {
552
+ if (issue.code === ZodIssueCode.invalid_union) {
553
+ return this.getMessageFromUnionErrors(issue.unionErrors);
539
554
  }
540
- }
541
- return mergeDeep(target, ...sources);
542
- }
543
-
544
- // ../utils/src/parse.ts
545
- function valibotRecursiveFlattenIssues(issues) {
546
- let flattened = v7.flatten(issues);
547
- for (const issue of issues) {
548
- if (issue.issues) {
549
- flattened = mergeDeep(flattened, valibotRecursiveFlattenIssues(issue.issues));
555
+ if (issue.code === ZodIssueCode.invalid_arguments) {
556
+ return [issue.message, ...issue.argumentsError.issues.map((issue2) => this.getMessageFromZodIssue(issue2))].join(
557
+ constants.issueSeparator
558
+ );
550
559
  }
551
- }
552
- return flattened;
553
- }
554
-
555
- // ../utils/src/error/ValidationError.ts
556
- var ValidationError = class extends Error {
557
- constructor(message, valibotIssues = []) {
558
- const errorDetails = valibotIssues.length > 0 ? JSON.stringify(valibotRecursiveFlattenIssues(valibotIssues), null, 2) : "No details provided";
559
- super(`${message}
560
- ${errorDetails}`);
561
- this.valibotIssues = valibotIssues;
560
+ if (issue.code === ZodIssueCode.invalid_return_type) {
561
+ return [issue.message, ...issue.returnTypeError.issues.map((issue2) => this.getMessageFromZodIssue(issue2))].join(
562
+ constants.issueSeparator
563
+ );
564
+ }
565
+ if (issue.path.length !== 0) {
566
+ if (issue.path.length === 1) {
567
+ const identifier = issue.path[0];
568
+ if (typeof identifier === "number") {
569
+ return `${issue.message} at index ${identifier}`;
570
+ }
571
+ }
572
+ return `${issue.message} at "${this.joinPath(issue.path)}"`;
573
+ }
574
+ return issue.message;
575
+ }
576
+ formatError(error) {
577
+ if (!error) return "";
578
+ return error?.issues.map((issue) => this.getMessageFromZodIssue(issue)).join(constants.issueSeparator);
579
+ }
580
+ constructor(message, zodError) {
581
+ super(message);
582
+ const formattedError = this.formatError(zodError);
583
+ this.message = `${message}
584
+ - ${formattedError}`;
585
+ Object.defineProperty(this, "zodError", {
586
+ value: zodError,
587
+ writable: false,
588
+ enumerable: false
589
+ });
562
590
  }
563
591
  };
564
592
 
565
593
  // src/metadata/fetch-well-known-metadata.ts
566
594
  async function fetchWellKnownMetadata(wellKnownMetadataUrl, schema, fetch) {
567
- const fetcher = createValibotFetcher(fetch);
595
+ const fetcher = createZodFetcher(fetch);
568
596
  const { result, response } = await fetcher(schema, ContentType.Json, wellKnownMetadataUrl);
569
597
  if (response.status === 404) {
570
598
  return null;
@@ -576,10 +604,10 @@ async function fetchWellKnownMetadata(wellKnownMetadataUrl, schema, fetch) {
576
604
  response
577
605
  );
578
606
  }
579
- if (!result || !result.success) {
580
- throw new ValidationError(`Validation of metadata from '${wellKnownMetadataUrl}' failed`, result?.issues);
607
+ if (!result?.success) {
608
+ throw new ValidationError(`Validation of metadata from '${wellKnownMetadataUrl}' failed`, result?.error);
581
609
  }
582
- return result.output;
610
+ return result.data;
583
611
  }
584
612
 
585
613
  // src/metadata/authorization-server/authorization-server-metadata.ts
@@ -590,7 +618,7 @@ async function fetchAuthorizationServerMetadata(issuer, fetch) {
590
618
  const authorizationServerWellKnownMetadataUrl = joinUriParts(issuer, [wellKnownAuthorizationServerSuffix]);
591
619
  const authorizationServerResult = await fetchWellKnownMetadata(
592
620
  authorizationServerWellKnownMetadataUrl,
593
- vAuthorizationServerMetadata,
621
+ zAuthorizationServerMetadata,
594
622
  fetch
595
623
  );
596
624
  if (authorizationServerResult) {
@@ -603,7 +631,7 @@ async function fetchAuthorizationServerMetadata(issuer, fetch) {
603
631
  }
604
632
  const openIdConfigurationResult = await fetchWellKnownMetadata(
605
633
  openIdConfigurationWellKnownMetadataUrl,
606
- vAuthorizationServerMetadata,
634
+ zAuthorizationServerMetadata,
607
635
  fetch
608
636
  );
609
637
  if (openIdConfigurationResult) {
@@ -629,17 +657,17 @@ function getAuthorizationServerMetadataFromList(authorizationServersMetadata, is
629
657
  }
630
658
 
631
659
  // src/metadata/fetch-jwks-uri.ts
632
- import { ContentType as ContentType2, createValibotFetcher as createValibotFetcher2 } from "@openid4vc/utils";
660
+ import { ContentType as ContentType2, createZodFetcher as createZodFetcher2 } from "@openid4vc/utils";
633
661
  import { InvalidFetchResponseError as InvalidFetchResponseError2 } from "@openid4vc/utils";
634
662
  async function fetchJwks(authorizationServer, fetch) {
635
- const fetcher = createValibotFetcher2(fetch);
663
+ const fetcher = createZodFetcher2(fetch);
636
664
  const jwksUrl = authorizationServer.jwks_uri;
637
665
  if (!jwksUrl) {
638
666
  throw new Oauth2Error(
639
667
  `Authorization server '${authorizationServer.issuer}' does not have a 'jwks_uri' parameter to fetch JWKs.`
640
668
  );
641
669
  }
642
- const { result, response } = await fetcher(vJwkSet, ContentType2.JwkSet, jwksUrl);
670
+ const { result, response } = await fetcher(zJwkSet, ContentType2.JwkSet, jwksUrl);
643
671
  if (!response.ok) {
644
672
  throw new InvalidFetchResponseError2(
645
673
  `Fetching JWKs from jwks_uri '${jwksUrl}' resulted in an unsuccessfull response with status code '${response.status}'.`,
@@ -647,32 +675,32 @@ async function fetchJwks(authorizationServer, fetch) {
647
675
  response
648
676
  );
649
677
  }
650
- if (!result || !result.success) {
651
- throw new ValidationError(`Validation of JWKs from jwks_uri '${jwksUrl}' failed`, result?.issues);
678
+ if (!result?.success) {
679
+ throw new ValidationError(`Validation of JWKs from jwks_uri '${jwksUrl}' failed`, result?.error);
652
680
  }
653
- return result.output;
681
+ return result.data;
654
682
  }
655
683
 
656
- // src/access-token/v-access-token-jwt.ts
657
- import { vInteger as vInteger2 } from "@openid4vc/utils";
658
- import * as v8 from "valibot";
659
- var vAccessTokenProfileJwtHeader = v8.looseObject({
660
- ...vJwtHeader.entries,
661
- typ: v8.picklist(["application/at+jwt", "at+jwt"])
662
- });
663
- var vAccessTokenProfileJwtPayload = v8.looseObject({
664
- ...vJwtPayload.entries,
665
- iss: v8.string(),
666
- exp: vInteger2,
667
- iat: vInteger2,
668
- aud: v8.string(),
669
- sub: v8.string(),
684
+ // src/access-token/z-access-token-jwt.ts
685
+ import { zInteger as zInteger2 } from "@openid4vc/utils";
686
+ import z7 from "zod";
687
+ var zAccessTokenProfileJwtHeader = z7.object({
688
+ ...zJwtHeader.shape,
689
+ typ: z7.enum(["application/at+jwt", "at+jwt"])
690
+ }).passthrough();
691
+ var zAccessTokenProfileJwtPayload = z7.object({
692
+ ...zJwtPayload.shape,
693
+ iss: z7.string(),
694
+ exp: zInteger2,
695
+ iat: zInteger2,
696
+ aud: z7.string(),
697
+ sub: z7.string(),
670
698
  // REQUIRED according to RFC 9068, but OID4VCI allows anonymous access
671
- client_id: v8.optional(v8.string()),
672
- jti: v8.string(),
699
+ client_id: z7.optional(z7.string()),
700
+ jti: z7.string(),
673
701
  // SHOULD be included in the authorization request contained it
674
- scope: v8.optional(v8.string())
675
- });
702
+ scope: z7.optional(z7.string())
703
+ }).passthrough();
676
704
 
677
705
  // src/access-token/verify-access-token.ts
678
706
  var SupportedAuthenticationScheme = /* @__PURE__ */ ((SupportedAuthenticationScheme2) => {
@@ -683,8 +711,8 @@ var SupportedAuthenticationScheme = /* @__PURE__ */ ((SupportedAuthenticationSch
683
711
  async function verifyJwtProfileAccessToken(options) {
684
712
  const decodedJwt = decodeJwt({
685
713
  jwt: options.accessToken,
686
- headerSchema: vAccessTokenProfileJwtHeader,
687
- payloadSchema: vAccessTokenProfileJwtPayload
714
+ headerSchema: zAccessTokenProfileJwtHeader,
715
+ payloadSchema: zAccessTokenProfileJwtPayload
688
716
  });
689
717
  const authorizationServer = options.authorizationServers.find(({ issuer }) => decodedJwt.payload.iss === issuer);
690
718
  if (!authorizationServer) {
@@ -727,23 +755,23 @@ import {
727
755
  parseWithErrorHandling as parseWithErrorHandling3
728
756
  } from "@openid4vc/utils";
729
757
 
730
- // src/dpop/v-dpop.ts
731
- import * as v9 from "valibot";
732
- import { vHttpMethod, vHttpsUrl as vHttpsUrl2, vInteger as vInteger3 } from "@openid4vc/utils";
733
- var vDpopJwtPayload = v9.looseObject({
734
- ...vJwtPayload.entries,
735
- iat: vInteger3,
736
- htu: vHttpsUrl2,
737
- htm: vHttpMethod,
738
- jti: v9.string(),
758
+ // src/dpop/z-dpop.ts
759
+ import { zHttpMethod, zHttpsUrl as zHttpsUrl2, zInteger as zInteger3 } from "@openid4vc/utils";
760
+ import z8 from "zod";
761
+ var zDpopJwtPayload = z8.object({
762
+ ...zJwtPayload.shape,
763
+ iat: zInteger3,
764
+ htu: zHttpsUrl2,
765
+ htm: zHttpMethod,
766
+ jti: z8.string(),
739
767
  // Only required when presenting in combination with access token
740
- ath: v9.optional(v9.string())
741
- });
742
- var vDpopJwtHeader = v9.looseObject({
743
- ...vJwtHeader.entries,
744
- typ: v9.literal("dpop+jwt"),
745
- jwk: vJwk
746
- });
768
+ ath: z8.optional(z8.string())
769
+ }).passthrough();
770
+ var zDpopJwtHeader = z8.object({
771
+ ...zJwtHeader.shape,
772
+ typ: z8.literal("dpop+jwt"),
773
+ jwk: zJwk
774
+ }).passthrough();
747
775
 
748
776
  // src/dpop/dpop.ts
749
777
  async function createDpopHeadersForRequest(options) {
@@ -757,12 +785,12 @@ async function createDpopJwt(options) {
757
785
  if (options.accessToken) {
758
786
  ath = encodeToBase64Url2(await options.callbacks.hash(decodeUtf8String2(options.accessToken), "SHA-256" /* Sha256 */));
759
787
  }
760
- const header = parseWithErrorHandling3(vDpopJwtHeader, {
788
+ const header = parseWithErrorHandling3(zDpopJwtHeader, {
761
789
  typ: "dpop+jwt",
762
790
  jwk: options.signer.publicJwk,
763
791
  alg: options.signer.alg
764
792
  });
765
- const payload = parseWithErrorHandling3(vDpopJwtPayload, {
793
+ const payload = parseWithErrorHandling3(zDpopJwtPayload, {
766
794
  htu: htuFromRequestUrl(options.request.url),
767
795
  iat: dateToSeconds2(options.issuedAt),
768
796
  htm: options.request.method,
@@ -780,8 +808,8 @@ async function createDpopJwt(options) {
780
808
  async function verifyDpopJwt(options) {
781
809
  const { header, payload } = decodeJwt({
782
810
  jwt: options.dpopJwt,
783
- headerSchema: vDpopJwtHeader,
784
- payloadSchema: vDpopJwtPayload
811
+ headerSchema: zDpopJwtHeader,
812
+ payloadSchema: zDpopJwtPayload
785
813
  });
786
814
  if (options.allowedSigningAlgs && !options.allowedSigningAlgs.includes(header.alg)) {
787
815
  throw new Oauth2Error(
@@ -985,37 +1013,37 @@ async function resourceRequest(options) {
985
1013
  import { ValidationError as ValidationError2 } from "@openid4vc/utils";
986
1014
 
987
1015
  // src/access-token/introspect-token.ts
988
- import { ContentType as ContentType3, createValibotFetcher as createValibotFetcher3, objectToQueryParams, parseWithErrorHandling as parseWithErrorHandling4 } from "@openid4vc/utils";
1016
+ import { ContentType as ContentType3, createZodFetcher as createZodFetcher3, objectToQueryParams, parseWithErrorHandling as parseWithErrorHandling4 } from "@openid4vc/utils";
989
1017
  import { InvalidFetchResponseError as InvalidFetchResponseError3 } from "@openid4vc/utils";
990
1018
  import { Headers } from "@openid4vc/utils";
991
1019
 
992
- // src/access-token/v-token-introspection.ts
993
- import { vInteger as vInteger4 } from "@openid4vc/utils";
994
- import * as v10 from "valibot";
995
- var vTokenIntrospectionRequest = v10.looseObject({
996
- token: v10.string(),
997
- token_type_hint: v10.optional(v10.string())
998
- });
999
- var vTokenIntrospectionResponse = v10.looseObject({
1000
- active: v10.boolean(),
1001
- scope: v10.optional(v10.string()),
1002
- client_id: v10.optional(v10.string()),
1003
- username: v10.optional(v10.string()),
1004
- token_type: v10.optional(v10.string()),
1005
- exp: v10.optional(vInteger4),
1006
- iat: v10.optional(vInteger4),
1007
- nbf: v10.optional(vInteger4),
1008
- sub: v10.optional(v10.string()),
1009
- aud: v10.optional(v10.string()),
1010
- iss: v10.optional(v10.string()),
1011
- jti: v10.optional(v10.string()),
1012
- cnf: v10.optional(vJwtConfirmationPayload)
1013
- });
1020
+ // src/access-token/z-token-introspection.ts
1021
+ import { zInteger as zInteger4 } from "@openid4vc/utils";
1022
+ import z9 from "zod";
1023
+ var zTokenIntrospectionRequest = z9.object({
1024
+ token: z9.string(),
1025
+ token_type_hint: z9.optional(z9.string())
1026
+ }).passthrough();
1027
+ var zTokenIntrospectionResponse = z9.object({
1028
+ active: z9.boolean(),
1029
+ scope: z9.optional(z9.string()),
1030
+ client_id: z9.optional(z9.string()),
1031
+ username: z9.optional(z9.string()),
1032
+ token_type: z9.optional(z9.string()),
1033
+ exp: z9.optional(zInteger4),
1034
+ iat: z9.optional(zInteger4),
1035
+ nbf: z9.optional(zInteger4),
1036
+ sub: z9.optional(z9.string()),
1037
+ aud: z9.optional(z9.string()),
1038
+ iss: z9.optional(z9.string()),
1039
+ jti: z9.optional(z9.string()),
1040
+ cnf: z9.optional(zJwtConfirmationPayload)
1041
+ }).passthrough();
1014
1042
 
1015
1043
  // src/access-token/introspect-token.ts
1016
1044
  async function introspectToken(options) {
1017
- const fetchWithValibot = createValibotFetcher3(options.callbacks.fetch);
1018
- const introspectionRequest = parseWithErrorHandling4(vTokenIntrospectionRequest, {
1045
+ const fetchWithZod = createZodFetcher3(options.callbacks.fetch);
1046
+ const introspectionRequest = parseWithErrorHandling4(zTokenIntrospectionRequest, {
1019
1047
  token: options.token,
1020
1048
  token_type_hint: options.tokenTypeHint,
1021
1049
  ...options.additionalPayload
@@ -1035,8 +1063,8 @@ async function introspectToken(options) {
1035
1063
  contentType: ContentType3.XWwwFormUrlencoded,
1036
1064
  headers
1037
1065
  });
1038
- const { result, response } = await fetchWithValibot(
1039
- vTokenIntrospectionResponse,
1066
+ const { result, response } = await fetchWithZod(
1067
+ zTokenIntrospectionResponse,
1040
1068
  ContentType3.Json,
1041
1069
  introspectionEndpoint,
1042
1070
  {
@@ -1052,7 +1080,7 @@ async function introspectToken(options) {
1052
1080
  response
1053
1081
  );
1054
1082
  }
1055
- return result.output;
1083
+ return result.data;
1056
1084
  }
1057
1085
 
1058
1086
  // src/resource-request/verify-resource-request.ts
@@ -1229,8 +1257,8 @@ function getSupportedClientAuthenticationMethod(authorizationServer, endpointTyp
1229
1257
  }
1230
1258
  function clientAuthenticationDynamic(options) {
1231
1259
  return (callbackOptions) => {
1232
- const { url: url3, authorizationServerMetata } = callbackOptions;
1233
- const endpointType = url3 === authorizationServerMetata.introspection_endpoint ? "introspection" : "endpoint";
1260
+ const { url, authorizationServerMetata } = callbackOptions;
1261
+ const endpointType = url === authorizationServerMetata.introspection_endpoint ? "introspection" : "endpoint";
1234
1262
  const method = getSupportedClientAuthenticationMethod(authorizationServerMetata, endpointType);
1235
1263
  if (method === "client_secret_basic" /* ClientSecretBasic */) {
1236
1264
  return clientAuthenticationClientSecretBasic(options)(callbackOptions);
@@ -1268,12 +1296,12 @@ import { parseWithErrorHandling as parseWithErrorHandling11 } from "@openid4vc/u
1268
1296
  // src/access-token/create-access-token.ts
1269
1297
  import { addSecondsToDate, dateToSeconds as dateToSeconds3, encodeToBase64Url as encodeToBase64Url4, parseWithErrorHandling as parseWithErrorHandling5 } from "@openid4vc/utils";
1270
1298
  async function createAccessTokenJwt(options) {
1271
- const header = parseWithErrorHandling5(vAccessTokenProfileJwtHeader, {
1299
+ const header = parseWithErrorHandling5(zAccessTokenProfileJwtHeader, {
1272
1300
  ...jwtHeaderFromJwtSigner(options.signer),
1273
1301
  typ: "at+jwt"
1274
1302
  });
1275
1303
  const now = options.now ?? /* @__PURE__ */ new Date();
1276
- const payload = parseWithErrorHandling5(vAccessTokenProfileJwtPayload, {
1304
+ const payload = parseWithErrorHandling5(zAccessTokenProfileJwtPayload, {
1277
1305
  iat: dateToSeconds3(now),
1278
1306
  exp: dateToSeconds3(addSecondsToDate(now, options.expiresInSeconds)),
1279
1307
  aud: options.audience,
@@ -1303,84 +1331,75 @@ async function createAccessTokenJwt(options) {
1303
1331
  // src/access-token/create-access-token-response.ts
1304
1332
  import { parseWithErrorHandling as parseWithErrorHandling6 } from "@openid4vc/utils";
1305
1333
 
1306
- // src/access-token/v-access-token.ts
1307
- import * as v12 from "valibot";
1308
- import { vHttpsUrl as vHttpsUrl3 } from "@openid4vc/utils";
1309
-
1310
- // src/v-grant-type.ts
1311
- import * as v11 from "valibot";
1312
- var vPreAuthorizedCodeGrantIdentifier = v11.literal("urn:ietf:params:oauth:grant-type:pre-authorized_code");
1313
- var preAuthorizedCodeGrantIdentifier = vPreAuthorizedCodeGrantIdentifier.literal;
1314
- var vAuthorizationCodeGrantIdentifier = v11.literal("authorization_code");
1315
- var authorizationCodeGrantIdentifier = vAuthorizationCodeGrantIdentifier.literal;
1316
- var vRefreshTokenGrantIdentifier = v11.literal("refresh_token");
1317
- var refreshTokenGrantIdentifier = vRefreshTokenGrantIdentifier.literal;
1318
-
1319
- // src/access-token/v-access-token.ts
1320
- var vAccessTokenRequest = v12.intersect([
1321
- v12.looseObject({
1334
+ // src/access-token/z-access-token.ts
1335
+ import z11 from "zod";
1336
+ import { zHttpsUrl as zHttpsUrl3 } from "@openid4vc/utils";
1337
+
1338
+ // src/z-grant-type.ts
1339
+ import z10 from "zod";
1340
+ var zPreAuthorizedCodeGrantIdentifier = z10.literal("urn:ietf:params:oauth:grant-type:pre-authorized_code");
1341
+ var preAuthorizedCodeGrantIdentifier = zPreAuthorizedCodeGrantIdentifier.value;
1342
+ var zAuthorizationCodeGrantIdentifier = z10.literal("authorization_code");
1343
+ var authorizationCodeGrantIdentifier = zAuthorizationCodeGrantIdentifier.value;
1344
+ var zRefreshTokenGrantIdentifier = z10.literal("refresh_token");
1345
+ var refreshTokenGrantIdentifier = zRefreshTokenGrantIdentifier.value;
1346
+
1347
+ // src/access-token/z-access-token.ts
1348
+ var zAccessTokenRequest = z11.intersection(
1349
+ z11.object({
1322
1350
  // Pre authorized code flow
1323
- "pre-authorized_code": v12.optional(v12.string()),
1351
+ "pre-authorized_code": z11.optional(z11.string()),
1324
1352
  // Authorization code flow
1325
- code: v12.optional(v12.string()),
1326
- redirect_uri: v12.optional(v12.pipe(v12.string(), v12.url())),
1353
+ code: z11.optional(z11.string()),
1354
+ redirect_uri: z11.string().url().optional(),
1327
1355
  // Refresh token grant
1328
- refresh_token: v12.optional(v12.string()),
1329
- resource: v12.optional(vHttpsUrl3),
1330
- code_verifier: v12.optional(v12.string()),
1331
- grant_type: v12.union([
1332
- vPreAuthorizedCodeGrantIdentifier,
1333
- vAuthorizationCodeGrantIdentifier,
1334
- vRefreshTokenGrantIdentifier,
1356
+ refresh_token: z11.optional(z11.string()),
1357
+ resource: z11.optional(zHttpsUrl3),
1358
+ code_verifier: z11.optional(z11.string()),
1359
+ grant_type: z11.union([
1360
+ zPreAuthorizedCodeGrantIdentifier,
1361
+ zAuthorizationCodeGrantIdentifier,
1362
+ zRefreshTokenGrantIdentifier,
1335
1363
  // string makes the previous ones unessary, but it does help with error messages
1336
- v12.string()
1364
+ z11.string()
1337
1365
  ])
1338
- }),
1339
- v12.pipe(
1340
- v12.looseObject({
1341
- tx_code: v12.optional(v12.string()),
1342
- // user_pin is from OID4VCI draft 11
1343
- user_pin: v12.optional(v12.string())
1344
- }),
1345
- // Check that user_pin and tx_code are the same if both are provided
1346
- // and transform user_pin to tx_code if only user_pin is provided
1347
- v12.check(
1348
- ({ tx_code, user_pin }) => !tx_code || !user_pin || user_pin === tx_code,
1349
- `If both 'tx_code' and 'user_pin' are present they must match`
1350
- ),
1351
- v12.transform(({ tx_code, user_pin, ...rest }) => {
1352
- return {
1353
- ...rest,
1354
- ...tx_code ?? user_pin ? { tx_code: tx_code ?? user_pin } : {}
1355
- };
1356
- })
1357
- )
1358
- ]);
1359
- var vAccessTokenResponse = v12.looseObject({
1360
- access_token: v12.string(),
1361
- token_type: v12.string(),
1362
- expires_in: v12.optional(v12.pipe(v12.number(), v12.integer())),
1363
- scope: v12.optional(v12.string()),
1364
- state: v12.optional(v12.string()),
1365
- refresh_token: v12.optional(v12.string()),
1366
+ }).passthrough(),
1367
+ z11.object({
1368
+ tx_code: z11.optional(z11.string()),
1369
+ // user_pin is from OID4VCI draft 11
1370
+ user_pin: z11.optional(z11.string())
1371
+ }).passthrough().refine(({ tx_code, user_pin }) => !tx_code || !user_pin || user_pin === tx_code, {
1372
+ message: `If both 'tx_code' and 'user_pin' are present they must match`
1373
+ }).transform(({ tx_code, user_pin, ...rest }) => {
1374
+ return {
1375
+ ...rest,
1376
+ ...tx_code ?? user_pin ? { tx_code: tx_code ?? user_pin } : {}
1377
+ };
1378
+ })
1379
+ );
1380
+ var zAccessTokenResponse = z11.object({
1381
+ access_token: z11.string(),
1382
+ token_type: z11.string(),
1383
+ expires_in: z11.optional(z11.number().int()),
1384
+ scope: z11.optional(z11.string()),
1385
+ state: z11.optional(z11.string()),
1386
+ refresh_token: z11.optional(z11.string()),
1366
1387
  // Oid4vci specific parameters
1367
- c_nonce: v12.optional(v12.string()),
1368
- c_nonce_expires_in: v12.optional(v12.pipe(v12.number(), v12.integer())),
1388
+ c_nonce: z11.optional(z11.string()),
1389
+ c_nonce_expires_in: z11.optional(z11.number().int()),
1369
1390
  // TODO: add additional params
1370
- authorization_details: v12.optional(
1371
- v12.array(
1372
- v12.looseObject({
1373
- // requried when type is openid_credential (so we probably need a discriminator)
1374
- // credential_identifiers: v.array(v.string()),
1375
- })
1376
- )
1377
- )
1378
- });
1379
- var vAccessTokenErrorResponse = vOauth2ErrorResponse;
1391
+ authorization_details: z11.array(
1392
+ z11.object({
1393
+ // requried when type is openid_credential (so we probably need a discriminator)
1394
+ // credential_identifiers: z.array(z.string()),
1395
+ }).passthrough()
1396
+ ).optional()
1397
+ }).passthrough();
1398
+ var zAccessTokenErrorResponse = zOauth2ErrorResponse;
1380
1399
 
1381
1400
  // src/access-token/create-access-token-response.ts
1382
1401
  async function createAccessTokenResponse(options) {
1383
- const accessTokenResponse = parseWithErrorHandling6(vAccessTokenResponse, {
1402
+ const accessTokenResponse = parseWithErrorHandling6(zAccessTokenResponse, {
1384
1403
  access_token: options.accessToken,
1385
1404
  token_type: options.tokenType,
1386
1405
  expires_in: options.expiresInSeconds,
@@ -1392,18 +1411,16 @@ async function createAccessTokenResponse(options) {
1392
1411
  }
1393
1412
 
1394
1413
  // src/access-token/parse-access-token-request.ts
1395
- import { valibotRecursiveFlattenIssues as valibotRecursiveFlattenIssues2 } from "@openid4vc/utils";
1396
- import * as v13 from "valibot";
1397
1414
  function parseAccessTokenRequest(options) {
1398
- const parsedAccessTokenRequest = v13.safeParse(vAccessTokenRequest, options.accessTokenRequest);
1415
+ const parsedAccessTokenRequest = zAccessTokenRequest.safeParse(options.accessTokenRequest);
1399
1416
  if (!parsedAccessTokenRequest.success) {
1400
1417
  throw new Oauth2ServerErrorResponseError({
1401
1418
  error: "invalid_request" /* InvalidRequest */,
1402
1419
  error_description: `Error occured during validation of authorization request.
1403
- ${JSON.stringify(valibotRecursiveFlattenIssues2(parsedAccessTokenRequest.issues), null, 2)}`
1420
+ ${JSON.stringify(parsedAccessTokenRequest.error.issues, null, 2)}`
1404
1421
  });
1405
1422
  }
1406
- const accessTokenRequest = parsedAccessTokenRequest.output;
1423
+ const accessTokenRequest = parsedAccessTokenRequest.data;
1407
1424
  let grant;
1408
1425
  if (accessTokenRequest.grant_type === preAuthorizedCodeGrantIdentifier) {
1409
1426
  if (!accessTokenRequest["pre-authorized_code"]) {
@@ -1629,67 +1646,67 @@ async function verifyAccessTokenRequestPkce(options, callbacks) {
1629
1646
  // src/authorization-challenge/create-authorization-challenge-response.ts
1630
1647
  import { parseWithErrorHandling as parseWithErrorHandling7 } from "@openid4vc/utils";
1631
1648
 
1632
- // src/authorization-challenge/v-authorization-challenge.ts
1633
- import { vInteger as vInteger5 } from "@openid4vc/utils";
1634
- import * as v15 from "valibot";
1635
-
1636
- // src/authorization-request/v-authorization-request.ts
1637
- import { vHttpsUrl as vHttpsUrl4 } from "@openid4vc/utils";
1638
- import * as v14 from "valibot";
1639
- var vAuthorizationRequest = v14.looseObject({
1640
- response_type: v14.string(),
1641
- client_id: v14.string(),
1642
- issuer_state: v14.optional(v14.string()),
1643
- redirect_uri: v14.optional(v14.pipe(v14.string(), v14.url())),
1644
- resource: v14.optional(vHttpsUrl4),
1645
- scope: v14.optional(v14.string()),
1649
+ // src/authorization-challenge/z-authorization-challenge.ts
1650
+ import { zInteger as zInteger5 } from "@openid4vc/utils";
1651
+ import z13 from "zod";
1652
+
1653
+ // src/authorization-request/z-authorization-request.ts
1654
+ import { zHttpsUrl as zHttpsUrl4 } from "@openid4vc/utils";
1655
+ import z12 from "zod";
1656
+ var zAuthorizationRequest = z12.object({
1657
+ response_type: z12.string(),
1658
+ client_id: z12.string(),
1659
+ issuer_state: z12.optional(z12.string()),
1660
+ redirect_uri: z12.string().url().optional(),
1661
+ resource: z12.optional(zHttpsUrl4),
1662
+ scope: z12.optional(z12.string()),
1646
1663
  // DPoP jwk thumbprint
1647
- dpop_jkt: v14.optional(v14.string()),
1648
- code_challenge: v14.optional(v14.string()),
1649
- code_challenge_method: v14.optional(v14.string())
1650
- });
1651
- var vPushedAuthorizationRequest = v14.looseObject({
1652
- request_uri: v14.string(),
1653
- client_id: v14.string()
1654
- });
1655
- var vPushedAuthorizationResponse = v14.looseObject({
1656
- request_uri: v14.string(),
1657
- expires_in: v14.pipe(v14.number(), v14.integer())
1658
- });
1659
-
1660
- // src/authorization-challenge/v-authorization-challenge.ts
1661
- var vAuthorizationChallengeRequest = v15.looseObject({
1664
+ dpop_jkt: z12.optional(z12.string()),
1665
+ code_challenge: z12.optional(z12.string()),
1666
+ code_challenge_method: z12.optional(z12.string())
1667
+ }).passthrough();
1668
+ var zPushedAuthorizationRequest = z12.object({
1669
+ request_uri: z12.string(),
1670
+ client_id: z12.string()
1671
+ }).passthrough();
1672
+ var zPushedAuthorizationResponse = z12.object({
1673
+ request_uri: z12.string(),
1674
+ expires_in: z12.number().int()
1675
+ }).passthrough();
1676
+
1677
+ // src/authorization-challenge/z-authorization-challenge.ts
1678
+ var zAuthorizationChallengeRequest = z13.object({
1662
1679
  // authorization challenge request can include same parameters as an authorization request
1663
1680
  // except for response_type (always `code`), and `client_id` is optional (becase
1664
1681
  // it's possible to do client authentication using different methods)
1665
- ...v15.omit(vAuthorizationRequest, ["response_type", "client_id"]).entries,
1666
- client_id: v15.optional(vAuthorizationRequest.entries.client_id),
1667
- auth_session: v15.optional(v15.string()),
1682
+ ...zAuthorizationRequest.omit({ response_type: true, client_id: true }).shape,
1683
+ client_id: z13.optional(zAuthorizationRequest.shape.client_id),
1684
+ auth_session: z13.optional(z13.string()),
1668
1685
  // DRAFT presentation during issuance
1669
- presentation_during_issuance_session: v15.optional(v15.string())
1670
- });
1671
- var vAuthorizationChallengeResponse = v15.looseObject({
1672
- authorization_code: v15.string()
1673
- });
1674
- var vAuthorizationChallengeErrorResponse = v15.looseObject({
1675
- ...vOauth2ErrorResponse.entries,
1676
- auth_session: v15.optional(v15.string()),
1677
- request_uri: v15.optional(v15.string()),
1678
- expires_in: v15.optional(vInteger5),
1686
+ presentation_during_issuance_session: z13.optional(z13.string())
1687
+ }).passthrough();
1688
+ var zAuthorizationChallengeResponse = z13.object({
1689
+ authorization_code: z13.string()
1690
+ }).passthrough();
1691
+ var zAuthorizationChallengeErrorResponse = z13.object({
1692
+ ...zOauth2ErrorResponse.shape,
1693
+ auth_session: z13.optional(z13.string()),
1694
+ request_uri: z13.optional(z13.string()),
1695
+ expires_in: z13.optional(zInteger5),
1679
1696
  // DRAFT: presentation during issuance
1680
- presentation: v15.optional(v15.string())
1681
- });
1697
+ presentation: z13.optional(z13.string())
1698
+ }).passthrough();
1682
1699
 
1683
1700
  // src/authorization-challenge/create-authorization-challenge-response.ts
1684
1701
  function createAuthorizationChallengeResponse(options) {
1685
- const authorizationChallengeResponse = parseWithErrorHandling7(vAuthorizationChallengeResponse, {
1702
+ const authorizationChallengeResponse = parseWithErrorHandling7(zAuthorizationChallengeResponse, {
1686
1703
  ...options.additionalPayload,
1687
1704
  authorization_code: options.authorizationCode
1688
1705
  });
1689
1706
  return { authorizationChallengeResponse };
1690
1707
  }
1691
1708
  function createAuthorizationChallengeErrorResponse(options) {
1692
- const authorizationChallengeErrorResponse = parseWithErrorHandling7(vAuthorizationChallengeErrorResponse, {
1709
+ const authorizationChallengeErrorResponse = parseWithErrorHandling7(zAuthorizationChallengeErrorResponse, {
1693
1710
  ...options.additionalPayload,
1694
1711
  // General FiPA
1695
1712
  error: options.error,
@@ -1708,7 +1725,7 @@ function createAuthorizationChallengeErrorResponse(options) {
1708
1725
  import { parseWithErrorHandling as parseWithErrorHandling8 } from "@openid4vc/utils";
1709
1726
  function parseAuthorizationChallengeRequest(options) {
1710
1727
  const authorizationChallengeRequest = parseWithErrorHandling8(
1711
- vAuthorizationChallengeRequest,
1728
+ zAuthorizationChallengeRequest,
1712
1729
  options.authorizationChallengeRequest
1713
1730
  );
1714
1731
  return { authorizationChallengeRequest };
@@ -1717,58 +1734,58 @@ function parseAuthorizationChallengeRequest(options) {
1717
1734
  // src/client-attestation/clent-attestation.ts
1718
1735
  import { dateToSeconds as dateToSeconds4, parseWithErrorHandling as parseWithErrorHandling9 } from "@openid4vc/utils";
1719
1736
 
1720
- // src/client-attestation/v-client-attestation.ts
1721
- import * as v16 from "valibot";
1722
- import { vHttpsUrl as vHttpsUrl5, vInteger as vInteger6 } from "@openid4vc/utils";
1723
- var vOauthClientAttestationHeader = v16.literal("OAuth-Client-Attestation");
1724
- var oauthClientAttestationHeader = vOauthClientAttestationHeader.literal;
1725
- var vClientAttestationJwtPayload = v16.looseObject({
1726
- ...vJwtPayload.entries,
1727
- iss: v16.string(),
1728
- sub: v16.string(),
1729
- exp: vInteger6,
1730
- cnf: v16.looseObject({
1731
- jwk: vJwk,
1732
- key_type: v16.optional(
1733
- v16.union([
1734
- v16.picklist(["software", "hardware", "tee", "secure_enclave", "strong_box", "secure_element", "hsm"]),
1735
- v16.string()
1737
+ // src/client-attestation/z-client-attestation.ts
1738
+ import { zHttpsUrl as zHttpsUrl5, zInteger as zInteger6 } from "@openid4vc/utils";
1739
+ import z14 from "zod";
1740
+ var zOauthClientAttestationHeader = z14.literal("OAuth-Client-Attestation");
1741
+ var oauthClientAttestationHeader = zOauthClientAttestationHeader.value;
1742
+ var zClientAttestationJwtPayload = z14.object({
1743
+ ...zJwtPayload.shape,
1744
+ iss: z14.string(),
1745
+ sub: z14.string(),
1746
+ exp: zInteger6,
1747
+ cnf: z14.object({
1748
+ jwk: zJwk,
1749
+ key_type: z14.optional(
1750
+ z14.union([
1751
+ z14.enum(["software", "hardware", "tee", "secure_enclave", "strong_box", "secure_element", "hsm"]),
1752
+ z14.string()
1736
1753
  ])
1737
1754
  ),
1738
- user_authentication: v16.optional(
1739
- v16.union([
1740
- v16.picklist(["system_biometry", "system_pin", "internal_biometry", "internal_pin", "secure_element_pin"]),
1741
- v16.string()
1755
+ user_authentication: z14.optional(
1756
+ z14.union([
1757
+ z14.enum(["system_biometry", "system_pin", "internal_biometry", "internal_pin", "secure_element_pin"]),
1758
+ z14.string()
1742
1759
  ])
1743
1760
  )
1744
- }),
1745
- aal: v16.optional(v16.string())
1746
- });
1747
- var vClientAttestationJwtHeader = v16.looseObject({
1748
- ...vJwtHeader.entries,
1749
- typ: v16.literal("oauth-client-attestation+jwt")
1750
- });
1751
- var vOauthClientAttestationPopHeader = v16.literal("OAuth-Client-Attestation-PoP");
1752
- var oauthClientAttestationPopHeader = vOauthClientAttestationPopHeader.literal;
1753
- var vClientAttestationPopJwtPayload = v16.looseObject({
1754
- ...vJwtPayload.entries,
1755
- iss: v16.string(),
1756
- exp: vInteger6,
1757
- aud: vHttpsUrl5,
1758
- jti: v16.string(),
1759
- nonce: v16.optional(v16.string())
1760
- });
1761
- var vClientAttestationPopJwtHeader = v16.looseObject({
1762
- ...vJwtHeader.entries,
1763
- typ: v16.literal("oauth-client-attestation-pop+jwt")
1764
- });
1761
+ }).passthrough(),
1762
+ aal: z14.optional(z14.string())
1763
+ }).passthrough();
1764
+ var zClientAttestationJwtHeader = z14.object({
1765
+ ...zJwtHeader.shape,
1766
+ typ: z14.literal("oauth-client-attestation+jwt")
1767
+ }).passthrough();
1768
+ var zOauthClientAttestationPopHeader = z14.literal("OAuth-Client-Attestation-PoP");
1769
+ var oauthClientAttestationPopHeader = zOauthClientAttestationPopHeader.value;
1770
+ var zClientAttestationPopJwtPayload = z14.object({
1771
+ ...zJwtPayload.shape,
1772
+ iss: z14.string(),
1773
+ exp: zInteger6,
1774
+ aud: zHttpsUrl5,
1775
+ jti: z14.string(),
1776
+ nonce: z14.optional(z14.string())
1777
+ }).passthrough();
1778
+ var zClientAttestationPopJwtHeader = z14.object({
1779
+ ...zJwtHeader.shape,
1780
+ typ: z14.literal("oauth-client-attestation-pop+jwt")
1781
+ }).passthrough();
1765
1782
 
1766
1783
  // src/client-attestation/clent-attestation.ts
1767
1784
  async function verifyClientAttestationJwt(options) {
1768
1785
  const { header, payload } = decodeJwt({
1769
1786
  jwt: options.clientAttestationJwt,
1770
- headerSchema: vClientAttestationJwtHeader,
1771
- payloadSchema: vClientAttestationJwtPayload
1787
+ headerSchema: zClientAttestationJwtHeader,
1788
+ payloadSchema: zClientAttestationJwtPayload
1772
1789
  });
1773
1790
  const { signer } = await verifyJwt({
1774
1791
  signer: jwtSignerFromJwt({ header, payload }),
@@ -1786,11 +1803,11 @@ async function verifyClientAttestationJwt(options) {
1786
1803
  };
1787
1804
  }
1788
1805
  async function createClientAttestationJwt(options) {
1789
- const header = parseWithErrorHandling9(vClientAttestationJwtHeader, {
1806
+ const header = parseWithErrorHandling9(zClientAttestationJwtHeader, {
1790
1807
  typ: "oauth-client-attestation+jwt",
1791
1808
  ...jwtHeaderFromJwtSigner(options.signer)
1792
1809
  });
1793
- const payload = parseWithErrorHandling9(vClientAttestationJwtPayload, {
1810
+ const payload = parseWithErrorHandling9(zClientAttestationJwtPayload, {
1794
1811
  iss: options.issuer,
1795
1812
  iat: dateToSeconds4(options.issuedAt),
1796
1813
  exp: dateToSeconds4(options.expiresAt),
@@ -1844,8 +1861,8 @@ async function createClientAttestationForRequest(options) {
1844
1861
  async function verifyClientAttestationPopJwt(options) {
1845
1862
  const { header, payload } = decodeJwt({
1846
1863
  jwt: options.clientAttestationPopJwt,
1847
- headerSchema: vClientAttestationPopJwtHeader,
1848
- payloadSchema: vClientAttestationPopJwtPayload
1864
+ headerSchema: zClientAttestationPopJwtHeader,
1865
+ payloadSchema: zClientAttestationPopJwtPayload
1849
1866
  });
1850
1867
  if (payload.iss !== options.clientAttestation.payload.sub) {
1851
1868
  throw new Oauth2Error(
@@ -1878,17 +1895,17 @@ async function verifyClientAttestationPopJwt(options) {
1878
1895
  };
1879
1896
  }
1880
1897
  async function createClientAttestationPopJwt(options) {
1881
- const header = parseWithErrorHandling10(vClientAttestationPopJwtHeader, {
1898
+ const header = parseWithErrorHandling10(zClientAttestationPopJwtHeader, {
1882
1899
  typ: "oauth-client-attestation-pop+jwt",
1883
1900
  alg: options.signer.alg
1884
1901
  });
1885
1902
  const clientAttestation = decodeJwt({
1886
1903
  jwt: options.clientAttestation,
1887
- headerSchema: vClientAttestationJwtHeader,
1888
- payloadSchema: vClientAttestationJwtPayload
1904
+ headerSchema: zClientAttestationJwtHeader,
1905
+ payloadSchema: zClientAttestationJwtPayload
1889
1906
  });
1890
1907
  const expiresAt = options.expiresAt ?? addSecondsToDate2(options.issuedAt ?? /* @__PURE__ */ new Date(), 1 * 60);
1891
- const payload = parseWithErrorHandling10(vClientAttestationPopJwtPayload, {
1908
+ const payload = parseWithErrorHandling10(zClientAttestationPopJwtPayload, {
1892
1909
  aud: options.authorizationServer,
1893
1910
  iss: clientAttestation.payload.sub,
1894
1911
  iat: dateToSeconds5(options.issuedAt),
@@ -1911,7 +1928,7 @@ var Oauth2AuthorizationServer = class {
1911
1928
  }
1912
1929
  createAuthorizationServerMetadata(authorizationServerMetadata) {
1913
1930
  return parseWithErrorHandling11(
1914
- vAuthorizationServerMetadata,
1931
+ zAuthorizationServerMetadata,
1915
1932
  authorizationServerMetadata,
1916
1933
  "Error validating authorization server metadata"
1917
1934
  );
@@ -2036,9 +2053,8 @@ var Oauth2ResourceServer = class {
2036
2053
  import { objectToQueryParams as objectToQueryParams5 } from "@openid4vc/utils";
2037
2054
 
2038
2055
  // src/access-token/retrieve-access-token.ts
2039
- import { ContentType as ContentType4, createValibotFetcher as createValibotFetcher4, objectToQueryParams as objectToQueryParams2, parseWithErrorHandling as parseWithErrorHandling12 } from "@openid4vc/utils";
2056
+ import { ContentType as ContentType4, createZodFetcher as createZodFetcher4, objectToQueryParams as objectToQueryParams2, parseWithErrorHandling as parseWithErrorHandling12 } from "@openid4vc/utils";
2040
2057
  import { InvalidFetchResponseError as InvalidFetchResponseError4 } from "@openid4vc/utils";
2041
- import * as v17 from "valibot";
2042
2058
  async function retrievePreAuthorizedCodeAccessToken(options) {
2043
2059
  const request = {
2044
2060
  grant_type: preAuthorizedCodeGrantIdentifier,
@@ -2091,9 +2107,9 @@ async function retrieveRefreshTokenAccessToken(options) {
2091
2107
  });
2092
2108
  }
2093
2109
  async function retrieveAccessToken(options) {
2094
- const fetchWithValibot = createValibotFetcher4(options.callbacks.fetch);
2110
+ const fetchWithZod = createZodFetcher4(options.callbacks.fetch);
2095
2111
  const accessTokenRequest = parseWithErrorHandling12(
2096
- vAccessTokenRequest,
2112
+ zAccessTokenRequest,
2097
2113
  options.request,
2098
2114
  "Error validating access token request"
2099
2115
  );
@@ -2121,8 +2137,8 @@ async function retrieveAccessToken(options) {
2121
2137
  ...accessTokenRequest,
2122
2138
  ...clientAttestation?.body
2123
2139
  });
2124
- const { response, result } = await fetchWithValibot(
2125
- vAccessTokenResponse,
2140
+ const { response, result } = await fetchWithZod(
2141
+ zAccessTokenResponse,
2126
2142
  ContentType4.Json,
2127
2143
  options.authorizationServerMetadata.token_endpoint,
2128
2144
  {
@@ -2136,14 +2152,13 @@ async function retrieveAccessToken(options) {
2136
2152
  }
2137
2153
  );
2138
2154
  if (!response.ok || !result) {
2139
- const tokenErrorResponse = v17.safeParse(
2140
- vAccessTokenErrorResponse,
2155
+ const tokenErrorResponse = zAccessTokenErrorResponse.safeParse(
2141
2156
  await response.clone().json().catch(() => null)
2142
2157
  );
2143
2158
  if (tokenErrorResponse.success) {
2144
2159
  throw new Oauth2ClientErrorResponseError(
2145
2160
  `Unable to retrieve access token from '${options.authorizationServerMetadata.token_endpoint}'. Received token error response with status ${response.status}`,
2146
- tokenErrorResponse.output,
2161
+ tokenErrorResponse.data,
2147
2162
  response
2148
2163
  );
2149
2164
  }
@@ -2154,7 +2169,7 @@ async function retrieveAccessToken(options) {
2154
2169
  );
2155
2170
  }
2156
2171
  if (!result.success) {
2157
- throw new ValidationError("Error validating access token response", result.issues);
2172
+ throw new ValidationError("Error validating access token response", result.error);
2158
2173
  }
2159
2174
  const dpopNonce = extractDpopNonceFromHeaders(response.headers) ?? void 0;
2160
2175
  return {
@@ -2162,7 +2177,7 @@ async function retrieveAccessToken(options) {
2162
2177
  ...dpop,
2163
2178
  nonce: dpopNonce
2164
2179
  } : void 0,
2165
- accessTokenResponse: result.output
2180
+ accessTokenResponse: result.data
2166
2181
  };
2167
2182
  }
2168
2183
  });
@@ -2172,14 +2187,13 @@ async function retrieveAccessToken(options) {
2172
2187
  import {
2173
2188
  ContentType as ContentType5,
2174
2189
  ValidationError as ValidationError3,
2175
- createValibotFetcher as createValibotFetcher5,
2190
+ createZodFetcher as createZodFetcher5,
2176
2191
  objectToQueryParams as objectToQueryParams3,
2177
2192
  parseWithErrorHandling as parseWithErrorHandling13
2178
2193
  } from "@openid4vc/utils";
2179
2194
  import { InvalidFetchResponseError as InvalidFetchResponseError5 } from "@openid4vc/utils";
2180
- import * as v18 from "valibot";
2181
2195
  async function sendAuthorizationChallengeRequest(options) {
2182
- const fetchWithValibot = createValibotFetcher5(options.callbacks.fetch);
2196
+ const fetchWithZod = createZodFetcher5(options.callbacks.fetch);
2183
2197
  const authorizationServerMetadata = options.authorizationServerMetadata;
2184
2198
  const authorizationChallengeEndpoint = authorizationServerMetadata.authorization_challenge_endpoint;
2185
2199
  if (!authorizationChallengeEndpoint) {
@@ -2197,7 +2211,7 @@ async function sendAuthorizationChallengeRequest(options) {
2197
2211
  clientAttestation: options.clientAttestation,
2198
2212
  callbacks: options.callbacks
2199
2213
  }) : void 0;
2200
- const authorizationChallengeRequest = parseWithErrorHandling13(vAuthorizationChallengeRequest, {
2214
+ const authorizationChallengeRequest = parseWithErrorHandling13(zAuthorizationChallengeRequest, {
2201
2215
  ...options.additionalRequestPayload,
2202
2216
  auth_session: options.authSession,
2203
2217
  client_id: options.clientId,
@@ -2220,8 +2234,8 @@ async function sendAuthorizationChallengeRequest(options) {
2220
2234
  callbacks: options.callbacks,
2221
2235
  nonce: dpop.nonce
2222
2236
  }) : void 0;
2223
- const { response, result } = await fetchWithValibot(
2224
- vAuthorizationChallengeResponse,
2237
+ const { response, result } = await fetchWithZod(
2238
+ zAuthorizationChallengeResponse,
2225
2239
  ContentType5.Json,
2226
2240
  authorizationChallengeEndpoint,
2227
2241
  {
@@ -2235,14 +2249,13 @@ async function sendAuthorizationChallengeRequest(options) {
2235
2249
  }
2236
2250
  );
2237
2251
  if (!response.ok || !result) {
2238
- const authorizationChallengeErrorResponse = v18.safeParse(
2239
- vAuthorizationChallengeErrorResponse,
2252
+ const authorizationChallengeErrorResponse = zAuthorizationChallengeErrorResponse.safeParse(
2240
2253
  await response.clone().json().catch(() => null)
2241
2254
  );
2242
2255
  if (authorizationChallengeErrorResponse.success) {
2243
2256
  throw new Oauth2ClientAuthorizationChallengeError(
2244
2257
  `Error requesting authorization code from authorization challenge endpoint '${authorizationServerMetadata.authorization_challenge_endpoint}'. Received response with status ${response.status}`,
2245
- authorizationChallengeErrorResponse.output,
2258
+ authorizationChallengeErrorResponse.data,
2246
2259
  response
2247
2260
  );
2248
2261
  }
@@ -2253,7 +2266,7 @@ async function sendAuthorizationChallengeRequest(options) {
2253
2266
  );
2254
2267
  }
2255
2268
  if (!result.success) {
2256
- throw new ValidationError3("Error validating authorization challenge response", result.issues);
2269
+ throw new ValidationError3("Error validating authorization challenge response", result.error);
2257
2270
  }
2258
2271
  const dpopNonce = extractDpopNonceFromHeaders(response.headers) ?? void 0;
2259
2272
  return {
@@ -2262,16 +2275,15 @@ async function sendAuthorizationChallengeRequest(options) {
2262
2275
  ...dpop,
2263
2276
  nonce: dpopNonce
2264
2277
  } : void 0,
2265
- authorizationChallengeResponse: result.output
2278
+ authorizationChallengeResponse: result.data
2266
2279
  };
2267
2280
  }
2268
2281
  });
2269
2282
  }
2270
2283
 
2271
2284
  // src/authorization-request/create-authorization-request.ts
2272
- import { ContentType as ContentType6, createValibotFetcher as createValibotFetcher6, objectToQueryParams as objectToQueryParams4 } from "@openid4vc/utils";
2285
+ import { ContentType as ContentType6, createZodFetcher as createZodFetcher6, objectToQueryParams as objectToQueryParams4 } from "@openid4vc/utils";
2273
2286
  import { InvalidFetchResponseError as InvalidFetchResponseError6 } from "@openid4vc/utils";
2274
- import * as v19 from "valibot";
2275
2287
  async function createAuthorizationRequestUrl(options) {
2276
2288
  const authorizationServerMetadata = options.authorizationServerMetadata;
2277
2289
  const pushedAuthorizationRequestEndpoint = authorizationServerMetadata.pushed_authorization_request_endpoint;
@@ -2361,14 +2373,14 @@ async function createAuthorizationRequestUrl(options) {
2361
2373
  };
2362
2374
  }
2363
2375
  async function pushAuthorizationRequest(options) {
2364
- const fetchWithValibot = createValibotFetcher6(options.fetch);
2376
+ const fetchWithZod = createZodFetcher6(options.fetch);
2365
2377
  if (options.authorizationRequest.request_uri) {
2366
2378
  throw new Oauth2Error(
2367
2379
  `Authorization request contains 'request_uri' parameter. This is not allowed for pushed authorization reuqests.`
2368
2380
  );
2369
2381
  }
2370
- const { response, result } = await fetchWithValibot(
2371
- vPushedAuthorizationResponse,
2382
+ const { response, result } = await fetchWithZod(
2383
+ zPushedAuthorizationResponse,
2372
2384
  ContentType6.Json,
2373
2385
  options.pushedAuthorizationRequestEndpoint,
2374
2386
  {
@@ -2381,14 +2393,13 @@ async function pushAuthorizationRequest(options) {
2381
2393
  }
2382
2394
  );
2383
2395
  if (!response.ok || !result) {
2384
- const parErrorResponse = v19.safeParse(
2385
- vOauth2ErrorResponse,
2396
+ const parErrorResponse = zOauth2ErrorResponse.safeParse(
2386
2397
  await response.clone().json().catch(() => null)
2387
2398
  );
2388
2399
  if (parErrorResponse.success) {
2389
2400
  throw new Oauth2ClientErrorResponseError(
2390
2401
  `Unable to push authorization request to '${options.pushedAuthorizationRequestEndpoint}'. Received response with status ${response.status}`,
2391
- parErrorResponse.output,
2402
+ parErrorResponse.data,
2392
2403
  response
2393
2404
  );
2394
2405
  }
@@ -2399,12 +2410,12 @@ async function pushAuthorizationRequest(options) {
2399
2410
  );
2400
2411
  }
2401
2412
  if (!result.success) {
2402
- throw new ValidationError("Error validating pushed authorization response", result.issues);
2413
+ throw new ValidationError("Error validating pushed authorization response", result.error);
2403
2414
  }
2404
2415
  const dpopNonce = extractDpopNonceFromHeaders(response.headers);
2405
2416
  return {
2406
2417
  dpopNonce,
2407
- pushedAuthorizationResponse: result.output
2418
+ pushedAuthorizationResponse: result.data
2408
2419
  };
2409
2420
  }
2410
2421
 
@@ -2626,16 +2637,16 @@ export {
2626
2637
  refreshTokenGrantIdentifier,
2627
2638
  resourceRequest,
2628
2639
  setGlobalConfig,
2629
- vAuthorizationCodeGrantIdentifier,
2630
- vAuthorizationServerMetadata,
2631
- vCompactJwt,
2632
- vJwk,
2633
- vJwtHeader,
2634
- vJwtPayload,
2635
- vOauth2ErrorResponse,
2636
- vPreAuthorizedCodeGrantIdentifier,
2637
- vRefreshTokenGrantIdentifier,
2638
2640
  verifyJwt,
2639
- verifyResourceRequest
2641
+ verifyResourceRequest,
2642
+ zAuthorizationCodeGrantIdentifier,
2643
+ zAuthorizationServerMetadata,
2644
+ zCompactJwt,
2645
+ zJwk,
2646
+ zJwtHeader,
2647
+ zJwtPayload,
2648
+ zOauth2ErrorResponse,
2649
+ zPreAuthorizedCodeGrantIdentifier,
2650
+ zRefreshTokenGrantIdentifier
2640
2651
  };
2641
2652
  //# sourceMappingURL=index.mjs.map