@logto/connector-apple 1.0.0-beta.8 → 1.0.0-beta.9

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.
Files changed (3) hide show
  1. package/LICENSE +21 -373
  2. package/lib/index.js +1123 -898
  3. package/package.json +6 -6
package/lib/index.js CHANGED
@@ -2,86 +2,188 @@
2
2
  /******/ "use strict";
3
3
  /******/ var __webpack_modules__ = ({
4
4
 
5
- /***/ 2325:
5
+ /***/ 8697:
6
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
7
+
8
+
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
24
+ exports.parseJson = exports.validateConfig = void 0;
25
+ const types_1 = __nccwpck_require__(444);
26
+ __exportStar(__nccwpck_require__(444), exports);
27
+ function validateConfig(config, guard) {
28
+ const result = guard.safeParse(config);
29
+ if (!result.success) {
30
+ throw new types_1.ConnectorError(types_1.ConnectorErrorCodes.InvalidConfig, result.error);
31
+ }
32
+ }
33
+ exports.validateConfig = validateConfig;
34
+ const parseJson = (jsonString, errorCode = types_1.ConnectorErrorCodes.InvalidResponse, errorPayload) => {
35
+ try {
36
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
37
+ return JSON.parse(jsonString);
38
+ }
39
+ catch {
40
+ throw new types_1.ConnectorError(errorCode, errorPayload ?? jsonString);
41
+ }
42
+ };
43
+ exports.parseJson = parseJson;
44
+
45
+
46
+ /***/ }),
47
+
48
+ /***/ 444:
49
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
50
+
51
+
52
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
53
+ exports.messageTypesGuard = exports.MessageTypes = exports.ConnectorError = exports.ConnectorErrorCodes = exports.ConnectorPlatform = exports.ConnectorType = void 0;
54
+ const zod_1 = __nccwpck_require__(8062);
55
+ // MARK: Foundation
56
+ var ConnectorType;
57
+ (function (ConnectorType) {
58
+ ConnectorType["Email"] = "Email";
59
+ ConnectorType["Sms"] = "Sms";
60
+ ConnectorType["Social"] = "Social";
61
+ })(ConnectorType = exports.ConnectorType || (exports.ConnectorType = {}));
62
+ var ConnectorPlatform;
63
+ (function (ConnectorPlatform) {
64
+ ConnectorPlatform["Native"] = "Native";
65
+ ConnectorPlatform["Universal"] = "Universal";
66
+ ConnectorPlatform["Web"] = "Web";
67
+ })(ConnectorPlatform = exports.ConnectorPlatform || (exports.ConnectorPlatform = {}));
68
+ var ConnectorErrorCodes;
69
+ (function (ConnectorErrorCodes) {
70
+ ConnectorErrorCodes["General"] = "general";
71
+ ConnectorErrorCodes["InvalidMetadata"] = "invalid_metadata";
72
+ ConnectorErrorCodes["UnexpectedType"] = "unexpected_type";
73
+ ConnectorErrorCodes["InvalidConfigGuard"] = "invalid_config_guard";
74
+ ConnectorErrorCodes["InvalidRequestParameters"] = "invalid_request_parameters";
75
+ ConnectorErrorCodes["InsufficientRequestParameters"] = "insufficient_request_parameters";
76
+ ConnectorErrorCodes["InvalidConfig"] = "invalid_config";
77
+ ConnectorErrorCodes["InvalidResponse"] = "invalid_response";
78
+ ConnectorErrorCodes["TemplateNotFound"] = "template_not_found";
79
+ ConnectorErrorCodes["NotImplemented"] = "not_implemented";
80
+ ConnectorErrorCodes["SocialAuthCodeInvalid"] = "social_auth_code_invalid";
81
+ ConnectorErrorCodes["SocialAccessTokenInvalid"] = "social_invalid_access_token";
82
+ ConnectorErrorCodes["SocialIdTokenInvalid"] = "social_invalid_id_token";
83
+ ConnectorErrorCodes["AuthorizationFailed"] = "authorization_failed";
84
+ })(ConnectorErrorCodes = exports.ConnectorErrorCodes || (exports.ConnectorErrorCodes = {}));
85
+ class ConnectorError extends Error {
86
+ constructor(code, data) {
87
+ const message = typeof data === 'string' ? data : 'Connector error occurred.';
88
+ super(message);
89
+ this.code = code;
90
+ this.data = typeof data === 'string' ? { message: data } : data;
91
+ }
92
+ }
93
+ exports.ConnectorError = ConnectorError;
94
+ var MessageTypes;
95
+ (function (MessageTypes) {
96
+ MessageTypes["SignIn"] = "SignIn";
97
+ MessageTypes["Register"] = "Register";
98
+ MessageTypes["ForgotPassword"] = "ForgotPassword";
99
+ MessageTypes["Test"] = "Test";
100
+ })(MessageTypes = exports.MessageTypes || (exports.MessageTypes = {}));
101
+ exports.messageTypesGuard = zod_1.z.nativeEnum(MessageTypes);
102
+
103
+
104
+ /***/ }),
105
+
106
+ /***/ 4974:
6
107
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7
108
 
8
109
 
9
110
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10
- exports.base64url = exports.generateSecret = exports.generateKeyPair = exports.errors = exports.decodeJwt = exports.decodeProtectedHeader = exports.importJWK = exports.importX509 = exports.importPKCS8 = exports.importSPKI = exports.exportJWK = exports.exportSPKI = exports.exportPKCS8 = exports.UnsecuredJWT = exports.createRemoteJWKSet = exports.createLocalJWKSet = exports.EmbeddedJWK = exports.calculateJwkThumbprint = exports.EncryptJWT = exports.SignJWT = exports.GeneralSign = exports.FlattenedSign = exports.CompactSign = exports.FlattenedEncrypt = exports.CompactEncrypt = exports.jwtDecrypt = exports.jwtVerify = exports.generalVerify = exports.flattenedVerify = exports.compactVerify = exports.GeneralEncrypt = exports.generalDecrypt = exports.flattenedDecrypt = exports.compactDecrypt = void 0;
11
- var decrypt_js_1 = __nccwpck_require__(7279);
111
+ exports.base64url = exports.generateSecret = exports.generateKeyPair = exports.errors = exports.decodeJwt = exports.decodeProtectedHeader = exports.importJWK = exports.importX509 = exports.importPKCS8 = exports.importSPKI = exports.exportJWK = exports.exportSPKI = exports.exportPKCS8 = exports.UnsecuredJWT = exports.createRemoteJWKSet = exports.createLocalJWKSet = exports.EmbeddedJWK = exports.calculateJwkThumbprintUri = exports.calculateJwkThumbprint = exports.EncryptJWT = exports.SignJWT = exports.GeneralSign = exports.FlattenedSign = exports.CompactSign = exports.FlattenedEncrypt = exports.CompactEncrypt = exports.jwtDecrypt = exports.jwtVerify = exports.generalVerify = exports.flattenedVerify = exports.compactVerify = exports.GeneralEncrypt = exports.generalDecrypt = exports.flattenedDecrypt = exports.compactDecrypt = void 0;
112
+ var decrypt_js_1 = __nccwpck_require__(1698);
12
113
  Object.defineProperty(exports, "compactDecrypt", ({ enumerable: true, get: function () { return decrypt_js_1.compactDecrypt; } }));
13
- var decrypt_js_2 = __nccwpck_require__(9508);
114
+ var decrypt_js_2 = __nccwpck_require__(827);
14
115
  Object.defineProperty(exports, "flattenedDecrypt", ({ enumerable: true, get: function () { return decrypt_js_2.flattenedDecrypt; } }));
15
- var decrypt_js_3 = __nccwpck_require__(7161);
116
+ var decrypt_js_3 = __nccwpck_require__(7978);
16
117
  Object.defineProperty(exports, "generalDecrypt", ({ enumerable: true, get: function () { return decrypt_js_3.generalDecrypt; } }));
17
- var encrypt_js_1 = __nccwpck_require__(3864);
118
+ var encrypt_js_1 = __nccwpck_require__(3170);
18
119
  Object.defineProperty(exports, "GeneralEncrypt", ({ enumerable: true, get: function () { return encrypt_js_1.GeneralEncrypt; } }));
19
- var verify_js_1 = __nccwpck_require__(5427);
120
+ var verify_js_1 = __nccwpck_require__(3757);
20
121
  Object.defineProperty(exports, "compactVerify", ({ enumerable: true, get: function () { return verify_js_1.compactVerify; } }));
21
- var verify_js_2 = __nccwpck_require__(721);
122
+ var verify_js_2 = __nccwpck_require__(1071);
22
123
  Object.defineProperty(exports, "flattenedVerify", ({ enumerable: true, get: function () { return verify_js_2.flattenedVerify; } }));
23
- var verify_js_3 = __nccwpck_require__(5363);
124
+ var verify_js_3 = __nccwpck_require__(8913);
24
125
  Object.defineProperty(exports, "generalVerify", ({ enumerable: true, get: function () { return verify_js_3.generalVerify; } }));
25
- var verify_js_4 = __nccwpck_require__(5626);
126
+ var verify_js_4 = __nccwpck_require__(958);
26
127
  Object.defineProperty(exports, "jwtVerify", ({ enumerable: true, get: function () { return verify_js_4.jwtVerify; } }));
27
- var decrypt_js_4 = __nccwpck_require__(4875);
128
+ var decrypt_js_4 = __nccwpck_require__(9486);
28
129
  Object.defineProperty(exports, "jwtDecrypt", ({ enumerable: true, get: function () { return decrypt_js_4.jwtDecrypt; } }));
29
- var encrypt_js_2 = __nccwpck_require__(9670);
130
+ var encrypt_js_2 = __nccwpck_require__(9325);
30
131
  Object.defineProperty(exports, "CompactEncrypt", ({ enumerable: true, get: function () { return encrypt_js_2.CompactEncrypt; } }));
31
- var encrypt_js_3 = __nccwpck_require__(5410);
132
+ var encrypt_js_3 = __nccwpck_require__(2878);
32
133
  Object.defineProperty(exports, "FlattenedEncrypt", ({ enumerable: true, get: function () { return encrypt_js_3.FlattenedEncrypt; } }));
33
- var sign_js_1 = __nccwpck_require__(9290);
134
+ var sign_js_1 = __nccwpck_require__(670);
34
135
  Object.defineProperty(exports, "CompactSign", ({ enumerable: true, get: function () { return sign_js_1.CompactSign; } }));
35
- var sign_js_2 = __nccwpck_require__(1659);
136
+ var sign_js_2 = __nccwpck_require__(657);
36
137
  Object.defineProperty(exports, "FlattenedSign", ({ enumerable: true, get: function () { return sign_js_2.FlattenedSign; } }));
37
- var sign_js_3 = __nccwpck_require__(493);
138
+ var sign_js_3 = __nccwpck_require__(8473);
38
139
  Object.defineProperty(exports, "GeneralSign", ({ enumerable: true, get: function () { return sign_js_3.GeneralSign; } }));
39
- var sign_js_4 = __nccwpck_require__(4952);
140
+ var sign_js_4 = __nccwpck_require__(3744);
40
141
  Object.defineProperty(exports, "SignJWT", ({ enumerable: true, get: function () { return sign_js_4.SignJWT; } }));
41
- var encrypt_js_4 = __nccwpck_require__(6112);
142
+ var encrypt_js_4 = __nccwpck_require__(242);
42
143
  Object.defineProperty(exports, "EncryptJWT", ({ enumerable: true, get: function () { return encrypt_js_4.EncryptJWT; } }));
43
- var thumbprint_js_1 = __nccwpck_require__(5117);
144
+ var thumbprint_js_1 = __nccwpck_require__(8166);
44
145
  Object.defineProperty(exports, "calculateJwkThumbprint", ({ enumerable: true, get: function () { return thumbprint_js_1.calculateJwkThumbprint; } }));
45
- var embedded_js_1 = __nccwpck_require__(7481);
146
+ Object.defineProperty(exports, "calculateJwkThumbprintUri", ({ enumerable: true, get: function () { return thumbprint_js_1.calculateJwkThumbprintUri; } }));
147
+ var embedded_js_1 = __nccwpck_require__(9483);
46
148
  Object.defineProperty(exports, "EmbeddedJWK", ({ enumerable: true, get: function () { return embedded_js_1.EmbeddedJWK; } }));
47
- var local_js_1 = __nccwpck_require__(863);
149
+ var local_js_1 = __nccwpck_require__(8560);
48
150
  Object.defineProperty(exports, "createLocalJWKSet", ({ enumerable: true, get: function () { return local_js_1.createLocalJWKSet; } }));
49
- var remote_js_1 = __nccwpck_require__(8815);
151
+ var remote_js_1 = __nccwpck_require__(7351);
50
152
  Object.defineProperty(exports, "createRemoteJWKSet", ({ enumerable: true, get: function () { return remote_js_1.createRemoteJWKSet; } }));
51
- var unsecured_js_1 = __nccwpck_require__(7086);
153
+ var unsecured_js_1 = __nccwpck_require__(9701);
52
154
  Object.defineProperty(exports, "UnsecuredJWT", ({ enumerable: true, get: function () { return unsecured_js_1.UnsecuredJWT; } }));
53
- var export_js_1 = __nccwpck_require__(4039);
155
+ var export_js_1 = __nccwpck_require__(8771);
54
156
  Object.defineProperty(exports, "exportPKCS8", ({ enumerable: true, get: function () { return export_js_1.exportPKCS8; } }));
55
157
  Object.defineProperty(exports, "exportSPKI", ({ enumerable: true, get: function () { return export_js_1.exportSPKI; } }));
56
158
  Object.defineProperty(exports, "exportJWK", ({ enumerable: true, get: function () { return export_js_1.exportJWK; } }));
57
- var import_js_1 = __nccwpck_require__(1173);
159
+ var import_js_1 = __nccwpck_require__(3287);
58
160
  Object.defineProperty(exports, "importSPKI", ({ enumerable: true, get: function () { return import_js_1.importSPKI; } }));
59
161
  Object.defineProperty(exports, "importPKCS8", ({ enumerable: true, get: function () { return import_js_1.importPKCS8; } }));
60
162
  Object.defineProperty(exports, "importX509", ({ enumerable: true, get: function () { return import_js_1.importX509; } }));
61
163
  Object.defineProperty(exports, "importJWK", ({ enumerable: true, get: function () { return import_js_1.importJWK; } }));
62
- var decode_protected_header_js_1 = __nccwpck_require__(919);
164
+ var decode_protected_header_js_1 = __nccwpck_require__(1158);
63
165
  Object.defineProperty(exports, "decodeProtectedHeader", ({ enumerable: true, get: function () { return decode_protected_header_js_1.decodeProtectedHeader; } }));
64
- var decode_jwt_js_1 = __nccwpck_require__(4860);
166
+ var decode_jwt_js_1 = __nccwpck_require__(6537);
65
167
  Object.defineProperty(exports, "decodeJwt", ({ enumerable: true, get: function () { return decode_jwt_js_1.decodeJwt; } }));
66
- exports.errors = __nccwpck_require__(2157);
67
- var generate_key_pair_js_1 = __nccwpck_require__(179);
168
+ exports.errors = __nccwpck_require__(6891);
169
+ var generate_key_pair_js_1 = __nccwpck_require__(8959);
68
170
  Object.defineProperty(exports, "generateKeyPair", ({ enumerable: true, get: function () { return generate_key_pair_js_1.generateKeyPair; } }));
69
- var generate_secret_js_1 = __nccwpck_require__(3473);
171
+ var generate_secret_js_1 = __nccwpck_require__(9896);
70
172
  Object.defineProperty(exports, "generateSecret", ({ enumerable: true, get: function () { return generate_secret_js_1.generateSecret; } }));
71
- exports.base64url = __nccwpck_require__(541);
173
+ exports.base64url = __nccwpck_require__(5831);
72
174
 
73
175
 
74
176
  /***/ }),
75
177
 
76
- /***/ 7279:
178
+ /***/ 1698:
77
179
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
78
180
 
79
181
 
80
182
  Object.defineProperty(exports, "__esModule", ({ value: true }));
81
183
  exports.compactDecrypt = void 0;
82
- const decrypt_js_1 = __nccwpck_require__(9508);
83
- const errors_js_1 = __nccwpck_require__(2157);
84
- const buffer_utils_js_1 = __nccwpck_require__(2302);
184
+ const decrypt_js_1 = __nccwpck_require__(827);
185
+ const errors_js_1 = __nccwpck_require__(6891);
186
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
85
187
  async function compactDecrypt(jwe, key, options) {
86
188
  if (jwe instanceof Uint8Array) {
87
189
  jwe = buffer_utils_js_1.decoder.decode(jwe);
@@ -111,13 +213,13 @@ exports.compactDecrypt = compactDecrypt;
111
213
 
112
214
  /***/ }),
113
215
 
114
- /***/ 9670:
216
+ /***/ 9325:
115
217
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
116
218
 
117
219
 
118
220
  Object.defineProperty(exports, "__esModule", ({ value: true }));
119
221
  exports.CompactEncrypt = void 0;
120
- const encrypt_js_1 = __nccwpck_require__(5410);
222
+ const encrypt_js_1 = __nccwpck_require__(2878);
121
223
  class CompactEncrypt {
122
224
  constructor(plaintext) {
123
225
  this._flattened = new encrypt_js_1.FlattenedEncrypt(plaintext);
@@ -148,23 +250,23 @@ exports.CompactEncrypt = CompactEncrypt;
148
250
 
149
251
  /***/ }),
150
252
 
151
- /***/ 9508:
253
+ /***/ 827:
152
254
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
153
255
 
154
256
 
155
257
  Object.defineProperty(exports, "__esModule", ({ value: true }));
156
258
  exports.flattenedDecrypt = void 0;
157
- const base64url_js_1 = __nccwpck_require__(8782);
158
- const decrypt_js_1 = __nccwpck_require__(7703);
159
- const zlib_js_1 = __nccwpck_require__(2148);
160
- const errors_js_1 = __nccwpck_require__(2157);
161
- const is_disjoint_js_1 = __nccwpck_require__(567);
162
- const is_object_js_1 = __nccwpck_require__(8692);
163
- const decrypt_key_management_js_1 = __nccwpck_require__(1732);
164
- const buffer_utils_js_1 = __nccwpck_require__(2302);
165
- const cek_js_1 = __nccwpck_require__(2391);
166
- const validate_crit_js_1 = __nccwpck_require__(3498);
167
- const validate_algorithms_js_1 = __nccwpck_require__(7934);
259
+ const base64url_js_1 = __nccwpck_require__(5091);
260
+ const decrypt_js_1 = __nccwpck_require__(1788);
261
+ const zlib_js_1 = __nccwpck_require__(3239);
262
+ const errors_js_1 = __nccwpck_require__(6891);
263
+ const is_disjoint_js_1 = __nccwpck_require__(3710);
264
+ const is_object_js_1 = __nccwpck_require__(7787);
265
+ const decrypt_key_management_js_1 = __nccwpck_require__(3635);
266
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
267
+ const cek_js_1 = __nccwpck_require__(9942);
268
+ const validate_crit_js_1 = __nccwpck_require__(1516);
269
+ const validate_algorithms_js_1 = __nccwpck_require__(7946);
168
270
  async function flattenedDecrypt(jwe, key, options) {
169
271
  var _a;
170
272
  if (!(0, is_object_js_1.default)(jwe)) {
@@ -199,8 +301,8 @@ async function flattenedDecrypt(jwe, key, options) {
199
301
  }
200
302
  let parsedProt;
201
303
  if (jwe.protected) {
202
- const protectedHeader = (0, base64url_js_1.decode)(jwe.protected);
203
304
  try {
305
+ const protectedHeader = (0, base64url_js_1.decode)(jwe.protected);
204
306
  parsedProt = JSON.parse(buffer_utils_js_1.decoder.decode(protectedHeader));
205
307
  }
206
308
  catch {
@@ -251,10 +353,10 @@ async function flattenedDecrypt(jwe, key, options) {
251
353
  }
252
354
  let cek;
253
355
  try {
254
- cek = await (0, decrypt_key_management_js_1.default)(alg, key, encryptedKey, joseHeader);
356
+ cek = await (0, decrypt_key_management_js_1.default)(alg, key, encryptedKey, joseHeader, options);
255
357
  }
256
358
  catch (err) {
257
- if (err instanceof TypeError) {
359
+ if (err instanceof TypeError || err instanceof errors_js_1.JWEInvalid || err instanceof errors_js_1.JOSENotSupported) {
258
360
  throw err;
259
361
  }
260
362
  cek = (0, cek_js_1.default)(enc);
@@ -296,21 +398,21 @@ exports.flattenedDecrypt = flattenedDecrypt;
296
398
 
297
399
  /***/ }),
298
400
 
299
- /***/ 5410:
401
+ /***/ 2878:
300
402
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
301
403
 
302
404
 
303
405
  Object.defineProperty(exports, "__esModule", ({ value: true }));
304
406
  exports.FlattenedEncrypt = exports.unprotected = void 0;
305
- const base64url_js_1 = __nccwpck_require__(8782);
306
- const encrypt_js_1 = __nccwpck_require__(7904);
307
- const zlib_js_1 = __nccwpck_require__(2148);
308
- const iv_js_1 = __nccwpck_require__(1688);
309
- const encrypt_key_management_js_1 = __nccwpck_require__(3964);
310
- const errors_js_1 = __nccwpck_require__(2157);
311
- const is_disjoint_js_1 = __nccwpck_require__(567);
312
- const buffer_utils_js_1 = __nccwpck_require__(2302);
313
- const validate_crit_js_1 = __nccwpck_require__(3498);
407
+ const base64url_js_1 = __nccwpck_require__(5091);
408
+ const encrypt_js_1 = __nccwpck_require__(5613);
409
+ const zlib_js_1 = __nccwpck_require__(3239);
410
+ const iv_js_1 = __nccwpck_require__(8379);
411
+ const encrypt_key_management_js_1 = __nccwpck_require__(6053);
412
+ const errors_js_1 = __nccwpck_require__(6891);
413
+ const is_disjoint_js_1 = __nccwpck_require__(3710);
414
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
415
+ const validate_crit_js_1 = __nccwpck_require__(1516);
314
416
  exports.unprotected = Symbol();
315
417
  class FlattenedEncrypt {
316
418
  constructor(plaintext) {
@@ -482,15 +584,15 @@ exports.FlattenedEncrypt = FlattenedEncrypt;
482
584
 
483
585
  /***/ }),
484
586
 
485
- /***/ 7161:
587
+ /***/ 7978:
486
588
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
487
589
 
488
590
 
489
591
  Object.defineProperty(exports, "__esModule", ({ value: true }));
490
592
  exports.generalDecrypt = void 0;
491
- const decrypt_js_1 = __nccwpck_require__(9508);
492
- const errors_js_1 = __nccwpck_require__(2157);
493
- const is_object_js_1 = __nccwpck_require__(8692);
593
+ const decrypt_js_1 = __nccwpck_require__(827);
594
+ const errors_js_1 = __nccwpck_require__(6891);
595
+ const is_object_js_1 = __nccwpck_require__(7787);
494
596
  async function generalDecrypt(jwe, key, options) {
495
597
  if (!(0, is_object_js_1.default)(jwe)) {
496
598
  throw new errors_js_1.JWEInvalid('General JWE must be an object');
@@ -524,19 +626,19 @@ exports.generalDecrypt = generalDecrypt;
524
626
 
525
627
  /***/ }),
526
628
 
527
- /***/ 3864:
629
+ /***/ 3170:
528
630
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
529
631
 
530
632
 
531
633
  Object.defineProperty(exports, "__esModule", ({ value: true }));
532
634
  exports.GeneralEncrypt = void 0;
533
- const encrypt_js_1 = __nccwpck_require__(5410);
534
- const errors_js_1 = __nccwpck_require__(2157);
535
- const cek_js_1 = __nccwpck_require__(2391);
536
- const is_disjoint_js_1 = __nccwpck_require__(567);
537
- const encrypt_key_management_js_1 = __nccwpck_require__(3964);
538
- const base64url_js_1 = __nccwpck_require__(8782);
539
- const validate_crit_js_1 = __nccwpck_require__(3498);
635
+ const encrypt_js_1 = __nccwpck_require__(2878);
636
+ const errors_js_1 = __nccwpck_require__(6891);
637
+ const cek_js_1 = __nccwpck_require__(9942);
638
+ const is_disjoint_js_1 = __nccwpck_require__(3710);
639
+ const encrypt_key_management_js_1 = __nccwpck_require__(6053);
640
+ const base64url_js_1 = __nccwpck_require__(5091);
641
+ const validate_crit_js_1 = __nccwpck_require__(1516);
540
642
  class IndividualRecipient {
541
643
  constructor(enc, key, options) {
542
644
  this.parent = enc;
@@ -713,15 +815,15 @@ exports.GeneralEncrypt = GeneralEncrypt;
713
815
 
714
816
  /***/ }),
715
817
 
716
- /***/ 7481:
818
+ /***/ 9483:
717
819
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
718
820
 
719
821
 
720
822
  Object.defineProperty(exports, "__esModule", ({ value: true }));
721
823
  exports.EmbeddedJWK = void 0;
722
- const import_js_1 = __nccwpck_require__(1173);
723
- const is_object_js_1 = __nccwpck_require__(8692);
724
- const errors_js_1 = __nccwpck_require__(2157);
824
+ const import_js_1 = __nccwpck_require__(3287);
825
+ const is_object_js_1 = __nccwpck_require__(7787);
826
+ const errors_js_1 = __nccwpck_require__(6891);
725
827
  async function EmbeddedJWK(protectedHeader, token) {
726
828
  const joseHeader = {
727
829
  ...protectedHeader,
@@ -741,26 +843,27 @@ exports.EmbeddedJWK = EmbeddedJWK;
741
843
 
742
844
  /***/ }),
743
845
 
744
- /***/ 5117:
846
+ /***/ 8166:
745
847
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
746
848
 
747
849
 
748
850
  Object.defineProperty(exports, "__esModule", ({ value: true }));
749
- exports.calculateJwkThumbprint = void 0;
750
- const digest_js_1 = __nccwpck_require__(1438);
751
- const base64url_js_1 = __nccwpck_require__(8782);
752
- const errors_js_1 = __nccwpck_require__(2157);
753
- const buffer_utils_js_1 = __nccwpck_require__(2302);
754
- const is_object_js_1 = __nccwpck_require__(8692);
851
+ exports.calculateJwkThumbprintUri = exports.calculateJwkThumbprint = void 0;
852
+ const digest_js_1 = __nccwpck_require__(7638);
853
+ const base64url_js_1 = __nccwpck_require__(5091);
854
+ const errors_js_1 = __nccwpck_require__(6891);
855
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
856
+ const is_object_js_1 = __nccwpck_require__(7787);
755
857
  const check = (value, description) => {
756
858
  if (typeof value !== 'string' || !value) {
757
859
  throw new errors_js_1.JWKInvalid(`${description} missing or invalid`);
758
860
  }
759
861
  };
760
- async function calculateJwkThumbprint(jwk, digestAlgorithm = 'sha256') {
862
+ async function calculateJwkThumbprint(jwk, digestAlgorithm) {
761
863
  if (!(0, is_object_js_1.default)(jwk)) {
762
864
  throw new TypeError('JWK must be an object');
763
865
  }
866
+ digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');
764
867
  if (digestAlgorithm !== 'sha256' &&
765
868
  digestAlgorithm !== 'sha384' &&
766
869
  digestAlgorithm !== 'sha512') {
@@ -795,19 +898,25 @@ async function calculateJwkThumbprint(jwk, digestAlgorithm = 'sha256') {
795
898
  return (0, base64url_js_1.encode)(await (0, digest_js_1.default)(digestAlgorithm, data));
796
899
  }
797
900
  exports.calculateJwkThumbprint = calculateJwkThumbprint;
901
+ async function calculateJwkThumbprintUri(jwk, digestAlgorithm) {
902
+ digestAlgorithm !== null && digestAlgorithm !== void 0 ? digestAlgorithm : (digestAlgorithm = 'sha256');
903
+ const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);
904
+ return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;
905
+ }
906
+ exports.calculateJwkThumbprintUri = calculateJwkThumbprintUri;
798
907
 
799
908
 
800
909
  /***/ }),
801
910
 
802
- /***/ 863:
911
+ /***/ 8560:
803
912
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
804
913
 
805
914
 
806
915
  Object.defineProperty(exports, "__esModule", ({ value: true }));
807
916
  exports.createLocalJWKSet = exports.LocalJWKSet = exports.isJWKSLike = void 0;
808
- const import_js_1 = __nccwpck_require__(1173);
809
- const errors_js_1 = __nccwpck_require__(2157);
810
- const is_object_js_1 = __nccwpck_require__(8692);
917
+ const import_js_1 = __nccwpck_require__(3287);
918
+ const errors_js_1 = __nccwpck_require__(6891);
919
+ const is_object_js_1 = __nccwpck_require__(7787);
811
920
  function getKtyFromAlg(alg) {
812
921
  switch (typeof alg === 'string' && alg.slice(0, 2)) {
813
922
  case 'RS':
@@ -847,8 +956,9 @@ class LocalJWKSet {
847
956
  }
848
957
  async getKey(protectedHeader, token) {
849
958
  const { alg, kid } = { ...protectedHeader, ...token.header };
959
+ const kty = getKtyFromAlg(alg);
850
960
  const candidates = this._jwks.keys.filter((jwk) => {
851
- let candidate = jwk.kty === getKtyFromAlg(alg);
961
+ let candidate = kty === jwk.kty;
852
962
  if (candidate && typeof kid === 'string') {
853
963
  candidate = kid === jwk.kid;
854
964
  }
@@ -909,16 +1019,16 @@ exports.createLocalJWKSet = createLocalJWKSet;
909
1019
 
910
1020
  /***/ }),
911
1021
 
912
- /***/ 8815:
1022
+ /***/ 7351:
913
1023
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
914
1024
 
915
1025
 
916
1026
  Object.defineProperty(exports, "__esModule", ({ value: true }));
917
1027
  exports.createRemoteJWKSet = void 0;
918
- const fetch_jwks_js_1 = __nccwpck_require__(5741);
919
- const env_js_1 = __nccwpck_require__(4002);
920
- const errors_js_1 = __nccwpck_require__(2157);
921
- const local_js_1 = __nccwpck_require__(863);
1028
+ const fetch_jwks_js_1 = __nccwpck_require__(7584);
1029
+ const env_js_1 = __nccwpck_require__(3354);
1030
+ const errors_js_1 = __nccwpck_require__(6891);
1031
+ const local_js_1 = __nccwpck_require__(8560);
922
1032
  class RemoteJWKSet extends local_js_1.LocalJWKSet {
923
1033
  constructor(url, options) {
924
1034
  super({ keys: [] });
@@ -927,20 +1037,25 @@ class RemoteJWKSet extends local_js_1.LocalJWKSet {
927
1037
  throw new TypeError('url must be an instance of URL');
928
1038
  }
929
1039
  this._url = new URL(url.href);
930
- this._options = { agent: options === null || options === void 0 ? void 0 : options.agent };
1040
+ this._options = { agent: options === null || options === void 0 ? void 0 : options.agent, headers: options === null || options === void 0 ? void 0 : options.headers };
931
1041
  this._timeoutDuration =
932
1042
  typeof (options === null || options === void 0 ? void 0 : options.timeoutDuration) === 'number' ? options === null || options === void 0 ? void 0 : options.timeoutDuration : 5000;
933
1043
  this._cooldownDuration =
934
1044
  typeof (options === null || options === void 0 ? void 0 : options.cooldownDuration) === 'number' ? options === null || options === void 0 ? void 0 : options.cooldownDuration : 30000;
1045
+ this._cacheMaxAge = typeof (options === null || options === void 0 ? void 0 : options.cacheMaxAge) === 'number' ? options === null || options === void 0 ? void 0 : options.cacheMaxAge : 600000;
935
1046
  }
936
1047
  coolingDown() {
937
- if (!this._cooldownStarted) {
938
- return false;
939
- }
940
- return Date.now() < this._cooldownStarted + this._cooldownDuration;
1048
+ return typeof this._jwksTimestamp === 'number'
1049
+ ? Date.now() < this._jwksTimestamp + this._cooldownDuration
1050
+ : false;
1051
+ }
1052
+ fresh() {
1053
+ return typeof this._jwksTimestamp === 'number'
1054
+ ? Date.now() < this._jwksTimestamp + this._cacheMaxAge
1055
+ : false;
941
1056
  }
942
1057
  async getKey(protectedHeader, token) {
943
- if (!this._jwks) {
1058
+ if (!this._jwks || !this.fresh()) {
944
1059
  await this.reload();
945
1060
  }
946
1061
  try {
@@ -977,7 +1092,7 @@ class RemoteJWKSet extends local_js_1.LocalJWKSet {
977
1092
  throw new errors_js_1.JWKSInvalid('JSON Web Key Set malformed');
978
1093
  }
979
1094
  this._jwks = { keys: json.keys };
980
- this._cooldownStarted = Date.now();
1095
+ this._jwksTimestamp = Date.now();
981
1096
  this._pendingFetch = undefined;
982
1097
  })
983
1098
  .catch((err) => {
@@ -996,13 +1111,13 @@ exports.createRemoteJWKSet = createRemoteJWKSet;
996
1111
 
997
1112
  /***/ }),
998
1113
 
999
- /***/ 9290:
1114
+ /***/ 670:
1000
1115
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1001
1116
 
1002
1117
 
1003
1118
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1004
1119
  exports.CompactSign = void 0;
1005
- const sign_js_1 = __nccwpck_require__(1659);
1120
+ const sign_js_1 = __nccwpck_require__(657);
1006
1121
  class CompactSign {
1007
1122
  constructor(payload) {
1008
1123
  this._flattened = new sign_js_1.FlattenedSign(payload);
@@ -1024,15 +1139,15 @@ exports.CompactSign = CompactSign;
1024
1139
 
1025
1140
  /***/ }),
1026
1141
 
1027
- /***/ 5427:
1142
+ /***/ 3757:
1028
1143
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1029
1144
 
1030
1145
 
1031
1146
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1032
1147
  exports.compactVerify = void 0;
1033
- const verify_js_1 = __nccwpck_require__(721);
1034
- const errors_js_1 = __nccwpck_require__(2157);
1035
- const buffer_utils_js_1 = __nccwpck_require__(2302);
1148
+ const verify_js_1 = __nccwpck_require__(1071);
1149
+ const errors_js_1 = __nccwpck_require__(6891);
1150
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
1036
1151
  async function compactVerify(jws, key, options) {
1037
1152
  if (jws instanceof Uint8Array) {
1038
1153
  jws = buffer_utils_js_1.decoder.decode(jws);
@@ -1056,19 +1171,19 @@ exports.compactVerify = compactVerify;
1056
1171
 
1057
1172
  /***/ }),
1058
1173
 
1059
- /***/ 1659:
1174
+ /***/ 657:
1060
1175
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1061
1176
 
1062
1177
 
1063
1178
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1064
1179
  exports.FlattenedSign = void 0;
1065
- const base64url_js_1 = __nccwpck_require__(8782);
1066
- const sign_js_1 = __nccwpck_require__(356);
1067
- const is_disjoint_js_1 = __nccwpck_require__(567);
1068
- const errors_js_1 = __nccwpck_require__(2157);
1069
- const buffer_utils_js_1 = __nccwpck_require__(2302);
1070
- const check_key_type_js_1 = __nccwpck_require__(7074);
1071
- const validate_crit_js_1 = __nccwpck_require__(3498);
1180
+ const base64url_js_1 = __nccwpck_require__(5091);
1181
+ const sign_js_1 = __nccwpck_require__(8979);
1182
+ const is_disjoint_js_1 = __nccwpck_require__(3710);
1183
+ const errors_js_1 = __nccwpck_require__(6891);
1184
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
1185
+ const check_key_type_js_1 = __nccwpck_require__(3067);
1186
+ const validate_crit_js_1 = __nccwpck_require__(1516);
1072
1187
  class FlattenedSign {
1073
1188
  constructor(payload) {
1074
1189
  if (!(payload instanceof Uint8Array)) {
@@ -1148,21 +1263,21 @@ exports.FlattenedSign = FlattenedSign;
1148
1263
 
1149
1264
  /***/ }),
1150
1265
 
1151
- /***/ 721:
1266
+ /***/ 1071:
1152
1267
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1153
1268
 
1154
1269
 
1155
1270
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1156
1271
  exports.flattenedVerify = void 0;
1157
- const base64url_js_1 = __nccwpck_require__(8782);
1158
- const verify_js_1 = __nccwpck_require__(5661);
1159
- const errors_js_1 = __nccwpck_require__(2157);
1160
- const buffer_utils_js_1 = __nccwpck_require__(2302);
1161
- const is_disjoint_js_1 = __nccwpck_require__(567);
1162
- const is_object_js_1 = __nccwpck_require__(8692);
1163
- const check_key_type_js_1 = __nccwpck_require__(7074);
1164
- const validate_crit_js_1 = __nccwpck_require__(3498);
1165
- const validate_algorithms_js_1 = __nccwpck_require__(7934);
1272
+ const base64url_js_1 = __nccwpck_require__(5091);
1273
+ const verify_js_1 = __nccwpck_require__(7190);
1274
+ const errors_js_1 = __nccwpck_require__(6891);
1275
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
1276
+ const is_disjoint_js_1 = __nccwpck_require__(3710);
1277
+ const is_object_js_1 = __nccwpck_require__(7787);
1278
+ const check_key_type_js_1 = __nccwpck_require__(3067);
1279
+ const validate_crit_js_1 = __nccwpck_require__(1516);
1280
+ const validate_algorithms_js_1 = __nccwpck_require__(7946);
1166
1281
  async function flattenedVerify(jws, key, options) {
1167
1282
  var _a;
1168
1283
  if (!(0, is_object_js_1.default)(jws)) {
@@ -1185,8 +1300,8 @@ async function flattenedVerify(jws, key, options) {
1185
1300
  }
1186
1301
  let parsedProt = {};
1187
1302
  if (jws.protected) {
1188
- const protectedHeader = (0, base64url_js_1.decode)(jws.protected);
1189
1303
  try {
1304
+ const protectedHeader = (0, base64url_js_1.decode)(jws.protected);
1190
1305
  parsedProt = JSON.parse(buffer_utils_js_1.decoder.decode(protectedHeader));
1191
1306
  }
1192
1307
  catch {
@@ -1263,14 +1378,14 @@ exports.flattenedVerify = flattenedVerify;
1263
1378
 
1264
1379
  /***/ }),
1265
1380
 
1266
- /***/ 493:
1381
+ /***/ 8473:
1267
1382
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1268
1383
 
1269
1384
 
1270
1385
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1271
1386
  exports.GeneralSign = void 0;
1272
- const sign_js_1 = __nccwpck_require__(1659);
1273
- const errors_js_1 = __nccwpck_require__(2157);
1387
+ const sign_js_1 = __nccwpck_require__(657);
1388
+ const errors_js_1 = __nccwpck_require__(6891);
1274
1389
  class IndividualSignature {
1275
1390
  constructor(sig, key, options) {
1276
1391
  this.parent = sig;
@@ -1341,15 +1456,15 @@ exports.GeneralSign = GeneralSign;
1341
1456
 
1342
1457
  /***/ }),
1343
1458
 
1344
- /***/ 5363:
1459
+ /***/ 8913:
1345
1460
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1346
1461
 
1347
1462
 
1348
1463
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1349
1464
  exports.generalVerify = void 0;
1350
- const verify_js_1 = __nccwpck_require__(721);
1351
- const errors_js_1 = __nccwpck_require__(2157);
1352
- const is_object_js_1 = __nccwpck_require__(8692);
1465
+ const verify_js_1 = __nccwpck_require__(1071);
1466
+ const errors_js_1 = __nccwpck_require__(6891);
1467
+ const is_object_js_1 = __nccwpck_require__(7787);
1353
1468
  async function generalVerify(jws, key, options) {
1354
1469
  if (!(0, is_object_js_1.default)(jws)) {
1355
1470
  throw new errors_js_1.JWSInvalid('General JWS must be an object');
@@ -1376,15 +1491,15 @@ exports.generalVerify = generalVerify;
1376
1491
 
1377
1492
  /***/ }),
1378
1493
 
1379
- /***/ 4875:
1494
+ /***/ 9486:
1380
1495
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1381
1496
 
1382
1497
 
1383
1498
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1384
1499
  exports.jwtDecrypt = void 0;
1385
- const decrypt_js_1 = __nccwpck_require__(7279);
1386
- const jwt_claims_set_js_1 = __nccwpck_require__(6859);
1387
- const errors_js_1 = __nccwpck_require__(2157);
1500
+ const decrypt_js_1 = __nccwpck_require__(1698);
1501
+ const jwt_claims_set_js_1 = __nccwpck_require__(8350);
1502
+ const errors_js_1 = __nccwpck_require__(6891);
1388
1503
  async function jwtDecrypt(jwt, key, options) {
1389
1504
  const decrypted = await (0, decrypt_js_1.compactDecrypt)(jwt, key, options);
1390
1505
  const payload = (0, jwt_claims_set_js_1.default)(decrypted.protectedHeader, decrypted.plaintext, options);
@@ -1410,15 +1525,15 @@ exports.jwtDecrypt = jwtDecrypt;
1410
1525
 
1411
1526
  /***/ }),
1412
1527
 
1413
- /***/ 6112:
1528
+ /***/ 242:
1414
1529
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1415
1530
 
1416
1531
 
1417
1532
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1418
1533
  exports.EncryptJWT = void 0;
1419
- const encrypt_js_1 = __nccwpck_require__(9670);
1420
- const buffer_utils_js_1 = __nccwpck_require__(2302);
1421
- const produce_js_1 = __nccwpck_require__(6231);
1534
+ const encrypt_js_1 = __nccwpck_require__(9325);
1535
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
1536
+ const produce_js_1 = __nccwpck_require__(395);
1422
1537
  class EncryptJWT extends produce_js_1.ProduceJWT {
1423
1538
  setProtectedHeader(protectedHeader) {
1424
1539
  if (this._protectedHeader) {
@@ -1489,15 +1604,15 @@ exports.EncryptJWT = EncryptJWT;
1489
1604
 
1490
1605
  /***/ }),
1491
1606
 
1492
- /***/ 6231:
1607
+ /***/ 395:
1493
1608
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1494
1609
 
1495
1610
 
1496
1611
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1497
1612
  exports.ProduceJWT = void 0;
1498
- const epoch_js_1 = __nccwpck_require__(6405);
1499
- const is_object_js_1 = __nccwpck_require__(8692);
1500
- const secs_js_1 = __nccwpck_require__(8735);
1613
+ const epoch_js_1 = __nccwpck_require__(1185);
1614
+ const is_object_js_1 = __nccwpck_require__(7787);
1615
+ const secs_js_1 = __nccwpck_require__(3393);
1501
1616
  class ProduceJWT {
1502
1617
  constructor(payload) {
1503
1618
  if (!(0, is_object_js_1.default)(payload)) {
@@ -1554,16 +1669,16 @@ exports.ProduceJWT = ProduceJWT;
1554
1669
 
1555
1670
  /***/ }),
1556
1671
 
1557
- /***/ 4952:
1672
+ /***/ 3744:
1558
1673
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1559
1674
 
1560
1675
 
1561
1676
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1562
1677
  exports.SignJWT = void 0;
1563
- const sign_js_1 = __nccwpck_require__(9290);
1564
- const errors_js_1 = __nccwpck_require__(2157);
1565
- const buffer_utils_js_1 = __nccwpck_require__(2302);
1566
- const produce_js_1 = __nccwpck_require__(6231);
1678
+ const sign_js_1 = __nccwpck_require__(670);
1679
+ const errors_js_1 = __nccwpck_require__(6891);
1680
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
1681
+ const produce_js_1 = __nccwpck_require__(395);
1567
1682
  class SignJWT extends produce_js_1.ProduceJWT {
1568
1683
  setProtectedHeader(protectedHeader) {
1569
1684
  this._protectedHeader = protectedHeader;
@@ -1586,17 +1701,17 @@ exports.SignJWT = SignJWT;
1586
1701
 
1587
1702
  /***/ }),
1588
1703
 
1589
- /***/ 7086:
1704
+ /***/ 9701:
1590
1705
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1591
1706
 
1592
1707
 
1593
1708
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1594
1709
  exports.UnsecuredJWT = void 0;
1595
- const base64url = __nccwpck_require__(8782);
1596
- const buffer_utils_js_1 = __nccwpck_require__(2302);
1597
- const errors_js_1 = __nccwpck_require__(2157);
1598
- const jwt_claims_set_js_1 = __nccwpck_require__(6859);
1599
- const produce_js_1 = __nccwpck_require__(6231);
1710
+ const base64url = __nccwpck_require__(5091);
1711
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
1712
+ const errors_js_1 = __nccwpck_require__(6891);
1713
+ const jwt_claims_set_js_1 = __nccwpck_require__(8350);
1714
+ const produce_js_1 = __nccwpck_require__(395);
1600
1715
  class UnsecuredJWT extends produce_js_1.ProduceJWT {
1601
1716
  encode() {
1602
1717
  const header = base64url.encode(JSON.stringify({ alg: 'none' }));
@@ -1629,15 +1744,15 @@ exports.UnsecuredJWT = UnsecuredJWT;
1629
1744
 
1630
1745
  /***/ }),
1631
1746
 
1632
- /***/ 5626:
1747
+ /***/ 958:
1633
1748
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1634
1749
 
1635
1750
 
1636
1751
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1637
1752
  exports.jwtVerify = void 0;
1638
- const verify_js_1 = __nccwpck_require__(5427);
1639
- const jwt_claims_set_js_1 = __nccwpck_require__(6859);
1640
- const errors_js_1 = __nccwpck_require__(2157);
1753
+ const verify_js_1 = __nccwpck_require__(3757);
1754
+ const jwt_claims_set_js_1 = __nccwpck_require__(8350);
1755
+ const errors_js_1 = __nccwpck_require__(6891);
1641
1756
  async function jwtVerify(jwt, key, options) {
1642
1757
  var _a;
1643
1758
  const verified = await (0, verify_js_1.compactVerify)(jwt, key, options);
@@ -1656,15 +1771,15 @@ exports.jwtVerify = jwtVerify;
1656
1771
 
1657
1772
  /***/ }),
1658
1773
 
1659
- /***/ 4039:
1774
+ /***/ 8771:
1660
1775
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1661
1776
 
1662
1777
 
1663
1778
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1664
1779
  exports.exportJWK = exports.exportPKCS8 = exports.exportSPKI = void 0;
1665
- const asn1_js_1 = __nccwpck_require__(3119);
1666
- const asn1_js_2 = __nccwpck_require__(3119);
1667
- const key_to_jwk_js_1 = __nccwpck_require__(1189);
1780
+ const asn1_js_1 = __nccwpck_require__(3029);
1781
+ const asn1_js_2 = __nccwpck_require__(3029);
1782
+ const key_to_jwk_js_1 = __nccwpck_require__(1297);
1668
1783
  async function exportSPKI(key) {
1669
1784
  return (0, asn1_js_1.toSPKI)(key);
1670
1785
  }
@@ -1681,13 +1796,13 @@ exports.exportJWK = exportJWK;
1681
1796
 
1682
1797
  /***/ }),
1683
1798
 
1684
- /***/ 179:
1799
+ /***/ 8959:
1685
1800
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1686
1801
 
1687
1802
 
1688
1803
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1689
1804
  exports.generateKeyPair = void 0;
1690
- const generate_js_1 = __nccwpck_require__(5719);
1805
+ const generate_js_1 = __nccwpck_require__(8737);
1691
1806
  async function generateKeyPair(alg, options) {
1692
1807
  return (0, generate_js_1.generateKeyPair)(alg, options);
1693
1808
  }
@@ -1696,13 +1811,13 @@ exports.generateKeyPair = generateKeyPair;
1696
1811
 
1697
1812
  /***/ }),
1698
1813
 
1699
- /***/ 3473:
1814
+ /***/ 9896:
1700
1815
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1701
1816
 
1702
1817
 
1703
1818
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1704
1819
  exports.generateSecret = void 0;
1705
- const generate_js_1 = __nccwpck_require__(5719);
1820
+ const generate_js_1 = __nccwpck_require__(8737);
1706
1821
  async function generateSecret(alg, options) {
1707
1822
  return (0, generate_js_1.generateSecret)(alg, options);
1708
1823
  }
@@ -1711,19 +1826,19 @@ exports.generateSecret = generateSecret;
1711
1826
 
1712
1827
  /***/ }),
1713
1828
 
1714
- /***/ 1173:
1829
+ /***/ 3287:
1715
1830
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1716
1831
 
1717
1832
 
1718
1833
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1719
1834
  exports.importJWK = exports.importPKCS8 = exports.importX509 = exports.importSPKI = void 0;
1720
- const base64url_js_1 = __nccwpck_require__(8782);
1721
- const asn1_js_1 = __nccwpck_require__(3119);
1722
- const asn1_js_2 = __nccwpck_require__(3119);
1723
- const jwk_to_key_js_1 = __nccwpck_require__(7570);
1724
- const errors_js_1 = __nccwpck_require__(2157);
1725
- const format_pem_js_1 = __nccwpck_require__(494);
1726
- const is_object_js_1 = __nccwpck_require__(8692);
1835
+ const base64url_js_1 = __nccwpck_require__(5091);
1836
+ const asn1_js_1 = __nccwpck_require__(3029);
1837
+ const asn1_js_2 = __nccwpck_require__(3029);
1838
+ const jwk_to_key_js_1 = __nccwpck_require__(2251);
1839
+ const errors_js_1 = __nccwpck_require__(6891);
1840
+ const format_pem_js_1 = __nccwpck_require__(7283);
1841
+ const is_object_js_1 = __nccwpck_require__(7787);
1727
1842
  function getElement(seq) {
1728
1843
  let result = [];
1729
1844
  let next = 0;
@@ -1845,16 +1960,16 @@ exports.importJWK = importJWK;
1845
1960
 
1846
1961
  /***/ }),
1847
1962
 
1848
- /***/ 8253:
1963
+ /***/ 7081:
1849
1964
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1850
1965
 
1851
1966
 
1852
1967
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1853
1968
  exports.unwrap = exports.wrap = void 0;
1854
- const encrypt_js_1 = __nccwpck_require__(7904);
1855
- const decrypt_js_1 = __nccwpck_require__(7703);
1856
- const iv_js_1 = __nccwpck_require__(1688);
1857
- const base64url_js_1 = __nccwpck_require__(8782);
1969
+ const encrypt_js_1 = __nccwpck_require__(5613);
1970
+ const decrypt_js_1 = __nccwpck_require__(1788);
1971
+ const iv_js_1 = __nccwpck_require__(8379);
1972
+ const base64url_js_1 = __nccwpck_require__(5091);
1858
1973
  async function wrap(alg, key, cek, iv) {
1859
1974
  const jweAlgorithm = alg.slice(0, 7);
1860
1975
  iv || (iv = (0, iv_js_1.default)(jweAlgorithm));
@@ -1871,13 +1986,13 @@ exports.unwrap = unwrap;
1871
1986
 
1872
1987
  /***/ }),
1873
1988
 
1874
- /***/ 2302:
1989
+ /***/ 3605:
1875
1990
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1876
1991
 
1877
1992
 
1878
1993
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1879
1994
  exports.concatKdf = exports.lengthAndInput = exports.uint32be = exports.uint64be = exports.p2s = exports.concat = exports.decoder = exports.encoder = void 0;
1880
- const digest_js_1 = __nccwpck_require__(1438);
1995
+ const digest_js_1 = __nccwpck_require__(7638);
1881
1996
  exports.encoder = new TextEncoder();
1882
1997
  exports.decoder = new TextDecoder();
1883
1998
  const MAX_INT32 = 2 ** 32;
@@ -1923,35 +2038,29 @@ function lengthAndInput(input) {
1923
2038
  exports.lengthAndInput = lengthAndInput;
1924
2039
  async function concatKdf(secret, bits, value) {
1925
2040
  const iterations = Math.ceil((bits >> 3) / 32);
1926
- let res;
1927
- for (let iter = 1; iter <= iterations; iter++) {
2041
+ const res = new Uint8Array(iterations * 32);
2042
+ for (let iter = 0; iter < iterations; iter++) {
1928
2043
  const buf = new Uint8Array(4 + secret.length + value.length);
1929
- buf.set(uint32be(iter));
2044
+ buf.set(uint32be(iter + 1));
1930
2045
  buf.set(secret, 4);
1931
2046
  buf.set(value, 4 + secret.length);
1932
- if (!res) {
1933
- res = await (0, digest_js_1.default)('sha256', buf);
1934
- }
1935
- else {
1936
- res = concat(res, await (0, digest_js_1.default)('sha256', buf));
1937
- }
2047
+ res.set(await (0, digest_js_1.default)('sha256', buf), iter * 32);
1938
2048
  }
1939
- res = res.slice(0, bits >> 3);
1940
- return res;
2049
+ return res.slice(0, bits >> 3);
1941
2050
  }
1942
2051
  exports.concatKdf = concatKdf;
1943
2052
 
1944
2053
 
1945
2054
  /***/ }),
1946
2055
 
1947
- /***/ 2391:
2056
+ /***/ 9942:
1948
2057
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1949
2058
 
1950
2059
 
1951
2060
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1952
2061
  exports.bitLength = void 0;
1953
- const errors_js_1 = __nccwpck_require__(2157);
1954
- const random_js_1 = __nccwpck_require__(3867);
2062
+ const errors_js_1 = __nccwpck_require__(6891);
2063
+ const random_js_1 = __nccwpck_require__(3609);
1955
2064
  function bitLength(alg) {
1956
2065
  switch (alg) {
1957
2066
  case 'A128GCM':
@@ -1975,13 +2084,13 @@ exports["default"] = (alg) => (0, random_js_1.default)(new Uint8Array(bitLength(
1975
2084
 
1976
2085
  /***/ }),
1977
2086
 
1978
- /***/ 8545:
2087
+ /***/ 962:
1979
2088
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1980
2089
 
1981
2090
 
1982
2091
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1983
- const errors_js_1 = __nccwpck_require__(2157);
1984
- const iv_js_1 = __nccwpck_require__(1688);
2092
+ const errors_js_1 = __nccwpck_require__(6891);
2093
+ const iv_js_1 = __nccwpck_require__(8379);
1985
2094
  const checkIvLength = (enc, iv) => {
1986
2095
  if (iv.length << 3 !== (0, iv_js_1.bitLength)(enc)) {
1987
2096
  throw new errors_js_1.JWEInvalid('Invalid Initialization Vector length');
@@ -1992,13 +2101,13 @@ exports["default"] = checkIvLength;
1992
2101
 
1993
2102
  /***/ }),
1994
2103
 
1995
- /***/ 7074:
2104
+ /***/ 3067:
1996
2105
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
1997
2106
 
1998
2107
 
1999
2108
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2000
- const invalid_key_input_js_1 = __nccwpck_require__(829);
2001
- const is_key_like_js_1 = __nccwpck_require__(5684);
2109
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
2110
+ const is_key_like_js_1 = __nccwpck_require__(938);
2002
2111
  const symmetricTypeCheck = (key) => {
2003
2112
  if (key instanceof Uint8Array)
2004
2113
  return;
@@ -2046,12 +2155,12 @@ exports["default"] = checkKeyType;
2046
2155
 
2047
2156
  /***/ }),
2048
2157
 
2049
- /***/ 3255:
2158
+ /***/ 2469:
2050
2159
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2051
2160
 
2052
2161
 
2053
2162
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2054
- const errors_js_1 = __nccwpck_require__(2157);
2163
+ const errors_js_1 = __nccwpck_require__(6891);
2055
2164
  function checkP2s(p2s) {
2056
2165
  if (!(p2s instanceof Uint8Array) || p2s.length < 8) {
2057
2166
  throw new errors_js_1.JWEInvalid('PBES2 Salt Input must be 8 or more octets');
@@ -2062,13 +2171,13 @@ exports["default"] = checkP2s;
2062
2171
 
2063
2172
  /***/ }),
2064
2173
 
2065
- /***/ 9996:
2174
+ /***/ 7849:
2066
2175
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2067
2176
 
2068
2177
 
2069
2178
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2070
2179
  exports.checkEncCryptoKey = exports.checkSigCryptoKey = void 0;
2071
- const env_js_1 = __nccwpck_require__(4002);
2180
+ const env_js_1 = __nccwpck_require__(3354);
2072
2181
  function unusable(name, prop = 'algorithm.name') {
2073
2182
  return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
2074
2183
  }
@@ -2141,11 +2250,6 @@ function checkSigCryptoKey(key, alg, ...usages) {
2141
2250
  throw unusable(`SHA-${expected}`, 'algorithm.hash');
2142
2251
  break;
2143
2252
  }
2144
- case (0, env_js_1.isNodeJs)() && 'EdDSA': {
2145
- if (key.algorithm.name !== 'NODE-ED25519' && key.algorithm.name !== 'NODE-ED448')
2146
- throw unusable('NODE-ED25519 or NODE-ED448');
2147
- break;
2148
- }
2149
2253
  case (0, env_js_1.isCloudflareWorkers)() && 'EdDSA': {
2150
2254
  if (!isAlgorithm(key.algorithm, 'NODE-ED25519'))
2151
2255
  throw unusable('NODE-ED25519');
@@ -2224,23 +2328,23 @@ exports.checkEncCryptoKey = checkEncCryptoKey;
2224
2328
 
2225
2329
  /***/ }),
2226
2330
 
2227
- /***/ 1732:
2331
+ /***/ 3635:
2228
2332
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2229
2333
 
2230
2334
 
2231
2335
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2232
- const aeskw_js_1 = __nccwpck_require__(4798);
2233
- const ECDH = __nccwpck_require__(9069);
2234
- const pbes2kw_js_1 = __nccwpck_require__(2441);
2235
- const rsaes_js_1 = __nccwpck_require__(2988);
2236
- const base64url_js_1 = __nccwpck_require__(8782);
2237
- const errors_js_1 = __nccwpck_require__(2157);
2238
- const cek_js_1 = __nccwpck_require__(2391);
2239
- const import_js_1 = __nccwpck_require__(1173);
2240
- const check_key_type_js_1 = __nccwpck_require__(7074);
2241
- const is_object_js_1 = __nccwpck_require__(8692);
2242
- const aesgcmkw_js_1 = __nccwpck_require__(8253);
2243
- async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
2336
+ const aeskw_js_1 = __nccwpck_require__(7052);
2337
+ const ECDH = __nccwpck_require__(2772);
2338
+ const pbes2kw_js_1 = __nccwpck_require__(5151);
2339
+ const rsaes_js_1 = __nccwpck_require__(8550);
2340
+ const base64url_js_1 = __nccwpck_require__(5091);
2341
+ const errors_js_1 = __nccwpck_require__(6891);
2342
+ const cek_js_1 = __nccwpck_require__(9942);
2343
+ const import_js_1 = __nccwpck_require__(3287);
2344
+ const check_key_type_js_1 = __nccwpck_require__(3067);
2345
+ const is_object_js_1 = __nccwpck_require__(7787);
2346
+ const aesgcmkw_js_1 = __nccwpck_require__(7081);
2347
+ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {
2244
2348
  (0, check_key_type_js_1.default)(alg, key, 'decrypt');
2245
2349
  switch (alg) {
2246
2350
  case 'dir': {
@@ -2294,6 +2398,9 @@ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
2294
2398
  throw new errors_js_1.JWEInvalid('JWE Encrypted Key missing');
2295
2399
  if (typeof joseHeader.p2c !== 'number')
2296
2400
  throw new errors_js_1.JWEInvalid(`JOSE Header "p2c" (PBES2 Count) missing or invalid`);
2401
+ const p2cLimit = (options === null || options === void 0 ? void 0 : options.maxPBES2Count) || 10000;
2402
+ if (joseHeader.p2c > p2cLimit)
2403
+ throw new errors_js_1.JWEInvalid(`JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds`);
2297
2404
  if (typeof joseHeader.p2s !== 'string')
2298
2405
  throw new errors_js_1.JWEInvalid(`JOSE Header "p2s" (PBES2 Salt) missing or invalid`);
2299
2406
  return (0, pbes2kw_js_1.decrypt)(alg, key, encryptedKey, joseHeader.p2c, (0, base64url_js_1.decode)(joseHeader.p2s));
@@ -2328,21 +2435,21 @@ exports["default"] = decryptKeyManagement;
2328
2435
 
2329
2436
  /***/ }),
2330
2437
 
2331
- /***/ 3964:
2438
+ /***/ 6053:
2332
2439
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2333
2440
 
2334
2441
 
2335
2442
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2336
- const aeskw_js_1 = __nccwpck_require__(4798);
2337
- const ECDH = __nccwpck_require__(9069);
2338
- const pbes2kw_js_1 = __nccwpck_require__(2441);
2339
- const rsaes_js_1 = __nccwpck_require__(2988);
2340
- const base64url_js_1 = __nccwpck_require__(8782);
2341
- const cek_js_1 = __nccwpck_require__(2391);
2342
- const errors_js_1 = __nccwpck_require__(2157);
2343
- const export_js_1 = __nccwpck_require__(4039);
2344
- const check_key_type_js_1 = __nccwpck_require__(7074);
2345
- const aesgcmkw_js_1 = __nccwpck_require__(8253);
2443
+ const aeskw_js_1 = __nccwpck_require__(7052);
2444
+ const ECDH = __nccwpck_require__(2772);
2445
+ const pbes2kw_js_1 = __nccwpck_require__(5151);
2446
+ const rsaes_js_1 = __nccwpck_require__(8550);
2447
+ const base64url_js_1 = __nccwpck_require__(5091);
2448
+ const cek_js_1 = __nccwpck_require__(9942);
2449
+ const errors_js_1 = __nccwpck_require__(6891);
2450
+ const export_js_1 = __nccwpck_require__(8771);
2451
+ const check_key_type_js_1 = __nccwpck_require__(3067);
2452
+ const aesgcmkw_js_1 = __nccwpck_require__(7081);
2346
2453
  async function encryptKeyManagement(alg, enc, key, providedCek, providedParameters = {}) {
2347
2454
  let encryptedKey;
2348
2455
  let parameters;
@@ -2424,7 +2531,7 @@ exports["default"] = encryptKeyManagement;
2424
2531
 
2425
2532
  /***/ }),
2426
2533
 
2427
- /***/ 6405:
2534
+ /***/ 1185:
2428
2535
  /***/ ((__unused_webpack_module, exports) => {
2429
2536
 
2430
2537
 
@@ -2434,7 +2541,7 @@ exports["default"] = (date) => Math.floor(date.getTime() / 1000);
2434
2541
 
2435
2542
  /***/ }),
2436
2543
 
2437
- /***/ 494:
2544
+ /***/ 7283:
2438
2545
  /***/ ((__unused_webpack_module, exports) => {
2439
2546
 
2440
2547
 
@@ -2447,7 +2554,7 @@ exports["default"] = (b64, descriptor) => {
2447
2554
 
2448
2555
  /***/ }),
2449
2556
 
2450
- /***/ 829:
2557
+ /***/ 9548:
2451
2558
  /***/ ((__unused_webpack_module, exports) => {
2452
2559
 
2453
2560
 
@@ -2481,7 +2588,7 @@ exports["default"] = (actual, ...types) => {
2481
2588
 
2482
2589
  /***/ }),
2483
2590
 
2484
- /***/ 567:
2591
+ /***/ 3710:
2485
2592
  /***/ ((__unused_webpack_module, exports) => {
2486
2593
 
2487
2594
 
@@ -2512,7 +2619,7 @@ exports["default"] = isDisjoint;
2512
2619
 
2513
2620
  /***/ }),
2514
2621
 
2515
- /***/ 8692:
2622
+ /***/ 7787:
2516
2623
  /***/ ((__unused_webpack_module, exports) => {
2517
2624
 
2518
2625
 
@@ -2538,14 +2645,14 @@ exports["default"] = isObject;
2538
2645
 
2539
2646
  /***/ }),
2540
2647
 
2541
- /***/ 1688:
2648
+ /***/ 8379:
2542
2649
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2543
2650
 
2544
2651
 
2545
2652
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2546
2653
  exports.bitLength = void 0;
2547
- const errors_js_1 = __nccwpck_require__(2157);
2548
- const random_js_1 = __nccwpck_require__(3867);
2654
+ const errors_js_1 = __nccwpck_require__(6891);
2655
+ const random_js_1 = __nccwpck_require__(3609);
2549
2656
  function bitLength(alg) {
2550
2657
  switch (alg) {
2551
2658
  case 'A128GCM':
@@ -2569,16 +2676,16 @@ exports["default"] = (alg) => (0, random_js_1.default)(new Uint8Array(bitLength(
2569
2676
 
2570
2677
  /***/ }),
2571
2678
 
2572
- /***/ 6859:
2679
+ /***/ 8350:
2573
2680
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2574
2681
 
2575
2682
 
2576
2683
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2577
- const errors_js_1 = __nccwpck_require__(2157);
2578
- const buffer_utils_js_1 = __nccwpck_require__(2302);
2579
- const epoch_js_1 = __nccwpck_require__(6405);
2580
- const secs_js_1 = __nccwpck_require__(8735);
2581
- const is_object_js_1 = __nccwpck_require__(8692);
2684
+ const errors_js_1 = __nccwpck_require__(6891);
2685
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
2686
+ const epoch_js_1 = __nccwpck_require__(1185);
2687
+ const secs_js_1 = __nccwpck_require__(3393);
2688
+ const is_object_js_1 = __nccwpck_require__(7787);
2582
2689
  const normalizeTyp = (value) => value.toLowerCase().replace(/^application\//, '');
2583
2690
  const checkAudiencePresence = (audPayload, audOption) => {
2584
2691
  if (typeof audPayload === 'string') {
@@ -2634,13 +2741,8 @@ exports["default"] = (protectedHeader, encodedPayload, options = {}) => {
2634
2741
  }
2635
2742
  const { currentDate } = options;
2636
2743
  const now = (0, epoch_js_1.default)(currentDate || new Date());
2637
- if (payload.iat !== undefined || options.maxTokenAge) {
2638
- if (typeof payload.iat !== 'number') {
2639
- throw new errors_js_1.JWTClaimValidationFailed('"iat" claim must be a number', 'iat', 'invalid');
2640
- }
2641
- if (payload.exp === undefined && payload.iat > now + tolerance) {
2642
- throw new errors_js_1.JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', 'iat', 'check_failed');
2643
- }
2744
+ if ((payload.iat !== undefined || options.maxTokenAge) && typeof payload.iat !== 'number') {
2745
+ throw new errors_js_1.JWTClaimValidationFailed('"iat" claim must be a number', 'iat', 'invalid');
2644
2746
  }
2645
2747
  if (payload.nbf !== undefined) {
2646
2748
  if (typeof payload.nbf !== 'number') {
@@ -2674,7 +2776,7 @@ exports["default"] = (protectedHeader, encodedPayload, options = {}) => {
2674
2776
 
2675
2777
  /***/ }),
2676
2778
 
2677
- /***/ 8735:
2779
+ /***/ 3393:
2678
2780
  /***/ ((__unused_webpack_module, exports) => {
2679
2781
 
2680
2782
 
@@ -2727,7 +2829,7 @@ exports["default"] = (str) => {
2727
2829
 
2728
2830
  /***/ }),
2729
2831
 
2730
- /***/ 7934:
2832
+ /***/ 7946:
2731
2833
  /***/ ((__unused_webpack_module, exports) => {
2732
2834
 
2733
2835
 
@@ -2747,12 +2849,12 @@ exports["default"] = validateAlgorithms;
2747
2849
 
2748
2850
  /***/ }),
2749
2851
 
2750
- /***/ 3498:
2852
+ /***/ 1516:
2751
2853
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2752
2854
 
2753
2855
 
2754
2856
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2755
- const errors_js_1 = __nccwpck_require__(2157);
2857
+ const errors_js_1 = __nccwpck_require__(6891);
2756
2858
  function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
2757
2859
  if (joseHeader.crit !== undefined && protectedHeader.crit === undefined) {
2758
2860
  throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
@@ -2790,7 +2892,7 @@ exports["default"] = validateCrit;
2790
2892
 
2791
2893
  /***/ }),
2792
2894
 
2793
- /***/ 4798:
2895
+ /***/ 7052:
2794
2896
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2795
2897
 
2796
2898
 
@@ -2798,14 +2900,14 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
2798
2900
  exports.unwrap = exports.wrap = void 0;
2799
2901
  const buffer_1 = __nccwpck_require__(4300);
2800
2902
  const crypto_1 = __nccwpck_require__(6113);
2801
- const errors_js_1 = __nccwpck_require__(2157);
2802
- const buffer_utils_js_1 = __nccwpck_require__(2302);
2803
- const webcrypto_js_1 = __nccwpck_require__(531);
2804
- const crypto_key_js_1 = __nccwpck_require__(9996);
2805
- const is_key_object_js_1 = __nccwpck_require__(5629);
2806
- const invalid_key_input_js_1 = __nccwpck_require__(829);
2807
- const ciphers_js_1 = __nccwpck_require__(1462);
2808
- const is_key_like_js_1 = __nccwpck_require__(5684);
2903
+ const errors_js_1 = __nccwpck_require__(6891);
2904
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
2905
+ const webcrypto_js_1 = __nccwpck_require__(6474);
2906
+ const crypto_key_js_1 = __nccwpck_require__(7849);
2907
+ const is_key_object_js_1 = __nccwpck_require__(3758);
2908
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
2909
+ const ciphers_js_1 = __nccwpck_require__(3227);
2910
+ const is_key_like_js_1 = __nccwpck_require__(938);
2809
2911
  function checkKeySize(key, alg) {
2810
2912
  if (key.symmetricKeySize << 3 !== parseInt(alg.slice(1, 4), 10)) {
2811
2913
  throw new TypeError(`Invalid key size for alg: ${alg}`);
@@ -2852,7 +2954,7 @@ exports.unwrap = unwrap;
2852
2954
 
2853
2955
  /***/ }),
2854
2956
 
2855
- /***/ 3119:
2957
+ /***/ 3029:
2856
2958
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2857
2959
 
2858
2960
 
@@ -2860,10 +2962,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
2860
2962
  exports.fromSPKI = exports.fromPKCS8 = exports.toPKCS8 = exports.toSPKI = void 0;
2861
2963
  const crypto_1 = __nccwpck_require__(6113);
2862
2964
  const buffer_1 = __nccwpck_require__(4300);
2863
- const webcrypto_js_1 = __nccwpck_require__(531);
2864
- const is_key_object_js_1 = __nccwpck_require__(5629);
2865
- const invalid_key_input_js_1 = __nccwpck_require__(829);
2866
- const is_key_like_js_1 = __nccwpck_require__(5684);
2965
+ const webcrypto_js_1 = __nccwpck_require__(6474);
2966
+ const is_key_object_js_1 = __nccwpck_require__(3758);
2967
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
2968
+ const is_key_like_js_1 = __nccwpck_require__(938);
2867
2969
  const genericExport = (keyType, keyFormat, key) => {
2868
2970
  let keyObject;
2869
2971
  if ((0, webcrypto_js_1.isCryptoKey)(key)) {
@@ -2907,7 +3009,7 @@ exports.fromSPKI = fromSPKI;
2907
3009
 
2908
3010
  /***/ }),
2909
3011
 
2910
- /***/ 3998:
3012
+ /***/ 9301:
2911
3013
  /***/ ((__unused_webpack_module, exports) => {
2912
3014
 
2913
3015
 
@@ -2961,13 +3063,13 @@ exports["default"] = Asn1SequenceDecoder;
2961
3063
 
2962
3064
  /***/ }),
2963
3065
 
2964
- /***/ 7624:
3066
+ /***/ 7326:
2965
3067
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2966
3068
 
2967
3069
 
2968
3070
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2969
3071
  const buffer_1 = __nccwpck_require__(4300);
2970
- const errors_js_1 = __nccwpck_require__(2157);
3072
+ const errors_js_1 = __nccwpck_require__(6891);
2971
3073
  const tagInteger = 0x02;
2972
3074
  const tagBitStr = 0x03;
2973
3075
  const tagOctStr = 0x04;
@@ -3059,14 +3161,14 @@ exports["default"] = DumbAsn1Encoder;
3059
3161
 
3060
3162
  /***/ }),
3061
3163
 
3062
- /***/ 8782:
3164
+ /***/ 5091:
3063
3165
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3064
3166
 
3065
3167
 
3066
3168
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3067
3169
  exports.decode = exports.encode = exports.encodeBase64 = exports.decodeBase64 = void 0;
3068
3170
  const buffer_1 = __nccwpck_require__(4300);
3069
- const buffer_utils_js_1 = __nccwpck_require__(2302);
3171
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
3070
3172
  let encode;
3071
3173
  exports.encode = encode;
3072
3174
  function normalize(input) {
@@ -3092,13 +3194,13 @@ exports.decode = decode;
3092
3194
 
3093
3195
  /***/ }),
3094
3196
 
3095
- /***/ 5685:
3197
+ /***/ 261:
3096
3198
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3097
3199
 
3098
3200
 
3099
3201
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3100
3202
  const crypto_1 = __nccwpck_require__(6113);
3101
- const buffer_utils_js_1 = __nccwpck_require__(2302);
3203
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
3102
3204
  function cbcTag(aad, iv, ciphertext, macSize, macKey, keySize) {
3103
3205
  const macData = (0, buffer_utils_js_1.concat)(aad, iv, ciphertext, (0, buffer_utils_js_1.uint64be)(aad.length << 3));
3104
3206
  const hmac = (0, crypto_1.createHmac)(`sha${macSize}`, macKey);
@@ -3110,13 +3212,13 @@ exports["default"] = cbcTag;
3110
3212
 
3111
3213
  /***/ }),
3112
3214
 
3113
- /***/ 7176:
3215
+ /***/ 1529:
3114
3216
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3115
3217
 
3116
3218
 
3117
3219
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3118
- const errors_js_1 = __nccwpck_require__(2157);
3119
- const is_key_object_js_1 = __nccwpck_require__(5629);
3220
+ const errors_js_1 = __nccwpck_require__(6891);
3221
+ const is_key_object_js_1 = __nccwpck_require__(3758);
3120
3222
  const checkCekLength = (enc, cek) => {
3121
3223
  let expected;
3122
3224
  switch (enc) {
@@ -3152,7 +3254,7 @@ exports["default"] = checkCekLength;
3152
3254
 
3153
3255
  /***/ }),
3154
3256
 
3155
- /***/ 9533:
3257
+ /***/ 1862:
3156
3258
  /***/ ((__unused_webpack_module, exports) => {
3157
3259
 
3158
3260
 
@@ -3211,7 +3313,7 @@ exports["default"] = (key, alg) => {
3211
3313
 
3212
3314
  /***/ }),
3213
3315
 
3214
- /***/ 1462:
3316
+ /***/ 3227:
3215
3317
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3216
3318
 
3217
3319
 
@@ -3226,24 +3328,24 @@ exports["default"] = (algorithm) => {
3226
3328
 
3227
3329
  /***/ }),
3228
3330
 
3229
- /***/ 7703:
3331
+ /***/ 1788:
3230
3332
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3231
3333
 
3232
3334
 
3233
3335
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3234
3336
  const crypto_1 = __nccwpck_require__(6113);
3235
- const check_iv_length_js_1 = __nccwpck_require__(8545);
3236
- const check_cek_length_js_1 = __nccwpck_require__(7176);
3237
- const buffer_utils_js_1 = __nccwpck_require__(2302);
3238
- const errors_js_1 = __nccwpck_require__(2157);
3239
- const timing_safe_equal_js_1 = __nccwpck_require__(1680);
3240
- const cbc_tag_js_1 = __nccwpck_require__(5685);
3241
- const webcrypto_js_1 = __nccwpck_require__(531);
3242
- const crypto_key_js_1 = __nccwpck_require__(9996);
3243
- const is_key_object_js_1 = __nccwpck_require__(5629);
3244
- const invalid_key_input_js_1 = __nccwpck_require__(829);
3245
- const ciphers_js_1 = __nccwpck_require__(1462);
3246
- const is_key_like_js_1 = __nccwpck_require__(5684);
3337
+ const check_iv_length_js_1 = __nccwpck_require__(962);
3338
+ const check_cek_length_js_1 = __nccwpck_require__(1529);
3339
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
3340
+ const errors_js_1 = __nccwpck_require__(6891);
3341
+ const timing_safe_equal_js_1 = __nccwpck_require__(4568);
3342
+ const cbc_tag_js_1 = __nccwpck_require__(261);
3343
+ const webcrypto_js_1 = __nccwpck_require__(6474);
3344
+ const crypto_key_js_1 = __nccwpck_require__(7849);
3345
+ const is_key_object_js_1 = __nccwpck_require__(3758);
3346
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
3347
+ const ciphers_js_1 = __nccwpck_require__(3227);
3348
+ const is_key_like_js_1 = __nccwpck_require__(938);
3247
3349
  function cbcDecrypt(enc, cek, ciphertext, iv, tag, aad) {
3248
3350
  const keySize = parseInt(enc.slice(1, 4), 10);
3249
3351
  if ((0, is_key_object_js_1.default)(cek)) {
@@ -3330,7 +3432,7 @@ exports["default"] = decrypt;
3330
3432
 
3331
3433
  /***/ }),
3332
3434
 
3333
- /***/ 1438:
3435
+ /***/ 7638:
3334
3436
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3335
3437
 
3336
3438
 
@@ -3342,12 +3444,12 @@ exports["default"] = digest;
3342
3444
 
3343
3445
  /***/ }),
3344
3446
 
3345
- /***/ 5311:
3447
+ /***/ 1312:
3346
3448
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3347
3449
 
3348
3450
 
3349
3451
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3350
- const errors_js_1 = __nccwpck_require__(2157);
3452
+ const errors_js_1 = __nccwpck_require__(6891);
3351
3453
  function dsaDigest(alg) {
3352
3454
  switch (alg) {
3353
3455
  case 'PS256':
@@ -3374,7 +3476,7 @@ exports["default"] = dsaDigest;
3374
3476
 
3375
3477
  /***/ }),
3376
3478
 
3377
- /***/ 9069:
3479
+ /***/ 2772:
3378
3480
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3379
3481
 
3380
3482
 
@@ -3382,14 +3484,14 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
3382
3484
  exports.ecdhAllowed = exports.generateEpk = exports.deriveKey = void 0;
3383
3485
  const crypto_1 = __nccwpck_require__(6113);
3384
3486
  const util_1 = __nccwpck_require__(3837);
3385
- const get_named_curve_js_1 = __nccwpck_require__(5465);
3386
- const buffer_utils_js_1 = __nccwpck_require__(2302);
3387
- const errors_js_1 = __nccwpck_require__(2157);
3388
- const webcrypto_js_1 = __nccwpck_require__(531);
3389
- const crypto_key_js_1 = __nccwpck_require__(9996);
3390
- const is_key_object_js_1 = __nccwpck_require__(5629);
3391
- const invalid_key_input_js_1 = __nccwpck_require__(829);
3392
- const is_key_like_js_1 = __nccwpck_require__(5684);
3487
+ const get_named_curve_js_1 = __nccwpck_require__(3607);
3488
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
3489
+ const errors_js_1 = __nccwpck_require__(6891);
3490
+ const webcrypto_js_1 = __nccwpck_require__(6474);
3491
+ const crypto_key_js_1 = __nccwpck_require__(7849);
3492
+ const is_key_object_js_1 = __nccwpck_require__(3758);
3493
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
3494
+ const is_key_like_js_1 = __nccwpck_require__(938);
3393
3495
  const generateKeyPair = (0, util_1.promisify)(crypto_1.generateKeyPair);
3394
3496
  async function deriveKey(publicKee, privateKee, algorithm, keyLength, apu = new Uint8Array(0), apv = new Uint8Array(0)) {
3395
3497
  let publicKey;
@@ -3451,23 +3553,23 @@ exports.ecdhAllowed = ecdhAllowed;
3451
3553
 
3452
3554
  /***/ }),
3453
3555
 
3454
- /***/ 7904:
3556
+ /***/ 5613:
3455
3557
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3456
3558
 
3457
3559
 
3458
3560
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3459
3561
  const crypto_1 = __nccwpck_require__(6113);
3460
- const check_iv_length_js_1 = __nccwpck_require__(8545);
3461
- const check_cek_length_js_1 = __nccwpck_require__(7176);
3462
- const buffer_utils_js_1 = __nccwpck_require__(2302);
3463
- const cbc_tag_js_1 = __nccwpck_require__(5685);
3464
- const webcrypto_js_1 = __nccwpck_require__(531);
3465
- const crypto_key_js_1 = __nccwpck_require__(9996);
3466
- const is_key_object_js_1 = __nccwpck_require__(5629);
3467
- const invalid_key_input_js_1 = __nccwpck_require__(829);
3468
- const errors_js_1 = __nccwpck_require__(2157);
3469
- const ciphers_js_1 = __nccwpck_require__(1462);
3470
- const is_key_like_js_1 = __nccwpck_require__(5684);
3562
+ const check_iv_length_js_1 = __nccwpck_require__(962);
3563
+ const check_cek_length_js_1 = __nccwpck_require__(1529);
3564
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
3565
+ const cbc_tag_js_1 = __nccwpck_require__(261);
3566
+ const webcrypto_js_1 = __nccwpck_require__(6474);
3567
+ const crypto_key_js_1 = __nccwpck_require__(7849);
3568
+ const is_key_object_js_1 = __nccwpck_require__(3758);
3569
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
3570
+ const errors_js_1 = __nccwpck_require__(6891);
3571
+ const ciphers_js_1 = __nccwpck_require__(3227);
3572
+ const is_key_like_js_1 = __nccwpck_require__(938);
3471
3573
  function cbcEncrypt(enc, plaintext, cek, iv, aad) {
3472
3574
  const keySize = parseInt(enc.slice(1, 4), 10);
3473
3575
  if ((0, is_key_object_js_1.default)(cek)) {
@@ -3532,25 +3634,21 @@ exports["default"] = encrypt;
3532
3634
 
3533
3635
  /***/ }),
3534
3636
 
3535
- /***/ 4002:
3637
+ /***/ 3354:
3536
3638
  /***/ ((__unused_webpack_module, exports) => {
3537
3639
 
3538
3640
 
3539
3641
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3540
- exports.isNodeJs = exports.isCloudflareWorkers = void 0;
3642
+ exports.isCloudflareWorkers = void 0;
3541
3643
  function isCloudflareWorkers() {
3542
3644
  return false;
3543
3645
  }
3544
3646
  exports.isCloudflareWorkers = isCloudflareWorkers;
3545
- function isNodeJs() {
3546
- return true;
3547
- }
3548
- exports.isNodeJs = isNodeJs;
3549
3647
 
3550
3648
 
3551
3649
  /***/ }),
3552
3650
 
3553
- /***/ 5741:
3651
+ /***/ 7584:
3554
3652
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3555
3653
 
3556
3654
 
@@ -3558,8 +3656,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
3558
3656
  const http = __nccwpck_require__(3685);
3559
3657
  const https = __nccwpck_require__(5687);
3560
3658
  const events_1 = __nccwpck_require__(2361);
3561
- const errors_js_1 = __nccwpck_require__(2157);
3562
- const buffer_utils_js_1 = __nccwpck_require__(2302);
3659
+ const errors_js_1 = __nccwpck_require__(6891);
3660
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
3563
3661
  const fetchJwks = async (url, timeout, options) => {
3564
3662
  let get;
3565
3663
  switch (url.protocol) {
@@ -3572,10 +3670,11 @@ const fetchJwks = async (url, timeout, options) => {
3572
3670
  default:
3573
3671
  throw new TypeError('Unsupported URL protocol.');
3574
3672
  }
3575
- const { agent } = options;
3673
+ const { agent, headers } = options;
3576
3674
  const req = get(url.href, {
3577
3675
  agent,
3578
3676
  timeout,
3677
+ headers,
3579
3678
  });
3580
3679
  const [response] = (await Promise.race([(0, events_1.once)(req, 'response'), (0, events_1.once)(req, 'timeout')]));
3581
3680
  if (!response) {
@@ -3601,7 +3700,7 @@ exports["default"] = fetchJwks;
3601
3700
 
3602
3701
  /***/ }),
3603
3702
 
3604
- /***/ 5719:
3703
+ /***/ 8737:
3605
3704
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3606
3705
 
3607
3706
 
@@ -3609,9 +3708,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
3609
3708
  exports.generateKeyPair = exports.generateSecret = void 0;
3610
3709
  const crypto_1 = __nccwpck_require__(6113);
3611
3710
  const util_1 = __nccwpck_require__(3837);
3612
- const random_js_1 = __nccwpck_require__(3867);
3613
- const check_modulus_length_js_1 = __nccwpck_require__(9533);
3614
- const errors_js_1 = __nccwpck_require__(2157);
3711
+ const random_js_1 = __nccwpck_require__(3609);
3712
+ const check_modulus_length_js_1 = __nccwpck_require__(1862);
3713
+ const errors_js_1 = __nccwpck_require__(6891);
3615
3714
  const generate = (0, util_1.promisify)(crypto_1.generateKeyPair);
3616
3715
  async function generateSecret(alg, options) {
3617
3716
  let length;
@@ -3690,12 +3789,13 @@ async function generateKeyPair(alg, options) {
3690
3789
  case 'ECDH-ES+A128KW':
3691
3790
  case 'ECDH-ES+A192KW':
3692
3791
  case 'ECDH-ES+A256KW':
3693
- switch (options === null || options === void 0 ? void 0 : options.crv) {
3792
+ const crv = (_b = options === null || options === void 0 ? void 0 : options.crv) !== null && _b !== void 0 ? _b : 'P-256';
3793
+ switch (crv) {
3694
3794
  case undefined:
3695
3795
  case 'P-256':
3696
3796
  case 'P-384':
3697
3797
  case 'P-521':
3698
- return generate('ec', { namedCurve: (_b = options === null || options === void 0 ? void 0 : options.crv) !== null && _b !== void 0 ? _b : 'P-256' });
3798
+ return generate('ec', { namedCurve: crv });
3699
3799
  case 'X25519':
3700
3800
  return generate('x25519');
3701
3801
  case 'X448':
@@ -3712,7 +3812,7 @@ exports.generateKeyPair = generateKeyPair;
3712
3812
 
3713
3813
  /***/ }),
3714
3814
 
3715
- /***/ 5465:
3815
+ /***/ 3607:
3716
3816
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3717
3817
 
3718
3818
 
@@ -3720,11 +3820,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
3720
3820
  exports.setCurve = exports.weakMap = void 0;
3721
3821
  const buffer_1 = __nccwpck_require__(4300);
3722
3822
  const crypto_1 = __nccwpck_require__(6113);
3723
- const errors_js_1 = __nccwpck_require__(2157);
3724
- const webcrypto_js_1 = __nccwpck_require__(531);
3725
- const is_key_object_js_1 = __nccwpck_require__(5629);
3726
- const invalid_key_input_js_1 = __nccwpck_require__(829);
3727
- const is_key_like_js_1 = __nccwpck_require__(5684);
3823
+ const errors_js_1 = __nccwpck_require__(6891);
3824
+ const webcrypto_js_1 = __nccwpck_require__(6474);
3825
+ const is_key_object_js_1 = __nccwpck_require__(3758);
3826
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
3827
+ const is_key_like_js_1 = __nccwpck_require__(938);
3728
3828
  const p256 = buffer_1.Buffer.from([42, 134, 72, 206, 61, 3, 1, 7]);
3729
3829
  const p384 = buffer_1.Buffer.from([43, 129, 4, 0, 34]);
3730
3830
  const p521 = buffer_1.Buffer.from([43, 129, 4, 0, 35]);
@@ -3814,16 +3914,16 @@ exports["default"] = getNamedCurve;
3814
3914
 
3815
3915
  /***/ }),
3816
3916
 
3817
- /***/ 9928:
3917
+ /***/ 9579:
3818
3918
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3819
3919
 
3820
3920
 
3821
3921
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3822
3922
  const crypto_1 = __nccwpck_require__(6113);
3823
- const webcrypto_js_1 = __nccwpck_require__(531);
3824
- const crypto_key_js_1 = __nccwpck_require__(9996);
3825
- const invalid_key_input_js_1 = __nccwpck_require__(829);
3826
- const is_key_like_js_1 = __nccwpck_require__(5684);
3923
+ const webcrypto_js_1 = __nccwpck_require__(6474);
3924
+ const crypto_key_js_1 = __nccwpck_require__(7849);
3925
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
3926
+ const is_key_like_js_1 = __nccwpck_require__(938);
3827
3927
  function getSignVerifyKey(alg, key, usage) {
3828
3928
  if (key instanceof Uint8Array) {
3829
3929
  if (!alg.startsWith('HS')) {
@@ -3845,12 +3945,12 @@ exports["default"] = getSignVerifyKey;
3845
3945
 
3846
3946
  /***/ }),
3847
3947
 
3848
- /***/ 8282:
3948
+ /***/ 3199:
3849
3949
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3850
3950
 
3851
3951
 
3852
3952
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3853
- const errors_js_1 = __nccwpck_require__(2157);
3953
+ const errors_js_1 = __nccwpck_require__(6891);
3854
3954
  function hmacDigest(alg) {
3855
3955
  switch (alg) {
3856
3956
  case 'HS256':
@@ -3868,14 +3968,14 @@ exports["default"] = hmacDigest;
3868
3968
 
3869
3969
  /***/ }),
3870
3970
 
3871
- /***/ 5684:
3971
+ /***/ 938:
3872
3972
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3873
3973
 
3874
3974
 
3875
3975
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3876
3976
  exports.types = void 0;
3877
- const webcrypto_js_1 = __nccwpck_require__(531);
3878
- const is_key_object_js_1 = __nccwpck_require__(5629);
3977
+ const webcrypto_js_1 = __nccwpck_require__(6474);
3978
+ const is_key_object_js_1 = __nccwpck_require__(3758);
3879
3979
  exports["default"] = (key) => (0, is_key_object_js_1.default)(key) || (0, webcrypto_js_1.isCryptoKey)(key);
3880
3980
  const types = ['KeyObject'];
3881
3981
  exports.types = types;
@@ -3886,7 +3986,7 @@ if (parseInt(process.versions.node) >= 16) {
3886
3986
 
3887
3987
  /***/ }),
3888
3988
 
3889
- /***/ 5629:
3989
+ /***/ 3758:
3890
3990
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3891
3991
 
3892
3992
 
@@ -3900,18 +4000,18 @@ exports["default"] = util.types.isKeyObject
3900
4000
 
3901
4001
  /***/ }),
3902
4002
 
3903
- /***/ 7570:
4003
+ /***/ 2251:
3904
4004
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
3905
4005
 
3906
4006
 
3907
4007
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3908
4008
  const buffer_1 = __nccwpck_require__(4300);
3909
4009
  const crypto_1 = __nccwpck_require__(6113);
3910
- const base64url_js_1 = __nccwpck_require__(8782);
3911
- const errors_js_1 = __nccwpck_require__(2157);
3912
- const get_named_curve_js_1 = __nccwpck_require__(5465);
3913
- const check_modulus_length_js_1 = __nccwpck_require__(9533);
3914
- const asn1_sequence_encoder_js_1 = __nccwpck_require__(7624);
4010
+ const base64url_js_1 = __nccwpck_require__(5091);
4011
+ const errors_js_1 = __nccwpck_require__(6891);
4012
+ const get_named_curve_js_1 = __nccwpck_require__(3607);
4013
+ const check_modulus_length_js_1 = __nccwpck_require__(1862);
4014
+ const asn1_sequence_encoder_js_1 = __nccwpck_require__(7326);
3915
4015
  const [major, minor] = process.version
3916
4016
  .slice(1)
3917
4017
  .split('.')
@@ -4029,20 +4129,20 @@ exports["default"] = parse;
4029
4129
 
4030
4130
  /***/ }),
4031
4131
 
4032
- /***/ 1189:
4132
+ /***/ 1297:
4033
4133
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4034
4134
 
4035
4135
 
4036
4136
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4037
4137
  const crypto_1 = __nccwpck_require__(6113);
4038
- const base64url_js_1 = __nccwpck_require__(8782);
4039
- const asn1_sequence_decoder_js_1 = __nccwpck_require__(3998);
4040
- const errors_js_1 = __nccwpck_require__(2157);
4041
- const get_named_curve_js_1 = __nccwpck_require__(5465);
4042
- const webcrypto_js_1 = __nccwpck_require__(531);
4043
- const is_key_object_js_1 = __nccwpck_require__(5629);
4044
- const invalid_key_input_js_1 = __nccwpck_require__(829);
4045
- const is_key_like_js_1 = __nccwpck_require__(5684);
4138
+ const base64url_js_1 = __nccwpck_require__(5091);
4139
+ const asn1_sequence_decoder_js_1 = __nccwpck_require__(9301);
4140
+ const errors_js_1 = __nccwpck_require__(6891);
4141
+ const get_named_curve_js_1 = __nccwpck_require__(3607);
4142
+ const webcrypto_js_1 = __nccwpck_require__(6474);
4143
+ const is_key_object_js_1 = __nccwpck_require__(3758);
4144
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
4145
+ const is_key_like_js_1 = __nccwpck_require__(938);
4046
4146
  const [major, minor] = process.version
4047
4147
  .slice(1)
4048
4148
  .split('.')
@@ -4069,6 +4169,10 @@ const keyToJWK = (key) => {
4069
4169
  throw new TypeError((0, invalid_key_input_js_1.default)(key, ...is_key_like_js_1.types, 'Uint8Array'));
4070
4170
  }
4071
4171
  if (jwkExportSupported) {
4172
+ if (keyObject.type !== 'secret' &&
4173
+ !['rsa', 'ec', 'ed25519', 'x25519', 'ed448', 'x448'].includes(keyObject.asymmetricKeyType)) {
4174
+ throw new errors_js_1.JOSENotSupported('Unsupported key asymmetricKeyType');
4175
+ }
4072
4176
  return keyObject.export({ format: 'jwk' });
4073
4177
  }
4074
4178
  switch (keyObject.type) {
@@ -4196,15 +4300,15 @@ exports["default"] = keyToJWK;
4196
4300
 
4197
4301
  /***/ }),
4198
4302
 
4199
- /***/ 4266:
4303
+ /***/ 7402:
4200
4304
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4201
4305
 
4202
4306
 
4203
4307
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4204
4308
  const crypto_1 = __nccwpck_require__(6113);
4205
- const get_named_curve_js_1 = __nccwpck_require__(5465);
4206
- const errors_js_1 = __nccwpck_require__(2157);
4207
- const check_modulus_length_js_1 = __nccwpck_require__(9533);
4309
+ const get_named_curve_js_1 = __nccwpck_require__(3607);
4310
+ const errors_js_1 = __nccwpck_require__(6891);
4311
+ const check_modulus_length_js_1 = __nccwpck_require__(1862);
4208
4312
  const [major, minor] = process.version
4209
4313
  .slice(1)
4210
4314
  .split('.')
@@ -4286,7 +4390,7 @@ exports["default"] = keyForCrypto;
4286
4390
 
4287
4391
  /***/ }),
4288
4392
 
4289
- /***/ 2441:
4393
+ /***/ 5151:
4290
4394
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4291
4395
 
4292
4396
 
@@ -4294,16 +4398,16 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
4294
4398
  exports.decrypt = exports.encrypt = void 0;
4295
4399
  const util_1 = __nccwpck_require__(3837);
4296
4400
  const crypto_1 = __nccwpck_require__(6113);
4297
- const random_js_1 = __nccwpck_require__(3867);
4298
- const buffer_utils_js_1 = __nccwpck_require__(2302);
4299
- const base64url_js_1 = __nccwpck_require__(8782);
4300
- const aeskw_js_1 = __nccwpck_require__(4798);
4301
- const check_p2s_js_1 = __nccwpck_require__(3255);
4302
- const webcrypto_js_1 = __nccwpck_require__(531);
4303
- const crypto_key_js_1 = __nccwpck_require__(9996);
4304
- const is_key_object_js_1 = __nccwpck_require__(5629);
4305
- const invalid_key_input_js_1 = __nccwpck_require__(829);
4306
- const is_key_like_js_1 = __nccwpck_require__(5684);
4401
+ const random_js_1 = __nccwpck_require__(3609);
4402
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
4403
+ const base64url_js_1 = __nccwpck_require__(5091);
4404
+ const aeskw_js_1 = __nccwpck_require__(7052);
4405
+ const check_p2s_js_1 = __nccwpck_require__(2469);
4406
+ const webcrypto_js_1 = __nccwpck_require__(6474);
4407
+ const crypto_key_js_1 = __nccwpck_require__(7849);
4408
+ const is_key_object_js_1 = __nccwpck_require__(3758);
4409
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
4410
+ const is_key_like_js_1 = __nccwpck_require__(938);
4307
4411
  const pbkdf2 = (0, util_1.promisify)(crypto_1.pbkdf2);
4308
4412
  function getPassword(key, alg) {
4309
4413
  if ((0, is_key_object_js_1.default)(key)) {
@@ -4341,7 +4445,7 @@ exports.decrypt = decrypt;
4341
4445
 
4342
4446
  /***/ }),
4343
4447
 
4344
- /***/ 3867:
4448
+ /***/ 3609:
4345
4449
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4346
4450
 
4347
4451
 
@@ -4353,19 +4457,19 @@ Object.defineProperty(exports, "default", ({ enumerable: true, get: function ()
4353
4457
 
4354
4458
  /***/ }),
4355
4459
 
4356
- /***/ 2988:
4460
+ /***/ 8550:
4357
4461
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4358
4462
 
4359
4463
 
4360
4464
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4361
4465
  exports.decrypt = exports.encrypt = void 0;
4362
4466
  const crypto_1 = __nccwpck_require__(6113);
4363
- const check_modulus_length_js_1 = __nccwpck_require__(9533);
4364
- const webcrypto_js_1 = __nccwpck_require__(531);
4365
- const crypto_key_js_1 = __nccwpck_require__(9996);
4366
- const is_key_object_js_1 = __nccwpck_require__(5629);
4367
- const invalid_key_input_js_1 = __nccwpck_require__(829);
4368
- const is_key_like_js_1 = __nccwpck_require__(5684);
4467
+ const check_modulus_length_js_1 = __nccwpck_require__(1862);
4468
+ const webcrypto_js_1 = __nccwpck_require__(6474);
4469
+ const crypto_key_js_1 = __nccwpck_require__(7849);
4470
+ const is_key_object_js_1 = __nccwpck_require__(3758);
4471
+ const invalid_key_input_js_1 = __nccwpck_require__(9548);
4472
+ const is_key_like_js_1 = __nccwpck_require__(938);
4369
4473
  const checkKey = (key, alg) => {
4370
4474
  if (key.asymmetricKeyType !== 'rsa') {
4371
4475
  throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be rsa');
@@ -4429,17 +4533,17 @@ exports.decrypt = decrypt;
4429
4533
 
4430
4534
  /***/ }),
4431
4535
 
4432
- /***/ 356:
4536
+ /***/ 8979:
4433
4537
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4434
4538
 
4435
4539
 
4436
4540
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4437
4541
  const crypto = __nccwpck_require__(6113);
4438
4542
  const util_1 = __nccwpck_require__(3837);
4439
- const dsa_digest_js_1 = __nccwpck_require__(5311);
4440
- const hmac_digest_js_1 = __nccwpck_require__(8282);
4441
- const node_key_js_1 = __nccwpck_require__(4266);
4442
- const get_sign_verify_key_js_1 = __nccwpck_require__(9928);
4543
+ const dsa_digest_js_1 = __nccwpck_require__(1312);
4544
+ const hmac_digest_js_1 = __nccwpck_require__(3199);
4545
+ const node_key_js_1 = __nccwpck_require__(7402);
4546
+ const get_sign_verify_key_js_1 = __nccwpck_require__(9579);
4443
4547
  let oneShotSign;
4444
4548
  if (crypto.sign.length > 3) {
4445
4549
  oneShotSign = (0, util_1.promisify)(crypto.sign);
@@ -4461,7 +4565,7 @@ exports["default"] = sign;
4461
4565
 
4462
4566
  /***/ }),
4463
4567
 
4464
- /***/ 1680:
4568
+ /***/ 4568:
4465
4569
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4466
4570
 
4467
4571
 
@@ -4473,17 +4577,17 @@ exports["default"] = timingSafeEqual;
4473
4577
 
4474
4578
  /***/ }),
4475
4579
 
4476
- /***/ 5661:
4580
+ /***/ 7190:
4477
4581
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4478
4582
 
4479
4583
 
4480
4584
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4481
4585
  const crypto = __nccwpck_require__(6113);
4482
4586
  const util_1 = __nccwpck_require__(3837);
4483
- const dsa_digest_js_1 = __nccwpck_require__(5311);
4484
- const node_key_js_1 = __nccwpck_require__(4266);
4485
- const sign_js_1 = __nccwpck_require__(356);
4486
- const get_sign_verify_key_js_1 = __nccwpck_require__(9928);
4587
+ const dsa_digest_js_1 = __nccwpck_require__(1312);
4588
+ const node_key_js_1 = __nccwpck_require__(7402);
4589
+ const sign_js_1 = __nccwpck_require__(8979);
4590
+ const get_sign_verify_key_js_1 = __nccwpck_require__(9579);
4487
4591
  const [major, minor] = process.version
4488
4592
  .slice(1)
4489
4593
  .split('.')
@@ -4522,7 +4626,7 @@ exports["default"] = verify;
4522
4626
 
4523
4627
  /***/ }),
4524
4628
 
4525
- /***/ 531:
4629
+ /***/ 6474:
4526
4630
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4527
4631
 
4528
4632
 
@@ -4533,14 +4637,14 @@ const util = __nccwpck_require__(3837);
4533
4637
  const webcrypto = crypto.webcrypto;
4534
4638
  exports["default"] = webcrypto;
4535
4639
  exports.isCryptoKey = util.types.isCryptoKey
4536
- ? (obj) => util.types.isCryptoKey(obj)
4640
+ ? (key) => util.types.isCryptoKey(key)
4537
4641
  :
4538
- (obj) => false;
4642
+ (key) => false;
4539
4643
 
4540
4644
 
4541
4645
  /***/ }),
4542
4646
 
4543
- /***/ 2148:
4647
+ /***/ 3239:
4544
4648
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4545
4649
 
4546
4650
 
@@ -4558,29 +4662,29 @@ exports.deflate = deflate;
4558
4662
 
4559
4663
  /***/ }),
4560
4664
 
4561
- /***/ 541:
4665
+ /***/ 5831:
4562
4666
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4563
4667
 
4564
4668
 
4565
4669
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4566
4670
  exports.decode = exports.encode = void 0;
4567
- const base64url = __nccwpck_require__(8782);
4671
+ const base64url = __nccwpck_require__(5091);
4568
4672
  exports.encode = base64url.encode;
4569
4673
  exports.decode = base64url.decode;
4570
4674
 
4571
4675
 
4572
4676
  /***/ }),
4573
4677
 
4574
- /***/ 4860:
4678
+ /***/ 6537:
4575
4679
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4576
4680
 
4577
4681
 
4578
4682
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4579
4683
  exports.decodeJwt = void 0;
4580
- const base64url_js_1 = __nccwpck_require__(541);
4581
- const buffer_utils_js_1 = __nccwpck_require__(2302);
4582
- const is_object_js_1 = __nccwpck_require__(8692);
4583
- const errors_js_1 = __nccwpck_require__(2157);
4684
+ const base64url_js_1 = __nccwpck_require__(5831);
4685
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
4686
+ const is_object_js_1 = __nccwpck_require__(7787);
4687
+ const errors_js_1 = __nccwpck_require__(6891);
4584
4688
  function decodeJwt(jwt) {
4585
4689
  if (typeof jwt !== 'string')
4586
4690
  throw new errors_js_1.JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');
@@ -4614,15 +4718,15 @@ exports.decodeJwt = decodeJwt;
4614
4718
 
4615
4719
  /***/ }),
4616
4720
 
4617
- /***/ 919:
4721
+ /***/ 1158:
4618
4722
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4619
4723
 
4620
4724
 
4621
4725
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4622
4726
  exports.decodeProtectedHeader = void 0;
4623
- const base64url_js_1 = __nccwpck_require__(541);
4624
- const buffer_utils_js_1 = __nccwpck_require__(2302);
4625
- const is_object_js_1 = __nccwpck_require__(8692);
4727
+ const base64url_js_1 = __nccwpck_require__(5831);
4728
+ const buffer_utils_js_1 = __nccwpck_require__(3605);
4729
+ const is_object_js_1 = __nccwpck_require__(7787);
4626
4730
  function decodeProtectedHeader(token) {
4627
4731
  let protectedB64u;
4628
4732
  if (typeof token === 'string') {
@@ -4659,7 +4763,7 @@ exports.decodeProtectedHeader = decodeProtectedHeader;
4659
4763
 
4660
4764
  /***/ }),
4661
4765
 
4662
- /***/ 2157:
4766
+ /***/ 6891:
4663
4767
  /***/ ((__unused_webpack_module, exports) => {
4664
4768
 
4665
4769
 
@@ -4831,15 +4935,17 @@ exports.JWSSignatureVerificationFailed = JWSSignatureVerificationFailed;
4831
4935
 
4832
4936
  /***/ }),
4833
4937
 
4834
- /***/ 3892:
4938
+ /***/ 6597:
4835
4939
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
4836
4940
 
4837
4941
 
4838
4942
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4839
- exports.setErrorMap = exports.overrideErrorMap = exports.defaultErrorMap = exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
4840
- const util_1 = __nccwpck_require__(977);
4943
+ exports.getErrorMap = exports.setErrorMap = exports.defaultErrorMap = exports.ZodError = exports.quotelessJson = exports.ZodIssueCode = void 0;
4944
+ const parseUtil_1 = __nccwpck_require__(7822);
4945
+ const util_1 = __nccwpck_require__(809);
4841
4946
  exports.ZodIssueCode = util_1.util.arrayToEnum([
4842
4947
  "invalid_type",
4948
+ "invalid_literal",
4843
4949
  "custom",
4844
4950
  "invalid_union",
4845
4951
  "invalid_union_discriminator",
@@ -4863,51 +4969,6 @@ class ZodError extends Error {
4863
4969
  constructor(issues) {
4864
4970
  super();
4865
4971
  this.issues = [];
4866
- this.format = () => {
4867
- const fieldErrors = { _errors: [] };
4868
- const processError = (error) => {
4869
- for (const issue of error.issues) {
4870
- if (issue.code === "invalid_union") {
4871
- issue.unionErrors.map(processError);
4872
- }
4873
- else if (issue.code === "invalid_return_type") {
4874
- processError(issue.returnTypeError);
4875
- }
4876
- else if (issue.code === "invalid_arguments") {
4877
- processError(issue.argumentsError);
4878
- }
4879
- else if (issue.path.length === 0) {
4880
- fieldErrors._errors.push(issue.message);
4881
- }
4882
- else {
4883
- let curr = fieldErrors;
4884
- let i = 0;
4885
- while (i < issue.path.length) {
4886
- const el = issue.path[i];
4887
- const terminal = i === issue.path.length - 1;
4888
- if (!terminal) {
4889
- if (typeof el === "string") {
4890
- curr[el] = curr[el] || { _errors: [] };
4891
- }
4892
- else if (typeof el === "number") {
4893
- const errorArray = [];
4894
- errorArray._errors = [];
4895
- curr[el] = curr[el] || errorArray;
4896
- }
4897
- }
4898
- else {
4899
- curr[el] = curr[el] || { _errors: [] };
4900
- curr[el]._errors.push(issue.message);
4901
- }
4902
- curr = curr[el];
4903
- i++;
4904
- }
4905
- }
4906
- }
4907
- };
4908
- processError(this);
4909
- return fieldErrors;
4910
- };
4911
4972
  this.addIssue = (sub) => {
4912
4973
  this.issues = [...this.issues, sub];
4913
4974
  };
@@ -4928,11 +4989,60 @@ class ZodError extends Error {
4928
4989
  get errors() {
4929
4990
  return this.issues;
4930
4991
  }
4992
+ format(_mapper) {
4993
+ const mapper = _mapper ||
4994
+ function (issue) {
4995
+ return issue.message;
4996
+ };
4997
+ const fieldErrors = { _errors: [] };
4998
+ const processError = (error) => {
4999
+ for (const issue of error.issues) {
5000
+ if (issue.code === "invalid_union") {
5001
+ issue.unionErrors.map(processError);
5002
+ }
5003
+ else if (issue.code === "invalid_return_type") {
5004
+ processError(issue.returnTypeError);
5005
+ }
5006
+ else if (issue.code === "invalid_arguments") {
5007
+ processError(issue.argumentsError);
5008
+ }
5009
+ else if (issue.path.length === 0) {
5010
+ fieldErrors._errors.push(mapper(issue));
5011
+ }
5012
+ else {
5013
+ let curr = fieldErrors;
5014
+ let i = 0;
5015
+ while (i < issue.path.length) {
5016
+ const el = issue.path[i];
5017
+ const terminal = i === issue.path.length - 1;
5018
+ if (!terminal) {
5019
+ curr[el] = curr[el] || { _errors: [] };
5020
+ // if (typeof el === "string") {
5021
+ // curr[el] = curr[el] || { _errors: [] };
5022
+ // } else if (typeof el === "number") {
5023
+ // const errorArray: any = [];
5024
+ // errorArray._errors = [];
5025
+ // curr[el] = curr[el] || errorArray;
5026
+ // }
5027
+ }
5028
+ else {
5029
+ curr[el] = curr[el] || { _errors: [] };
5030
+ curr[el]._errors.push(mapper(issue));
5031
+ }
5032
+ curr = curr[el];
5033
+ i++;
5034
+ }
5035
+ }
5036
+ }
5037
+ };
5038
+ processError(this);
5039
+ return fieldErrors;
5040
+ }
4931
5041
  toString() {
4932
5042
  return this.message;
4933
5043
  }
4934
5044
  get message() {
4935
- return JSON.stringify(this.issues, null, 2);
5045
+ return JSON.stringify(this.issues, parseUtil_1.jsonStringifyReplacer, 2);
4936
5046
  }
4937
5047
  get isEmpty() {
4938
5048
  return this.issues.length === 0;
@@ -4964,30 +5074,27 @@ const defaultErrorMap = (issue, _ctx) => {
4964
5074
  let message;
4965
5075
  switch (issue.code) {
4966
5076
  case exports.ZodIssueCode.invalid_type:
4967
- if (issue.received === "undefined") {
5077
+ if (issue.received === util_1.ZodParsedType.undefined) {
4968
5078
  message = "Required";
4969
5079
  }
4970
5080
  else {
4971
5081
  message = `Expected ${issue.expected}, received ${issue.received}`;
4972
5082
  }
4973
5083
  break;
5084
+ case exports.ZodIssueCode.invalid_literal:
5085
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, parseUtil_1.jsonStringifyReplacer)}`;
5086
+ break;
4974
5087
  case exports.ZodIssueCode.unrecognized_keys:
4975
- message = `Unrecognized key(s) in object: ${issue.keys
4976
- .map((k) => `'${k}'`)
4977
- .join(", ")}`;
5088
+ message = `Unrecognized key(s) in object: ${util_1.util.joinValues(issue.keys, ", ")}`;
4978
5089
  break;
4979
5090
  case exports.ZodIssueCode.invalid_union:
4980
5091
  message = `Invalid input`;
4981
5092
  break;
4982
5093
  case exports.ZodIssueCode.invalid_union_discriminator:
4983
- message = `Invalid discriminator value. Expected ${issue.options
4984
- .map((val) => (typeof val === "string" ? `'${val}'` : val))
4985
- .join(" | ")}`;
5094
+ message = `Invalid discriminator value. Expected ${util_1.util.joinValues(issue.options)}`;
4986
5095
  break;
4987
5096
  case exports.ZodIssueCode.invalid_enum_value:
4988
- message = `Invalid enum value. Expected ${issue.options
4989
- .map((val) => (typeof val === "string" ? `'${val}'` : val))
4990
- .join(" | ")}`;
5097
+ message = `Invalid enum value. Expected ${util_1.util.joinValues(issue.options)}, received '${issue.received}'`;
4991
5098
  break;
4992
5099
  case exports.ZodIssueCode.invalid_arguments:
4993
5100
  message = `Invalid function arguments`;
@@ -4999,10 +5106,23 @@ const defaultErrorMap = (issue, _ctx) => {
4999
5106
  message = `Invalid date`;
5000
5107
  break;
5001
5108
  case exports.ZodIssueCode.invalid_string:
5002
- if (issue.validation !== "regex")
5109
+ if (typeof issue.validation === "object") {
5110
+ if ("startsWith" in issue.validation) {
5111
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
5112
+ }
5113
+ else if ("endsWith" in issue.validation) {
5114
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
5115
+ }
5116
+ else {
5117
+ util_1.util.assertNever(issue.validation);
5118
+ }
5119
+ }
5120
+ else if (issue.validation !== "regex") {
5003
5121
  message = `Invalid ${issue.validation}`;
5004
- else
5122
+ }
5123
+ else {
5005
5124
  message = "Invalid";
5125
+ }
5006
5126
  break;
5007
5127
  case exports.ZodIssueCode.too_small:
5008
5128
  if (issue.type === "array")
@@ -5011,6 +5131,8 @@ const defaultErrorMap = (issue, _ctx) => {
5011
5131
  message = `String must contain ${issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
5012
5132
  else if (issue.type === "number")
5013
5133
  message = `Number must be greater than ${issue.inclusive ? `or equal to ` : ``}${issue.minimum}`;
5134
+ else if (issue.type === "date")
5135
+ message = `Date must be greater than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.minimum)}`;
5014
5136
  else
5015
5137
  message = "Invalid input";
5016
5138
  break;
@@ -5021,6 +5143,8 @@ const defaultErrorMap = (issue, _ctx) => {
5021
5143
  message = `String must contain ${issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
5022
5144
  else if (issue.type === "number")
5023
5145
  message = `Number must be less than ${issue.inclusive ? `or equal to ` : ``}${issue.maximum}`;
5146
+ else if (issue.type === "date")
5147
+ message = `Date must be smaller than ${issue.inclusive ? `or equal to ` : ``}${new Date(issue.maximum)}`;
5024
5148
  else
5025
5149
  message = "Invalid input";
5026
5150
  break;
@@ -5040,26 +5164,26 @@ const defaultErrorMap = (issue, _ctx) => {
5040
5164
  return { message };
5041
5165
  };
5042
5166
  exports.defaultErrorMap = defaultErrorMap;
5043
- exports.overrideErrorMap = exports.defaultErrorMap;
5044
- const setErrorMap = (map) => {
5045
- exports.overrideErrorMap = map;
5046
- };
5167
+ let overrideErrorMap = exports.defaultErrorMap;
5168
+ function setErrorMap(map) {
5169
+ overrideErrorMap = map;
5170
+ }
5047
5171
  exports.setErrorMap = setErrorMap;
5172
+ function getErrorMap() {
5173
+ return overrideErrorMap;
5174
+ }
5175
+ exports.getErrorMap = getErrorMap;
5048
5176
 
5049
5177
 
5050
5178
  /***/ }),
5051
5179
 
5052
- /***/ 7897:
5180
+ /***/ 8857:
5053
5181
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
5054
5182
 
5055
5183
 
5056
5184
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5057
5185
  if (k2 === undefined) k2 = k;
5058
- var desc = Object.getOwnPropertyDescriptor(m, k);
5059
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5060
- desc = { enumerable: true, get: function() { return m[k]; } };
5061
- }
5062
- Object.defineProperty(o, k2, desc);
5186
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5063
5187
  }) : (function(o, m, k, k2) {
5064
5188
  if (k2 === undefined) k2 = k;
5065
5189
  o[k2] = m[k];
@@ -5068,15 +5192,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
5068
5192
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
5069
5193
  };
5070
5194
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5071
- __exportStar(__nccwpck_require__(6198), exports);
5072
- __exportStar(__nccwpck_require__(6840), exports);
5073
- __exportStar(__nccwpck_require__(7122), exports);
5074
- __exportStar(__nccwpck_require__(3892), exports);
5195
+ exports.ZodParsedType = exports.getParsedType = void 0;
5196
+ __exportStar(__nccwpck_require__(7822), exports);
5197
+ __exportStar(__nccwpck_require__(6836), exports);
5198
+ var util_1 = __nccwpck_require__(809);
5199
+ Object.defineProperty(exports, "getParsedType", ({ enumerable: true, get: function () { return util_1.getParsedType; } }));
5200
+ Object.defineProperty(exports, "ZodParsedType", ({ enumerable: true, get: function () { return util_1.ZodParsedType; } }));
5201
+ __exportStar(__nccwpck_require__(54), exports);
5202
+ __exportStar(__nccwpck_require__(6597), exports);
5075
5203
 
5076
5204
 
5077
5205
  /***/ }),
5078
5206
 
5079
- /***/ 216:
5207
+ /***/ 3797:
5080
5208
  /***/ ((__unused_webpack_module, exports) => {
5081
5209
 
5082
5210
 
@@ -5091,79 +5219,13 @@ var errorUtil;
5091
5219
 
5092
5220
  /***/ }),
5093
5221
 
5094
- /***/ 6198:
5222
+ /***/ 7822:
5095
5223
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5096
5224
 
5097
5225
 
5098
5226
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5099
- exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = exports.getParsedType = exports.ZodParsedType = void 0;
5100
- const ZodError_1 = __nccwpck_require__(3892);
5101
- const util_1 = __nccwpck_require__(977);
5102
- exports.ZodParsedType = util_1.util.arrayToEnum([
5103
- "string",
5104
- "nan",
5105
- "number",
5106
- "integer",
5107
- "float",
5108
- "boolean",
5109
- "date",
5110
- "bigint",
5111
- "symbol",
5112
- "function",
5113
- "undefined",
5114
- "null",
5115
- "array",
5116
- "object",
5117
- "unknown",
5118
- "promise",
5119
- "void",
5120
- "never",
5121
- "map",
5122
- "set",
5123
- ]);
5124
- const getParsedType = (data) => {
5125
- const t = typeof data;
5126
- switch (t) {
5127
- case "undefined":
5128
- return exports.ZodParsedType.undefined;
5129
- case "string":
5130
- return exports.ZodParsedType.string;
5131
- case "number":
5132
- return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
5133
- case "boolean":
5134
- return exports.ZodParsedType.boolean;
5135
- case "function":
5136
- return exports.ZodParsedType.function;
5137
- case "bigint":
5138
- return exports.ZodParsedType.bigint;
5139
- case "object":
5140
- if (Array.isArray(data)) {
5141
- return exports.ZodParsedType.array;
5142
- }
5143
- if (data === null) {
5144
- return exports.ZodParsedType.null;
5145
- }
5146
- if (data.then &&
5147
- typeof data.then === "function" &&
5148
- data.catch &&
5149
- typeof data.catch === "function") {
5150
- return exports.ZodParsedType.promise;
5151
- }
5152
- if (typeof Map !== "undefined" && data instanceof Map) {
5153
- return exports.ZodParsedType.map;
5154
- }
5155
- if (typeof Set !== "undefined" && data instanceof Set) {
5156
- return exports.ZodParsedType.set;
5157
- }
5158
- if (typeof Date !== "undefined" && data instanceof Date) {
5159
- return exports.ZodParsedType.date;
5160
- }
5161
- return exports.ZodParsedType.object;
5162
- default:
5163
- return exports.ZodParsedType.unknown;
5164
- }
5165
- };
5166
- exports.getParsedType = getParsedType;
5227
+ exports.jsonStringifyReplacer = exports.isAsync = exports.isValid = exports.isDirty = exports.isAborted = exports.OK = exports.DIRTY = exports.INVALID = exports.ParseStatus = exports.addIssueToContext = exports.EMPTY_PATH = exports.makeIssue = void 0;
5228
+ const ZodError_1 = __nccwpck_require__(6597);
5167
5229
  const makeIssue = (params) => {
5168
5230
  const { data, path, errorMaps, issueData } = params;
5169
5231
  const fullPath = [...path, ...(issueData.path || [])];
@@ -5188,15 +5250,15 @@ const makeIssue = (params) => {
5188
5250
  exports.makeIssue = makeIssue;
5189
5251
  exports.EMPTY_PATH = [];
5190
5252
  function addIssueToContext(ctx, issueData) {
5191
- const issue = (0, exports.makeIssue)({
5253
+ const issue = exports.makeIssue({
5192
5254
  issueData: issueData,
5193
5255
  data: ctx.data,
5194
5256
  path: ctx.path,
5195
5257
  errorMaps: [
5196
5258
  ctx.common.contextualErrorMap,
5197
5259
  ctx.schemaErrorMap,
5198
- ZodError_1.overrideErrorMap,
5199
- ZodError_1.defaultErrorMap, // then global default map
5260
+ ZodError_1.getErrorMap(),
5261
+ ZodError_1.defaultErrorMap,
5200
5262
  ].filter((x) => !!x),
5201
5263
  });
5202
5264
  ctx.common.issues.push(issue);
@@ -5270,11 +5332,18 @@ const isValid = (x) => x.status === "valid";
5270
5332
  exports.isValid = isValid;
5271
5333
  const isAsync = (x) => typeof Promise !== undefined && x instanceof Promise;
5272
5334
  exports.isAsync = isAsync;
5335
+ const jsonStringifyReplacer = (_, value) => {
5336
+ if (typeof value === "bigint") {
5337
+ return value.toString();
5338
+ }
5339
+ return value;
5340
+ };
5341
+ exports.jsonStringifyReplacer = jsonStringifyReplacer;
5273
5342
 
5274
5343
 
5275
5344
  /***/ }),
5276
5345
 
5277
- /***/ 6840:
5346
+ /***/ 6836:
5278
5347
  /***/ ((__unused_webpack_module, exports) => {
5279
5348
 
5280
5349
 
@@ -5283,14 +5352,17 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
5283
5352
 
5284
5353
  /***/ }),
5285
5354
 
5286
- /***/ 977:
5355
+ /***/ 809:
5287
5356
  /***/ ((__unused_webpack_module, exports) => {
5288
5357
 
5289
5358
 
5290
5359
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5291
- exports.util = void 0;
5360
+ exports.getParsedType = exports.ZodParsedType = exports.util = void 0;
5292
5361
  var util;
5293
5362
  (function (util) {
5363
+ util.assertEqual = (val) => val;
5364
+ function assertIs(_arg) { }
5365
+ util.assertIs = assertIs;
5294
5366
  function assertNever(_x) {
5295
5367
  throw new Error();
5296
5368
  }
@@ -5336,62 +5408,129 @@ var util;
5336
5408
  util.isInteger = typeof Number.isInteger === "function"
5337
5409
  ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
5338
5410
  : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
5339
- })(util = exports.util || (exports.util = {}));
5340
-
5341
-
5342
- /***/ }),
5343
-
5344
- /***/ 4786:
5345
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
5346
-
5347
-
5348
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5349
- if (k2 === undefined) k2 = k;
5350
- var desc = Object.getOwnPropertyDescriptor(m, k);
5351
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5352
- desc = { enumerable: true, get: function() { return m[k]; } };
5411
+ function joinValues(array, separator = " | ") {
5412
+ return array
5413
+ .map((val) => (typeof val === "string" ? `'${val}'` : val))
5414
+ .join(separator);
5353
5415
  }
5354
- Object.defineProperty(o, k2, desc);
5355
- }) : (function(o, m, k, k2) {
5356
- if (k2 === undefined) k2 = k;
5357
- o[k2] = m[k];
5358
- }));
5359
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
5360
- Object.defineProperty(o, "default", { enumerable: true, value: v });
5361
- }) : function(o, v) {
5362
- o["default"] = v;
5363
- });
5364
- var __importStar = (this && this.__importStar) || function (mod) {
5365
- if (mod && mod.__esModule) return mod;
5366
- var result = {};
5367
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
5368
- __setModuleDefault(result, mod);
5369
- return result;
5370
- };
5371
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
5372
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
5373
- };
5374
- Object.defineProperty(exports, "__esModule", ({ value: true }));
5375
- exports.z = void 0;
5376
- const mod = __importStar(__nccwpck_require__(7897));
5377
- exports.z = mod;
5378
- __exportStar(__nccwpck_require__(7897), exports);
5379
- exports["default"] = mod;
5380
-
5381
-
5382
- /***/ }),
5383
-
5384
- /***/ 7122:
5385
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5386
-
5387
-
5416
+ util.joinValues = joinValues;
5417
+ })(util = exports.util || (exports.util = {}));
5418
+ exports.ZodParsedType = util.arrayToEnum([
5419
+ "string",
5420
+ "nan",
5421
+ "number",
5422
+ "integer",
5423
+ "float",
5424
+ "boolean",
5425
+ "date",
5426
+ "bigint",
5427
+ "symbol",
5428
+ "function",
5429
+ "undefined",
5430
+ "null",
5431
+ "array",
5432
+ "object",
5433
+ "unknown",
5434
+ "promise",
5435
+ "void",
5436
+ "never",
5437
+ "map",
5438
+ "set",
5439
+ ]);
5440
+ const getParsedType = (data) => {
5441
+ const t = typeof data;
5442
+ switch (t) {
5443
+ case "undefined":
5444
+ return exports.ZodParsedType.undefined;
5445
+ case "string":
5446
+ return exports.ZodParsedType.string;
5447
+ case "number":
5448
+ return isNaN(data) ? exports.ZodParsedType.nan : exports.ZodParsedType.number;
5449
+ case "boolean":
5450
+ return exports.ZodParsedType.boolean;
5451
+ case "function":
5452
+ return exports.ZodParsedType.function;
5453
+ case "bigint":
5454
+ return exports.ZodParsedType.bigint;
5455
+ case "object":
5456
+ if (Array.isArray(data)) {
5457
+ return exports.ZodParsedType.array;
5458
+ }
5459
+ if (data === null) {
5460
+ return exports.ZodParsedType.null;
5461
+ }
5462
+ if (data.then &&
5463
+ typeof data.then === "function" &&
5464
+ data.catch &&
5465
+ typeof data.catch === "function") {
5466
+ return exports.ZodParsedType.promise;
5467
+ }
5468
+ if (typeof Map !== "undefined" && data instanceof Map) {
5469
+ return exports.ZodParsedType.map;
5470
+ }
5471
+ if (typeof Set !== "undefined" && data instanceof Set) {
5472
+ return exports.ZodParsedType.set;
5473
+ }
5474
+ if (typeof Date !== "undefined" && data instanceof Date) {
5475
+ return exports.ZodParsedType.date;
5476
+ }
5477
+ return exports.ZodParsedType.object;
5478
+ default:
5479
+ return exports.ZodParsedType.unknown;
5480
+ }
5481
+ };
5482
+ exports.getParsedType = getParsedType;
5483
+
5484
+
5485
+ /***/ }),
5486
+
5487
+ /***/ 8062:
5488
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
5489
+
5490
+
5491
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5492
+ if (k2 === undefined) k2 = k;
5493
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5494
+ }) : (function(o, m, k, k2) {
5495
+ if (k2 === undefined) k2 = k;
5496
+ o[k2] = m[k];
5497
+ }));
5498
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
5499
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
5500
+ }) : function(o, v) {
5501
+ o["default"] = v;
5502
+ });
5503
+ var __importStar = (this && this.__importStar) || function (mod) {
5504
+ if (mod && mod.__esModule) return mod;
5505
+ var result = {};
5506
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
5507
+ __setModuleDefault(result, mod);
5508
+ return result;
5509
+ };
5510
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
5511
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
5512
+ };
5513
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5514
+ exports.z = void 0;
5515
+ const mod = __importStar(__nccwpck_require__(8857));
5516
+ exports.z = mod;
5517
+ __exportStar(__nccwpck_require__(8857), exports);
5518
+ exports["default"] = mod;
5519
+
5520
+
5521
+ /***/ }),
5522
+
5523
+ /***/ 54:
5524
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5525
+
5526
+
5388
5527
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5389
- exports.intersection = exports["instanceof"] = exports["function"] = exports["enum"] = exports.effect = exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodNaN = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.objectUtil = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
5390
- exports["void"] = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports["null"] = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = void 0;
5391
- const errorUtil_1 = __nccwpck_require__(216);
5392
- const parseUtil_1 = __nccwpck_require__(6198);
5393
- const util_1 = __nccwpck_require__(977);
5394
- const ZodError_1 = __nccwpck_require__(3892);
5528
+ exports["function"] = exports["enum"] = exports.effect = exports.discriminatedUnion = exports.date = exports.boolean = exports.bigint = exports.array = exports.any = exports.ZodFirstPartyTypeKind = exports.late = exports.ZodSchema = exports.Schema = exports.custom = exports.ZodBranded = exports.BRAND = exports.ZodNaN = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodEffects = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.objectUtil = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.ZodType = void 0;
5529
+ exports["void"] = exports.unknown = exports.union = exports.undefined = exports.tuple = exports.transformer = exports.string = exports.strictObject = exports.set = exports.record = exports.promise = exports.preprocess = exports.ostring = exports.optional = exports.onumber = exports.oboolean = exports.object = exports.number = exports.nullable = exports["null"] = exports.never = exports.nativeEnum = exports.nan = exports.map = exports.literal = exports.lazy = exports.intersection = exports["instanceof"] = void 0;
5530
+ const errorUtil_1 = __nccwpck_require__(3797);
5531
+ const parseUtil_1 = __nccwpck_require__(7822);
5532
+ const util_1 = __nccwpck_require__(809);
5533
+ const ZodError_1 = __nccwpck_require__(6597);
5395
5534
  class ParseInputLazyPath {
5396
5535
  constructor(parent, value, path, key) {
5397
5536
  this.parent = parent;
@@ -5404,7 +5543,7 @@ class ParseInputLazyPath {
5404
5543
  }
5405
5544
  }
5406
5545
  const handleResult = (ctx, result) => {
5407
- if ((0, parseUtil_1.isValid)(result)) {
5546
+ if (parseUtil_1.isValid(result)) {
5408
5547
  return { success: true, data: result.value };
5409
5548
  }
5410
5549
  else {
@@ -5427,11 +5566,10 @@ function processCreateParams(params) {
5427
5566
  const customMap = (iss, ctx) => {
5428
5567
  if (iss.code !== "invalid_type")
5429
5568
  return { message: ctx.defaultError };
5430
- if (typeof ctx.data === "undefined" && required_error)
5431
- return { message: required_error };
5432
- if (params.invalid_type_error)
5433
- return { message: params.invalid_type_error };
5434
- return { message: ctx.defaultError };
5569
+ if (typeof ctx.data === "undefined") {
5570
+ return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError };
5571
+ }
5572
+ return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError };
5435
5573
  };
5436
5574
  return { errorMap: customMap, description };
5437
5575
  }
@@ -5466,13 +5604,13 @@ class ZodType {
5466
5604
  return this._def.description;
5467
5605
  }
5468
5606
  _getType(input) {
5469
- return (0, parseUtil_1.getParsedType)(input.data);
5607
+ return util_1.getParsedType(input.data);
5470
5608
  }
5471
5609
  _getOrReturnCtx(input, ctx) {
5472
5610
  return (ctx || {
5473
5611
  common: input.parent.common,
5474
5612
  data: input.data,
5475
- parsedType: (0, parseUtil_1.getParsedType)(input.data),
5613
+ parsedType: util_1.getParsedType(input.data),
5476
5614
  schemaErrorMap: this._def.errorMap,
5477
5615
  path: input.path,
5478
5616
  parent: input.parent,
@@ -5484,7 +5622,7 @@ class ZodType {
5484
5622
  ctx: {
5485
5623
  common: input.parent.common,
5486
5624
  data: input.data,
5487
- parsedType: (0, parseUtil_1.getParsedType)(input.data),
5625
+ parsedType: util_1.getParsedType(input.data),
5488
5626
  schemaErrorMap: this._def.errorMap,
5489
5627
  path: input.path,
5490
5628
  parent: input.parent,
@@ -5493,7 +5631,7 @@ class ZodType {
5493
5631
  }
5494
5632
  _parseSync(input) {
5495
5633
  const result = this._parse(input);
5496
- if ((0, parseUtil_1.isAsync)(result)) {
5634
+ if (parseUtil_1.isAsync(result)) {
5497
5635
  throw new Error("Synchronous parse encountered promise.");
5498
5636
  }
5499
5637
  return result;
@@ -5514,14 +5652,13 @@ class ZodType {
5514
5652
  common: {
5515
5653
  issues: [],
5516
5654
  async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
5517
- typeCache: typeof Map !== "undefined" ? new Map() : undefined,
5518
5655
  contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
5519
5656
  },
5520
5657
  path: (params === null || params === void 0 ? void 0 : params.path) || [],
5521
5658
  schemaErrorMap: this._def.errorMap,
5522
5659
  parent: null,
5523
5660
  data,
5524
- parsedType: (0, parseUtil_1.getParsedType)(data),
5661
+ parsedType: util_1.getParsedType(data),
5525
5662
  };
5526
5663
  const result = this._parseSync({ data, path: ctx.path, parent: ctx });
5527
5664
  return handleResult(ctx, result);
@@ -5538,16 +5675,15 @@ class ZodType {
5538
5675
  issues: [],
5539
5676
  contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
5540
5677
  async: true,
5541
- typeCache: typeof Map !== "undefined" ? new Map() : undefined,
5542
5678
  },
5543
5679
  path: (params === null || params === void 0 ? void 0 : params.path) || [],
5544
5680
  schemaErrorMap: this._def.errorMap,
5545
5681
  parent: null,
5546
5682
  data,
5547
- parsedType: (0, parseUtil_1.getParsedType)(data),
5683
+ parsedType: util_1.getParsedType(data),
5548
5684
  };
5549
5685
  const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
5550
- const result = await ((0, parseUtil_1.isAsync)(maybeAsyncResult)
5686
+ const result = await (parseUtil_1.isAsync(maybeAsyncResult)
5551
5687
  ? maybeAsyncResult
5552
5688
  : Promise.resolve(maybeAsyncResult));
5553
5689
  return handleResult(ctx, result);
@@ -5611,8 +5747,6 @@ class ZodType {
5611
5747
  });
5612
5748
  }
5613
5749
  optional() {
5614
- ("");
5615
- ("asdf");
5616
5750
  return ZodOptional.create(this);
5617
5751
  }
5618
5752
  nullable() {
@@ -5648,6 +5782,13 @@ class ZodType {
5648
5782
  typeName: ZodFirstPartyTypeKind.ZodDefault,
5649
5783
  });
5650
5784
  }
5785
+ brand() {
5786
+ return new ZodBranded({
5787
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
5788
+ type: this,
5789
+ ...processCreateParams(undefined),
5790
+ });
5791
+ }
5651
5792
  describe(description) {
5652
5793
  const This = this.constructor;
5653
5794
  return new This({
@@ -5681,18 +5822,22 @@ class ZodString extends ZodType {
5681
5822
  ...errorUtil_1.errorUtil.errToObj(message),
5682
5823
  });
5683
5824
  /**
5684
- * Deprecated.
5685
- * Use z.string().min(1) instead.
5825
+ * @deprecated Use z.string().min(1) instead.
5826
+ * @see {@link ZodString.min}
5686
5827
  */
5687
5828
  this.nonempty = (message) => this.min(1, errorUtil_1.errorUtil.errToObj(message));
5829
+ this.trim = () => new ZodString({
5830
+ ...this._def,
5831
+ checks: [...this._def.checks, { kind: "trim" }],
5832
+ });
5688
5833
  }
5689
5834
  _parse(input) {
5690
5835
  const parsedType = this._getType(input);
5691
- if (parsedType !== parseUtil_1.ZodParsedType.string) {
5836
+ if (parsedType !== util_1.ZodParsedType.string) {
5692
5837
  const ctx = this._getOrReturnCtx(input);
5693
- (0, parseUtil_1.addIssueToContext)(ctx, {
5838
+ parseUtil_1.addIssueToContext(ctx, {
5694
5839
  code: ZodError_1.ZodIssueCode.invalid_type,
5695
- expected: parseUtil_1.ZodParsedType.string,
5840
+ expected: util_1.ZodParsedType.string,
5696
5841
  received: ctx.parsedType,
5697
5842
  }
5698
5843
  //
@@ -5705,7 +5850,7 @@ class ZodString extends ZodType {
5705
5850
  if (check.kind === "min") {
5706
5851
  if (input.data.length < check.value) {
5707
5852
  ctx = this._getOrReturnCtx(input, ctx);
5708
- (0, parseUtil_1.addIssueToContext)(ctx, {
5853
+ parseUtil_1.addIssueToContext(ctx, {
5709
5854
  code: ZodError_1.ZodIssueCode.too_small,
5710
5855
  minimum: check.value,
5711
5856
  type: "string",
@@ -5718,7 +5863,7 @@ class ZodString extends ZodType {
5718
5863
  else if (check.kind === "max") {
5719
5864
  if (input.data.length > check.value) {
5720
5865
  ctx = this._getOrReturnCtx(input, ctx);
5721
- (0, parseUtil_1.addIssueToContext)(ctx, {
5866
+ parseUtil_1.addIssueToContext(ctx, {
5722
5867
  code: ZodError_1.ZodIssueCode.too_big,
5723
5868
  maximum: check.value,
5724
5869
  type: "string",
@@ -5731,7 +5876,7 @@ class ZodString extends ZodType {
5731
5876
  else if (check.kind === "email") {
5732
5877
  if (!emailRegex.test(input.data)) {
5733
5878
  ctx = this._getOrReturnCtx(input, ctx);
5734
- (0, parseUtil_1.addIssueToContext)(ctx, {
5879
+ parseUtil_1.addIssueToContext(ctx, {
5735
5880
  validation: "email",
5736
5881
  code: ZodError_1.ZodIssueCode.invalid_string,
5737
5882
  message: check.message,
@@ -5742,7 +5887,7 @@ class ZodString extends ZodType {
5742
5887
  else if (check.kind === "uuid") {
5743
5888
  if (!uuidRegex.test(input.data)) {
5744
5889
  ctx = this._getOrReturnCtx(input, ctx);
5745
- (0, parseUtil_1.addIssueToContext)(ctx, {
5890
+ parseUtil_1.addIssueToContext(ctx, {
5746
5891
  validation: "uuid",
5747
5892
  code: ZodError_1.ZodIssueCode.invalid_string,
5748
5893
  message: check.message,
@@ -5753,7 +5898,7 @@ class ZodString extends ZodType {
5753
5898
  else if (check.kind === "cuid") {
5754
5899
  if (!cuidRegex.test(input.data)) {
5755
5900
  ctx = this._getOrReturnCtx(input, ctx);
5756
- (0, parseUtil_1.addIssueToContext)(ctx, {
5901
+ parseUtil_1.addIssueToContext(ctx, {
5757
5902
  validation: "cuid",
5758
5903
  code: ZodError_1.ZodIssueCode.invalid_string,
5759
5904
  message: check.message,
@@ -5767,7 +5912,7 @@ class ZodString extends ZodType {
5767
5912
  }
5768
5913
  catch (_a) {
5769
5914
  ctx = this._getOrReturnCtx(input, ctx);
5770
- (0, parseUtil_1.addIssueToContext)(ctx, {
5915
+ parseUtil_1.addIssueToContext(ctx, {
5771
5916
  validation: "url",
5772
5917
  code: ZodError_1.ZodIssueCode.invalid_string,
5773
5918
  message: check.message,
@@ -5780,7 +5925,7 @@ class ZodString extends ZodType {
5780
5925
  const testResult = check.regex.test(input.data);
5781
5926
  if (!testResult) {
5782
5927
  ctx = this._getOrReturnCtx(input, ctx);
5783
- (0, parseUtil_1.addIssueToContext)(ctx, {
5928
+ parseUtil_1.addIssueToContext(ctx, {
5784
5929
  validation: "regex",
5785
5930
  code: ZodError_1.ZodIssueCode.invalid_string,
5786
5931
  message: check.message,
@@ -5788,6 +5933,34 @@ class ZodString extends ZodType {
5788
5933
  status.dirty();
5789
5934
  }
5790
5935
  }
5936
+ else if (check.kind === "trim") {
5937
+ input.data = input.data.trim();
5938
+ }
5939
+ else if (check.kind === "startsWith") {
5940
+ if (!input.data.startsWith(check.value)) {
5941
+ ctx = this._getOrReturnCtx(input, ctx);
5942
+ parseUtil_1.addIssueToContext(ctx, {
5943
+ code: ZodError_1.ZodIssueCode.invalid_string,
5944
+ validation: { startsWith: check.value },
5945
+ message: check.message,
5946
+ });
5947
+ status.dirty();
5948
+ }
5949
+ }
5950
+ else if (check.kind === "endsWith") {
5951
+ if (!input.data.endsWith(check.value)) {
5952
+ ctx = this._getOrReturnCtx(input, ctx);
5953
+ parseUtil_1.addIssueToContext(ctx, {
5954
+ code: ZodError_1.ZodIssueCode.invalid_string,
5955
+ validation: { endsWith: check.value },
5956
+ message: check.message,
5957
+ });
5958
+ status.dirty();
5959
+ }
5960
+ }
5961
+ else {
5962
+ util_1.util.assertNever(check);
5963
+ }
5791
5964
  }
5792
5965
  return { status: status.value, value: input.data };
5793
5966
  }
@@ -5816,6 +5989,20 @@ class ZodString extends ZodType {
5816
5989
  ...errorUtil_1.errorUtil.errToObj(message),
5817
5990
  });
5818
5991
  }
5992
+ startsWith(value, message) {
5993
+ return this._addCheck({
5994
+ kind: "startsWith",
5995
+ value: value,
5996
+ ...errorUtil_1.errorUtil.errToObj(message),
5997
+ });
5998
+ }
5999
+ endsWith(value, message) {
6000
+ return this._addCheck({
6001
+ kind: "endsWith",
6002
+ value: value,
6003
+ ...errorUtil_1.errorUtil.errToObj(message),
6004
+ });
6005
+ }
5819
6006
  min(minLength, message) {
5820
6007
  return this._addCheck({
5821
6008
  kind: "min",
@@ -5846,25 +6033,23 @@ class ZodString extends ZodType {
5846
6033
  return !!this._def.checks.find((ch) => ch.kind === "cuid");
5847
6034
  }
5848
6035
  get minLength() {
5849
- let min = -Infinity;
5850
- this._def.checks.map((ch) => {
6036
+ let min = null;
6037
+ for (const ch of this._def.checks) {
5851
6038
  if (ch.kind === "min") {
5852
- if (min === null || ch.value > min) {
6039
+ if (min === null || ch.value > min)
5853
6040
  min = ch.value;
5854
- }
5855
6041
  }
5856
- });
6042
+ }
5857
6043
  return min;
5858
6044
  }
5859
6045
  get maxLength() {
5860
6046
  let max = null;
5861
- this._def.checks.map((ch) => {
6047
+ for (const ch of this._def.checks) {
5862
6048
  if (ch.kind === "max") {
5863
- if (max === null || ch.value < max) {
6049
+ if (max === null || ch.value < max)
5864
6050
  max = ch.value;
5865
- }
5866
6051
  }
5867
- });
6052
+ }
5868
6053
  return max;
5869
6054
  }
5870
6055
  }
@@ -5894,11 +6079,11 @@ class ZodNumber extends ZodType {
5894
6079
  }
5895
6080
  _parse(input) {
5896
6081
  const parsedType = this._getType(input);
5897
- if (parsedType !== parseUtil_1.ZodParsedType.number) {
6082
+ if (parsedType !== util_1.ZodParsedType.number) {
5898
6083
  const ctx = this._getOrReturnCtx(input);
5899
- (0, parseUtil_1.addIssueToContext)(ctx, {
6084
+ parseUtil_1.addIssueToContext(ctx, {
5900
6085
  code: ZodError_1.ZodIssueCode.invalid_type,
5901
- expected: parseUtil_1.ZodParsedType.number,
6086
+ expected: util_1.ZodParsedType.number,
5902
6087
  received: ctx.parsedType,
5903
6088
  });
5904
6089
  return parseUtil_1.INVALID;
@@ -5909,7 +6094,7 @@ class ZodNumber extends ZodType {
5909
6094
  if (check.kind === "int") {
5910
6095
  if (!util_1.util.isInteger(input.data)) {
5911
6096
  ctx = this._getOrReturnCtx(input, ctx);
5912
- (0, parseUtil_1.addIssueToContext)(ctx, {
6097
+ parseUtil_1.addIssueToContext(ctx, {
5913
6098
  code: ZodError_1.ZodIssueCode.invalid_type,
5914
6099
  expected: "integer",
5915
6100
  received: "float",
@@ -5924,7 +6109,7 @@ class ZodNumber extends ZodType {
5924
6109
  : input.data <= check.value;
5925
6110
  if (tooSmall) {
5926
6111
  ctx = this._getOrReturnCtx(input, ctx);
5927
- (0, parseUtil_1.addIssueToContext)(ctx, {
6112
+ parseUtil_1.addIssueToContext(ctx, {
5928
6113
  code: ZodError_1.ZodIssueCode.too_small,
5929
6114
  minimum: check.value,
5930
6115
  type: "number",
@@ -5940,7 +6125,7 @@ class ZodNumber extends ZodType {
5940
6125
  : input.data >= check.value;
5941
6126
  if (tooBig) {
5942
6127
  ctx = this._getOrReturnCtx(input, ctx);
5943
- (0, parseUtil_1.addIssueToContext)(ctx, {
6128
+ parseUtil_1.addIssueToContext(ctx, {
5944
6129
  code: ZodError_1.ZodIssueCode.too_big,
5945
6130
  maximum: check.value,
5946
6131
  type: "number",
@@ -5953,7 +6138,7 @@ class ZodNumber extends ZodType {
5953
6138
  else if (check.kind === "multipleOf") {
5954
6139
  if (floatSafeRemainder(input.data, check.value) !== 0) {
5955
6140
  ctx = this._getOrReturnCtx(input, ctx);
5956
- (0, parseUtil_1.addIssueToContext)(ctx, {
6141
+ parseUtil_1.addIssueToContext(ctx, {
5957
6142
  code: ZodError_1.ZodIssueCode.not_multiple_of,
5958
6143
  multipleOf: check.value,
5959
6144
  message: check.message,
@@ -6079,16 +6264,16 @@ ZodNumber.create = (params) => {
6079
6264
  class ZodBigInt extends ZodType {
6080
6265
  _parse(input) {
6081
6266
  const parsedType = this._getType(input);
6082
- if (parsedType !== parseUtil_1.ZodParsedType.bigint) {
6267
+ if (parsedType !== util_1.ZodParsedType.bigint) {
6083
6268
  const ctx = this._getOrReturnCtx(input);
6084
- (0, parseUtil_1.addIssueToContext)(ctx, {
6269
+ parseUtil_1.addIssueToContext(ctx, {
6085
6270
  code: ZodError_1.ZodIssueCode.invalid_type,
6086
- expected: parseUtil_1.ZodParsedType.bigint,
6271
+ expected: util_1.ZodParsedType.bigint,
6087
6272
  received: ctx.parsedType,
6088
6273
  });
6089
6274
  return parseUtil_1.INVALID;
6090
6275
  }
6091
- return (0, parseUtil_1.OK)(input.data);
6276
+ return parseUtil_1.OK(input.data);
6092
6277
  }
6093
6278
  }
6094
6279
  exports.ZodBigInt = ZodBigInt;
@@ -6101,16 +6286,16 @@ ZodBigInt.create = (params) => {
6101
6286
  class ZodBoolean extends ZodType {
6102
6287
  _parse(input) {
6103
6288
  const parsedType = this._getType(input);
6104
- if (parsedType !== parseUtil_1.ZodParsedType.boolean) {
6289
+ if (parsedType !== util_1.ZodParsedType.boolean) {
6105
6290
  const ctx = this._getOrReturnCtx(input);
6106
- (0, parseUtil_1.addIssueToContext)(ctx, {
6291
+ parseUtil_1.addIssueToContext(ctx, {
6107
6292
  code: ZodError_1.ZodIssueCode.invalid_type,
6108
- expected: parseUtil_1.ZodParsedType.boolean,
6293
+ expected: util_1.ZodParsedType.boolean,
6109
6294
  received: ctx.parsedType,
6110
6295
  });
6111
6296
  return parseUtil_1.INVALID;
6112
6297
  }
6113
- return (0, parseUtil_1.OK)(input.data);
6298
+ return parseUtil_1.OK(input.data);
6114
6299
  }
6115
6300
  }
6116
6301
  exports.ZodBoolean = ZodBoolean;
@@ -6123,31 +6308,105 @@ ZodBoolean.create = (params) => {
6123
6308
  class ZodDate extends ZodType {
6124
6309
  _parse(input) {
6125
6310
  const parsedType = this._getType(input);
6126
- if (parsedType !== parseUtil_1.ZodParsedType.date) {
6311
+ if (parsedType !== util_1.ZodParsedType.date) {
6127
6312
  const ctx = this._getOrReturnCtx(input);
6128
- (0, parseUtil_1.addIssueToContext)(ctx, {
6313
+ parseUtil_1.addIssueToContext(ctx, {
6129
6314
  code: ZodError_1.ZodIssueCode.invalid_type,
6130
- expected: parseUtil_1.ZodParsedType.date,
6315
+ expected: util_1.ZodParsedType.date,
6131
6316
  received: ctx.parsedType,
6132
6317
  });
6133
6318
  return parseUtil_1.INVALID;
6134
6319
  }
6135
6320
  if (isNaN(input.data.getTime())) {
6136
6321
  const ctx = this._getOrReturnCtx(input);
6137
- (0, parseUtil_1.addIssueToContext)(ctx, {
6322
+ parseUtil_1.addIssueToContext(ctx, {
6138
6323
  code: ZodError_1.ZodIssueCode.invalid_date,
6139
6324
  });
6140
6325
  return parseUtil_1.INVALID;
6141
6326
  }
6327
+ const status = new parseUtil_1.ParseStatus();
6328
+ let ctx = undefined;
6329
+ for (const check of this._def.checks) {
6330
+ if (check.kind === "min") {
6331
+ if (input.data.getTime() < check.value) {
6332
+ ctx = this._getOrReturnCtx(input, ctx);
6333
+ parseUtil_1.addIssueToContext(ctx, {
6334
+ code: ZodError_1.ZodIssueCode.too_small,
6335
+ message: check.message,
6336
+ inclusive: true,
6337
+ minimum: check.value,
6338
+ type: "date",
6339
+ });
6340
+ status.dirty();
6341
+ }
6342
+ }
6343
+ else if (check.kind === "max") {
6344
+ if (input.data.getTime() > check.value) {
6345
+ ctx = this._getOrReturnCtx(input, ctx);
6346
+ parseUtil_1.addIssueToContext(ctx, {
6347
+ code: ZodError_1.ZodIssueCode.too_big,
6348
+ message: check.message,
6349
+ inclusive: true,
6350
+ maximum: check.value,
6351
+ type: "date",
6352
+ });
6353
+ status.dirty();
6354
+ }
6355
+ }
6356
+ else {
6357
+ util_1.util.assertNever(check);
6358
+ }
6359
+ }
6142
6360
  return {
6143
- status: "valid",
6361
+ status: status.value,
6144
6362
  value: new Date(input.data.getTime()),
6145
6363
  };
6146
6364
  }
6365
+ _addCheck(check) {
6366
+ return new ZodDate({
6367
+ ...this._def,
6368
+ checks: [...this._def.checks, check],
6369
+ });
6370
+ }
6371
+ min(minDate, message) {
6372
+ return this._addCheck({
6373
+ kind: "min",
6374
+ value: minDate.getTime(),
6375
+ message: errorUtil_1.errorUtil.toString(message),
6376
+ });
6377
+ }
6378
+ max(maxDate, message) {
6379
+ return this._addCheck({
6380
+ kind: "max",
6381
+ value: maxDate.getTime(),
6382
+ message: errorUtil_1.errorUtil.toString(message),
6383
+ });
6384
+ }
6385
+ get minDate() {
6386
+ let min = null;
6387
+ for (const ch of this._def.checks) {
6388
+ if (ch.kind === "min") {
6389
+ if (min === null || ch.value > min)
6390
+ min = ch.value;
6391
+ }
6392
+ }
6393
+ return min != null ? new Date(min) : null;
6394
+ }
6395
+ get maxDate() {
6396
+ let max = null;
6397
+ for (const ch of this._def.checks) {
6398
+ if (ch.kind === "max") {
6399
+ if (max === null || ch.value < max)
6400
+ max = ch.value;
6401
+ }
6402
+ }
6403
+ return max != null ? new Date(max) : null;
6404
+ }
6147
6405
  }
6148
6406
  exports.ZodDate = ZodDate;
6149
6407
  ZodDate.create = (params) => {
6150
6408
  return new ZodDate({
6409
+ checks: [],
6151
6410
  typeName: ZodFirstPartyTypeKind.ZodDate,
6152
6411
  ...processCreateParams(params),
6153
6412
  });
@@ -6155,16 +6414,16 @@ ZodDate.create = (params) => {
6155
6414
  class ZodUndefined extends ZodType {
6156
6415
  _parse(input) {
6157
6416
  const parsedType = this._getType(input);
6158
- if (parsedType !== parseUtil_1.ZodParsedType.undefined) {
6417
+ if (parsedType !== util_1.ZodParsedType.undefined) {
6159
6418
  const ctx = this._getOrReturnCtx(input);
6160
- (0, parseUtil_1.addIssueToContext)(ctx, {
6419
+ parseUtil_1.addIssueToContext(ctx, {
6161
6420
  code: ZodError_1.ZodIssueCode.invalid_type,
6162
- expected: parseUtil_1.ZodParsedType.undefined,
6421
+ expected: util_1.ZodParsedType.undefined,
6163
6422
  received: ctx.parsedType,
6164
6423
  });
6165
6424
  return parseUtil_1.INVALID;
6166
6425
  }
6167
- return (0, parseUtil_1.OK)(input.data);
6426
+ return parseUtil_1.OK(input.data);
6168
6427
  }
6169
6428
  }
6170
6429
  exports.ZodUndefined = ZodUndefined;
@@ -6177,16 +6436,16 @@ ZodUndefined.create = (params) => {
6177
6436
  class ZodNull extends ZodType {
6178
6437
  _parse(input) {
6179
6438
  const parsedType = this._getType(input);
6180
- if (parsedType !== parseUtil_1.ZodParsedType.null) {
6439
+ if (parsedType !== util_1.ZodParsedType.null) {
6181
6440
  const ctx = this._getOrReturnCtx(input);
6182
- (0, parseUtil_1.addIssueToContext)(ctx, {
6441
+ parseUtil_1.addIssueToContext(ctx, {
6183
6442
  code: ZodError_1.ZodIssueCode.invalid_type,
6184
- expected: parseUtil_1.ZodParsedType.null,
6443
+ expected: util_1.ZodParsedType.null,
6185
6444
  received: ctx.parsedType,
6186
6445
  });
6187
6446
  return parseUtil_1.INVALID;
6188
6447
  }
6189
- return (0, parseUtil_1.OK)(input.data);
6448
+ return parseUtil_1.OK(input.data);
6190
6449
  }
6191
6450
  }
6192
6451
  exports.ZodNull = ZodNull;
@@ -6203,7 +6462,7 @@ class ZodAny extends ZodType {
6203
6462
  this._any = true;
6204
6463
  }
6205
6464
  _parse(input) {
6206
- return (0, parseUtil_1.OK)(input.data);
6465
+ return parseUtil_1.OK(input.data);
6207
6466
  }
6208
6467
  }
6209
6468
  exports.ZodAny = ZodAny;
@@ -6220,7 +6479,7 @@ class ZodUnknown extends ZodType {
6220
6479
  this._unknown = true;
6221
6480
  }
6222
6481
  _parse(input) {
6223
- return (0, parseUtil_1.OK)(input.data);
6482
+ return parseUtil_1.OK(input.data);
6224
6483
  }
6225
6484
  }
6226
6485
  exports.ZodUnknown = ZodUnknown;
@@ -6233,9 +6492,9 @@ ZodUnknown.create = (params) => {
6233
6492
  class ZodNever extends ZodType {
6234
6493
  _parse(input) {
6235
6494
  const ctx = this._getOrReturnCtx(input);
6236
- (0, parseUtil_1.addIssueToContext)(ctx, {
6495
+ parseUtil_1.addIssueToContext(ctx, {
6237
6496
  code: ZodError_1.ZodIssueCode.invalid_type,
6238
- expected: parseUtil_1.ZodParsedType.never,
6497
+ expected: util_1.ZodParsedType.never,
6239
6498
  received: ctx.parsedType,
6240
6499
  });
6241
6500
  return parseUtil_1.INVALID;
@@ -6251,16 +6510,16 @@ ZodNever.create = (params) => {
6251
6510
  class ZodVoid extends ZodType {
6252
6511
  _parse(input) {
6253
6512
  const parsedType = this._getType(input);
6254
- if (parsedType !== parseUtil_1.ZodParsedType.undefined) {
6513
+ if (parsedType !== util_1.ZodParsedType.undefined) {
6255
6514
  const ctx = this._getOrReturnCtx(input);
6256
- (0, parseUtil_1.addIssueToContext)(ctx, {
6515
+ parseUtil_1.addIssueToContext(ctx, {
6257
6516
  code: ZodError_1.ZodIssueCode.invalid_type,
6258
- expected: parseUtil_1.ZodParsedType.void,
6517
+ expected: util_1.ZodParsedType.void,
6259
6518
  received: ctx.parsedType,
6260
6519
  });
6261
6520
  return parseUtil_1.INVALID;
6262
6521
  }
6263
- return (0, parseUtil_1.OK)(input.data);
6522
+ return parseUtil_1.OK(input.data);
6264
6523
  }
6265
6524
  }
6266
6525
  exports.ZodVoid = ZodVoid;
@@ -6274,17 +6533,17 @@ class ZodArray extends ZodType {
6274
6533
  _parse(input) {
6275
6534
  const { ctx, status } = this._processInputParams(input);
6276
6535
  const def = this._def;
6277
- if (ctx.parsedType !== parseUtil_1.ZodParsedType.array) {
6278
- (0, parseUtil_1.addIssueToContext)(ctx, {
6536
+ if (ctx.parsedType !== util_1.ZodParsedType.array) {
6537
+ parseUtil_1.addIssueToContext(ctx, {
6279
6538
  code: ZodError_1.ZodIssueCode.invalid_type,
6280
- expected: parseUtil_1.ZodParsedType.array,
6539
+ expected: util_1.ZodParsedType.array,
6281
6540
  received: ctx.parsedType,
6282
6541
  });
6283
6542
  return parseUtil_1.INVALID;
6284
6543
  }
6285
6544
  if (def.minLength !== null) {
6286
6545
  if (ctx.data.length < def.minLength.value) {
6287
- (0, parseUtil_1.addIssueToContext)(ctx, {
6546
+ parseUtil_1.addIssueToContext(ctx, {
6288
6547
  code: ZodError_1.ZodIssueCode.too_small,
6289
6548
  minimum: def.minLength.value,
6290
6549
  type: "array",
@@ -6296,7 +6555,7 @@ class ZodArray extends ZodType {
6296
6555
  }
6297
6556
  if (def.maxLength !== null) {
6298
6557
  if (ctx.data.length > def.maxLength.value) {
6299
- (0, parseUtil_1.addIssueToContext)(ctx, {
6558
+ parseUtil_1.addIssueToContext(ctx, {
6300
6559
  code: ZodError_1.ZodIssueCode.too_big,
6301
6560
  maximum: def.maxLength.value,
6302
6561
  type: "array",
@@ -6362,7 +6621,7 @@ var objectUtil;
6362
6621
  objectUtil.mergeShapes = (first, second) => {
6363
6622
  return {
6364
6623
  ...first,
6365
- ...second, // second overwrites first
6624
+ ...second,
6366
6625
  };
6367
6626
  };
6368
6627
  })(objectUtil = exports.objectUtil || (exports.objectUtil = {}));
@@ -6424,19 +6683,23 @@ class ZodObject extends ZodType {
6424
6683
  }
6425
6684
  _parse(input) {
6426
6685
  const parsedType = this._getType(input);
6427
- if (parsedType !== parseUtil_1.ZodParsedType.object) {
6686
+ if (parsedType !== util_1.ZodParsedType.object) {
6428
6687
  const ctx = this._getOrReturnCtx(input);
6429
- (0, parseUtil_1.addIssueToContext)(ctx, {
6688
+ parseUtil_1.addIssueToContext(ctx, {
6430
6689
  code: ZodError_1.ZodIssueCode.invalid_type,
6431
- expected: parseUtil_1.ZodParsedType.object,
6690
+ expected: util_1.ZodParsedType.object,
6432
6691
  received: ctx.parsedType,
6433
6692
  });
6434
6693
  return parseUtil_1.INVALID;
6435
6694
  }
6436
6695
  const { status, ctx } = this._processInputParams(input);
6437
6696
  const { shape, keys: shapeKeys } = this._getCached();
6438
- const dataKeys = util_1.util.objectKeys(ctx.data);
6439
- const extraKeys = dataKeys.filter((k) => !shapeKeys.includes(k));
6697
+ const extraKeys = [];
6698
+ for (const key in ctx.data) {
6699
+ if (!shapeKeys.includes(key)) {
6700
+ extraKeys.push(key);
6701
+ }
6702
+ }
6440
6703
  const pairs = [];
6441
6704
  for (const key of shapeKeys) {
6442
6705
  const keyValidator = shape[key];
@@ -6459,7 +6722,7 @@ class ZodObject extends ZodType {
6459
6722
  }
6460
6723
  else if (unknownKeys === "strict") {
6461
6724
  if (extraKeys.length > 0) {
6462
- (0, parseUtil_1.addIssueToContext)(ctx, {
6725
+ parseUtil_1.addIssueToContext(ctx, {
6463
6726
  code: ZodError_1.ZodIssueCode.unrecognized_keys,
6464
6727
  keys: extraKeys,
6465
6728
  });
@@ -6574,7 +6837,9 @@ class ZodObject extends ZodType {
6574
6837
  pick(mask) {
6575
6838
  const shape = {};
6576
6839
  util_1.util.objectKeys(mask).map((key) => {
6577
- shape[key] = this.shape[key];
6840
+ // only add to shape if key corresponds to an element of the current shape
6841
+ if (this.shape[key])
6842
+ shape[key] = this.shape[key];
6578
6843
  });
6579
6844
  return new ZodObject({
6580
6845
  ...this._def,
@@ -6638,6 +6903,9 @@ class ZodObject extends ZodType {
6638
6903
  shape: () => newShape,
6639
6904
  });
6640
6905
  }
6906
+ keyof() {
6907
+ return createZodEnum(util_1.util.objectKeys(this.shape));
6908
+ }
6641
6909
  }
6642
6910
  exports.ZodObject = ZodObject;
6643
6911
  ZodObject.create = (shape, params) => {
@@ -6687,7 +6955,7 @@ class ZodUnion extends ZodType {
6687
6955
  }
6688
6956
  // return invalid
6689
6957
  const unionErrors = results.map((result) => new ZodError_1.ZodError(result.ctx.common.issues));
6690
- (0, parseUtil_1.addIssueToContext)(ctx, {
6958
+ parseUtil_1.addIssueToContext(ctx, {
6691
6959
  code: ZodError_1.ZodIssueCode.invalid_union,
6692
6960
  unionErrors,
6693
6961
  });
@@ -6745,7 +7013,7 @@ class ZodUnion extends ZodType {
6745
7013
  return dirty.result;
6746
7014
  }
6747
7015
  const unionErrors = issues.map((issues) => new ZodError_1.ZodError(issues));
6748
- (0, parseUtil_1.addIssueToContext)(ctx, {
7016
+ parseUtil_1.addIssueToContext(ctx, {
6749
7017
  code: ZodError_1.ZodIssueCode.invalid_union,
6750
7018
  unionErrors,
6751
7019
  });
@@ -6767,10 +7035,10 @@ ZodUnion.create = (types, params) => {
6767
7035
  class ZodDiscriminatedUnion extends ZodType {
6768
7036
  _parse(input) {
6769
7037
  const { ctx } = this._processInputParams(input);
6770
- if (ctx.parsedType !== parseUtil_1.ZodParsedType.object) {
6771
- (0, parseUtil_1.addIssueToContext)(ctx, {
7038
+ if (ctx.parsedType !== util_1.ZodParsedType.object) {
7039
+ parseUtil_1.addIssueToContext(ctx, {
6772
7040
  code: ZodError_1.ZodIssueCode.invalid_type,
6773
- expected: parseUtil_1.ZodParsedType.object,
7041
+ expected: util_1.ZodParsedType.object,
6774
7042
  received: ctx.parsedType,
6775
7043
  });
6776
7044
  return parseUtil_1.INVALID;
@@ -6779,7 +7047,7 @@ class ZodDiscriminatedUnion extends ZodType {
6779
7047
  const discriminatorValue = ctx.data[discriminator];
6780
7048
  const option = this.options.get(discriminatorValue);
6781
7049
  if (!option) {
6782
- (0, parseUtil_1.addIssueToContext)(ctx, {
7050
+ parseUtil_1.addIssueToContext(ctx, {
6783
7051
  code: ZodError_1.ZodIssueCode.invalid_union_discriminator,
6784
7052
  options: this.validDiscriminatorValues,
6785
7053
  path: [discriminator],
@@ -6844,12 +7112,12 @@ class ZodDiscriminatedUnion extends ZodType {
6844
7112
  }
6845
7113
  exports.ZodDiscriminatedUnion = ZodDiscriminatedUnion;
6846
7114
  function mergeValues(a, b) {
6847
- const aType = (0, parseUtil_1.getParsedType)(a);
6848
- const bType = (0, parseUtil_1.getParsedType)(b);
7115
+ const aType = util_1.getParsedType(a);
7116
+ const bType = util_1.getParsedType(b);
6849
7117
  if (a === b) {
6850
7118
  return { valid: true, data: a };
6851
7119
  }
6852
- else if (aType === parseUtil_1.ZodParsedType.object && bType === parseUtil_1.ZodParsedType.object) {
7120
+ else if (aType === util_1.ZodParsedType.object && bType === util_1.ZodParsedType.object) {
6853
7121
  const bKeys = util_1.util.objectKeys(b);
6854
7122
  const sharedKeys = util_1.util
6855
7123
  .objectKeys(a)
@@ -6864,7 +7132,7 @@ function mergeValues(a, b) {
6864
7132
  }
6865
7133
  return { valid: true, data: newObj };
6866
7134
  }
6867
- else if (aType === parseUtil_1.ZodParsedType.array && bType === parseUtil_1.ZodParsedType.array) {
7135
+ else if (aType === util_1.ZodParsedType.array && bType === util_1.ZodParsedType.array) {
6868
7136
  if (a.length !== b.length) {
6869
7137
  return { valid: false };
6870
7138
  }
@@ -6880,8 +7148,8 @@ function mergeValues(a, b) {
6880
7148
  }
6881
7149
  return { valid: true, data: newArray };
6882
7150
  }
6883
- else if (aType === parseUtil_1.ZodParsedType.date &&
6884
- bType === parseUtil_1.ZodParsedType.date &&
7151
+ else if (aType === util_1.ZodParsedType.date &&
7152
+ bType === util_1.ZodParsedType.date &&
6885
7153
  +a === +b) {
6886
7154
  return { valid: true, data: a };
6887
7155
  }
@@ -6893,17 +7161,17 @@ class ZodIntersection extends ZodType {
6893
7161
  _parse(input) {
6894
7162
  const { status, ctx } = this._processInputParams(input);
6895
7163
  const handleParsed = (parsedLeft, parsedRight) => {
6896
- if ((0, parseUtil_1.isAborted)(parsedLeft) || (0, parseUtil_1.isAborted)(parsedRight)) {
7164
+ if (parseUtil_1.isAborted(parsedLeft) || parseUtil_1.isAborted(parsedRight)) {
6897
7165
  return parseUtil_1.INVALID;
6898
7166
  }
6899
7167
  const merged = mergeValues(parsedLeft.value, parsedRight.value);
6900
7168
  if (!merged.valid) {
6901
- (0, parseUtil_1.addIssueToContext)(ctx, {
7169
+ parseUtil_1.addIssueToContext(ctx, {
6902
7170
  code: ZodError_1.ZodIssueCode.invalid_intersection_types,
6903
7171
  });
6904
7172
  return parseUtil_1.INVALID;
6905
7173
  }
6906
- if ((0, parseUtil_1.isDirty)(parsedLeft) || (0, parseUtil_1.isDirty)(parsedRight)) {
7174
+ if (parseUtil_1.isDirty(parsedLeft) || parseUtil_1.isDirty(parsedRight)) {
6907
7175
  status.dirty();
6908
7176
  }
6909
7177
  return { status: status.value, value: merged.data };
@@ -6947,16 +7215,16 @@ ZodIntersection.create = (left, right, params) => {
6947
7215
  class ZodTuple extends ZodType {
6948
7216
  _parse(input) {
6949
7217
  const { status, ctx } = this._processInputParams(input);
6950
- if (ctx.parsedType !== parseUtil_1.ZodParsedType.array) {
6951
- (0, parseUtil_1.addIssueToContext)(ctx, {
7218
+ if (ctx.parsedType !== util_1.ZodParsedType.array) {
7219
+ parseUtil_1.addIssueToContext(ctx, {
6952
7220
  code: ZodError_1.ZodIssueCode.invalid_type,
6953
- expected: parseUtil_1.ZodParsedType.array,
7221
+ expected: util_1.ZodParsedType.array,
6954
7222
  received: ctx.parsedType,
6955
7223
  });
6956
7224
  return parseUtil_1.INVALID;
6957
7225
  }
6958
7226
  if (ctx.data.length < this._def.items.length) {
6959
- (0, parseUtil_1.addIssueToContext)(ctx, {
7227
+ parseUtil_1.addIssueToContext(ctx, {
6960
7228
  code: ZodError_1.ZodIssueCode.too_small,
6961
7229
  minimum: this._def.items.length,
6962
7230
  inclusive: true,
@@ -6966,7 +7234,7 @@ class ZodTuple extends ZodType {
6966
7234
  }
6967
7235
  const rest = this._def.rest;
6968
7236
  if (!rest && ctx.data.length > this._def.items.length) {
6969
- (0, parseUtil_1.addIssueToContext)(ctx, {
7237
+ parseUtil_1.addIssueToContext(ctx, {
6970
7238
  code: ZodError_1.ZodIssueCode.too_big,
6971
7239
  maximum: this._def.items.length,
6972
7240
  inclusive: true,
@@ -7019,10 +7287,10 @@ class ZodRecord extends ZodType {
7019
7287
  }
7020
7288
  _parse(input) {
7021
7289
  const { status, ctx } = this._processInputParams(input);
7022
- if (ctx.parsedType !== parseUtil_1.ZodParsedType.object) {
7023
- (0, parseUtil_1.addIssueToContext)(ctx, {
7290
+ if (ctx.parsedType !== util_1.ZodParsedType.object) {
7291
+ parseUtil_1.addIssueToContext(ctx, {
7024
7292
  code: ZodError_1.ZodIssueCode.invalid_type,
7025
- expected: parseUtil_1.ZodParsedType.object,
7293
+ expected: util_1.ZodParsedType.object,
7026
7294
  received: ctx.parsedType,
7027
7295
  });
7028
7296
  return parseUtil_1.INVALID;
@@ -7067,10 +7335,10 @@ exports.ZodRecord = ZodRecord;
7067
7335
  class ZodMap extends ZodType {
7068
7336
  _parse(input) {
7069
7337
  const { status, ctx } = this._processInputParams(input);
7070
- if (ctx.parsedType !== parseUtil_1.ZodParsedType.map) {
7071
- (0, parseUtil_1.addIssueToContext)(ctx, {
7338
+ if (ctx.parsedType !== util_1.ZodParsedType.map) {
7339
+ parseUtil_1.addIssueToContext(ctx, {
7072
7340
  code: ZodError_1.ZodIssueCode.invalid_type,
7073
- expected: parseUtil_1.ZodParsedType.map,
7341
+ expected: util_1.ZodParsedType.map,
7074
7342
  received: ctx.parsedType,
7075
7343
  });
7076
7344
  return parseUtil_1.INVALID;
@@ -7129,10 +7397,10 @@ ZodMap.create = (keyType, valueType, params) => {
7129
7397
  class ZodSet extends ZodType {
7130
7398
  _parse(input) {
7131
7399
  const { status, ctx } = this._processInputParams(input);
7132
- if (ctx.parsedType !== parseUtil_1.ZodParsedType.set) {
7133
- (0, parseUtil_1.addIssueToContext)(ctx, {
7400
+ if (ctx.parsedType !== util_1.ZodParsedType.set) {
7401
+ parseUtil_1.addIssueToContext(ctx, {
7134
7402
  code: ZodError_1.ZodIssueCode.invalid_type,
7135
- expected: parseUtil_1.ZodParsedType.set,
7403
+ expected: util_1.ZodParsedType.set,
7136
7404
  received: ctx.parsedType,
7137
7405
  });
7138
7406
  return parseUtil_1.INVALID;
@@ -7140,7 +7408,7 @@ class ZodSet extends ZodType {
7140
7408
  const def = this._def;
7141
7409
  if (def.minSize !== null) {
7142
7410
  if (ctx.data.size < def.minSize.value) {
7143
- (0, parseUtil_1.addIssueToContext)(ctx, {
7411
+ parseUtil_1.addIssueToContext(ctx, {
7144
7412
  code: ZodError_1.ZodIssueCode.too_small,
7145
7413
  minimum: def.minSize.value,
7146
7414
  type: "set",
@@ -7152,7 +7420,7 @@ class ZodSet extends ZodType {
7152
7420
  }
7153
7421
  if (def.maxSize !== null) {
7154
7422
  if (ctx.data.size > def.maxSize.value) {
7155
- (0, parseUtil_1.addIssueToContext)(ctx, {
7423
+ parseUtil_1.addIssueToContext(ctx, {
7156
7424
  code: ZodError_1.ZodIssueCode.too_big,
7157
7425
  maximum: def.maxSize.value,
7158
7426
  type: "set",
@@ -7218,22 +7486,22 @@ class ZodFunction extends ZodType {
7218
7486
  }
7219
7487
  _parse(input) {
7220
7488
  const { ctx } = this._processInputParams(input);
7221
- if (ctx.parsedType !== parseUtil_1.ZodParsedType.function) {
7222
- (0, parseUtil_1.addIssueToContext)(ctx, {
7489
+ if (ctx.parsedType !== util_1.ZodParsedType.function) {
7490
+ parseUtil_1.addIssueToContext(ctx, {
7223
7491
  code: ZodError_1.ZodIssueCode.invalid_type,
7224
- expected: parseUtil_1.ZodParsedType.function,
7492
+ expected: util_1.ZodParsedType.function,
7225
7493
  received: ctx.parsedType,
7226
7494
  });
7227
7495
  return parseUtil_1.INVALID;
7228
7496
  }
7229
7497
  function makeArgsIssue(args, error) {
7230
- return (0, parseUtil_1.makeIssue)({
7498
+ return parseUtil_1.makeIssue({
7231
7499
  data: args,
7232
7500
  path: ctx.path,
7233
7501
  errorMaps: [
7234
7502
  ctx.common.contextualErrorMap,
7235
7503
  ctx.schemaErrorMap,
7236
- ZodError_1.overrideErrorMap,
7504
+ ZodError_1.getErrorMap(),
7237
7505
  ZodError_1.defaultErrorMap,
7238
7506
  ].filter((x) => !!x),
7239
7507
  issueData: {
@@ -7243,13 +7511,13 @@ class ZodFunction extends ZodType {
7243
7511
  });
7244
7512
  }
7245
7513
  function makeReturnsIssue(returns, error) {
7246
- return (0, parseUtil_1.makeIssue)({
7514
+ return parseUtil_1.makeIssue({
7247
7515
  data: returns,
7248
7516
  path: ctx.path,
7249
7517
  errorMaps: [
7250
7518
  ctx.common.contextualErrorMap,
7251
7519
  ctx.schemaErrorMap,
7252
- ZodError_1.overrideErrorMap,
7520
+ ZodError_1.getErrorMap(),
7253
7521
  ZodError_1.defaultErrorMap,
7254
7522
  ].filter((x) => !!x),
7255
7523
  issueData: {
@@ -7261,7 +7529,7 @@ class ZodFunction extends ZodType {
7261
7529
  const params = { errorMap: ctx.common.contextualErrorMap };
7262
7530
  const fn = ctx.data;
7263
7531
  if (this._def.returns instanceof ZodPromise) {
7264
- return (0, parseUtil_1.OK)(async (...args) => {
7532
+ return parseUtil_1.OK(async (...args) => {
7265
7533
  const error = new ZodError_1.ZodError([]);
7266
7534
  const parsedArgs = await this._def.args
7267
7535
  .parseAsync(args, params)
@@ -7280,7 +7548,7 @@ class ZodFunction extends ZodType {
7280
7548
  });
7281
7549
  }
7282
7550
  else {
7283
- return (0, parseUtil_1.OK)((...args) => {
7551
+ return parseUtil_1.OK((...args) => {
7284
7552
  const parsedArgs = this._def.args.safeParse(args, params);
7285
7553
  if (!parsedArgs.success) {
7286
7554
  throw new ZodError_1.ZodError([makeArgsIssue(args, parsedArgs.error)]);
@@ -7354,10 +7622,9 @@ class ZodLiteral extends ZodType {
7354
7622
  _parse(input) {
7355
7623
  if (input.data !== this._def.value) {
7356
7624
  const ctx = this._getOrReturnCtx(input);
7357
- (0, parseUtil_1.addIssueToContext)(ctx, {
7358
- code: ZodError_1.ZodIssueCode.invalid_type,
7359
- expected: (0, parseUtil_1.getParsedType)(this._def.value),
7360
- received: ctx.parsedType,
7625
+ parseUtil_1.addIssueToContext(ctx, {
7626
+ code: ZodError_1.ZodIssueCode.invalid_literal,
7627
+ expected: this._def.value,
7361
7628
  });
7362
7629
  return parseUtil_1.INVALID;
7363
7630
  }
@@ -7375,23 +7642,36 @@ ZodLiteral.create = (value, params) => {
7375
7642
  ...processCreateParams(params),
7376
7643
  });
7377
7644
  };
7378
- function createZodEnum(values) {
7645
+ function createZodEnum(values, params) {
7379
7646
  return new ZodEnum({
7380
7647
  values: values,
7381
7648
  typeName: ZodFirstPartyTypeKind.ZodEnum,
7649
+ ...processCreateParams(params),
7382
7650
  });
7383
7651
  }
7384
7652
  class ZodEnum extends ZodType {
7385
7653
  _parse(input) {
7654
+ if (typeof input.data !== "string") {
7655
+ const ctx = this._getOrReturnCtx(input);
7656
+ const expectedValues = this._def.values;
7657
+ parseUtil_1.addIssueToContext(ctx, {
7658
+ expected: util_1.util.joinValues(expectedValues),
7659
+ received: ctx.parsedType,
7660
+ code: ZodError_1.ZodIssueCode.invalid_type,
7661
+ });
7662
+ return parseUtil_1.INVALID;
7663
+ }
7386
7664
  if (this._def.values.indexOf(input.data) === -1) {
7387
7665
  const ctx = this._getOrReturnCtx(input);
7388
- (0, parseUtil_1.addIssueToContext)(ctx, {
7666
+ const expectedValues = this._def.values;
7667
+ parseUtil_1.addIssueToContext(ctx, {
7668
+ received: ctx.data,
7389
7669
  code: ZodError_1.ZodIssueCode.invalid_enum_value,
7390
- options: this._def.values,
7670
+ options: expectedValues,
7391
7671
  });
7392
7672
  return parseUtil_1.INVALID;
7393
7673
  }
7394
- return (0, parseUtil_1.OK)(input.data);
7674
+ return parseUtil_1.OK(input.data);
7395
7675
  }
7396
7676
  get options() {
7397
7677
  return this._def.values;
@@ -7423,15 +7703,27 @@ ZodEnum.create = createZodEnum;
7423
7703
  class ZodNativeEnum extends ZodType {
7424
7704
  _parse(input) {
7425
7705
  const nativeEnumValues = util_1.util.getValidEnumValues(this._def.values);
7706
+ const ctx = this._getOrReturnCtx(input);
7707
+ if (ctx.parsedType !== util_1.ZodParsedType.string &&
7708
+ ctx.parsedType !== util_1.ZodParsedType.number) {
7709
+ const expectedValues = util_1.util.objectValues(nativeEnumValues);
7710
+ parseUtil_1.addIssueToContext(ctx, {
7711
+ expected: util_1.util.joinValues(expectedValues),
7712
+ received: ctx.parsedType,
7713
+ code: ZodError_1.ZodIssueCode.invalid_type,
7714
+ });
7715
+ return parseUtil_1.INVALID;
7716
+ }
7426
7717
  if (nativeEnumValues.indexOf(input.data) === -1) {
7427
- const ctx = this._getOrReturnCtx(input);
7428
- (0, parseUtil_1.addIssueToContext)(ctx, {
7718
+ const expectedValues = util_1.util.objectValues(nativeEnumValues);
7719
+ parseUtil_1.addIssueToContext(ctx, {
7720
+ received: ctx.data,
7429
7721
  code: ZodError_1.ZodIssueCode.invalid_enum_value,
7430
- options: util_1.util.objectValues(nativeEnumValues),
7722
+ options: expectedValues,
7431
7723
  });
7432
7724
  return parseUtil_1.INVALID;
7433
7725
  }
7434
- return (0, parseUtil_1.OK)(input.data);
7726
+ return parseUtil_1.OK(input.data);
7435
7727
  }
7436
7728
  get enum() {
7437
7729
  return this._def.values;
@@ -7448,19 +7740,19 @@ ZodNativeEnum.create = (values, params) => {
7448
7740
  class ZodPromise extends ZodType {
7449
7741
  _parse(input) {
7450
7742
  const { ctx } = this._processInputParams(input);
7451
- if (ctx.parsedType !== parseUtil_1.ZodParsedType.promise &&
7743
+ if (ctx.parsedType !== util_1.ZodParsedType.promise &&
7452
7744
  ctx.common.async === false) {
7453
- (0, parseUtil_1.addIssueToContext)(ctx, {
7745
+ parseUtil_1.addIssueToContext(ctx, {
7454
7746
  code: ZodError_1.ZodIssueCode.invalid_type,
7455
- expected: parseUtil_1.ZodParsedType.promise,
7747
+ expected: util_1.ZodParsedType.promise,
7456
7748
  received: ctx.parsedType,
7457
7749
  });
7458
7750
  return parseUtil_1.INVALID;
7459
7751
  }
7460
- const promisified = ctx.parsedType === parseUtil_1.ZodParsedType.promise
7752
+ const promisified = ctx.parsedType === util_1.ZodParsedType.promise
7461
7753
  ? ctx.data
7462
7754
  : Promise.resolve(ctx.data);
7463
- return (0, parseUtil_1.OK)(promisified.then((data) => {
7755
+ return parseUtil_1.OK(promisified.then((data) => {
7464
7756
  return this._def.type.parseAsync(data, {
7465
7757
  path: ctx.path,
7466
7758
  errorMap: ctx.common.contextualErrorMap,
@@ -7502,22 +7794,22 @@ class ZodEffects extends ZodType {
7502
7794
  });
7503
7795
  }
7504
7796
  }
7797
+ const checkCtx = {
7798
+ addIssue: (arg) => {
7799
+ parseUtil_1.addIssueToContext(ctx, arg);
7800
+ if (arg.fatal) {
7801
+ status.abort();
7802
+ }
7803
+ else {
7804
+ status.dirty();
7805
+ }
7806
+ },
7807
+ get path() {
7808
+ return ctx.path;
7809
+ },
7810
+ };
7811
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
7505
7812
  if (effect.type === "refinement") {
7506
- const checkCtx = {
7507
- addIssue: (arg) => {
7508
- (0, parseUtil_1.addIssueToContext)(ctx, arg);
7509
- if (arg.fatal) {
7510
- status.abort();
7511
- }
7512
- else {
7513
- status.dirty();
7514
- }
7515
- },
7516
- get path() {
7517
- return ctx.path;
7518
- },
7519
- };
7520
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
7521
7813
  const executeRefinement = (acc
7522
7814
  // effect: RefinementEffect<any>
7523
7815
  ) => {
@@ -7569,25 +7861,25 @@ class ZodEffects extends ZodType {
7569
7861
  // if (base.status === "dirty") {
7570
7862
  // return { status: "dirty", value: base.value };
7571
7863
  // }
7572
- if (!(0, parseUtil_1.isValid)(base))
7864
+ if (!parseUtil_1.isValid(base))
7573
7865
  return base;
7574
- const result = effect.transform(base.value);
7866
+ const result = effect.transform(base.value, checkCtx);
7575
7867
  if (result instanceof Promise) {
7576
7868
  throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
7577
7869
  }
7578
- return (0, parseUtil_1.OK)(result);
7870
+ return { status: status.value, value: result };
7579
7871
  }
7580
7872
  else {
7581
7873
  return this._def.schema
7582
7874
  ._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx })
7583
7875
  .then((base) => {
7584
- if (!(0, parseUtil_1.isValid)(base))
7876
+ if (!parseUtil_1.isValid(base))
7585
7877
  return base;
7586
7878
  // if (base.status === "aborted") return INVALID;
7587
7879
  // if (base.status === "dirty") {
7588
7880
  // return { status: "dirty", value: base.value };
7589
7881
  // }
7590
- return Promise.resolve(effect.transform(base.value)).then(parseUtil_1.OK);
7882
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
7591
7883
  });
7592
7884
  }
7593
7885
  }
@@ -7615,8 +7907,8 @@ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
7615
7907
  class ZodOptional extends ZodType {
7616
7908
  _parse(input) {
7617
7909
  const parsedType = this._getType(input);
7618
- if (parsedType === parseUtil_1.ZodParsedType.undefined) {
7619
- return (0, parseUtil_1.OK)(undefined);
7910
+ if (parsedType === util_1.ZodParsedType.undefined) {
7911
+ return parseUtil_1.OK(undefined);
7620
7912
  }
7621
7913
  return this._def.innerType._parse(input);
7622
7914
  }
@@ -7635,8 +7927,8 @@ ZodOptional.create = (type, params) => {
7635
7927
  class ZodNullable extends ZodType {
7636
7928
  _parse(input) {
7637
7929
  const parsedType = this._getType(input);
7638
- if (parsedType === parseUtil_1.ZodParsedType.null) {
7639
- return (0, parseUtil_1.OK)(null);
7930
+ if (parsedType === util_1.ZodParsedType.null) {
7931
+ return parseUtil_1.OK(null);
7640
7932
  }
7641
7933
  return this._def.innerType._parse(input);
7642
7934
  }
@@ -7656,7 +7948,7 @@ class ZodDefault extends ZodType {
7656
7948
  _parse(input) {
7657
7949
  const { ctx } = this._processInputParams(input);
7658
7950
  let data = ctx.data;
7659
- if (ctx.parsedType === parseUtil_1.ZodParsedType.undefined) {
7951
+ if (ctx.parsedType === util_1.ZodParsedType.undefined) {
7660
7952
  data = this._def.defaultValue();
7661
7953
  }
7662
7954
  return this._def.innerType._parse({
@@ -7680,11 +7972,11 @@ ZodDefault.create = (type, params) => {
7680
7972
  class ZodNaN extends ZodType {
7681
7973
  _parse(input) {
7682
7974
  const parsedType = this._getType(input);
7683
- if (parsedType !== parseUtil_1.ZodParsedType.nan) {
7975
+ if (parsedType !== util_1.ZodParsedType.nan) {
7684
7976
  const ctx = this._getOrReturnCtx(input);
7685
- (0, parseUtil_1.addIssueToContext)(ctx, {
7977
+ parseUtil_1.addIssueToContext(ctx, {
7686
7978
  code: ZodError_1.ZodIssueCode.invalid_type,
7687
- expected: parseUtil_1.ZodParsedType.nan,
7979
+ expected: util_1.ZodParsedType.nan,
7688
7980
  received: ctx.parsedType,
7689
7981
  });
7690
7982
  return parseUtil_1.INVALID;
@@ -7699,9 +7991,31 @@ ZodNaN.create = (params) => {
7699
7991
  ...processCreateParams(params),
7700
7992
  });
7701
7993
  };
7702
- const custom = (check, params) => {
7994
+ exports.BRAND = Symbol("zod_brand");
7995
+ class ZodBranded extends ZodType {
7996
+ _parse(input) {
7997
+ const { ctx } = this._processInputParams(input);
7998
+ const data = ctx.data;
7999
+ return this._def.type._parse({
8000
+ data,
8001
+ path: ctx.path,
8002
+ parent: ctx,
8003
+ });
8004
+ }
8005
+ unwrap() {
8006
+ return this._def.type;
8007
+ }
8008
+ }
8009
+ exports.ZodBranded = ZodBranded;
8010
+ const custom = (check, params = {}, fatal) => {
7703
8011
  if (check)
7704
- return ZodAny.create().refine(check, params);
8012
+ return ZodAny.create().superRefine((data, ctx) => {
8013
+ if (!check(data)) {
8014
+ const p = typeof params === "function" ? params(data) : params;
8015
+ const p2 = typeof p === "string" ? { message: p } : p;
8016
+ ctx.addIssue({ code: "custom", ...p2, fatal });
8017
+ }
8018
+ });
7705
8019
  return ZodAny.create();
7706
8020
  };
7707
8021
  exports.custom = custom;
@@ -7741,10 +8055,11 @@ var ZodFirstPartyTypeKind;
7741
8055
  ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
7742
8056
  ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
7743
8057
  ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
8058
+ ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
7744
8059
  })(ZodFirstPartyTypeKind = exports.ZodFirstPartyTypeKind || (exports.ZodFirstPartyTypeKind = {}));
7745
8060
  const instanceOfType = (cls, params = {
7746
8061
  message: `Input not instance of ${cls.name}`,
7747
- }) => (0, exports.custom)((data) => data instanceof cls, params);
8062
+ }) => exports.custom((data) => data instanceof cls, params, true);
7748
8063
  exports["instanceof"] = instanceOfType;
7749
8064
  const stringType = ZodString.create;
7750
8065
  exports.string = stringType;
@@ -7819,96 +8134,6 @@ const oboolean = () => booleanType().optional();
7819
8134
  exports.oboolean = oboolean;
7820
8135
 
7821
8136
 
7822
- /***/ }),
7823
-
7824
- /***/ 7271:
7825
- /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
7826
-
7827
-
7828
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7829
- if (k2 === undefined) k2 = k;
7830
- var desc = Object.getOwnPropertyDescriptor(m, k);
7831
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7832
- desc = { enumerable: true, get: function() { return m[k]; } };
7833
- }
7834
- Object.defineProperty(o, k2, desc);
7835
- }) : (function(o, m, k, k2) {
7836
- if (k2 === undefined) k2 = k;
7837
- o[k2] = m[k];
7838
- }));
7839
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
7840
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
7841
- };
7842
- Object.defineProperty(exports, "__esModule", ({ value: true }));
7843
- exports.validateConfig = void 0;
7844
- const types_1 = __nccwpck_require__(1523);
7845
- __exportStar(__nccwpck_require__(1523), exports);
7846
- function validateConfig(config, guard) {
7847
- const result = guard.safeParse(config);
7848
- if (!result.success) {
7849
- throw new types_1.ConnectorError(types_1.ConnectorErrorCodes.InvalidConfig, result.error);
7850
- }
7851
- }
7852
- exports.validateConfig = validateConfig;
7853
-
7854
-
7855
- /***/ }),
7856
-
7857
- /***/ 1523:
7858
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
7859
-
7860
-
7861
- Object.defineProperty(exports, "__esModule", ({ value: true }));
7862
- exports.messageTypesGuard = exports.MessageTypes = exports.ConnectorError = exports.ConnectorErrorCodes = exports.ConnectorPlatform = exports.ConnectorType = void 0;
7863
- const zod_1 = __nccwpck_require__(4786);
7864
- // MARK: Foundation
7865
- var ConnectorType;
7866
- (function (ConnectorType) {
7867
- ConnectorType["Email"] = "Email";
7868
- ConnectorType["Sms"] = "Sms";
7869
- ConnectorType["Social"] = "Social";
7870
- })(ConnectorType = exports.ConnectorType || (exports.ConnectorType = {}));
7871
- var ConnectorPlatform;
7872
- (function (ConnectorPlatform) {
7873
- ConnectorPlatform["Native"] = "Native";
7874
- ConnectorPlatform["Universal"] = "Universal";
7875
- ConnectorPlatform["Web"] = "Web";
7876
- })(ConnectorPlatform = exports.ConnectorPlatform || (exports.ConnectorPlatform = {}));
7877
- var ConnectorErrorCodes;
7878
- (function (ConnectorErrorCodes) {
7879
- ConnectorErrorCodes["General"] = "general";
7880
- ConnectorErrorCodes["InvalidMetadata"] = "invalid_metadata";
7881
- ConnectorErrorCodes["UnexpectedType"] = "unexpected_type";
7882
- ConnectorErrorCodes["InvalidConfigGuard"] = "invalid_config_guard";
7883
- ConnectorErrorCodes["InsufficientRequestParameters"] = "insufficient_request_parameters";
7884
- ConnectorErrorCodes["InvalidConfig"] = "invalid_config";
7885
- ConnectorErrorCodes["InvalidResponse"] = "invalid_response";
7886
- ConnectorErrorCodes["TemplateNotFound"] = "template_not_found";
7887
- ConnectorErrorCodes["NotImplemented"] = "not_implemented";
7888
- ConnectorErrorCodes["SocialAuthCodeInvalid"] = "social_auth_code_invalid";
7889
- ConnectorErrorCodes["SocialAccessTokenInvalid"] = "social_invalid_access_token";
7890
- ConnectorErrorCodes["SocialIdTokenInvalid"] = "social_invalid_id_token";
7891
- ConnectorErrorCodes["AuthorizationFailed"] = "authorization_failed";
7892
- })(ConnectorErrorCodes = exports.ConnectorErrorCodes || (exports.ConnectorErrorCodes = {}));
7893
- class ConnectorError extends Error {
7894
- constructor(code, data) {
7895
- const message = typeof data === 'string' ? data : 'Connector error occurred.';
7896
- super(message);
7897
- this.code = code;
7898
- this.data = typeof data === 'string' ? { message: data } : data;
7899
- }
7900
- }
7901
- exports.ConnectorError = ConnectorError;
7902
- var MessageTypes;
7903
- (function (MessageTypes) {
7904
- MessageTypes["SignIn"] = "SignIn";
7905
- MessageTypes["Register"] = "Register";
7906
- MessageTypes["ForgotPassword"] = "ForgotPassword";
7907
- MessageTypes["Test"] = "Test";
7908
- })(MessageTypes = exports.MessageTypes || (exports.MessageTypes = {}));
7909
- exports.messageTypesGuard = zod_1.z.nativeEnum(MessageTypes);
7910
-
7911
-
7912
8137
  /***/ }),
7913
8138
 
7914
8139
  /***/ 87:
@@ -7917,7 +8142,7 @@ exports.messageTypesGuard = zod_1.z.nativeEnum(MessageTypes);
7917
8142
 
7918
8143
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7919
8144
  exports.defaultTimeout = exports.defaultMetadata = exports.scope = exports.jwksUri = exports.accessTokenEndpoint = exports.authorizationEndpoint = exports.issuer = void 0;
7920
- const connector_core_1 = __nccwpck_require__(7271);
8145
+ const connector_core_1 = __nccwpck_require__(8697);
7921
8146
  // https://appleid.apple.com/.well-known/openid-configuration
7922
8147
  exports.issuer = 'https://appleid.apple.com';
7923
8148
  exports.authorizationEndpoint = `${exports.issuer}/auth/authorize`;
@@ -7957,7 +8182,7 @@ exports.defaultTimeout = 5000;
7957
8182
 
7958
8183
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7959
8184
  exports.dataGuard = exports.appleConfigGuard = void 0;
7960
- const zod_1 = __nccwpck_require__(4786);
8185
+ const zod_1 = __nccwpck_require__(8062);
7961
8186
  exports.appleConfigGuard = zod_1.z.object({
7962
8187
  clientId: zod_1.z.string(),
7963
8188
  });
@@ -8062,8 +8287,8 @@ var __webpack_exports__ = {};
8062
8287
  var exports = __webpack_exports__;
8063
8288
 
8064
8289
  Object.defineProperty(exports, "__esModule", ({ value: true }));
8065
- const connector_core_1 = __nccwpck_require__(7271);
8066
- const jose_1 = __nccwpck_require__(2325);
8290
+ const connector_core_1 = __nccwpck_require__(8697);
8291
+ const jose_1 = __nccwpck_require__(4974);
8067
8292
  const constant_1 = __nccwpck_require__(87);
8068
8293
  const types_1 = __nccwpck_require__(7760);
8069
8294
  // TO-DO: support nonce validation