@cauth/express 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +25 -28
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/express-BgF1jv36.d.ts +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import { RequestHandler } from "express";
|
|
1
|
+
import { NextFunction, Request, Response } from "express";
|
|
3
2
|
import z$1, { z } from "zod";
|
|
4
3
|
import ms from "ms";
|
|
5
4
|
|
|
@@ -40,7 +39,7 @@ type FNError = {
|
|
|
40
39
|
* @template T - The type of the value.
|
|
41
40
|
* @template E - The type of the errors, which must extend { type: string; error: Error }.
|
|
42
41
|
*/
|
|
43
|
-
type Result
|
|
42
|
+
type Result<T, E extends FNError = FNError> = {
|
|
44
43
|
success: true;
|
|
45
44
|
value: T;
|
|
46
45
|
} | {
|
|
@@ -176,31 +175,32 @@ declare const ChangePasswordSchema: z.ZodObject<{
|
|
|
176
175
|
type ChangePasswordSchemaType = z.infer<typeof ChangePasswordSchema>;
|
|
177
176
|
//#endregion
|
|
178
177
|
//#region ../core/src/cauth.d.ts
|
|
179
|
-
declare class _CAuth<T extends string[]> {
|
|
178
|
+
declare class _CAuth<T extends string[], TContractor extends RoutesContract<any> = RoutesContract<any>> {
|
|
180
179
|
#private;
|
|
181
180
|
constructor(config: Omit<CAuthOptions, 'roles'> & {
|
|
182
181
|
roles: T;
|
|
182
|
+
routeContractor: TContractor;
|
|
183
183
|
});
|
|
184
184
|
get RoleType(): T[number];
|
|
185
185
|
/**
|
|
186
|
-
* @description
|
|
187
|
-
*
|
|
188
|
-
* If 'roles' is empty it allows all authenticated users, without respecting specific role
|
|
189
|
-
*
|
|
190
|
-
* @default undefined
|
|
186
|
+
* @description Auth guard middleware — roles optional.
|
|
187
|
+
* Automatically typed as the handler type from the contractor (e.g. Express.RequestHandler).
|
|
191
188
|
*/
|
|
192
189
|
Guard: (roles?: Array<T[number]>) => (...args: any[]) => any;
|
|
190
|
+
/**
|
|
191
|
+
* Route Handlers — typed from the contractor automatically.
|
|
192
|
+
*/
|
|
193
193
|
Routes: {
|
|
194
|
-
Register: () =>
|
|
195
|
-
Login: () =>
|
|
196
|
-
Logout: () =>
|
|
197
|
-
Refresh: () =>
|
|
198
|
-
ChangePassword: (userId: string) =>
|
|
194
|
+
Register: () => ReturnType<TContractor["Register"]>;
|
|
195
|
+
Login: () => ReturnType<TContractor["Login"]>;
|
|
196
|
+
Logout: () => ReturnType<TContractor["Logout"]>;
|
|
197
|
+
Refresh: () => ReturnType<TContractor["Refresh"]>;
|
|
198
|
+
ChangePassword: (userId: string) => ReturnType<TContractor["ChangePassword"]>;
|
|
199
199
|
};
|
|
200
200
|
FN: {
|
|
201
201
|
Login: ({
|
|
202
202
|
...args
|
|
203
|
-
}: LoginSchemaType) => Promise<Result
|
|
203
|
+
}: LoginSchemaType) => Promise<Result<{
|
|
204
204
|
account: Account;
|
|
205
205
|
tokens: Tokens;
|
|
206
206
|
}>>;
|
|
@@ -212,10 +212,10 @@ declare class _CAuth<T extends string[]> {
|
|
|
212
212
|
}>>;
|
|
213
213
|
Logout: ({
|
|
214
214
|
...args
|
|
215
|
-
}: LogoutSchemaType) => Promise<Result<
|
|
215
|
+
}: LogoutSchemaType) => Promise<Result<unknown>>;
|
|
216
216
|
Refresh: ({
|
|
217
217
|
...args
|
|
218
|
-
}: RefreshTokenSchemaType) => Promise<Result
|
|
218
|
+
}: RefreshTokenSchemaType) => Promise<Result<{
|
|
219
219
|
account: Account;
|
|
220
220
|
tokens: Tokens;
|
|
221
221
|
}>>;
|
|
@@ -232,23 +232,19 @@ declare class _CAuth<T extends string[]> {
|
|
|
232
232
|
id: string;
|
|
233
233
|
code: string;
|
|
234
234
|
}>>;
|
|
235
|
-
LoginWithOTP: ({
|
|
236
|
-
...args
|
|
237
|
-
}: Omit<LoginSchemaType, "password"> & {
|
|
235
|
+
LoginWithOTP: (args: Omit<LoginSchemaType, "password"> & {
|
|
238
236
|
code: string;
|
|
239
237
|
}) => Promise<Result<{
|
|
240
238
|
account: Account;
|
|
241
239
|
tokens: Tokens;
|
|
242
240
|
}>>;
|
|
243
|
-
VerifyOTP: ({
|
|
244
|
-
...args
|
|
245
|
-
}: {
|
|
241
|
+
VerifyOTP: (args: {
|
|
246
242
|
id: string;
|
|
247
243
|
code: string;
|
|
248
244
|
otpPurpose: OtpPurpose;
|
|
249
|
-
}) => Promise<{
|
|
245
|
+
}) => Promise<Result<{
|
|
250
246
|
isValid: boolean;
|
|
251
|
-
}
|
|
247
|
+
}>>;
|
|
252
248
|
};
|
|
253
249
|
Tokens: {
|
|
254
250
|
GenerateRefreshToken: (payload: any) => Promise<string>;
|
|
@@ -257,8 +253,8 @@ declare class _CAuth<T extends string[]> {
|
|
|
257
253
|
accessToken: string;
|
|
258
254
|
refreshToken: string;
|
|
259
255
|
}>;
|
|
260
|
-
VerifyRefreshToken: <
|
|
261
|
-
VerifyAccessToken: <
|
|
256
|
+
VerifyRefreshToken: <R>(token: any) => Promise<R | null>;
|
|
257
|
+
VerifyAccessToken: <R>(token: any) => Promise<R | null>;
|
|
262
258
|
};
|
|
263
259
|
}
|
|
264
260
|
//#endregion
|
|
@@ -300,7 +296,8 @@ interface RoutesContract<THandler extends (...args: any[]) => any = (...args: an
|
|
|
300
296
|
}
|
|
301
297
|
//#endregion
|
|
302
298
|
//#region src/express.contractor.d.ts
|
|
303
|
-
|
|
299
|
+
type OptionalNextHandler = (req: Request, res: Response, next?: NextFunction) => any;
|
|
300
|
+
declare class ExpressContractor<THandler extends (...args: any[]) => any = OptionalNextHandler> implements RoutesContract<THandler> {
|
|
304
301
|
Register: ({
|
|
305
302
|
config,
|
|
306
303
|
tokens
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./express-BgF1jv36.d.ts";import e from"bcrypt";var t=Object.defineProperty,n=e=>{let n={};for(var r in e)t(n,r,{get:e[r],enumerable:!0});return n},r=class{static ServerError=`internal-server-error`;static ServerErrorMessage=`Internal server error. We are working to fix this, please try again later`;static InvalidToken=`invalid-token`;static InvalidTokenMessage=`Invalid Token`;static ForbiddenResource=`forbidden-resource`;static ForbiddenResourceMessage=`You don't have sufficient permission for this action`;static InvalidOtp=`invalid-otp`;static InvalidOtpMessage=`Invalid Otp. Please check and try again`;static CredentialMismatch=`credential-mismatch`;static CredentialMismatchMessage=`Credential mismatch. Please check your credentials and try again.`;static InvalidData=`invalid-data`;static InvalidDataMessage=e=>`Invalid Body: ${e}`;static AccountNotFound=`account-not-found`;static AccountNotFoundMessage=`Account not found`;static InvalidRole=`invalid-role`;static InvalidRoleMessage=e=>`Role is invalid, please use one of the following roles: ${e.join(`, `)}`;static InvalidRefreshToken=`invalid-refresh-token`;static InvalidRefreshTokenMessage=`Invalid refresh token`;static DuplicateAccount=`account-already-exists`;static DuplicateAccountMessage=`Account with this credentials already exists`};async function i(e){try{return{data:await e,error:null}}catch(e){return{data:null,error:e}}}function a({tokens:e,config:t,roles:n}){return async(a,o,s)=>{try{let c=a.cookies?.accessToken;if(!c){let e=a.headers.authorization;e?.startsWith(`Bearer `)&&(c=e.split(` `)[1])}if(!c)return o.status(401).send({code:r.InvalidToken});let l=await i(e.VerifyAccessToken(c));return l.error||!l.data?o.status(401).send({code:r.InvalidToken}):n&&!n.includes(l.data.role)||!t.roles.includes(l.data.role)?o.status(403).send({code:r.ForbiddenResource,message:r.ForbiddenResourceMessage}):(a.cauth={id:l.data.id,role:l.data.role},s())}catch{return o.status(500).send({code:r.ServerError})}}}const o=Object.freeze({status:`aborted`});function s(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}const c=Symbol(`zod_brand`);var l=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},u=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const d={};function f(e){return e&&Object.assign(d,e),d}var p=n({BIGINT_FORMAT_RANGES:()=>De,Class:()=>Ge,NUMBER_FORMAT_RANGES:()=>Ee,aborted:()=>T,allowsEval:()=>ve,assert:()=>ie,assertEqual:()=>ee,assertIs:()=>ne,assertNever:()=>re,assertNotEqual:()=>te,assignProp:()=>_,base64ToUint8Array:()=>ze,base64urlToUint8Array:()=>Ve,cached:()=>se,captureStackTrace:()=>_e,cleanEnum:()=>Re,cleanRegex:()=>ce,clone:()=>S,cloneDef:()=>fe,createTransparentProxy:()=>we,defineLazy:()=>g,esc:()=>ge,escapeRegex:()=>x,extend:()=>Ae,finalizeIssue:()=>D,floatSafeRemainder:()=>le,getElementAtPath:()=>pe,getEnumValues:()=>ae,getLengthableOrigin:()=>Le,getParsedType:()=>xe,getSizableOrigin:()=>Ie,hexToUint8Array:()=>Ue,isObject:()=>y,isPlainObject:()=>b,issue:()=>O,joinValues:()=>m,jsonStringifyReplacer:()=>oe,merge:()=>Me,mergeDefs:()=>v,normalizeParams:()=>C,nullish:()=>h,numKeys:()=>be,objectClone:()=>de,omit:()=>ke,optionalKeys:()=>Te,partial:()=>Ne,pick:()=>Oe,prefixIssues:()=>E,primitiveTypes:()=>Ce,promiseAllObject:()=>me,propertyKeyTypes:()=>Se,randomString:()=>he,required:()=>Pe,safeExtend:()=>je,shallowClone:()=>ye,stringifyPrimitive:()=>w,uint8ArrayToBase64:()=>Be,uint8ArrayToBase64url:()=>He,uint8ArrayToHex:()=>We,unwrapMessage:()=>Fe});function ee(e){return e}function te(e){return e}function ne(e){}function re(e){throw Error()}function ie(e){}function ae(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function m(e,t=`|`){return e.map(e=>w(e)).join(t)}function oe(e,t){return typeof t==`bigint`?t.toString():t}function se(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function h(e){return e==null}function ce(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function le(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}const ue=Symbol(`evaluating`);function g(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ue)return r===void 0&&(r=ue,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function de(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function _(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function v(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function fe(e){return v(e._zod.def)}function pe(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function me(e){let t=Object.keys(e),n=t.map(t=>e[t]);return Promise.all(n).then(e=>{let n={};for(let r=0;r<t.length;r++)n[t[r]]=e[r];return n})}function he(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function ge(e){return JSON.stringify(e)}const _e=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ve=se(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function b(e){if(y(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(y(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ye(e){return b(e)?{...e}:Array.isArray(e)?[...e]:e}function be(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const xe=e=>{let t=typeof e;switch(t){case`undefined`:return`undefined`;case`string`:return`string`;case`number`:return Number.isNaN(e)?`nan`:`number`;case`boolean`:return`boolean`;case`function`:return`function`;case`bigint`:return`bigint`;case`symbol`:return`symbol`;case`object`:return Array.isArray(e)?`array`:e===null?`null`:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?`promise`:typeof Map<`u`&&e instanceof Map?`map`:typeof Set<`u`&&e instanceof Set?`set`:typeof Date<`u`&&e instanceof Date?`date`:typeof File<`u`&&e instanceof File?`file`:`object`;default:throw Error(`Unknown data type: ${t}`)}},Se=new Set([`string`,`number`,`symbol`]),Ce=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function S(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function C(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function we(e){let t;return new Proxy({},{get(n,r,i){return t??=e(),Reflect.get(t,r,i)},set(n,r,i,a){return t??=e(),Reflect.set(t,r,i,a)},has(n,r){return t??=e(),Reflect.has(t,r)},deleteProperty(n,r){return t??=e(),Reflect.deleteProperty(t,r)},ownKeys(n){return t??=e(),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??=e(),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??=e(),Reflect.defineProperty(t,r,i)}})}function w(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Te(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Ee={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},De={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Oe(e,t){let n=e._zod.def;return S(e,v(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return _(this,`shape`,e),e},checks:[]}))}function ke(e,t){let n=e._zod.def;return S(e,v(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return _(this,`shape`,r),r},checks:[]}))}function Ae(e,t){if(!b(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return S(e,v(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return _(this,`shape`,n),n},checks:[]}))}function je(e,t){if(!b(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return S(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return _(this,`shape`,n),n},checks:e._zod.def.checks})}function Me(e,t){return S(e,v(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return _(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Ne(e,t,n){return S(t,v(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return _(this,`shape`,i),i},checks:[]}))}function Pe(e,t,n){return S(t,v(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return _(this,`shape`,i),i},checks:[]}))}function T(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function E(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Fe(e){return typeof e==`string`?e:e?.message}function D(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Fe(e.inst?._zod.def?.error?.(e))??Fe(t?.error?.(e))??Fe(n.customError?.(e))??Fe(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ie(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function Le(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function O(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Re(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function ze(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Be(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Ve(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return ze(t+`=`.repeat((4-t.length%4)%4))}function He(e){return Be(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Ue(e){let t=e.replace(/^0x/,``);if(t.length%2!=0)throw Error(`Invalid hex string length`);let n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=Number.parseInt(t.slice(e,e+2),16);return n}function We(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var Ge=class{constructor(...e){}};const Ke=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,oe,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},qe=s(`$ZodError`,Ke),k=s(`$ZodError`,Ke,{Parent:Error});function Je(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ye(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}function Xe(e,t=e=>e.message){let n={errors:[]},r=(e,i=[])=>{var a,o;for(let s of e.issues)if(s.code===`invalid_union`&&s.errors.length)s.errors.map(e=>r({issues:e},s.path));else if(s.code===`invalid_key`)r({issues:s.issues},s.path);else if(s.code===`invalid_element`)r({issues:s.issues},s.path);else{let e=[...i,...s.path];if(e.length===0){n.errors.push(t(s));continue}let r=n,c=0;for(;c<e.length;){let n=e[c],i=c===e.length-1;typeof n==`string`?(r.properties??={},(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??=[],(o=r.items)[n]??(o[n]={errors:[]}),r=r.items[n]),i&&r.errors.push(t(s)),c++}}};return r(e),n}function Ze(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Qe(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Ze(e.path)}`);return t.join(`
|
|
1
|
+
import e from"bcrypt";var t=Object.defineProperty,n=e=>{let n={};for(var r in e)t(n,r,{get:e[r],enumerable:!0});return n},r=class{static ServerError=`internal-server-error`;static ServerErrorMessage=`Internal server error. We are working to fix this, please try again later`;static InvalidToken=`invalid-token`;static InvalidTokenMessage=`Invalid Token`;static ForbiddenResource=`forbidden-resource`;static ForbiddenResourceMessage=`You don't have sufficient permission for this action`;static InvalidOtp=`invalid-otp`;static InvalidOtpMessage=`Invalid Otp. Please check and try again`;static CredentialMismatch=`credential-mismatch`;static CredentialMismatchMessage=`Credential mismatch. Please check your credentials and try again.`;static InvalidData=`invalid-data`;static InvalidDataMessage=e=>`Invalid Body: ${e}`;static AccountNotFound=`account-not-found`;static AccountNotFoundMessage=`Account not found`;static InvalidRole=`invalid-role`;static InvalidRoleMessage=e=>`Role is invalid, please use one of the following roles: ${e.join(`, `)}`;static InvalidRefreshToken=`invalid-refresh-token`;static InvalidRefreshTokenMessage=`Invalid refresh token`;static DuplicateAccount=`account-already-exists`;static DuplicateAccountMessage=`Account with this credentials already exists`};async function i(e){try{return{data:await e,error:null}}catch(e){return{data:null,error:e}}}function a({tokens:e,config:t,roles:n}){return async(a,o,s)=>{try{let c=a.cookies?.accessToken;if(!c){let e=a.headers.authorization;e?.startsWith(`Bearer `)&&(c=e.split(` `)[1])}if(!c)return o.status(401).send({code:r.InvalidToken});let l=await i(e.VerifyAccessToken(c));return l.error||!l.data?o.status(401).send({code:r.InvalidToken}):n&&!n.includes(l.data.role)||!t.roles.includes(l.data.role)?o.status(403).send({code:r.ForbiddenResource,message:r.ForbiddenResourceMessage}):(a.cauth={id:l.data.id,role:l.data.role},s())}catch{return o.status(500).send({code:r.ServerError})}}}const o=Object.freeze({status:`aborted`});function s(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}const c=Symbol(`zod_brand`);var l=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},u=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const d={};function f(e){return e&&Object.assign(d,e),d}var p=n({BIGINT_FORMAT_RANGES:()=>De,Class:()=>Ge,NUMBER_FORMAT_RANGES:()=>Ee,aborted:()=>T,allowsEval:()=>ve,assert:()=>ie,assertEqual:()=>ee,assertIs:()=>ne,assertNever:()=>re,assertNotEqual:()=>te,assignProp:()=>_,base64ToUint8Array:()=>ze,base64urlToUint8Array:()=>Ve,cached:()=>se,captureStackTrace:()=>_e,cleanEnum:()=>Re,cleanRegex:()=>ce,clone:()=>S,cloneDef:()=>fe,createTransparentProxy:()=>we,defineLazy:()=>g,esc:()=>ge,escapeRegex:()=>x,extend:()=>Ae,finalizeIssue:()=>D,floatSafeRemainder:()=>le,getElementAtPath:()=>pe,getEnumValues:()=>ae,getLengthableOrigin:()=>Le,getParsedType:()=>xe,getSizableOrigin:()=>Ie,hexToUint8Array:()=>Ue,isObject:()=>y,isPlainObject:()=>b,issue:()=>O,joinValues:()=>m,jsonStringifyReplacer:()=>oe,merge:()=>Me,mergeDefs:()=>v,normalizeParams:()=>C,nullish:()=>h,numKeys:()=>be,objectClone:()=>de,omit:()=>ke,optionalKeys:()=>Te,partial:()=>Ne,pick:()=>Oe,prefixIssues:()=>E,primitiveTypes:()=>Ce,promiseAllObject:()=>me,propertyKeyTypes:()=>Se,randomString:()=>he,required:()=>Pe,safeExtend:()=>je,shallowClone:()=>ye,stringifyPrimitive:()=>w,uint8ArrayToBase64:()=>Be,uint8ArrayToBase64url:()=>He,uint8ArrayToHex:()=>We,unwrapMessage:()=>Fe});function ee(e){return e}function te(e){return e}function ne(e){}function re(e){throw Error()}function ie(e){}function ae(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function m(e,t=`|`){return e.map(e=>w(e)).join(t)}function oe(e,t){return typeof t==`bigint`?t.toString():t}function se(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function h(e){return e==null}function ce(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function le(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}const ue=Symbol(`evaluating`);function g(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ue)return r===void 0&&(r=ue,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function de(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function _(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function v(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function fe(e){return v(e._zod.def)}function pe(e,t){return t?t.reduce((e,t)=>e?.[t],e):e}function me(e){let t=Object.keys(e),n=t.map(t=>e[t]);return Promise.all(n).then(e=>{let n={};for(let r=0;r<t.length;r++)n[t[r]]=e[r];return n})}function he(e=10){let t=``;for(let n=0;n<e;n++)t+=`abcdefghijklmnopqrstuvwxyz`[Math.floor(Math.random()*26)];return t}function ge(e){return JSON.stringify(e)}const _e=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function y(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ve=se(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function b(e){if(y(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(y(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ye(e){return b(e)?{...e}:Array.isArray(e)?[...e]:e}function be(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const xe=e=>{let t=typeof e;switch(t){case`undefined`:return`undefined`;case`string`:return`string`;case`number`:return Number.isNaN(e)?`nan`:`number`;case`boolean`:return`boolean`;case`function`:return`function`;case`bigint`:return`bigint`;case`symbol`:return`symbol`;case`object`:return Array.isArray(e)?`array`:e===null?`null`:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?`promise`:typeof Map<`u`&&e instanceof Map?`map`:typeof Set<`u`&&e instanceof Set?`set`:typeof Date<`u`&&e instanceof Date?`date`:typeof File<`u`&&e instanceof File?`file`:`object`;default:throw Error(`Unknown data type: ${t}`)}},Se=new Set([`string`,`number`,`symbol`]),Ce=new Set([`string`,`number`,`bigint`,`boolean`,`symbol`,`undefined`]);function x(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function S(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function C(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function we(e){let t;return new Proxy({},{get(n,r,i){return t??=e(),Reflect.get(t,r,i)},set(n,r,i,a){return t??=e(),Reflect.set(t,r,i,a)},has(n,r){return t??=e(),Reflect.has(t,r)},deleteProperty(n,r){return t??=e(),Reflect.deleteProperty(t,r)},ownKeys(n){return t??=e(),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??=e(),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,i){return t??=e(),Reflect.defineProperty(t,r,i)}})}function w(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Te(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Ee={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},De={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Oe(e,t){let n=e._zod.def;return S(e,v(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return _(this,`shape`,e),e},checks:[]}))}function ke(e,t){let n=e._zod.def;return S(e,v(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return _(this,`shape`,r),r},checks:[]}))}function Ae(e,t){if(!b(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return S(e,v(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return _(this,`shape`,n),n},checks:[]}))}function je(e,t){if(!b(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return S(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return _(this,`shape`,n),n},checks:e._zod.def.checks})}function Me(e,t){return S(e,v(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return _(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Ne(e,t,n){return S(t,v(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return _(this,`shape`,i),i},checks:[]}))}function Pe(e,t,n){return S(t,v(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return _(this,`shape`,i),i},checks:[]}))}function T(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function E(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Fe(e){return typeof e==`string`?e:e?.message}function D(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Fe(e.inst?._zod.def?.error?.(e))??Fe(t?.error?.(e))??Fe(n.customError?.(e))??Fe(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ie(e){return e instanceof Set?`set`:e instanceof Map?`map`:e instanceof File?`file`:`unknown`}function Le(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function O(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Re(e){return Object.entries(e).filter(([e,t])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function ze(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Be(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Ve(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`);return ze(t+`=`.repeat((4-t.length%4)%4))}function He(e){return Be(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function Ue(e){let t=e.replace(/^0x/,``);if(t.length%2!=0)throw Error(`Invalid hex string length`);let n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e/2]=Number.parseInt(t.slice(e,e+2),16);return n}function We(e){return Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``)}var Ge=class{constructor(...e){}};const Ke=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,oe,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},qe=s(`$ZodError`,Ke),k=s(`$ZodError`,Ke,{Parent:Error});function Je(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ye(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}function Xe(e,t=e=>e.message){let n={errors:[]},r=(e,i=[])=>{var a,o;for(let s of e.issues)if(s.code===`invalid_union`&&s.errors.length)s.errors.map(e=>r({issues:e},s.path));else if(s.code===`invalid_key`)r({issues:s.issues},s.path);else if(s.code===`invalid_element`)r({issues:s.issues},s.path);else{let e=[...i,...s.path];if(e.length===0){n.errors.push(t(s));continue}let r=n,c=0;for(;c<e.length;){let n=e[c],i=c===e.length-1;typeof n==`string`?(r.properties??={},(a=r.properties)[n]??(a[n]={errors:[]}),r=r.properties[n]):(r.items??=[],(o=r.items)[n]??(o[n]={errors:[]}),r=r.items[n]),i&&r.errors.push(t(s)),c++}}};return r(e),n}function Ze(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Qe(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Ze(e.path)}`);return t.join(`
|
|
2
2
|
`)}const $e=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new l;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>D(e,a,f())));throw _e(t,i?.callee),t}return o.value},et=$e(k),tt=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>D(e,a,f())));throw _e(t,i?.callee),t}return o.value},nt=tt(k),rt=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new l;return a.issues.length?{success:!1,error:new(e??qe)(a.issues.map(e=>D(e,i,f())))}:{success:!0,data:a.value}},it=rt(k),at=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>D(e,i,f())))}:{success:!0,data:a.value}},ot=at(k),st=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return $e(e)(t,n,i)},ct=st(k),lt=e=>(t,n,r)=>$e(e)(t,n,r),ut=lt(k),dt=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return tt(e)(t,n,i)},ft=dt(k),pt=e=>async(t,n,r)=>tt(e)(t,n,r),mt=pt(k),ht=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return rt(e)(t,n,i)},gt=ht(k),_t=e=>(t,n,r)=>rt(e)(t,n,r),vt=_t(k),yt=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return at(e)(t,n,i)},bt=yt(k),xt=e=>async(t,n,r)=>at(e)(t,n,r),St=xt(k);var Ct=n({base64:()=>qt,base64url:()=>Jt,bigint:()=>an,boolean:()=>cn,browserEmail:()=>Vt,cidrv4:()=>Gt,cidrv6:()=>Kt,cuid:()=>wt,cuid2:()=>Tt,date:()=>$t,datetime:()=>nn,domain:()=>Xt,duration:()=>At,e164:()=>Zt,email:()=>It,emoji:()=>Ht,extendedDuration:()=>jt,guid:()=>Mt,hex:()=>pn,hostname:()=>Yt,html5Email:()=>Lt,idnEmail:()=>Bt,integer:()=>on,ipv4:()=>Ut,ipv6:()=>Wt,ksuid:()=>Ot,lowercase:()=>dn,md5_base64:()=>_n,md5_base64url:()=>vn,md5_hex:()=>gn,nanoid:()=>kt,null:()=>ln,number:()=>sn,rfc5322Email:()=>Rt,sha1_base64:()=>bn,sha1_base64url:()=>xn,sha1_hex:()=>yn,sha256_base64:()=>Cn,sha256_base64url:()=>wn,sha256_hex:()=>Sn,sha384_base64:()=>En,sha384_base64url:()=>Dn,sha384_hex:()=>Tn,sha512_base64:()=>kn,sha512_base64url:()=>An,sha512_hex:()=>On,string:()=>rn,time:()=>tn,ulid:()=>Et,undefined:()=>un,unicodeEmail:()=>zt,uppercase:()=>fn,uuid:()=>A,uuid4:()=>Nt,uuid6:()=>Pt,uuid7:()=>Ft,xid:()=>Dt});const wt=/^[cC][^\s-]{8,}$/,Tt=/^[0-9a-z]+$/,Et=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Dt=/^[0-9a-vA-V]{20}$/,Ot=/^[A-Za-z0-9]{27}$/,kt=/^[a-zA-Z0-9_-]{21}$/,At=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,jt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Mt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,A=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Nt=A(4),Pt=A(6),Ft=A(7),It=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Lt=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Rt=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,zt=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Bt=zt,Vt=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;function Ht(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const Ut=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Wt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Gt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Kt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jt=/^[A-Za-z0-9_-]*$/,Yt=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Xt=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Zt=/^\+(?:[0-9]){6,14}[0-9]$/,Qt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,$t=RegExp(`^${Qt}$`);function en(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tn(e){return RegExp(`^${en(e)}$`)}function nn(e){let t=en({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Qt}T(?:${r})$`)}const rn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},an=/^-?\d+n?$/,on=/^-?\d+$/,sn=/^-?\d+(?:\.\d+)?/,cn=/^(?:true|false)$/i,ln=/^null$/i,un=/^undefined$/i,dn=/^[^A-Z]*$/,fn=/^[^a-z]*$/,pn=/^[0-9a-fA-F]*$/;function mn(e,t){return RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function hn(e){return RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const gn=/^[0-9a-fA-F]{32}$/,_n=mn(22,`==`),vn=hn(22),yn=/^[0-9a-fA-F]{40}$/,bn=mn(27,`=`),xn=hn(27),Sn=/^[0-9a-fA-F]{64}$/,Cn=mn(43,`=`),wn=hn(43),Tn=/^[0-9a-fA-F]{96}$/,En=mn(64,``),Dn=hn(64),On=/^[0-9a-fA-F]{128}$/,kn=mn(86,`==`),An=hn(86),j=s(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jn={number:`number`,bigint:`bigint`,object:`date`},Mn=s(`$ZodCheckLessThan`,(e,t)=>{j.init(e,t);let n=jn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Nn=s(`$ZodCheckGreaterThan`,(e,t)=>{j.init(e,t);let n=jn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pn=s(`$ZodCheckMultipleOf`,(e,t)=>{j.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):le(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Fn=s(`$ZodCheckNumberFormat`,(e,t)=>{j.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ee[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=on)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),In=s(`$ZodCheckBigIntFormat`,(e,t)=>{j.init(e,t);let[n,r]=De[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=n,i.maximum=r}),e._zod.check=i=>{let a=i.value;a<n&&i.issues.push({origin:`bigint`,input:a,code:`too_small`,minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>r&&i.issues.push({origin:`bigint`,input:a,code:`too_big`,maximum:r,inst:e})}}),Ln=s(`$ZodCheckMaxSize`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;r.size<=t.maximum||n.issues.push({origin:Ie(r),code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Rn=s(`$ZodCheckMinSize`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;r.size>=t.minimum||n.issues.push({origin:Ie(r),code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),zn=s(`$ZodCheckSizeEquals`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.size!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=n=>{let r=n.value,i=r.size;if(i===t.size)return;let a=i>t.size;n.issues.push({origin:Ie(r),...a?{code:`too_big`,maximum:t.size}:{code:`too_small`,minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Bn=s(`$ZodCheckMaxLength`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Le(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Vn=s(`$ZodCheckMinLength`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Le(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Hn=s(`$ZodCheckLengthEquals`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!h(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Le(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Un=s(`$ZodCheckStringFormat`,(e,t)=>{var n,r;j.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Wn=s(`$ZodCheckRegex`,(e,t)=>{Un.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Gn=s(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=dn,Un.init(e,t)}),Kn=s(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=fn,Un.init(e,t)}),qn=s(`$ZodCheckIncludes`,(e,t)=>{j.init(e,t);let n=x(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Jn=s(`$ZodCheckStartsWith`,(e,t)=>{j.init(e,t);let n=RegExp(`^${x(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Yn=s(`$ZodCheckEndsWith`,(e,t)=>{j.init(e,t);let n=RegExp(`.*${x(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function Xn(e,t,n){e.issues.length&&t.issues.push(...E(n,e.issues))}const Zn=s(`$ZodCheckProperty`,(e,t)=>{j.init(e,t),e._zod.check=e=>{let n=t.schema._zod.run({value:e.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(n=>Xn(n,e,t.property));Xn(n,e,t.property)}}),Qn=s(`$ZodCheckMimeType`,(e,t)=>{j.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:`invalid_value`,values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),$n=s(`$ZodCheckOverwrite`,(e,t)=>{j.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var er=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
3
3
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
4
4
|
`))}};const tr={major:4,minor:1,patch:12},M=s(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=tr;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=T(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new l;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=T(e,t))});else{if(e.issues.length===t)continue;r||=T(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(T(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new l;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new l;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=it(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return ot(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),nr=s(`$ZodString`,(e,t)=>{M.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??rn(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),N=s(`$ZodStringFormat`,(e,t)=>{Un.init(e,t),nr.init(e,t)}),rr=s(`$ZodGUID`,(e,t)=>{t.pattern??=Mt,N.init(e,t)}),ir=s(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=A(e)}else t.pattern??=A();N.init(e,t)}),ar=s(`$ZodEmail`,(e,t)=>{t.pattern??=It,N.init(e,t)}),or=s(`$ZodURL`,(e,t)=>{N.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:Yt.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),sr=s(`$ZodEmoji`,(e,t)=>{t.pattern??=Ht(),N.init(e,t)}),cr=s(`$ZodNanoID`,(e,t)=>{t.pattern??=kt,N.init(e,t)}),lr=s(`$ZodCUID`,(e,t)=>{t.pattern??=wt,N.init(e,t)}),ur=s(`$ZodCUID2`,(e,t)=>{t.pattern??=Tt,N.init(e,t)}),dr=s(`$ZodULID`,(e,t)=>{t.pattern??=Et,N.init(e,t)}),fr=s(`$ZodXID`,(e,t)=>{t.pattern??=Dt,N.init(e,t)}),pr=s(`$ZodKSUID`,(e,t)=>{t.pattern??=Ot,N.init(e,t)}),mr=s(`$ZodISODateTime`,(e,t)=>{t.pattern??=nn(t),N.init(e,t)}),hr=s(`$ZodISODate`,(e,t)=>{t.pattern??=$t,N.init(e,t)}),gr=s(`$ZodISOTime`,(e,t)=>{t.pattern??=tn(t),N.init(e,t)}),_r=s(`$ZodISODuration`,(e,t)=>{t.pattern??=At,N.init(e,t)}),vr=s(`$ZodIPv4`,(e,t)=>{t.pattern??=Ut,N.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),yr=s(`$ZodIPv6`,(e,t)=>{t.pattern??=Wt,N.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),br=s(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Gt,N.init(e,t)}),xr=s(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Kt,N.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Sr(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Cr=s(`$ZodBase64`,(e,t)=>{t.pattern??=qt,N.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{Sr(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function wr(e){if(!Jt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Sr(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Tr=s(`$ZodBase64URL`,(e,t)=>{t.pattern??=Jt,N.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{wr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Er=s(`$ZodE164`,(e,t)=>{t.pattern??=Zt,N.init(e,t)});function Dr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const Or=s(`$ZodJWT`,(e,t)=>{N.init(e,t),e._zod.check=n=>{Dr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),kr=s(`$ZodCustomStringFormat`,(e,t)=>{N.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:`invalid_format`,format:t.format,input:n.value,inst:e,continue:!t.abort})}}),Ar=s(`$ZodNumber`,(e,t)=>{M.init(e,t),e._zod.pattern=e._zod.bag.pattern??sn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),jr=s(`$ZodNumber`,(e,t)=>{Fn.init(e,t),Ar.init(e,t)}),Mr=s(`$ZodBoolean`,(e,t)=>{M.init(e,t),e._zod.pattern=cn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Nr=s(`$ZodBigInt`,(e,t)=>{M.init(e,t),e._zod.pattern=an,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value==`bigint`||n.issues.push({expected:`bigint`,code:`invalid_type`,input:n.value,inst:e}),n}}),Pr=s(`$ZodBigInt`,(e,t)=>{In.init(e,t),Nr.init(e,t)}),Fr=s(`$ZodSymbol`,(e,t)=>{M.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return typeof r==`symbol`||t.issues.push({expected:`symbol`,code:`invalid_type`,input:r,inst:e}),t}}),Ir=s(`$ZodUndefined`,(e,t)=>{M.init(e,t),e._zod.pattern=un,e._zod.values=new Set([void 0]),e._zod.optin=`optional`,e._zod.optout=`optional`,e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),Lr=s(`$ZodNull`,(e,t)=>{M.init(e,t),e._zod.pattern=ln,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Rr=s(`$ZodAny`,(e,t)=>{M.init(e,t),e._zod.parse=e=>e}),zr=s(`$ZodUnknown`,(e,t)=>{M.init(e,t),e._zod.parse=e=>e}),Br=s(`$ZodNever`,(e,t)=>{M.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),Vr=s(`$ZodVoid`,(e,t)=>{M.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`void`,code:`invalid_type`,input:r,inst:e}),t}}),Hr=s(`$ZodDate`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let i=n.value,a=i instanceof Date;return a&&!Number.isNaN(i.getTime())||n.issues.push({expected:`date`,code:`invalid_type`,input:i,...a?{received:`Invalid Date`}:{},inst:e}),n}});function Ur(e,t,n){e.issues.length&&t.issues.push(...E(n,e.issues)),t.value[n]=e.value}const Wr=s(`$ZodArray`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Ur(t,n,e))):Ur(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Gr(e,t,n,r){e.issues.length&&t.issues.push(...E(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Kr(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Te(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function qr(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i of Object.keys(t)){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Gr(e,n,i,t))):Gr(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const Jr=s(`$ZodObject`,(e,t)=>{if(M.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=se(()=>Kr(t));g(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=y,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>Gr(n,t,e,s))):Gr(n,t,e,s)}return i?qr(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Yr=s(`$ZodObjectJIT`,(e,t)=>{Jr.init(e,t);let n=e._zod.parse,r=se(()=>Kr(t)),i=e=>{let t=new er([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=ge(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=ge(e);t.write(`const ${n} = ${i(e)};`),t.write(`
|
package/package.json
CHANGED