@better-auth/electron 1.5.7-beta.1 → 1.6.0

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.
@@ -306,6 +306,14 @@ type Where = {
306
306
  * @default AND
307
307
  */
308
308
  connector?: ("AND" | "OR") | undefined;
309
+ /**
310
+ * Case sensitivity for string comparisons.
311
+ * When "insensitive", string equality and pattern matching (contains, starts_with, ends_with)
312
+ * will be case-insensitive. Only applies to string values.
313
+ *
314
+ * @default "sensitive"
315
+ */
316
+ mode?: "sensitive" | "insensitive" | undefined;
309
317
  };
310
318
  /**
311
319
  * JoinOption configuration for relational queries.
@@ -3934,97 +3942,14 @@ type BaseAccount = z.infer<typeof accountSchema>;
3934
3942
  */
3935
3943
  type Account<DBOptions extends BetterAuthOptions["account"] = BetterAuthOptions["account"], Plugins extends BetterAuthOptions["plugins"] = BetterAuthOptions["plugins"]> = Prettify$1<BaseAccount & InferDBFieldsFromOptions<DBOptions> & InferDBFieldsFromPlugins<"account", Plugins>>; //#endregion
3936
3944
  //#endregion
3937
- //#region ../../node_modules/.pnpm/better-call@2.0.2_zod@4.3.6/node_modules/better-call/dist/cookies.d.mts
3938
- //#region src/cookies.d.ts
3939
- type CookiePrefixOptions = "host" | "secure";
3940
- type CookieOptions = {
3941
- /**
3942
- * Domain of the cookie
3943
- *
3944
- * The Domain attribute specifies which server can receive a cookie. If specified, cookies are
3945
- * available on the specified server and its subdomains. If the it is not
3946
- * specified, the cookies are available on the server that sets it but not on
3947
- * its subdomains.
3948
- *
3949
- * @example
3950
- * `domain: "example.com"`
3951
- */
3952
- domain?: string;
3953
- /**
3954
- * A lifetime of a cookie. Permanent cookies are deleted after the date specified in the
3955
- * Expires attribute:
3956
- *
3957
- * Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and
3958
- * takes precedence when both are set. The rationale behind this is that when you set an
3959
- * Expires date and time, they're relative to the client the cookie is being set on. If the
3960
- * server is set to a different time, this could cause errors
3961
- */
3962
- expires?: Date;
3963
- /**
3964
- * Forbids JavaScript from accessing the cookie, for example, through the Document.cookie
3965
- * property. Note that a cookie that has been created with HttpOnly will still be sent with
3966
- * JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().
3967
- * This mitigates attacks against cross-site scripting
3968
- */
3969
- httpOnly?: boolean;
3970
- /**
3971
- * Indicates the number of seconds until the cookie expires. A zero or negative number will
3972
- * expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.
3973
- *
3974
- * @example 604800 - 7 days
3975
- */
3976
- maxAge?: number;
3977
- /**
3978
- * Indicates the path that must exist in the requested URL for the browser to send the Cookie
3979
- * header.
3980
- *
3981
- * @example
3982
- * "/docs"
3983
- * // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.
3984
- */
3985
- path?: string;
3986
- /**
3987
- * Indicates that the cookie is sent to the server only when a request is made with the https:
3988
- * scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.
3989
- */
3990
- secure?: boolean;
3991
- /**
3992
- * Controls whether or not a cookie is sent with cross-site requests, providing some protection
3993
- * against cross-site request forgery attacks (CSRF).
3994
- *
3995
- * Strict - Means that the browser sends the cookie only for same-site requests, that is,
3996
- * requests originating from the same site that set the cookie. If a request originates from a
3997
- * different domain or scheme (even with the same domain), no cookies with the SameSite=Strict
3998
- * attribute are sent.
3999
- *
4000
- * Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load
4001
- * images or frames, but is sent when a user is navigating to the origin site from an external
4002
- * site (for example, when following a link). This is the default behavior if the SameSite
4003
- * attribute is not specified.
4004
- *
4005
- * None - Means that the browser sends the cookie with both cross-site and same-site requests.
4006
- * The Secure attribute must also be set when setting this value.
4007
- */
4008
- sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
4009
- /**
4010
- * Indicates that the cookie should be stored using partitioned storage. Note that if this is
4011
- * set, the Secure directive must also be set.
4012
- *
4013
- * @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
4014
- */
4015
- partitioned?: boolean;
4016
- /**
4017
- * Cooke Prefix
4018
- *
4019
- * - secure: `__Secure-` -> `__Secure-cookie-name`
4020
- * - host: `__Host-` -> `__Host-cookie-name`
4021
- *
4022
- * `secure` must be set to true to use prefixes
4023
- */
4024
- prefix?: CookiePrefixOptions;
4025
- };
3945
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/helper.d.mts
3946
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
3947
+ type IsEmptyObject<T> = keyof T extends never ? true : false;
3948
+ type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
3949
+ type InferParamPath<Path> = Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}:${infer Param}` ? { [K in Param]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamPath<Rest> : {};
3950
+ type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/${infer Rest}` | `${infer _Start}/**:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}/*` ? { [K in "_"]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamWildCard<Rest> : {}; //#endregion
4026
3951
  //#endregion
4027
- //#region ../../node_modules/.pnpm/better-call@2.0.2_zod@4.3.6/node_modules/better-call/dist/standard-schema.d.mts
3952
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/standard-schema.d.mts
4028
3953
  //#region src/standard-schema.d.ts
4029
3954
  /** The Standard Schema interface. */
4030
3955
  interface StandardSchemaV1$1<Input = unknown, Output = Input> {
@@ -4082,7 +4007,7 @@ declare namespace StandardSchemaV1$1 {
4082
4007
  type InferOutput<Schema extends StandardSchemaV1$1> = NonNullable<Schema["~standard"]["types"]>["output"];
4083
4008
  } //#endregion
4084
4009
  //#endregion
4085
- //#region ../../node_modules/.pnpm/better-call@2.0.2_zod@4.3.6/node_modules/better-call/dist/error.d.mts
4010
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/error.d.mts
4086
4011
  declare const statusCodes: {
4087
4012
  OK: number;
4088
4013
  CREATED: number;
@@ -4160,284 +4085,341 @@ declare const APIError: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "
4160
4085
  errorStack: string | undefined;
4161
4086
  }; //#endregion
4162
4087
  //#endregion
4163
- //#region ../../node_modules/.pnpm/better-call@2.0.2_zod@4.3.6/node_modules/better-call/dist/helper.d.mts
4164
- type Prettify<T> = 0 extends 1 & T ? any : { [K in keyof T]: T[K] } & {};
4165
- type IsEmptyObject<T> = keyof T extends never ? true : false;
4166
- type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
4167
- type InferParamPath<Path> = Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}:${infer Param}` ? { [K in Param]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamPath<Rest> : {};
4168
- type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/${infer Rest}` | `${infer _Start}/**:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}/*` ? { [K in "_"]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamWildCard<Rest> : {}; //#endregion
4169
- //#endregion
4170
- //#region ../../node_modules/.pnpm/better-call@2.0.2_zod@4.3.6/node_modules/better-call/dist/middleware.d.mts
4171
- //#region src/middleware.d.ts
4172
- type MiddlewareContext<Context = {}> = {
4088
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/cookies.d.mts
4089
+ //#region src/cookies.d.ts
4090
+ type CookiePrefixOptions = "host" | "secure";
4091
+ type CookieOptions = {
4173
4092
  /**
4174
- * Method
4093
+ * Domain of the cookie
4175
4094
  *
4176
- * The request method
4177
- */
4178
- method: string;
4179
- /**
4180
- * Path
4095
+ * The Domain attribute specifies which server can receive a cookie. If specified, cookies are
4096
+ * available on the specified server and its subdomains. If the it is not
4097
+ * specified, the cookies are available on the server that sets it but not on
4098
+ * its subdomains.
4181
4099
  *
4182
- * The path of the endpoint
4100
+ * @example
4101
+ * `domain: "example.com"`
4183
4102
  */
4184
- path: string;
4103
+ domain?: string;
4185
4104
  /**
4186
- * Body
4105
+ * A lifetime of a cookie. Permanent cookies are deleted after the date specified in the
4106
+ * Expires attribute:
4187
4107
  *
4188
- * The body object will be the parsed JSON from the request and validated
4189
- * against the body schema if it exists
4108
+ * Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and
4109
+ * takes precedence when both are set. The rationale behind this is that when you set an
4110
+ * Expires date and time, they're relative to the client the cookie is being set on. If the
4111
+ * server is set to a different time, this could cause errors
4190
4112
  */
4191
- body: any;
4113
+ expires?: Date;
4192
4114
  /**
4193
- * Query
4194
- *
4195
- * The query object will be the parsed query string from the request
4196
- * and validated against the query schema if it exists
4115
+ * Forbids JavaScript from accessing the cookie, for example, through the Document.cookie
4116
+ * property. Note that a cookie that has been created with HttpOnly will still be sent with
4117
+ * JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().
4118
+ * This mitigates attacks against cross-site scripting
4197
4119
  */
4198
- query: Record<string, any> | undefined;
4120
+ httpOnly?: boolean;
4199
4121
  /**
4200
- * Params
4122
+ * Indicates the number of seconds until the cookie expires. A zero or negative number will
4123
+ * expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.
4201
4124
  *
4202
- * If the path is `/user/:id` and the request is `/user/1` then the
4203
- * params will be `{ id: "1" }` and if the path includes a wildcard like
4204
- * `/user/*` then the params will be `{ _: "1" }` where `_` is the wildcard
4205
- * key. If the wildcard is named like `/user/**:name` then the params will
4206
- * be `{ name: string }`
4125
+ * @example 604800 - 7 days
4207
4126
  */
4208
- params: Record<string, any> | undefined;
4127
+ maxAge?: number;
4209
4128
  /**
4210
- * Request object
4129
+ * Indicates the path that must exist in the requested URL for the browser to send the Cookie
4130
+ * header.
4211
4131
  *
4212
- * If `requireRequest` is set to true in the endpoint options this will be
4213
- * required
4132
+ * @example
4133
+ * "/docs"
4134
+ * // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.
4214
4135
  */
4215
- request: Request | undefined;
4136
+ path?: string;
4216
4137
  /**
4217
- * Headers
4218
- *
4219
- * If `requireHeaders` is set to true in the endpoint options this will be
4220
- * required
4138
+ * Indicates that the cookie is sent to the server only when a request is made with the https:
4139
+ * scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.
4221
4140
  */
4222
- headers: Headers | undefined;
4141
+ secure?: boolean;
4223
4142
  /**
4224
- * Set header
4143
+ * Controls whether or not a cookie is sent with cross-site requests, providing some protection
4144
+ * against cross-site request forgery attacks (CSRF).
4225
4145
  *
4226
- * If it's called outside of a request it will just be ignored.
4227
- */
4228
- setHeader: (key: string, value: string) => void;
4229
- /**
4230
- * Set the response status code
4231
- */
4232
- setStatus: (status: Status) => void;
4233
- /**
4234
- * Get header
4146
+ * Strict - Means that the browser sends the cookie only for same-site requests, that is,
4147
+ * requests originating from the same site that set the cookie. If a request originates from a
4148
+ * different domain or scheme (even with the same domain), no cookies with the SameSite=Strict
4149
+ * attribute are sent.
4235
4150
  *
4236
- * If it's called outside of a request it will just return null
4151
+ * Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load
4152
+ * images or frames, but is sent when a user is navigating to the origin site from an external
4153
+ * site (for example, when following a link). This is the default behavior if the SameSite
4154
+ * attribute is not specified.
4237
4155
  *
4238
- * @param key - The key of the header
4156
+ * None - Means that the browser sends the cookie with both cross-site and same-site requests.
4157
+ * The Secure attribute must also be set when setting this value.
4239
4158
  */
4240
- getHeader: (key: string) => string | null;
4159
+ sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
4241
4160
  /**
4242
- * Get a cookie value from the request
4161
+ * Indicates that the cookie should be stored using partitioned storage. Note that if this is
4162
+ * set, the Secure directive must also be set.
4243
4163
  *
4244
- * @param key - The key of the cookie
4245
- * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
4246
- * @returns The value of the cookie
4164
+ * @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
4247
4165
  */
4248
- getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
4166
+ partitioned?: boolean;
4249
4167
  /**
4250
- * Get a signed cookie value from the request
4168
+ * Cooke Prefix
4251
4169
  *
4252
- * @param key - The key of the cookie
4253
- * @param secret - The secret of the signed cookie
4254
- * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
4255
- * @returns The value of the cookie or null if the cookie is not found or false if the signature is invalid
4256
- */
4257
- getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | null | false>;
4258
- /**
4259
- * Set a cookie value in the response
4170
+ * - secure: `__Secure-` -> `__Secure-cookie-name`
4171
+ * - host: `__Host-` -> `__Host-cookie-name`
4260
4172
  *
4261
- * @param key - The key of the cookie
4262
- * @param value - The value to set
4263
- * @param options - The options of the cookie
4264
- * @returns The cookie string
4173
+ * `secure` must be set to true to use prefixes
4265
4174
  */
4266
- setCookie: (key: string, value: string, options?: CookieOptions) => string;
4175
+ prefix?: CookiePrefixOptions;
4176
+ };
4177
+ //#endregion
4178
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/openapi.d.mts
4179
+ //#region src/openapi.d.ts
4180
+ type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
4181
+ interface OpenAPIParameter {
4182
+ in: "query" | "path" | "header" | "cookie";
4183
+ name?: string;
4184
+ description?: string;
4185
+ required?: boolean;
4186
+ schema?: {
4187
+ type: OpenAPISchemaType;
4188
+ format?: string | undefined;
4189
+ items?: {
4190
+ type: OpenAPISchemaType;
4191
+ };
4192
+ enum?: string[];
4193
+ minLength?: number;
4194
+ description?: string | undefined;
4195
+ default?: string | undefined;
4196
+ example?: string | undefined;
4197
+ };
4198
+ }
4199
+ //#endregion
4200
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/endpoint.d.mts
4201
+ //#region src/endpoint.d.ts
4202
+ interface EndpointBaseOptions {
4267
4203
  /**
4268
- * Set signed cookie
4269
- *
4270
- * @param key - The key of the cookie
4271
- * @param value - The value to set
4272
- * @param secret - The secret to sign the cookie with
4273
- * @param options - The options of the cookie
4274
- * @returns The cookie string
4204
+ * Query Schema
4275
4205
  */
4276
- setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
4206
+ query?: StandardSchemaV1$1;
4277
4207
  /**
4278
- * JSON
4279
- *
4280
- * A helper function to create a JSON response with the correct headers
4281
- * and status code. If `asResponse` is set to true in the context then
4282
- * it will return a Response object instead of the JSON object.
4283
- *
4284
- * @param json - The JSON object to return
4285
- * @param routerResponse - The response object to return if `asResponse` is
4286
- * true in the context this will take precedence
4208
+ * Error Schema
4287
4209
  */
4288
- json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
4289
- status?: number;
4290
- headers?: Record<string, string>;
4291
- response?: Response;
4292
- body?: Record<string, any>;
4293
- } | Response) => R;
4210
+ error?: StandardSchemaV1$1;
4294
4211
  /**
4295
- * Middleware context
4212
+ * If true headers will be required to be passed in the context
4296
4213
  */
4297
- context: Prettify<Context>;
4214
+ requireHeaders?: boolean;
4298
4215
  /**
4299
- * Redirect to a new URL
4216
+ * If true request object will be required
4300
4217
  */
4301
- redirect: (url: string) => APIError;
4218
+ requireRequest?: boolean;
4302
4219
  /**
4303
- * Return error
4220
+ * Clone the request object from the router
4304
4221
  */
4305
- error: (status: keyof typeof statusCodes | Status, body?: {
4306
- message?: string;
4307
- code?: string;
4308
- } & Record<string, any>, headers?: HeadersInit) => APIError;
4309
- asResponse?: boolean;
4310
- returnHeaders?: boolean;
4311
- returnStatus?: boolean;
4312
- responseHeaders: Headers;
4313
- };
4314
- type DefaultHandler = (inputCtx: MiddlewareContext<any>) => Promise<any>;
4315
- type Middleware<Handler extends (inputCtx: MiddlewareContext<any>) => Promise<any> = DefaultHandler> = Handler & {
4316
- options: Record<string, any>;
4317
- };
4318
- //#endregion
4319
- //#region ../../node_modules/.pnpm/better-call@2.0.2_zod@4.3.6/node_modules/better-call/dist/types.d.mts
4320
- //#region src/types.d.ts
4321
- type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD";
4322
- /**
4323
- * Resolves a method type parameter to its effective runtime type.
4324
- */
4325
- type ResolveMethod<M> = M extends Array<infer U> ? U : M extends "*" ? HTTPMethod : M;
4326
- /**
4327
- * Resolve a $Infer value: if it's a StandardSchemaV1 schema, extract the
4328
- * output type; otherwise use as-is.
4329
- */
4330
- type ResolveInferValue<T> = T extends StandardSchemaV1$1 ? StandardSchemaV1$1.InferOutput<T> : T;
4331
- /**
4332
- * Resolves a body schema to its output type.
4333
- */
4334
- type ResolveBody<S, Meta = undefined> = Meta extends {
4335
- $Infer: {
4336
- body: infer B;
4337
- };
4338
- } ? ResolveInferValue<B> : S extends StandardSchemaV1$1 ? StandardSchemaV1$1.InferOutput<S> : any;
4339
- /**
4340
- * Resolves a query schema to its output type.
4341
- */
4342
- type ResolveQuery<S, Meta = undefined> = Meta extends {
4343
- $Infer: {
4344
- query: infer Q;
4222
+ cloneRequest?: boolean;
4223
+ /**
4224
+ * If true the body will be undefined
4225
+ */
4226
+ disableBody?: boolean;
4227
+ /**
4228
+ * Endpoint metadata
4229
+ */
4230
+ metadata?: {
4231
+ /**
4232
+ * Open API definition
4233
+ */
4234
+ openapi?: {
4235
+ summary?: string;
4236
+ description?: string;
4237
+ tags?: string[];
4238
+ operationId?: string;
4239
+ parameters?: OpenAPIParameter[];
4240
+ requestBody?: {
4241
+ content: {
4242
+ "application/json": {
4243
+ schema: {
4244
+ type?: OpenAPISchemaType;
4245
+ properties?: Record<string, any>;
4246
+ required?: string[];
4247
+ $ref?: string;
4248
+ };
4249
+ };
4250
+ };
4251
+ };
4252
+ responses?: {
4253
+ [status: string]: {
4254
+ description: string;
4255
+ content?: {
4256
+ "application/json"?: {
4257
+ schema: {
4258
+ type?: OpenAPISchemaType;
4259
+ properties?: Record<string, any>;
4260
+ required?: string[];
4261
+ $ref?: string;
4262
+ };
4263
+ };
4264
+ "text/plain"?: {
4265
+ schema?: {
4266
+ type?: OpenAPISchemaType;
4267
+ properties?: Record<string, any>;
4268
+ required?: string[];
4269
+ $ref?: string;
4270
+ };
4271
+ };
4272
+ "text/html"?: {
4273
+ schema?: {
4274
+ type?: OpenAPISchemaType;
4275
+ properties?: Record<string, any>;
4276
+ required?: string[];
4277
+ $ref?: string;
4278
+ };
4279
+ };
4280
+ };
4281
+ };
4282
+ };
4283
+ };
4284
+ /**
4285
+ * Infer body and query type from ts interface
4286
+ *
4287
+ * useful for generic and dynamic types
4288
+ *
4289
+ * @example
4290
+ * ```ts
4291
+ * const endpoint = createEndpoint("/path", {
4292
+ * method: "POST",
4293
+ * body: z.record(z.string()),
4294
+ * $Infer: {
4295
+ * body: {} as {
4296
+ * type: InferTypeFromOptions<Option> // custom type inference
4297
+ * }
4298
+ * }
4299
+ * }, async(ctx)=>{
4300
+ * const body = ctx.body
4301
+ * })
4302
+ * ```
4303
+ */
4304
+ $Infer?: {
4305
+ /**
4306
+ * Body
4307
+ */
4308
+ body?: any;
4309
+ /**
4310
+ * Query
4311
+ */
4312
+ query?: Record<string, any>;
4313
+ };
4314
+ /**
4315
+ * If enabled, endpoint won't be exposed over a router
4316
+ * @deprecated Use path-less endpoints instead
4317
+ */
4318
+ SERVER_ONLY?: boolean;
4319
+ /**
4320
+ * If enabled, endpoint won't be exposed as an action to the client
4321
+ * @deprecated Use path-less endpoints instead
4322
+ */
4323
+ isAction?: boolean;
4324
+ /**
4325
+ * Defines the places where the endpoint will be available
4326
+ *
4327
+ * Possible options:
4328
+ * - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
4329
+ * - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
4330
+ * - `http` - the endpoint is only exposed to the router
4331
+ * @default "rpc"
4332
+ */
4333
+ scope?: "rpc" | "server" | "http";
4334
+ /**
4335
+ * List of allowed media types (MIME types) for the endpoint
4336
+ *
4337
+ * if provided, only the media types in the list will be allowed to be passed in the body
4338
+ *
4339
+ * @example
4340
+ * ```ts
4341
+ * const endpoint = createEndpoint("/path", {
4342
+ * method: "POST",
4343
+ * allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
4344
+ * }, async(ctx)=>{
4345
+ * const body = ctx.body
4346
+ * })
4347
+ * ```
4348
+ */
4349
+ allowedMediaTypes?: string[];
4350
+ /**
4351
+ * Extra metadata
4352
+ */
4353
+ [key: string]: any;
4345
4354
  };
4346
- } ? ResolveInferValue<Q> : S extends StandardSchemaV1$1 ? StandardSchemaV1$1.InferOutput<S> : Record<string, any> | undefined;
4347
- /**
4348
- * Resolves body schema to its input type (for InputContext at call-site).
4349
- */
4350
- /**
4351
- * Infer param types from a path string.
4352
- */
4353
- type InferParam<Path extends string> = [Path] extends [never] ? Record<string, any> | undefined : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? Record<string, any> | undefined : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
4354
- /**
4355
- * Infer param input (required vs optional based on whether path has params).
4356
- */
4357
- type InferParamInput<Path extends string> = [Path] extends [never] ? {
4358
- params?: Record<string, any>;
4359
- } : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
4360
- params?: Record<string, any>;
4361
- } : {
4362
- params: Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
4363
- };
4364
- /**
4365
- * Infer body input from an already-resolved body type.
4366
- * Body is the plain resolved type (not a schema).
4367
- */
4368
- type InferBodyInput<Body> = undefined extends Body ? {
4369
- body?: Body;
4370
- } : {
4371
- body: Body;
4372
- };
4373
- /**
4374
- * Infer query input from an already-resolved query type.
4375
- * Query is the plain resolved type (not a schema).
4376
- */
4377
- type InferQueryInput<Query> = undefined extends Query ? {
4378
- query?: Query;
4379
- } : {
4380
- query: Query;
4381
- };
4382
- /**
4383
- * Infer method input: required for wildcard, optional for arrays and single methods.
4384
- */
4385
- type InferMethodInput<M> = 0 extends 1 & M ? {
4386
- method?: HTTPMethod | undefined;
4387
- } : M extends "*" ? {
4388
- method: HTTPMethod;
4389
- } : M extends Array<any> ? {
4390
- method?: M[number] | undefined;
4391
- } : {
4392
- method?: M | undefined;
4393
- };
4394
- /**
4395
- * Infer request input.
4396
- */
4397
- type InferRequestInput<ReqRequest extends boolean> = 0 extends 1 & ReqRequest ? {
4398
- request?: Request;
4399
- } : ReqRequest extends true ? {
4400
- request: Request;
4401
- } : {
4402
- request?: Request;
4403
- };
4404
- /**
4405
- * Infer headers input.
4406
- */
4407
- type InferHeadersInput<ReqHeaders extends boolean> = 0 extends 1 & ReqHeaders ? {
4408
- headers?: HeadersInit;
4409
- } : ReqHeaders extends true ? {
4410
- headers: HeadersInit;
4411
- } : {
4412
- headers?: HeadersInit;
4413
- };
4414
- /**
4415
- * Infer the use (middleware) context union.
4416
- * Guards against `any` and `[]` to avoid poisoning the Context type.
4417
- */
4418
- type InferUse<Opts extends Middleware[] | undefined> = 0 extends 1 & Opts ? any : Opts extends Middleware[] ? Opts extends [] ? {} : UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : {};
4419
- /**
4420
- * The full InputContext type for the Endpoint call signature.
4421
- * Body and Query are already-resolved plain types.
4422
- */
4423
- type InputContext<Path extends string, M, Body, Query, ReqHeaders extends boolean, ReqRequest extends boolean> = InferBodyInput<Body> & InferMethodInput<M> & InferQueryInput<Query> & InferParamInput<Path> & InferRequestInput<ReqRequest> & InferHeadersInput<ReqHeaders> & {
4424
- asResponse?: boolean;
4425
- returnHeaders?: boolean;
4426
- returnStatus?: boolean;
4355
+ /**
4356
+ * List of middlewares to use
4357
+ */
4427
4358
  use?: Middleware[];
4428
- path?: string;
4429
- context?: Record<string, any>;
4430
- }; //#endregion
4431
- //#endregion
4432
- //#region ../../node_modules/.pnpm/better-call@2.0.2_zod@4.3.6/node_modules/better-call/dist/context.d.mts
4433
- //#region src/context.d.ts
4434
- type EndpointContext<Path extends string, M, BodySchema extends object | undefined, QuerySchema extends object | undefined, Use extends Middleware[], ReqHeaders extends boolean, ReqRequest extends boolean, Context = {}, Meta = undefined> = {
4359
+ /**
4360
+ * A callback to run before any API error is throw or returned
4361
+ *
4362
+ * @param e - The API error
4363
+ * @returns - The response to return
4364
+ */
4365
+ onAPIError?: (e: APIError) => void | Promise<void>;
4366
+ /**
4367
+ * A callback to run before a validation error is thrown
4368
+ * You can customize the validation error message by throwing your own APIError
4369
+ */
4370
+ onValidationError?: ({
4371
+ issues,
4372
+ message
4373
+ }: {
4374
+ message: string;
4375
+ issues: readonly StandardSchemaV1$1.Issue[];
4376
+ }) => void | Promise<void>;
4377
+ }
4378
+ type EndpointBodyMethodOptions = {
4379
+ /**
4380
+ * Request Method
4381
+ */
4382
+ method: "POST" | "PUT" | "DELETE" | "PATCH" | ("POST" | "PUT" | "DELETE" | "PATCH")[];
4383
+ /**
4384
+ * Body Schema
4385
+ */
4386
+ body?: StandardSchemaV1$1;
4387
+ } | {
4388
+ /**
4389
+ * Request Method
4390
+ */
4391
+ method: "GET" | "HEAD" | ("GET" | "HEAD")[];
4392
+ /**
4393
+ * Body Schema
4394
+ */
4395
+ body?: never;
4396
+ } | {
4397
+ /**
4398
+ * Request Method
4399
+ */
4400
+ method: "*";
4401
+ /**
4402
+ * Body Schema
4403
+ */
4404
+ body?: StandardSchemaV1$1;
4405
+ } | {
4406
+ /**
4407
+ * Request Method
4408
+ */
4409
+ method: ("POST" | "PUT" | "DELETE" | "PATCH" | "GET" | "HEAD")[];
4410
+ /**
4411
+ * Body Schema
4412
+ */
4413
+ body?: StandardSchemaV1$1;
4414
+ };
4415
+ type EndpointOptions = EndpointBaseOptions & EndpointBodyMethodOptions;
4416
+ type EndpointContext<Path extends string, Options extends EndpointOptions, Context = {}> = {
4435
4417
  /**
4436
4418
  * Method
4437
4419
  *
4438
4420
  * The request method
4439
4421
  */
4440
- method: ResolveMethod<M>;
4422
+ method: InferMethod<Options>;
4441
4423
  /**
4442
4424
  * Path
4443
4425
  *
@@ -4450,14 +4432,14 @@ type EndpointContext<Path extends string, M, BodySchema extends object | undefin
4450
4432
  * The body object will be the parsed JSON from the request and validated
4451
4433
  * against the body schema if it exists.
4452
4434
  */
4453
- body: ResolveBody<BodySchema, Meta>;
4435
+ body: InferBody<Options>;
4454
4436
  /**
4455
4437
  * Query
4456
4438
  *
4457
4439
  * The query object will be the parsed query string from the request
4458
4440
  * and validated against the query schema if it exists
4459
4441
  */
4460
- query: ResolveQuery<QuerySchema, Meta>;
4442
+ query: InferQuery<Options>;
4461
4443
  /**
4462
4444
  * Params
4463
4445
  *
@@ -4473,14 +4455,14 @@ type EndpointContext<Path extends string, M, BodySchema extends object | undefin
4473
4455
  * If `requireRequest` is set to true in the endpoint options this will be
4474
4456
  * required
4475
4457
  */
4476
- request: ReqRequest extends true ? Request : Request | undefined;
4458
+ request: InferRequest<Options>;
4477
4459
  /**
4478
4460
  * Headers
4479
4461
  *
4480
4462
  * If `requireHeaders` is set to true in the endpoint options this will be
4481
4463
  * required
4482
4464
  */
4483
- headers: ReqHeaders extends true ? Headers : Headers | undefined;
4465
+ headers: InferHeaders<Options>;
4484
4466
  /**
4485
4467
  * Set header
4486
4468
  *
@@ -4496,7 +4478,8 @@ type EndpointContext<Path extends string, M, BodySchema extends object | undefin
4496
4478
  *
4497
4479
  * If it's called outside of a request it will just return null
4498
4480
  *
4499
- * @param key - The key of the header
4481
+ * @param key - The key of the header
4482
+ * @returns
4500
4483
  */
4501
4484
  getHeader: (key: string) => string | null;
4502
4485
  /**
@@ -4504,7 +4487,7 @@ type EndpointContext<Path extends string, M, BodySchema extends object | undefin
4504
4487
  *
4505
4488
  * @param key - The key of the cookie
4506
4489
  * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
4507
- * @returns The value of the cookie
4490
+ * @returns - The value of the cookie
4508
4491
  */
4509
4492
  getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
4510
4493
  /**
@@ -4513,7 +4496,7 @@ type EndpointContext<Path extends string, M, BodySchema extends object | undefin
4513
4496
  * @param key - The key of the cookie
4514
4497
  * @param secret - The secret of the signed cookie
4515
4498
  * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
4516
- * @returns The value of the cookie or null if the cookie is not found or false if the signature is invalid
4499
+ * @returns - The value of the cookie or null if the cookie is not found or false if the signature is invalid
4517
4500
  */
4518
4501
  getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | null | false>;
4519
4502
  /**
@@ -4522,40 +4505,44 @@ type EndpointContext<Path extends string, M, BodySchema extends object | undefin
4522
4505
  * @param key - The key of the cookie
4523
4506
  * @param value - The value to set
4524
4507
  * @param options - The options of the cookie
4525
- * @returns The cookie string
4508
+ * @returns - The cookie string
4526
4509
  */
4527
4510
  setCookie: (key: string, value: string, options?: CookieOptions) => string;
4528
4511
  /**
4529
4512
  * Set signed cookie
4530
4513
  *
4531
4514
  * @param key - The key of the cookie
4532
- * @param value - The value to set
4515
+ * @param value - The value to set
4533
4516
  * @param secret - The secret to sign the cookie with
4534
4517
  * @param options - The options of the cookie
4535
- * @returns The cookie string
4518
+ * @returns - The cookie string
4536
4519
  */
4537
4520
  setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
4538
4521
  /**
4539
4522
  * JSON
4540
4523
  *
4541
- * A helper function to create a JSON response with the correct headers
4542
- * and status code. If `asResponse` is set to true in the context then
4543
- * it will return a Response object instead of the JSON object.
4524
+ * a helper function to create a JSON response with
4525
+ * the correct headers
4526
+ * and status code. If `asResponse` is set to true in
4527
+ * the context then
4528
+ * it will return a Response object instead of the
4529
+ * JSON object.
4544
4530
  *
4545
4531
  * @param json - The JSON object to return
4546
- * @param routerResponse - The response object to return if `asResponse` is
4532
+ * @param routerResponse - The response object to
4533
+ * return if `asResponse` is
4547
4534
  * true in the context this will take precedence
4548
4535
  */
4549
4536
  json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
4550
4537
  status?: number;
4551
4538
  headers?: Record<string, string>;
4552
4539
  response?: Response;
4553
- body?: Record<string, any>;
4554
- } | Response) => R;
4540
+ body?: Record<string, string>;
4541
+ } | Response) => Promise<R>;
4555
4542
  /**
4556
4543
  * Middleware context
4557
4544
  */
4558
- context: 0 extends 1 & Use ? Prettify<Context> : Prettify<Context & InferUse<Use>>;
4545
+ context: Prettify<Context & InferUse<Options["use"]>>;
4559
4546
  /**
4560
4547
  * Redirect to a new URL
4561
4548
  */
@@ -4567,242 +4554,188 @@ type EndpointContext<Path extends string, M, BodySchema extends object | undefin
4567
4554
  message?: string;
4568
4555
  code?: string;
4569
4556
  } & Record<string, any>, headers?: HeadersInit) => APIError;
4557
+ };
4558
+ type Endpoint<Path extends string = string, Options extends EndpointOptions = EndpointOptions, Handler extends (inputCtx: any) => Promise<any> = (inputCtx: any) => Promise<any>> = Handler & {
4559
+ options: Options;
4560
+ path: Path;
4570
4561
  }; //#endregion
4571
4562
  //#endregion
4572
- //#region ../../node_modules/.pnpm/better-call@2.0.2_zod@4.3.6/node_modules/better-call/dist/endpoint.d.mts
4573
- //#region src/endpoint.d.ts
4574
- interface EndpointMetadata {
4575
- /**
4576
- * Open API definition
4577
- */
4578
- openapi?: {
4579
- summary?: string;
4580
- description?: string;
4581
- tags?: string[];
4582
- operationId?: string;
4583
- parameters?: OpenAPIParameter[];
4584
- requestBody?: {
4585
- content: {
4586
- "application/json": {
4587
- schema: {
4588
- type?: OpenAPISchemaType;
4589
- properties?: Record<string, any>;
4590
- required?: string[];
4591
- $ref?: string;
4592
- };
4593
- };
4594
- };
4595
- };
4596
- responses?: {
4597
- [status: string]: {
4598
- description: string;
4599
- content?: {
4600
- "application/json"?: {
4601
- schema: {
4602
- type?: OpenAPISchemaType;
4603
- properties?: Record<string, any>;
4604
- required?: string[];
4605
- $ref?: string;
4606
- };
4607
- };
4608
- "text/plain"?: {
4609
- schema?: {
4610
- type?: OpenAPISchemaType;
4611
- properties?: Record<string, any>;
4612
- required?: string[];
4613
- $ref?: string;
4614
- };
4615
- };
4616
- "text/html"?: {
4617
- schema?: {
4618
- type?: OpenAPISchemaType;
4619
- properties?: Record<string, any>;
4620
- required?: string[];
4621
- $ref?: string;
4622
- };
4623
- };
4624
- };
4625
- };
4626
- };
4627
- };
4563
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/middleware.d.mts
4564
+ //#region src/middleware.d.ts
4565
+ interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {}
4566
+ type MiddlewareContext<Options extends MiddlewareOptions, Context = {}> = EndpointContext<string, Options & {
4567
+ method: "*";
4568
+ }> & {
4628
4569
  /**
4629
- * Infer body and query type from ts interface
4630
- *
4631
- * useful for generic and dynamic types
4570
+ * Method
4632
4571
  *
4633
- * @example
4634
- * ```ts
4635
- * const endpoint = createEndpoint("/path", {
4636
- * method: "POST",
4637
- * body: z.record(z.string()),
4638
- * $Infer: {
4639
- * body: {} as {
4640
- * type: InferTypeFromOptions<Option> // custom type inference
4641
- * }
4642
- * }
4643
- * }, async(ctx)=>{
4644
- * const body = ctx.body
4645
- * })
4646
- * ```
4647
- */
4648
- $Infer?: {
4649
- /**
4650
- * Body
4651
- */
4652
- body?: any;
4653
- /**
4654
- * Query
4655
- */
4656
- query?: Record<string, any>;
4657
- /**
4658
- * Error
4659
- */
4660
- error?: any;
4661
- };
4662
- /**
4663
- * If enabled, endpoint won't be exposed over a router
4664
- * @deprecated Use path-less endpoints instead
4665
- */
4666
- SERVER_ONLY?: boolean;
4667
- /**
4668
- * If enabled, endpoint won't be exposed as an action to the client
4669
- * @deprecated Use path-less endpoints instead
4572
+ * The request method
4670
4573
  */
4671
- isAction?: boolean;
4574
+ method: string;
4672
4575
  /**
4673
- * Defines the places where the endpoint will be available
4576
+ * Path
4674
4577
  *
4675
- * Possible options:
4676
- * - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
4677
- * - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
4678
- * - `http` - the endpoint is only exposed to the router
4679
- * @default "rpc"
4578
+ * The path of the endpoint
4680
4579
  */
4681
- scope?: "rpc" | "server" | "http";
4580
+ path: string;
4682
4581
  /**
4683
- * List of allowed media types (MIME types) for the endpoint
4684
- *
4685
- * if provided, only the media types in the list will be allowed to be passed in the body
4582
+ * Body
4686
4583
  *
4687
- * @example
4688
- * ```ts
4689
- * const endpoint = createEndpoint("/path", {
4690
- * method: "POST",
4691
- * allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
4692
- * }, async(ctx)=>{
4693
- * const body = ctx.body
4694
- * })
4695
- * ```
4696
- */
4697
- allowedMediaTypes?: string[];
4698
- /**
4699
- * Extra metadata
4700
- */
4701
- [key: string]: any;
4702
- }
4703
- interface EndpointRuntimeOptions {
4704
- method: string | string[];
4705
- body?: StandardSchemaV1$1;
4706
- /**
4707
- * Query Schema
4708
- */
4709
- query?: StandardSchemaV1$1;
4710
- /**
4711
- * Error Schema
4584
+ * The body object will be the parsed JSON from the request and validated
4585
+ * against the body schema if it exists
4712
4586
  */
4713
- error?: StandardSchemaV1$1;
4587
+ body: InferMiddlewareBody<Options>;
4714
4588
  /**
4715
- * If true headers will be required to be passed in the context
4589
+ * Query
4590
+ *
4591
+ * The query object will be the parsed query string from the request
4592
+ * and validated against the query schema if it exists
4716
4593
  */
4717
- requireHeaders?: boolean;
4594
+ query: InferMiddlewareQuery<Options>;
4718
4595
  /**
4719
- * If true request object will be required
4596
+ * Params
4597
+ *
4598
+ * If the path is `/user/:id` and the request is `/user/1` then the
4599
+ * params will
4600
+ * be `{ id: "1" }` and if the path includes a wildcard like `/user/*`
4601
+ * then the
4602
+ * params will be `{ _: "1" }` where `_` is the wildcard key. If the
4603
+ * wildcard
4604
+ * is named like `/user/**:name` then the params will be `{ name: string }`
4720
4605
  */
4721
- requireRequest?: boolean;
4606
+ params: string;
4722
4607
  /**
4723
- * Clone the request object from the router
4608
+ * Request object
4609
+ *
4610
+ * If `requireRequest` is set to true in the endpoint options this will be
4611
+ * required
4724
4612
  */
4725
- cloneRequest?: boolean;
4613
+ request: InferRequest<Options>;
4726
4614
  /**
4727
- * If true the body will be undefined
4615
+ * Headers
4616
+ *
4617
+ * If `requireHeaders` is set to true in the endpoint options this will be
4618
+ * required
4728
4619
  */
4729
- disableBody?: boolean;
4620
+ headers: InferHeaders<Options>;
4730
4621
  /**
4731
- * Endpoint metadata
4622
+ * Set header
4623
+ *
4624
+ * If it's called outside of a request it will just be ignored.
4732
4625
  */
4733
- metadata?: EndpointMetadata;
4626
+ setHeader: (key: string, value: string) => void;
4734
4627
  /**
4735
- * List of middlewares to use
4628
+ * Get header
4629
+ *
4630
+ * If it's called outside of a request it will just return null
4631
+ *
4632
+ * @param key - The key of the header
4633
+ * @returns
4736
4634
  */
4737
- use?: Middleware[];
4635
+ getHeader: (key: string) => string | null;
4738
4636
  /**
4739
- * A callback to run before any API error is thrown or returned
4637
+ * JSON
4740
4638
  *
4741
- * @param e - The API error
4639
+ * a helper function to create a JSON response with
4640
+ * the correct headers
4641
+ * and status code. If `asResponse` is set to true in
4642
+ * the context then
4643
+ * it will return a Response object instead of the
4644
+ * JSON object.
4645
+ *
4646
+ * @param json - The JSON object to return
4647
+ * @param routerResponse - The response object to
4648
+ * return if `asResponse` is
4649
+ * true in the context this will take precedence
4742
4650
  */
4743
- onAPIError?: (e: APIError) => void | Promise<void>;
4651
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
4652
+ status?: number;
4653
+ headers?: Record<string, string>;
4654
+ response?: Response;
4655
+ } | Response) => Promise<R>;
4744
4656
  /**
4745
- * A callback to run before a validation error is thrown.
4746
- * You can customize the validation error message by throwing your own APIError.
4657
+ * Middleware context
4747
4658
  */
4748
- onValidationError?: (info: {
4749
- message: string;
4750
- issues: readonly StandardSchemaV1$1.Issue[];
4751
- }) => void | Promise<void>;
4752
- }
4753
- type Endpoint<Path extends string = string, Method = any, Body = any, Query = any, Use extends Middleware[] = any, R = any, Meta extends EndpointMetadata | undefined = EndpointMetadata | undefined, Error = any> = {
4754
- (context: InputContext<Path, Method, Body, Query, false, false> & {
4755
- asResponse: true;
4756
- }): Promise<Response>;
4757
- (context: InputContext<Path, Method, Body, Query, false, false> & {
4758
- returnHeaders: true;
4759
- returnStatus: true;
4760
- }): Promise<{
4761
- headers: Headers;
4762
- status: number;
4763
- response: Awaited<R>;
4764
- }>;
4765
- (context: InputContext<Path, Method, Body, Query, false, false> & {
4766
- returnHeaders: true;
4767
- }): Promise<{
4768
- headers: Headers;
4769
- response: Awaited<R>;
4770
- }>;
4771
- (context: InputContext<Path, Method, Body, Query, false, false> & {
4772
- returnStatus: true;
4773
- }): Promise<{
4774
- status: number;
4775
- response: Awaited<R>;
4776
- }>;
4777
- (context?: InputContext<Path, Method, Body, Query, false, false>): Promise<Awaited<R>>;
4778
- options: Omit<EndpointRuntimeOptions, "method" | "metadata"> & {
4779
- method: Method;
4780
- metadata?: Meta;
4781
- };
4782
- path: Path;
4659
+ context: Prettify<Context>;
4660
+ };
4661
+ type MiddlewareInputContext<Options extends MiddlewareOptions> = InferBodyInput<Options> & InferQueryInput<Options> & InferRequestInput<Options> & InferHeadersInput<Options> & {
4662
+ asResponse?: boolean;
4663
+ returnHeaders?: boolean;
4664
+ use?: Middleware[];
4783
4665
  };
4666
+ type Middleware<Options extends MiddlewareOptions = MiddlewareOptions, Handler extends (inputCtx: any) => Promise<any> = any> = Handler & {
4667
+ options: Options;
4668
+ }; //#endregion
4784
4669
  //#endregion
4785
- //#region ../../node_modules/.pnpm/better-call@2.0.2_zod@4.3.6/node_modules/better-call/dist/openapi.d.mts
4786
- //#region src/openapi.d.ts
4787
- type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
4788
- interface OpenAPIParameter {
4789
- in: "query" | "path" | "header" | "cookie";
4790
- name?: string;
4791
- description?: string;
4792
- required?: boolean;
4793
- schema?: {
4794
- type: OpenAPISchemaType;
4795
- format?: string;
4796
- items?: {
4797
- type: OpenAPISchemaType;
4798
- };
4799
- enum?: string[];
4800
- minLength?: number;
4801
- description?: string;
4802
- default?: string;
4803
- example?: string;
4670
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/context.d.mts
4671
+ //#region src/context.d.ts
4672
+ type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
4673
+ type Method = HTTPMethod | "*";
4674
+ type InferBodyInput<Options extends EndpointOptions | MiddlewareOptions, Body = (Options["metadata"] extends {
4675
+ $Infer: {
4676
+ body: infer B;
4804
4677
  };
4805
- }
4678
+ } ? B : Options["body"] extends StandardSchemaV1$1 ? StandardSchemaV1$1.InferInput<Options["body"]> : undefined)> = undefined extends Body ? {
4679
+ body?: Body;
4680
+ } : {
4681
+ body: Body;
4682
+ };
4683
+ type InferBody<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
4684
+ $Infer: {
4685
+ body: infer Body;
4686
+ };
4687
+ } ? Body : Options["body"] extends StandardSchemaV1$1 ? StandardSchemaV1$1.InferOutput<Options["body"]> : any;
4688
+ type InferQueryInput<Options extends EndpointOptions | MiddlewareOptions, Query = (Options["metadata"] extends {
4689
+ $Infer: {
4690
+ query: infer Query;
4691
+ };
4692
+ } ? Query : Options["query"] extends StandardSchemaV1$1 ? StandardSchemaV1$1.InferInput<Options["query"]> : Record<string, any> | undefined)> = undefined extends Query ? {
4693
+ query?: Query;
4694
+ } : {
4695
+ query: Query;
4696
+ };
4697
+ type InferQuery<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
4698
+ $Infer: {
4699
+ query: infer Query;
4700
+ };
4701
+ } ? Query : Options["query"] extends StandardSchemaV1$1 ? StandardSchemaV1$1.InferOutput<Options["query"]> : Record<string, any> | undefined;
4702
+ type InferMethod<Options extends EndpointOptions> = Options["method"] extends Array<Method> ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"];
4703
+ type InferInputMethod<Options extends EndpointOptions, Method = (Options["method"] extends Array<any> ? Options["method"][number] | undefined : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined)> = undefined extends Method ? {
4704
+ method?: Method;
4705
+ } : {
4706
+ method: Method;
4707
+ };
4708
+ type InferParam<Path extends string> = [Path] extends [never] ? Record<string, any> | undefined : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? Record<string, any> | undefined : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
4709
+ type InferParamInput<Path extends string> = [Path] extends [never] ? {
4710
+ params?: Record<string, any>;
4711
+ } : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
4712
+ params?: Record<string, any>;
4713
+ } : {
4714
+ params: Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
4715
+ };
4716
+ type InferRequest<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? Request : Request | undefined;
4717
+ type InferRequestInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? {
4718
+ request: Request;
4719
+ } : {
4720
+ request?: Request;
4721
+ };
4722
+ type InferHeaders<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? Headers : Headers | undefined;
4723
+ type InferHeadersInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? {
4724
+ headers: HeadersInit;
4725
+ } : {
4726
+ headers?: HeadersInit;
4727
+ };
4728
+ type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Middleware[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : {};
4729
+ type InferMiddlewareBody<Options extends MiddlewareOptions> = Options["body"] extends StandardSchemaV1$1<infer T> ? T : any;
4730
+ type InferMiddlewareQuery<Options extends MiddlewareOptions> = Options["query"] extends StandardSchemaV1$1<infer T> ? T : Record<string, any> | undefined;
4731
+ type InputContext<Path extends string, Options extends EndpointOptions> = InferBodyInput<Options> & InferInputMethod<Options> & InferQueryInput<Options> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
4732
+ asResponse?: boolean;
4733
+ returnHeaders?: boolean;
4734
+ returnStatus?: boolean;
4735
+ use?: Middleware[];
4736
+ path?: string;
4737
+ context?: Record<string, any>;
4738
+ };
4806
4739
  //#endregion
4807
4740
  //#region ../core/dist/types/cookie.d.mts
4808
4741
  //#region src/types/cookie.d.ts
@@ -4851,6 +4784,7 @@ type InferPluginOptions<O extends BetterAuthOptions, ID extends BetterAuthPlugin
4851
4784
  *
4852
4785
  * const createMyPlugin = <Options extends MyPluginOptions>(options?: Options) => ({
4853
4786
  * id: 'my-plugin',
4787
+ * version: '1.0.0',
4854
4788
  * options,
4855
4789
  * } satisfies BetterAuthPlugin);
4856
4790
  *
@@ -4865,7 +4799,9 @@ type InferPluginOptions<O extends BetterAuthOptions, ID extends BetterAuthPlugin
4865
4799
  */
4866
4800
  interface BetterAuthPluginRegistry<AuthOptions, Options> {}
4867
4801
  type BetterAuthPluginRegistryIdentifier = keyof BetterAuthPluginRegistry<unknown, unknown>;
4868
- type GenericEndpointContext<Options extends BetterAuthOptions = BetterAuthOptions> = EndpointContext<string, any, any, any, any, any, any, AuthContext<Options>>;
4802
+ type GenericEndpointContext<Options extends BetterAuthOptions = BetterAuthOptions> = EndpointContext<string, any> & {
4803
+ context: AuthContext<Options>;
4804
+ };
4869
4805
  interface InternalAdapter<_Options extends BetterAuthOptions = BetterAuthOptions> {
4870
4806
  createOAuthUser(user: Omit<User, "id" | "createdAt" | "updatedAt">, account: Omit<Account, "userId" | "id" | "createdAt" | "updatedAt"> & Partial<Account>): Promise<{
4871
4807
  user: User;
@@ -5088,13 +5024,267 @@ type AuthContext<Options extends BetterAuthOptions = BetterAuthOptions> = Plugin
5088
5024
  }; //#endregion
5089
5025
  //#endregion
5090
5026
  //#region ../core/dist/api/index.d.mts
5091
- /**
5092
- * The handler type for plugin hooks.
5093
- *
5094
- * Accepts both `Middleware` instances (from `createAuthMiddleware`)
5095
- * and plain async functions for better-call v1/v2 compatibility.
5096
- */
5097
- type AuthMiddleware = (inputContext: Record<string, any>) => Promise<unknown>; //#endregion
5027
+ declare const createAuthMiddleware: {
5028
+ <Options extends MiddlewareOptions, R>(options: Options, handler: (ctx: MiddlewareContext<Options, {
5029
+ returned?: unknown | undefined;
5030
+ responseHeaders?: Headers | undefined;
5031
+ } & PluginContext<BetterAuthOptions> & InfoContext & {
5032
+ options: BetterAuthOptions;
5033
+ trustedOrigins: string[];
5034
+ trustedProviders: string[];
5035
+ isTrustedOrigin: (url: string, settings?: {
5036
+ allowRelativePaths: boolean;
5037
+ }) => boolean;
5038
+ oauthConfig: {
5039
+ skipStateCookieCheck?: boolean | undefined;
5040
+ storeStateStrategy: "database" | "cookie";
5041
+ };
5042
+ newSession: {
5043
+ session: {
5044
+ id: string;
5045
+ createdAt: Date;
5046
+ updatedAt: Date;
5047
+ userId: string;
5048
+ expiresAt: Date;
5049
+ token: string;
5050
+ ipAddress?: string | null | undefined;
5051
+ userAgent?: string | null | undefined;
5052
+ } & Record<string, any>;
5053
+ user: {
5054
+ id: string;
5055
+ createdAt: Date;
5056
+ updatedAt: Date;
5057
+ email: string;
5058
+ emailVerified: boolean;
5059
+ name: string;
5060
+ image?: string | null | undefined;
5061
+ } & Record<string, any>;
5062
+ } | null;
5063
+ session: {
5064
+ session: {
5065
+ id: string;
5066
+ createdAt: Date;
5067
+ updatedAt: Date;
5068
+ userId: string;
5069
+ expiresAt: Date;
5070
+ token: string;
5071
+ ipAddress?: string | null | undefined;
5072
+ userAgent?: string | null | undefined;
5073
+ } & Record<string, any>;
5074
+ user: {
5075
+ id: string;
5076
+ createdAt: Date;
5077
+ updatedAt: Date;
5078
+ email: string;
5079
+ emailVerified: boolean;
5080
+ name: string;
5081
+ image?: string | null | undefined;
5082
+ } & Record<string, any>;
5083
+ } | null;
5084
+ setNewSession: (session: {
5085
+ session: {
5086
+ id: string;
5087
+ createdAt: Date;
5088
+ updatedAt: Date;
5089
+ userId: string;
5090
+ expiresAt: Date;
5091
+ token: string;
5092
+ ipAddress?: string | null | undefined;
5093
+ userAgent?: string | null | undefined;
5094
+ } & Record<string, any>;
5095
+ user: {
5096
+ id: string;
5097
+ createdAt: Date;
5098
+ updatedAt: Date;
5099
+ email: string;
5100
+ emailVerified: boolean;
5101
+ name: string;
5102
+ image?: string | null | undefined;
5103
+ } & Record<string, any>;
5104
+ } | null) => void;
5105
+ socialProviders: OAuthProvider[];
5106
+ authCookies: BetterAuthCookies;
5107
+ logger: ReturnType<typeof createLogger>;
5108
+ rateLimit: {
5109
+ enabled: boolean;
5110
+ window: number;
5111
+ max: number;
5112
+ storage: "memory" | "database" | "secondary-storage";
5113
+ } & Omit<BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
5114
+ adapter: DBAdapter<BetterAuthOptions>;
5115
+ internalAdapter: InternalAdapter<BetterAuthOptions>;
5116
+ createAuthCookie: (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => BetterAuthCookie;
5117
+ secret: string;
5118
+ secretConfig: string | SecretConfig;
5119
+ sessionConfig: {
5120
+ updateAge: number;
5121
+ expiresIn: number;
5122
+ freshAge: number;
5123
+ cookieRefreshCache: false | {
5124
+ enabled: true;
5125
+ updateAge: number;
5126
+ };
5127
+ };
5128
+ generateId: (options: {
5129
+ model: ModelNames;
5130
+ size?: number | undefined;
5131
+ }) => string | false;
5132
+ secondaryStorage: SecondaryStorage | undefined;
5133
+ password: {
5134
+ hash: (password: string) => Promise<string>;
5135
+ verify: (data: {
5136
+ password: string;
5137
+ hash: string;
5138
+ }) => Promise<boolean>;
5139
+ config: {
5140
+ minPasswordLength: number;
5141
+ maxPasswordLength: number;
5142
+ };
5143
+ checkPassword: (userId: string, ctx: GenericEndpointContext<BetterAuthOptions>) => Promise<boolean>;
5144
+ };
5145
+ tables: BetterAuthDBSchema;
5146
+ runMigrations: () => Promise<void>;
5147
+ publishTelemetry: (event: {
5148
+ type: string;
5149
+ anonymousId?: string | undefined;
5150
+ payload: Record<string, any>;
5151
+ }) => Promise<void>;
5152
+ skipOriginCheck: boolean | string[];
5153
+ skipCSRFCheck: boolean;
5154
+ runInBackground: (promise: Promise<unknown>) => void;
5155
+ runInBackgroundOrAwait: (promise: Promise<unknown> | void) => Awaitable<unknown>;
5156
+ }>) => Promise<R>): (inputContext: MiddlewareInputContext<Options>) => Promise<R>;
5157
+ <Options extends MiddlewareOptions, R_1>(handler: (ctx: MiddlewareContext<Options, {
5158
+ returned?: unknown | undefined;
5159
+ responseHeaders?: Headers | undefined;
5160
+ } & PluginContext<BetterAuthOptions> & InfoContext & {
5161
+ options: BetterAuthOptions;
5162
+ trustedOrigins: string[];
5163
+ trustedProviders: string[];
5164
+ isTrustedOrigin: (url: string, settings?: {
5165
+ allowRelativePaths: boolean;
5166
+ }) => boolean;
5167
+ oauthConfig: {
5168
+ skipStateCookieCheck?: boolean | undefined;
5169
+ storeStateStrategy: "database" | "cookie";
5170
+ };
5171
+ newSession: {
5172
+ session: {
5173
+ id: string;
5174
+ createdAt: Date;
5175
+ updatedAt: Date;
5176
+ userId: string;
5177
+ expiresAt: Date;
5178
+ token: string;
5179
+ ipAddress?: string | null | undefined;
5180
+ userAgent?: string | null | undefined;
5181
+ } & Record<string, any>;
5182
+ user: {
5183
+ id: string;
5184
+ createdAt: Date;
5185
+ updatedAt: Date;
5186
+ email: string;
5187
+ emailVerified: boolean;
5188
+ name: string;
5189
+ image?: string | null | undefined;
5190
+ } & Record<string, any>;
5191
+ } | null;
5192
+ session: {
5193
+ session: {
5194
+ id: string;
5195
+ createdAt: Date;
5196
+ updatedAt: Date;
5197
+ userId: string;
5198
+ expiresAt: Date;
5199
+ token: string;
5200
+ ipAddress?: string | null | undefined;
5201
+ userAgent?: string | null | undefined;
5202
+ } & Record<string, any>;
5203
+ user: {
5204
+ id: string;
5205
+ createdAt: Date;
5206
+ updatedAt: Date;
5207
+ email: string;
5208
+ emailVerified: boolean;
5209
+ name: string;
5210
+ image?: string | null | undefined;
5211
+ } & Record<string, any>;
5212
+ } | null;
5213
+ setNewSession: (session: {
5214
+ session: {
5215
+ id: string;
5216
+ createdAt: Date;
5217
+ updatedAt: Date;
5218
+ userId: string;
5219
+ expiresAt: Date;
5220
+ token: string;
5221
+ ipAddress?: string | null | undefined;
5222
+ userAgent?: string | null | undefined;
5223
+ } & Record<string, any>;
5224
+ user: {
5225
+ id: string;
5226
+ createdAt: Date;
5227
+ updatedAt: Date;
5228
+ email: string;
5229
+ emailVerified: boolean;
5230
+ name: string;
5231
+ image?: string | null | undefined;
5232
+ } & Record<string, any>;
5233
+ } | null) => void;
5234
+ socialProviders: OAuthProvider[];
5235
+ authCookies: BetterAuthCookies;
5236
+ logger: ReturnType<typeof createLogger>;
5237
+ rateLimit: {
5238
+ enabled: boolean;
5239
+ window: number;
5240
+ max: number;
5241
+ storage: "memory" | "database" | "secondary-storage";
5242
+ } & Omit<BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
5243
+ adapter: DBAdapter<BetterAuthOptions>;
5244
+ internalAdapter: InternalAdapter<BetterAuthOptions>;
5245
+ createAuthCookie: (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => BetterAuthCookie;
5246
+ secret: string;
5247
+ secretConfig: string | SecretConfig;
5248
+ sessionConfig: {
5249
+ updateAge: number;
5250
+ expiresIn: number;
5251
+ freshAge: number;
5252
+ cookieRefreshCache: false | {
5253
+ enabled: true;
5254
+ updateAge: number;
5255
+ };
5256
+ };
5257
+ generateId: (options: {
5258
+ model: ModelNames;
5259
+ size?: number | undefined;
5260
+ }) => string | false;
5261
+ secondaryStorage: SecondaryStorage | undefined;
5262
+ password: {
5263
+ hash: (password: string) => Promise<string>;
5264
+ verify: (data: {
5265
+ password: string;
5266
+ hash: string;
5267
+ }) => Promise<boolean>;
5268
+ config: {
5269
+ minPasswordLength: number;
5270
+ maxPasswordLength: number;
5271
+ };
5272
+ checkPassword: (userId: string, ctx: GenericEndpointContext<BetterAuthOptions>) => Promise<boolean>;
5273
+ };
5274
+ tables: BetterAuthDBSchema;
5275
+ runMigrations: () => Promise<void>;
5276
+ publishTelemetry: (event: {
5277
+ type: string;
5278
+ anonymousId?: string | undefined;
5279
+ payload: Record<string, any>;
5280
+ }) => Promise<void>;
5281
+ skipOriginCheck: boolean | string[];
5282
+ skipCSRFCheck: boolean;
5283
+ runInBackground: (promise: Promise<unknown>) => void;
5284
+ runInBackgroundOrAwait: (promise: Promise<unknown> | void) => Awaitable<unknown>;
5285
+ }>) => Promise<R_1>): (inputContext: MiddlewareInputContext<Options>) => Promise<R_1>;
5286
+ };
5287
+ type AuthMiddleware = ReturnType<typeof createAuthMiddleware>; //#endregion
5098
5288
  //#endregion
5099
5289
  //#region ../core/dist/types/init-options.d.mts
5100
5290
  //#region src/types/init-options.d.ts
@@ -5245,7 +5435,9 @@ type BetterAuthAdvancedOptions = {
5245
5435
  ipv6Subnet?: 128 | 64 | 48 | 32;
5246
5436
  } | undefined;
5247
5437
  /**
5248
- * Use secure cookies
5438
+ * Force cookies to always use the `Secure` attribute. By default,
5439
+ * cookies are secure in production environments. Set this to `true`
5440
+ * to enforce secure cookies in all environments.
5249
5441
  *
5250
5442
  * @default false
5251
5443
  */
@@ -5394,9 +5586,11 @@ type BetterAuthAdvancedOptions = {
5394
5586
  };
5395
5587
  type BetterAuthOptions = {
5396
5588
  /**
5397
- * The name of the application
5589
+ * The name of your application. Used as a display name in contexts
5590
+ * where your app needs to be identified — for example, as the default
5591
+ * issuer name in authenticator apps when users set up 2FA/TOTP.
5398
5592
  *
5399
- * process.env.APP_NAME
5593
+ * Can also be set via the `APP_NAME` environment variable.
5400
5594
  *
5401
5595
  * @default "Better Auth"
5402
5596
  */
@@ -6095,7 +6289,12 @@ type BetterAuthOptions = {
6095
6289
  storeInDatabase?: boolean;
6096
6290
  }) | undefined;
6097
6291
  /**
6098
- * List of trusted origins.
6292
+ * Additional trusted origins. By default, Better Auth trusts your
6293
+ * app's {@link baseURL}. Use this option to allow additional origins
6294
+ * (e.g. a separate frontend domain).
6295
+ *
6296
+ * Can be a static array, a function that returns origins dynamically,
6297
+ * or use wildcard patterns (e.g. `"https://*.example.com"`).
6099
6298
  *
6100
6299
  * @param request - The request object.
6101
6300
  * It'll be undefined if no request was
@@ -6603,10 +6802,7 @@ type RawError<K extends string = string> = {
6603
6802
  //#region ../core/dist/types/plugin.d.mts
6604
6803
  //#region src/types/plugin.d.ts
6605
6804
  type DeepPartial<T> = T extends Function ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]> } : T;
6606
- type HookEndpointContext = Partial<EndpointContext<string, any, any, any, any, any, any, AuthContext & {
6607
- returned?: unknown | undefined;
6608
- responseHeaders?: Headers | undefined;
6609
- }> & Omit<InputContext<string, any, any, any, any, any>, "method">> & {
6805
+ type HookEndpointContext = Partial<EndpointContext<string, any> & Omit<InputContext<string, any>, "method">> & {
6610
6806
  path?: string;
6611
6807
  context: AuthContext & {
6612
6808
  returned?: unknown | undefined;
@@ -6622,6 +6818,7 @@ type BetterAuthPluginErrorCodePart = {
6622
6818
  };
6623
6819
  type BetterAuthPlugin = BetterAuthPluginErrorCodePart & {
6624
6820
  id: LiteralString;
6821
+ version?: string | undefined;
6625
6822
  /**
6626
6823
  * The init function is called when the plugin is initialized.
6627
6824
  * You can return a new context or modify the existing context.
@@ -6853,7 +7050,14 @@ interface ElectronClientOptions extends ElectronSharedClientOptions {
6853
7050
  //#endregion
6854
7051
  //#region src/authenticate.d.ts
6855
7052
  declare const requestAuthOptionsSchema: z.ZodObject<{
6856
- [x: string]: any;
7053
+ provider: z.ZodOptional<z.ZodString>;
7054
+ callbackURL: z.ZodOptional<z.ZodString>;
7055
+ newUserCallbackURL: z.ZodOptional<z.ZodString>;
7056
+ errorCallbackURL: z.ZodOptional<z.ZodString>;
7057
+ disableRedirect: z.ZodOptional<z.ZodBoolean>;
7058
+ scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
7059
+ requestSignUp: z.ZodOptional<z.ZodBoolean>;
7060
+ additionalData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
6857
7061
  }, z.core.$strip>;
6858
7062
  type ElectronRequestAuthOptions = z.infer<typeof requestAuthOptionsSchema>;
6859
7063
  //#endregion