@better-auth/api-key 1.6.0-beta.0 → 1.6.1

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.
@@ -1,98 +1,17 @@
1
1
  import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-CCe5L05Y.mjs";
2
2
  import * as better_auth0 from "better-auth";
3
+ import * as zod from "zod";
4
+ import * as zod_v4_core0 from "zod/v4/core";
3
5
  import { HookEndpointContext } from "@better-auth/core";
4
6
 
5
- //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/cookies.d.mts
6
- //#region src/cookies.d.ts
7
- type CookiePrefixOptions = "host" | "secure";
8
- type CookieOptions = {
9
- /**
10
- * Domain of the cookie
11
- *
12
- * The Domain attribute specifies which server can receive a cookie. If specified, cookies are
13
- * available on the specified server and its subdomains. If the it is not
14
- * specified, the cookies are available on the server that sets it but not on
15
- * its subdomains.
16
- *
17
- * @example
18
- * `domain: "example.com"`
19
- */
20
- domain?: string;
21
- /**
22
- * A lifetime of a cookie. Permanent cookies are deleted after the date specified in the
23
- * Expires attribute:
24
- *
25
- * Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and
26
- * takes precedence when both are set. The rationale behind this is that when you set an
27
- * Expires date and time, they're relative to the client the cookie is being set on. If the
28
- * server is set to a different time, this could cause errors
29
- */
30
- expires?: Date;
31
- /**
32
- * Forbids JavaScript from accessing the cookie, for example, through the Document.cookie
33
- * property. Note that a cookie that has been created with HttpOnly will still be sent with
34
- * JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().
35
- * This mitigates attacks against cross-site scripting
36
- */
37
- httpOnly?: boolean;
38
- /**
39
- * Indicates the number of seconds until the cookie expires. A zero or negative number will
40
- * expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.
41
- *
42
- * @example 604800 - 7 days
43
- */
44
- maxAge?: number;
45
- /**
46
- * Indicates the path that must exist in the requested URL for the browser to send the Cookie
47
- * header.
48
- *
49
- * @example
50
- * "/docs"
51
- * // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.
52
- */
53
- path?: string;
54
- /**
55
- * Indicates that the cookie is sent to the server only when a request is made with the https:
56
- * scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.
57
- */
58
- secure?: boolean;
59
- /**
60
- * Controls whether or not a cookie is sent with cross-site requests, providing some protection
61
- * against cross-site request forgery attacks (CSRF).
62
- *
63
- * Strict - Means that the browser sends the cookie only for same-site requests, that is,
64
- * requests originating from the same site that set the cookie. If a request originates from a
65
- * different domain or scheme (even with the same domain), no cookies with the SameSite=Strict
66
- * attribute are sent.
67
- *
68
- * Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load
69
- * images or frames, but is sent when a user is navigating to the origin site from an external
70
- * site (for example, when following a link). This is the default behavior if the SameSite
71
- * attribute is not specified.
72
- *
73
- * None - Means that the browser sends the cookie with both cross-site and same-site requests.
74
- * The Secure attribute must also be set when setting this value.
75
- */
76
- sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
77
- /**
78
- * Indicates that the cookie should be stored using partitioned storage. Note that if this is
79
- * set, the Secure directive must also be set.
80
- *
81
- * @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
82
- */
83
- partitioned?: boolean;
84
- /**
85
- * Cooke Prefix
86
- *
87
- * - secure: `__Secure-` -> `__Secure-cookie-name`
88
- * - host: `__Host-` -> `__Host-cookie-name`
89
- *
90
- * `secure` must be set to true to use prefixes
91
- */
92
- prefix?: CookiePrefixOptions;
93
- };
7
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/helper.d.mts
8
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
9
+ type IsEmptyObject<T> = keyof T extends never ? true : false;
10
+ type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
11
+ 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> : {};
12
+ 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
94
13
  //#endregion
95
- //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/standard-schema.d.mts
14
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/standard-schema.d.mts
96
15
  //#region src/standard-schema.d.ts
97
16
  /** The Standard Schema interface. */
98
17
  interface StandardSchemaV1<Input = unknown, Output = Input> {
@@ -150,7 +69,7 @@ declare namespace StandardSchemaV1 {
150
69
  type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
151
70
  } //#endregion
152
71
  //#endregion
153
- //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/error.d.mts
72
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/error.d.mts
154
73
  declare const statusCodes: {
155
74
  OK: number;
156
75
  CREATED: number;
@@ -228,273 +147,161 @@ declare const APIError: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "
228
147
  errorStack: string | undefined;
229
148
  }; //#endregion
230
149
  //#endregion
231
- //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/helper.d.mts
232
- type Prettify<T> = 0 extends 1 & T ? any : { [K in keyof T]: T[K] } & {};
233
- type IsEmptyObject<T> = keyof T extends never ? true : false;
234
- 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> : {};
235
- 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
236
- //#endregion
237
- //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/middleware.d.mts
238
- //#region src/middleware.d.ts
239
- type MiddlewareContext<Context = {}> = {
150
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/cookies.d.mts
151
+ //#region src/cookies.d.ts
152
+ type CookiePrefixOptions = "host" | "secure";
153
+ type CookieOptions = {
240
154
  /**
241
- * Method
155
+ * Domain of the cookie
242
156
  *
243
- * The request method
244
- */
245
- method: string;
246
- /**
247
- * Path
157
+ * The Domain attribute specifies which server can receive a cookie. If specified, cookies are
158
+ * available on the specified server and its subdomains. If the it is not
159
+ * specified, the cookies are available on the server that sets it but not on
160
+ * its subdomains.
248
161
  *
249
- * The path of the endpoint
162
+ * @example
163
+ * `domain: "example.com"`
250
164
  */
251
- path: string;
165
+ domain?: string;
252
166
  /**
253
- * Body
167
+ * A lifetime of a cookie. Permanent cookies are deleted after the date specified in the
168
+ * Expires attribute:
254
169
  *
255
- * The body object will be the parsed JSON from the request and validated
256
- * against the body schema if it exists
170
+ * Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and
171
+ * takes precedence when both are set. The rationale behind this is that when you set an
172
+ * Expires date and time, they're relative to the client the cookie is being set on. If the
173
+ * server is set to a different time, this could cause errors
257
174
  */
258
- body: any;
175
+ expires?: Date;
259
176
  /**
260
- * Query
261
- *
262
- * The query object will be the parsed query string from the request
263
- * and validated against the query schema if it exists
177
+ * Forbids JavaScript from accessing the cookie, for example, through the Document.cookie
178
+ * property. Note that a cookie that has been created with HttpOnly will still be sent with
179
+ * JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().
180
+ * This mitigates attacks against cross-site scripting
264
181
  */
265
- query: Record<string, any> | undefined;
182
+ httpOnly?: boolean;
266
183
  /**
267
- * Params
184
+ * Indicates the number of seconds until the cookie expires. A zero or negative number will
185
+ * expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.
268
186
  *
269
- * If the path is `/user/:id` and the request is `/user/1` then the
270
- * params will be `{ id: "1" }` and if the path includes a wildcard like
271
- * `/user/*` then the params will be `{ _: "1" }` where `_` is the wildcard
272
- * key. If the wildcard is named like `/user/**:name` then the params will
273
- * be `{ name: string }`
187
+ * @example 604800 - 7 days
274
188
  */
275
- params: Record<string, any> | undefined;
189
+ maxAge?: number;
276
190
  /**
277
- * Request object
191
+ * Indicates the path that must exist in the requested URL for the browser to send the Cookie
192
+ * header.
278
193
  *
279
- * If `requireRequest` is set to true in the endpoint options this will be
280
- * required
194
+ * @example
195
+ * "/docs"
196
+ * // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.
281
197
  */
282
- request: Request | undefined;
198
+ path?: string;
283
199
  /**
284
- * Headers
285
- *
286
- * If `requireHeaders` is set to true in the endpoint options this will be
287
- * required
200
+ * Indicates that the cookie is sent to the server only when a request is made with the https:
201
+ * scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.
288
202
  */
289
- headers: Headers | undefined;
203
+ secure?: boolean;
290
204
  /**
291
- * Set header
205
+ * Controls whether or not a cookie is sent with cross-site requests, providing some protection
206
+ * against cross-site request forgery attacks (CSRF).
292
207
  *
293
- * If it's called outside of a request it will just be ignored.
294
- */
295
- setHeader: (key: string, value: string) => void;
296
- /**
297
- * Set the response status code
298
- */
299
- setStatus: (status: Status) => void;
300
- /**
301
- * Get header
208
+ * Strict - Means that the browser sends the cookie only for same-site requests, that is,
209
+ * requests originating from the same site that set the cookie. If a request originates from a
210
+ * different domain or scheme (even with the same domain), no cookies with the SameSite=Strict
211
+ * attribute are sent.
302
212
  *
303
- * If it's called outside of a request it will just return null
213
+ * Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load
214
+ * images or frames, but is sent when a user is navigating to the origin site from an external
215
+ * site (for example, when following a link). This is the default behavior if the SameSite
216
+ * attribute is not specified.
304
217
  *
305
- * @param key - The key of the header
218
+ * None - Means that the browser sends the cookie with both cross-site and same-site requests.
219
+ * The Secure attribute must also be set when setting this value.
306
220
  */
307
- getHeader: (key: string) => string | null;
221
+ sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
308
222
  /**
309
- * Get a cookie value from the request
223
+ * Indicates that the cookie should be stored using partitioned storage. Note that if this is
224
+ * set, the Secure directive must also be set.
310
225
  *
311
- * @param key - The key of the cookie
312
- * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
313
- * @returns The value of the cookie
226
+ * @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
314
227
  */
315
- getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
228
+ partitioned?: boolean;
316
229
  /**
317
- * Get a signed cookie value from the request
230
+ * Cooke Prefix
318
231
  *
319
- * @param key - The key of the cookie
320
- * @param secret - The secret of the signed cookie
321
- * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
322
- * @returns The value of the cookie or null if the cookie is not found or false if the signature is invalid
323
- */
324
- getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | null | false>;
325
- /**
326
- * Set a cookie value in the response
232
+ * - secure: `__Secure-` -> `__Secure-cookie-name`
233
+ * - host: `__Host-` -> `__Host-cookie-name`
327
234
  *
328
- * @param key - The key of the cookie
329
- * @param value - The value to set
330
- * @param options - The options of the cookie
331
- * @returns The cookie string
235
+ * `secure` must be set to true to use prefixes
332
236
  */
333
- setCookie: (key: string, value: string, options?: CookieOptions) => string;
237
+ prefix?: CookiePrefixOptions;
238
+ };
239
+ //#endregion
240
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/openapi.d.mts
241
+ //#region src/openapi.d.ts
242
+ type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
243
+ interface OpenAPIParameter {
244
+ in: "query" | "path" | "header" | "cookie";
245
+ name?: string;
246
+ description?: string;
247
+ required?: boolean;
248
+ schema?: {
249
+ type: OpenAPISchemaType;
250
+ format?: string | undefined;
251
+ items?: {
252
+ type: OpenAPISchemaType;
253
+ };
254
+ enum?: string[];
255
+ minLength?: number;
256
+ description?: string | undefined;
257
+ default?: string | undefined;
258
+ example?: string | undefined;
259
+ };
260
+ }
261
+ //#endregion
262
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/endpoint.d.mts
263
+ //#region src/endpoint.d.ts
264
+ interface EndpointBaseOptions {
334
265
  /**
335
- * Set signed cookie
336
- *
337
- * @param key - The key of the cookie
338
- * @param value - The value to set
339
- * @param secret - The secret to sign the cookie with
340
- * @param options - The options of the cookie
341
- * @returns The cookie string
266
+ * Query Schema
342
267
  */
343
- setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
268
+ query?: StandardSchemaV1;
344
269
  /**
345
- * JSON
346
- *
347
- * A helper function to create a JSON response with the correct headers
348
- * and status code. If `asResponse` is set to true in the context then
349
- * it will return a Response object instead of the JSON object.
350
- *
351
- * @param json - The JSON object to return
352
- * @param routerResponse - The response object to return if `asResponse` is
353
- * true in the context this will take precedence
270
+ * Error Schema
354
271
  */
355
- json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
356
- status?: number;
357
- headers?: Record<string, string>;
358
- response?: Response;
359
- body?: Record<string, any>;
360
- } | Response) => R;
272
+ error?: StandardSchemaV1;
361
273
  /**
362
- * Middleware context
274
+ * If true headers will be required to be passed in the context
363
275
  */
364
- context: Prettify<Context>;
276
+ requireHeaders?: boolean;
365
277
  /**
366
- * Redirect to a new URL
278
+ * If true request object will be required
367
279
  */
368
- redirect: (url: string) => APIError;
280
+ requireRequest?: boolean;
369
281
  /**
370
- * Return error
282
+ * Clone the request object from the router
371
283
  */
372
- error: (status: keyof typeof statusCodes | Status, body?: {
373
- message?: string;
374
- code?: string;
375
- } & Record<string, any>, headers?: HeadersInit) => APIError;
376
- asResponse?: boolean;
377
- returnHeaders?: boolean;
378
- returnStatus?: boolean;
379
- responseHeaders: Headers;
380
- };
381
- type DefaultHandler = (inputCtx: MiddlewareContext<any>) => Promise<any>;
382
- type Middleware<Handler extends (inputCtx: MiddlewareContext<any>) => Promise<any> = DefaultHandler> = Handler & {
383
- options: Record<string, any>;
384
- };
385
- //#endregion
386
- //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/types.d.mts
387
- //#region src/types.d.ts
388
- type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD";
389
- /**
390
- * Resolves a method type parameter to its effective runtime type.
391
- */
392
- /**
393
- * Infer param input (required vs optional based on whether path has params).
394
- */
395
- type InferParamInput<Path extends string> = [Path] extends [never] ? {
396
- params?: Record<string, any>;
397
- } : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
398
- params?: Record<string, any>;
399
- } : {
400
- params: Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
401
- };
402
- /**
403
- * Infer body input from an already-resolved body type.
404
- * Body is the plain resolved type (not a schema).
405
- */
406
- type InferBodyInput<Body> = undefined extends Body ? {
407
- body?: Body;
408
- } : {
409
- body: Body;
410
- };
411
- /**
412
- * Infer query input from an already-resolved query type.
413
- * Query is the plain resolved type (not a schema).
414
- */
415
- type InferQueryInput<Query> = undefined extends Query ? {
416
- query?: Query;
417
- } : {
418
- query: Query;
419
- };
420
- /**
421
- * Infer method input: required for wildcard, optional for arrays and single methods.
422
- */
423
- type InferMethodInput<M> = 0 extends 1 & M ? {
424
- method?: HTTPMethod | undefined;
425
- } : M extends "*" ? {
426
- method: HTTPMethod;
427
- } : M extends Array<any> ? {
428
- method?: M[number] | undefined;
429
- } : {
430
- method?: M | undefined;
431
- };
432
- /**
433
- * Infer request input.
434
- */
435
- type InferRequestInput<ReqRequest extends boolean> = 0 extends 1 & ReqRequest ? {
436
- request?: Request;
437
- } : ReqRequest extends true ? {
438
- request: Request;
439
- } : {
440
- request?: Request;
441
- };
442
- /**
443
- * Infer headers input.
444
- */
445
- type InferHeadersInput<ReqHeaders extends boolean> = 0 extends 1 & ReqHeaders ? {
446
- headers?: HeadersInit;
447
- } : ReqHeaders extends true ? {
448
- headers: HeadersInit;
449
- } : {
450
- headers?: HeadersInit;
451
- };
452
- /**
453
- * Infer the use (middleware) context union.
454
- * Guards against `any` and `[]` to avoid poisoning the Context type.
455
- */
456
- /**
457
- * The full InputContext type for the Endpoint call signature.
458
- * Body and Query are already-resolved plain types.
459
- */
460
- 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> & {
461
- asResponse?: boolean;
462
- returnHeaders?: boolean;
463
- returnStatus?: boolean;
464
- use?: Middleware[];
465
- path?: string;
466
- context?: Record<string, any>;
467
- }; //#endregion
468
- //#endregion
469
- //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/endpoint.d.mts
470
- //#region src/endpoint.d.ts
471
- interface EndpointMetadata {
284
+ cloneRequest?: boolean;
285
+ /**
286
+ * If true the body will be undefined
287
+ */
288
+ disableBody?: boolean;
472
289
  /**
473
- * Open API definition
290
+ * Endpoint metadata
474
291
  */
475
- openapi?: {
476
- summary?: string;
477
- description?: string;
478
- tags?: string[];
479
- operationId?: string;
480
- parameters?: OpenAPIParameter[];
481
- requestBody?: {
482
- content: {
483
- "application/json": {
484
- schema: {
485
- type?: OpenAPISchemaType;
486
- properties?: Record<string, any>;
487
- required?: string[];
488
- $ref?: string;
489
- };
490
- };
491
- };
492
- };
493
- responses?: {
494
- [status: string]: {
495
- description: string;
496
- content?: {
497
- "application/json"?: {
292
+ metadata?: {
293
+ /**
294
+ * Open API definition
295
+ */
296
+ openapi?: {
297
+ summary?: string;
298
+ description?: string;
299
+ tags?: string[];
300
+ operationId?: string;
301
+ parameters?: OpenAPIParameter[];
302
+ requestBody?: {
303
+ content: {
304
+ "application/json": {
498
305
  schema: {
499
306
  type?: OpenAPISchemaType;
500
307
  properties?: Record<string, any>;
@@ -502,156 +309,319 @@ interface EndpointMetadata {
502
309
  $ref?: string;
503
310
  };
504
311
  };
505
- "text/plain"?: {
506
- schema?: {
507
- type?: OpenAPISchemaType;
508
- properties?: Record<string, any>;
509
- required?: string[];
510
- $ref?: string;
312
+ };
313
+ };
314
+ responses?: {
315
+ [status: string]: {
316
+ description: string;
317
+ content?: {
318
+ "application/json"?: {
319
+ schema: {
320
+ type?: OpenAPISchemaType;
321
+ properties?: Record<string, any>;
322
+ required?: string[];
323
+ $ref?: string;
324
+ };
511
325
  };
512
- };
513
- "text/html"?: {
514
- schema?: {
515
- type?: OpenAPISchemaType;
516
- properties?: Record<string, any>;
517
- required?: string[];
518
- $ref?: string;
326
+ "text/plain"?: {
327
+ schema?: {
328
+ type?: OpenAPISchemaType;
329
+ properties?: Record<string, any>;
330
+ required?: string[];
331
+ $ref?: string;
332
+ };
333
+ };
334
+ "text/html"?: {
335
+ schema?: {
336
+ type?: OpenAPISchemaType;
337
+ properties?: Record<string, any>;
338
+ required?: string[];
339
+ $ref?: string;
340
+ };
519
341
  };
520
342
  };
521
343
  };
522
344
  };
523
345
  };
524
- };
525
- /**
526
- * Infer body and query type from ts interface
527
- *
528
- * useful for generic and dynamic types
529
- *
530
- * @example
531
- * ```ts
532
- * const endpoint = createEndpoint("/path", {
533
- * method: "POST",
534
- * body: z.record(z.string()),
535
- * $Infer: {
536
- * body: {} as {
537
- * type: InferTypeFromOptions<Option> // custom type inference
538
- * }
539
- * }
540
- * }, async(ctx)=>{
541
- * const body = ctx.body
542
- * })
543
- * ```
544
- */
545
- $Infer?: {
546
346
  /**
547
- * Body
347
+ * Infer body and query type from ts interface
348
+ *
349
+ * useful for generic and dynamic types
350
+ *
351
+ * @example
352
+ * ```ts
353
+ * const endpoint = createEndpoint("/path", {
354
+ * method: "POST",
355
+ * body: z.record(z.string()),
356
+ * $Infer: {
357
+ * body: {} as {
358
+ * type: InferTypeFromOptions<Option> // custom type inference
359
+ * }
360
+ * }
361
+ * }, async(ctx)=>{
362
+ * const body = ctx.body
363
+ * })
364
+ * ```
365
+ */
366
+ $Infer?: {
367
+ /**
368
+ * Body
369
+ */
370
+ body?: any;
371
+ /**
372
+ * Query
373
+ */
374
+ query?: Record<string, any>;
375
+ };
376
+ /**
377
+ * If enabled, endpoint won't be exposed over a router
378
+ * @deprecated Use path-less endpoints instead
379
+ */
380
+ SERVER_ONLY?: boolean;
381
+ /**
382
+ * If enabled, endpoint won't be exposed as an action to the client
383
+ * @deprecated Use path-less endpoints instead
548
384
  */
549
- body?: any;
385
+ isAction?: boolean;
550
386
  /**
551
- * Query
387
+ * Defines the places where the endpoint will be available
388
+ *
389
+ * Possible options:
390
+ * - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
391
+ * - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
392
+ * - `http` - the endpoint is only exposed to the router
393
+ * @default "rpc"
552
394
  */
553
- query?: Record<string, any>;
395
+ scope?: "rpc" | "server" | "http";
554
396
  /**
555
- * Error
397
+ * List of allowed media types (MIME types) for the endpoint
398
+ *
399
+ * if provided, only the media types in the list will be allowed to be passed in the body
400
+ *
401
+ * @example
402
+ * ```ts
403
+ * const endpoint = createEndpoint("/path", {
404
+ * method: "POST",
405
+ * allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
406
+ * }, async(ctx)=>{
407
+ * const body = ctx.body
408
+ * })
409
+ * ```
556
410
  */
557
- error?: any;
411
+ allowedMediaTypes?: string[];
412
+ /**
413
+ * Extra metadata
414
+ */
415
+ [key: string]: any;
558
416
  };
559
417
  /**
560
- * If enabled, endpoint won't be exposed over a router
561
- * @deprecated Use path-less endpoints instead
418
+ * List of middlewares to use
419
+ */
420
+ use?: Middleware[];
421
+ /**
422
+ * A callback to run before any API error is throw or returned
423
+ *
424
+ * @param e - The API error
425
+ * @returns - The response to return
426
+ */
427
+ onAPIError?: (e: APIError) => void | Promise<void>;
428
+ /**
429
+ * A callback to run before a validation error is thrown
430
+ * You can customize the validation error message by throwing your own APIError
431
+ */
432
+ onValidationError?: ({
433
+ issues,
434
+ message
435
+ }: {
436
+ message: string;
437
+ issues: readonly StandardSchemaV1.Issue[];
438
+ }) => void | Promise<void>;
439
+ }
440
+ type EndpointBodyMethodOptions = {
441
+ /**
442
+ * Request Method
443
+ */
444
+ method: "POST" | "PUT" | "DELETE" | "PATCH" | ("POST" | "PUT" | "DELETE" | "PATCH")[];
445
+ /**
446
+ * Body Schema
447
+ */
448
+ body?: StandardSchemaV1;
449
+ } | {
450
+ /**
451
+ * Request Method
452
+ */
453
+ method: "GET" | "HEAD" | ("GET" | "HEAD")[];
454
+ /**
455
+ * Body Schema
456
+ */
457
+ body?: never;
458
+ } | {
459
+ /**
460
+ * Request Method
562
461
  */
563
- SERVER_ONLY?: boolean;
462
+ method: "*";
564
463
  /**
565
- * If enabled, endpoint won't be exposed as an action to the client
566
- * @deprecated Use path-less endpoints instead
464
+ * Body Schema
567
465
  */
568
- isAction?: boolean;
466
+ body?: StandardSchemaV1;
467
+ } | {
569
468
  /**
570
- * Defines the places where the endpoint will be available
469
+ * Request Method
470
+ */
471
+ method: ("POST" | "PUT" | "DELETE" | "PATCH" | "GET" | "HEAD")[];
472
+ /**
473
+ * Body Schema
474
+ */
475
+ body?: StandardSchemaV1;
476
+ };
477
+ type EndpointOptions = EndpointBaseOptions & EndpointBodyMethodOptions;
478
+ type EndpointContext<Path extends string, Options extends EndpointOptions, Context = {}> = {
479
+ /**
480
+ * Method
571
481
  *
572
- * Possible options:
573
- * - `rpc` - the endpoint is exposed to the router, can be invoked directly and is available to the client
574
- * - `server` - the endpoint is exposed to the router, can be invoked directly, but is not available to the client
575
- * - `http` - the endpoint is only exposed to the router
576
- * @default "rpc"
482
+ * The request method
577
483
  */
578
- scope?: "rpc" | "server" | "http";
484
+ method: InferMethod<Options>;
579
485
  /**
580
- * List of allowed media types (MIME types) for the endpoint
486
+ * Path
581
487
  *
582
- * if provided, only the media types in the list will be allowed to be passed in the body
488
+ * The path of the endpoint
489
+ */
490
+ path: Path;
491
+ /**
492
+ * Body
583
493
  *
584
- * @example
585
- * ```ts
586
- * const endpoint = createEndpoint("/path", {
587
- * method: "POST",
588
- * allowedMediaTypes: ["application/json", "application/x-www-form-urlencoded"],
589
- * }, async(ctx)=>{
590
- * const body = ctx.body
591
- * })
592
- * ```
494
+ * The body object will be the parsed JSON from the request and validated
495
+ * against the body schema if it exists.
593
496
  */
594
- allowedMediaTypes?: string[];
497
+ body: InferBody<Options>;
595
498
  /**
596
- * Extra metadata
499
+ * Query
500
+ *
501
+ * The query object will be the parsed query string from the request
502
+ * and validated against the query schema if it exists
597
503
  */
598
- [key: string]: any;
599
- }
600
- interface EndpointRuntimeOptions {
601
- method: string | string[];
602
- body?: StandardSchemaV1;
504
+ query: InferQuery<Options>;
603
505
  /**
604
- * Query Schema
506
+ * Params
507
+ *
508
+ * If the path is `/user/:id` and the request is `/user/1` then the params will
509
+ * be `{ id: "1" }` and if the path includes a wildcard like `/user/*` then the
510
+ * params will be `{ _: "1" }` where `_` is the wildcard key. If the wildcard
511
+ * is named like `/user/**:name` then the params will be `{ name: string }`
605
512
  */
606
- query?: StandardSchemaV1;
513
+ params: InferParam<Path>;
607
514
  /**
608
- * Error Schema
515
+ * Request object
516
+ *
517
+ * If `requireRequest` is set to true in the endpoint options this will be
518
+ * required
609
519
  */
610
- error?: StandardSchemaV1;
520
+ request: InferRequest<Options>;
611
521
  /**
612
- * If true headers will be required to be passed in the context
522
+ * Headers
523
+ *
524
+ * If `requireHeaders` is set to true in the endpoint options this will be
525
+ * required
613
526
  */
614
- requireHeaders?: boolean;
527
+ headers: InferHeaders<Options>;
615
528
  /**
616
- * If true request object will be required
529
+ * Set header
530
+ *
531
+ * If it's called outside of a request it will just be ignored.
617
532
  */
618
- requireRequest?: boolean;
533
+ setHeader: (key: string, value: string) => void;
619
534
  /**
620
- * Clone the request object from the router
535
+ * Set the response status code
621
536
  */
622
- cloneRequest?: boolean;
537
+ setStatus: (status: Status) => void;
623
538
  /**
624
- * If true the body will be undefined
539
+ * Get header
540
+ *
541
+ * If it's called outside of a request it will just return null
542
+ *
543
+ * @param key - The key of the header
544
+ * @returns
625
545
  */
626
- disableBody?: boolean;
546
+ getHeader: (key: string) => string | null;
627
547
  /**
628
- * Endpoint metadata
548
+ * Get a cookie value from the request
549
+ *
550
+ * @param key - The key of the cookie
551
+ * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
552
+ * @returns - The value of the cookie
629
553
  */
630
- metadata?: EndpointMetadata;
554
+ getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
631
555
  /**
632
- * List of middlewares to use
556
+ * Get a signed cookie value from the request
557
+ *
558
+ * @param key - The key of the cookie
559
+ * @param secret - The secret of the signed cookie
560
+ * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
561
+ * @returns - The value of the cookie or null if the cookie is not found or false if the signature is invalid
633
562
  */
634
- use?: Middleware[];
563
+ getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | null | false>;
635
564
  /**
636
- * A callback to run before any API error is thrown or returned
565
+ * Set a cookie value in the response
637
566
  *
638
- * @param e - The API error
567
+ * @param key - The key of the cookie
568
+ * @param value - The value to set
569
+ * @param options - The options of the cookie
570
+ * @returns - The cookie string
639
571
  */
640
- onAPIError?: (e: APIError) => void | Promise<void>;
572
+ setCookie: (key: string, value: string, options?: CookieOptions) => string;
641
573
  /**
642
- * A callback to run before a validation error is thrown.
643
- * You can customize the validation error message by throwing your own APIError.
574
+ * Set signed cookie
575
+ *
576
+ * @param key - The key of the cookie
577
+ * @param value - The value to set
578
+ * @param secret - The secret to sign the cookie with
579
+ * @param options - The options of the cookie
580
+ * @returns - The cookie string
644
581
  */
645
- onValidationError?: (info: {
646
- message: string;
647
- issues: readonly StandardSchemaV1.Issue[];
648
- }) => void | Promise<void>;
649
- }
650
- 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> = {
651
- (context: InputContext<Path, Method, Body, Query, false, false> & {
582
+ setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
583
+ /**
584
+ * JSON
585
+ *
586
+ * a helper function to create a JSON response with
587
+ * the correct headers
588
+ * and status code. If `asResponse` is set to true in
589
+ * the context then
590
+ * it will return a Response object instead of the
591
+ * JSON object.
592
+ *
593
+ * @param json - The JSON object to return
594
+ * @param routerResponse - The response object to
595
+ * return if `asResponse` is
596
+ * true in the context this will take precedence
597
+ */
598
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
599
+ status?: number;
600
+ headers?: Record<string, string>;
601
+ response?: Response;
602
+ body?: Record<string, string>;
603
+ } | Response) => Promise<R>;
604
+ /**
605
+ * Middleware context
606
+ */
607
+ context: Prettify<Context & InferUse<Options["use"]>>;
608
+ /**
609
+ * Redirect to a new URL
610
+ */
611
+ redirect: (url: string) => APIError;
612
+ /**
613
+ * Return error
614
+ */
615
+ error: (status: keyof typeof statusCodes | Status, body?: {
616
+ message?: string;
617
+ code?: string;
618
+ } & Record<string, any>, headers?: HeadersInit) => APIError;
619
+ };
620
+ type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = any> = {
621
+ (context: InputContext<Path, Options> & {
652
622
  asResponse: true;
653
623
  }): Promise<Response>;
654
- (context: InputContext<Path, Method, Body, Query, false, false> & {
624
+ (context: InputContext<Path, Options> & {
655
625
  returnHeaders: true;
656
626
  returnStatus: true;
657
627
  }): Promise<{
@@ -659,47 +629,217 @@ type Endpoint<Path extends string = string, Method = any, Body = any, Query = an
659
629
  status: number;
660
630
  response: Awaited<R>;
661
631
  }>;
662
- (context: InputContext<Path, Method, Body, Query, false, false> & {
632
+ (context: InputContext<Path, Options> & {
663
633
  returnHeaders: true;
634
+ returnStatus: false;
664
635
  }): Promise<{
665
636
  headers: Headers;
666
637
  response: Awaited<R>;
667
638
  }>;
668
- (context: InputContext<Path, Method, Body, Query, false, false> & {
639
+ (context: InputContext<Path, Options> & {
640
+ returnHeaders: false;
669
641
  returnStatus: true;
670
642
  }): Promise<{
671
643
  status: number;
672
644
  response: Awaited<R>;
673
645
  }>;
674
- (context?: InputContext<Path, Method, Body, Query, false, false>): Promise<Awaited<R>>;
675
- readonly options: Omit<EndpointRuntimeOptions, "method" | "metadata"> & {
676
- readonly method: Method;
677
- readonly metadata?: Meta;
678
- };
679
- readonly path: Path;
646
+ (context: InputContext<Path, Options> & {
647
+ returnHeaders: false;
648
+ returnStatus: false;
649
+ }): Promise<R>;
650
+ (context: InputContext<Path, Options> & {
651
+ returnHeaders: true;
652
+ }): Promise<{
653
+ headers: Headers;
654
+ response: Awaited<R>;
655
+ }>;
656
+ (context: InputContext<Path, Options> & {
657
+ returnStatus: true;
658
+ }): Promise<{
659
+ status: number;
660
+ response: Awaited<R>;
661
+ }>;
662
+ (context?: InputContext<Path, Options>): Promise<R>;
663
+ options: Options;
664
+ path: Path;
680
665
  };
681
666
  //#endregion
682
- //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/openapi.d.mts
683
- //#region src/openapi.d.ts
684
- type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
685
- interface OpenAPIParameter {
686
- in: "query" | "path" | "header" | "cookie";
687
- name?: string;
688
- description?: string;
689
- required?: boolean;
690
- schema?: {
691
- type: OpenAPISchemaType;
692
- format?: string | undefined;
693
- items?: {
694
- type: OpenAPISchemaType;
695
- };
696
- enum?: string[];
697
- minLength?: number;
698
- description?: string | undefined;
699
- default?: string | undefined;
700
- example?: string | undefined;
667
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/middleware.d.mts
668
+ //#region src/middleware.d.ts
669
+ interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {}
670
+ type MiddlewareContext<Options extends MiddlewareOptions, Context = {}> = EndpointContext<string, Options & {
671
+ method: "*";
672
+ }> & {
673
+ /**
674
+ * Method
675
+ *
676
+ * The request method
677
+ */
678
+ method: string;
679
+ /**
680
+ * Path
681
+ *
682
+ * The path of the endpoint
683
+ */
684
+ path: string;
685
+ /**
686
+ * Body
687
+ *
688
+ * The body object will be the parsed JSON from the request and validated
689
+ * against the body schema if it exists
690
+ */
691
+ body: InferMiddlewareBody<Options>;
692
+ /**
693
+ * Query
694
+ *
695
+ * The query object will be the parsed query string from the request
696
+ * and validated against the query schema if it exists
697
+ */
698
+ query: InferMiddlewareQuery<Options>;
699
+ /**
700
+ * Params
701
+ *
702
+ * If the path is `/user/:id` and the request is `/user/1` then the
703
+ * params will
704
+ * be `{ id: "1" }` and if the path includes a wildcard like `/user/*`
705
+ * then the
706
+ * params will be `{ _: "1" }` where `_` is the wildcard key. If the
707
+ * wildcard
708
+ * is named like `/user/**:name` then the params will be `{ name: string }`
709
+ */
710
+ params: string;
711
+ /**
712
+ * Request object
713
+ *
714
+ * If `requireRequest` is set to true in the endpoint options this will be
715
+ * required
716
+ */
717
+ request: InferRequest<Options>;
718
+ /**
719
+ * Headers
720
+ *
721
+ * If `requireHeaders` is set to true in the endpoint options this will be
722
+ * required
723
+ */
724
+ headers: InferHeaders<Options>;
725
+ /**
726
+ * Set header
727
+ *
728
+ * If it's called outside of a request it will just be ignored.
729
+ */
730
+ setHeader: (key: string, value: string) => void;
731
+ /**
732
+ * Get header
733
+ *
734
+ * If it's called outside of a request it will just return null
735
+ *
736
+ * @param key - The key of the header
737
+ * @returns
738
+ */
739
+ getHeader: (key: string) => string | null;
740
+ /**
741
+ * JSON
742
+ *
743
+ * a helper function to create a JSON response with
744
+ * the correct headers
745
+ * and status code. If `asResponse` is set to true in
746
+ * the context then
747
+ * it will return a Response object instead of the
748
+ * JSON object.
749
+ *
750
+ * @param json - The JSON object to return
751
+ * @param routerResponse - The response object to
752
+ * return if `asResponse` is
753
+ * true in the context this will take precedence
754
+ */
755
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
756
+ status?: number;
757
+ headers?: Record<string, string>;
758
+ response?: Response;
759
+ } | Response) => Promise<R>;
760
+ /**
761
+ * Middleware context
762
+ */
763
+ context: Prettify<Context>;
764
+ };
765
+ type MiddlewareInputContext<Options extends MiddlewareOptions> = InferBodyInput<Options> & InferQueryInput<Options> & InferRequestInput<Options> & InferHeadersInput<Options> & {
766
+ asResponse?: boolean;
767
+ returnHeaders?: boolean;
768
+ use?: Middleware[];
769
+ };
770
+ type Middleware<Options extends MiddlewareOptions = MiddlewareOptions, Handler extends (inputCtx: any) => Promise<any> = any> = Handler & {
771
+ options: Options;
772
+ }; //#endregion
773
+ //#endregion
774
+ //#region ../../node_modules/.pnpm/better-call@1.3.5_zod@4.3.6/node_modules/better-call/dist/context.d.mts
775
+ //#region src/context.d.ts
776
+ type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
777
+ type Method = HTTPMethod | "*";
778
+ type InferBodyInput<Options extends EndpointOptions | MiddlewareOptions, Body = (Options["metadata"] extends {
779
+ $Infer: {
780
+ body: infer B;
701
781
  };
702
- }
782
+ } ? B : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["body"]> : undefined)> = undefined extends Body ? {
783
+ body?: Body;
784
+ } : {
785
+ body: Body;
786
+ };
787
+ type InferBody<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
788
+ $Infer: {
789
+ body: infer Body;
790
+ };
791
+ } ? Body : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Options["body"]> : any;
792
+ type InferQueryInput<Options extends EndpointOptions | MiddlewareOptions, Query = (Options["metadata"] extends {
793
+ $Infer: {
794
+ query: infer Query;
795
+ };
796
+ } ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined)> = undefined extends Query ? {
797
+ query?: Query;
798
+ } : {
799
+ query: Query;
800
+ };
801
+ type InferQuery<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
802
+ $Infer: {
803
+ query: infer Query;
804
+ };
805
+ } ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Options["query"]> : Record<string, any> | undefined;
806
+ type InferMethod<Options extends EndpointOptions> = Options["method"] extends Array<Method> ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"];
807
+ 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 ? {
808
+ method?: Method;
809
+ } : {
810
+ method: Method;
811
+ };
812
+ 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>>;
813
+ type InferParamInput<Path extends string> = [Path] extends [never] ? {
814
+ params?: Record<string, any>;
815
+ } : IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
816
+ params?: Record<string, any>;
817
+ } : {
818
+ params: Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
819
+ };
820
+ type InferRequest<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? Request : Request | undefined;
821
+ type InferRequestInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? {
822
+ request: Request;
823
+ } : {
824
+ request?: Request;
825
+ };
826
+ type InferHeaders<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? Headers : Headers | undefined;
827
+ type InferHeadersInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? {
828
+ headers: HeadersInit;
829
+ } : {
830
+ headers?: HeadersInit;
831
+ };
832
+ type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Middleware[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : {};
833
+ type InferMiddlewareBody<Options extends MiddlewareOptions> = Options["body"] extends StandardSchemaV1<infer T> ? T : any;
834
+ type InferMiddlewareQuery<Options extends MiddlewareOptions> = Options["query"] extends StandardSchemaV1<infer T> ? T : Record<string, any> | undefined;
835
+ type InputContext<Path extends string, Options extends EndpointOptions> = InferBodyInput<Options> & InferInputMethod<Options> & InferQueryInput<Options> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
836
+ asResponse?: boolean;
837
+ returnHeaders?: boolean;
838
+ returnStatus?: boolean;
839
+ use?: Middleware[];
840
+ path?: string;
841
+ context?: Record<string, any>;
842
+ };
703
843
  //#endregion
704
844
  //#region src/error-codes.d.ts
705
845
  declare const API_KEY_ERROR_CODES: {
@@ -785,7 +925,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
785
925
  hooks: {
786
926
  before: {
787
927
  matcher: (ctx: HookEndpointContext) => boolean;
788
- handler: Middleware<(inputContext: Record<string, any>) => Promise<{
928
+ handler: (inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<{
789
929
  user: {
790
930
  id: string;
791
931
  createdAt: Date;
@@ -806,7 +946,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
806
946
  expiresAt: Date;
807
947
  };
808
948
  } | {
809
- context: MiddlewareContext<{
949
+ context: MiddlewareContext<MiddlewareOptions, {
810
950
  returned?: unknown | undefined;
811
951
  responseHeaders?: Headers | undefined;
812
952
  } & better_auth0.PluginContext<better_auth0.BetterAuthOptions> & better_auth0.InfoContext & {
@@ -935,7 +1075,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
935
1075
  runInBackground: (promise: Promise<unknown>) => void;
936
1076
  runInBackgroundOrAwait: (promise: Promise<unknown> | void) => better_auth0.Awaitable<unknown>;
937
1077
  }>;
938
- }>>;
1078
+ }>;
939
1079
  }[];
940
1080
  };
941
1081
  endpoints: {
@@ -954,22 +1094,154 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
954
1094
  *
955
1095
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-create)
956
1096
  */
957
- createApiKey: Endpoint<"/api-key/create", "POST", {
958
- configId?: string | undefined;
959
- name?: string | undefined;
960
- expiresIn?: number | null | undefined;
961
- prefix?: string | undefined;
962
- remaining?: number | null | undefined;
963
- metadata?: any;
964
- refillAmount?: number | undefined;
965
- refillInterval?: number | undefined;
966
- rateLimitTimeWindow?: number | undefined;
967
- rateLimitMax?: number | undefined;
968
- rateLimitEnabled?: boolean | undefined;
969
- permissions?: Record<string, string[]> | undefined;
970
- userId?: unknown;
971
- organizationId?: unknown;
972
- }, Record<string, any> | undefined, [], {
1097
+ createApiKey: StrictEndpoint<"/api-key/create", {
1098
+ method: "POST";
1099
+ body: zod.ZodObject<{
1100
+ configId: zod.ZodOptional<zod.ZodString>;
1101
+ name: zod.ZodOptional<zod.ZodString>;
1102
+ expiresIn: zod.ZodDefault<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
1103
+ prefix: zod.ZodOptional<zod.ZodString>;
1104
+ remaining: zod.ZodDefault<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
1105
+ metadata: zod.ZodOptional<zod.ZodAny>;
1106
+ refillAmount: zod.ZodOptional<zod.ZodNumber>;
1107
+ refillInterval: zod.ZodOptional<zod.ZodNumber>;
1108
+ rateLimitTimeWindow: zod.ZodOptional<zod.ZodNumber>;
1109
+ rateLimitMax: zod.ZodOptional<zod.ZodNumber>;
1110
+ rateLimitEnabled: zod.ZodOptional<zod.ZodBoolean>;
1111
+ permissions: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>>;
1112
+ userId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
1113
+ organizationId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
1114
+ }, zod_v4_core0.$strip>;
1115
+ metadata: {
1116
+ openapi: {
1117
+ description: string;
1118
+ responses: {
1119
+ "200": {
1120
+ description: string;
1121
+ content: {
1122
+ "application/json": {
1123
+ schema: {
1124
+ type: "object";
1125
+ properties: {
1126
+ id: {
1127
+ type: string;
1128
+ description: string;
1129
+ };
1130
+ createdAt: {
1131
+ type: string;
1132
+ format: string;
1133
+ description: string;
1134
+ };
1135
+ updatedAt: {
1136
+ type: string;
1137
+ format: string;
1138
+ description: string;
1139
+ };
1140
+ name: {
1141
+ type: string;
1142
+ nullable: boolean;
1143
+ description: string;
1144
+ };
1145
+ prefix: {
1146
+ type: string;
1147
+ nullable: boolean;
1148
+ description: string;
1149
+ };
1150
+ start: {
1151
+ type: string;
1152
+ nullable: boolean;
1153
+ description: string;
1154
+ };
1155
+ key: {
1156
+ type: string;
1157
+ description: string;
1158
+ };
1159
+ enabled: {
1160
+ type: string;
1161
+ description: string;
1162
+ };
1163
+ expiresAt: {
1164
+ type: string;
1165
+ format: string;
1166
+ nullable: boolean;
1167
+ description: string;
1168
+ };
1169
+ referenceId: {
1170
+ type: string;
1171
+ description: string;
1172
+ };
1173
+ lastRefillAt: {
1174
+ type: string;
1175
+ format: string;
1176
+ nullable: boolean;
1177
+ description: string;
1178
+ };
1179
+ lastRequest: {
1180
+ type: string;
1181
+ format: string;
1182
+ nullable: boolean;
1183
+ description: string;
1184
+ };
1185
+ metadata: {
1186
+ type: string;
1187
+ nullable: boolean;
1188
+ additionalProperties: boolean;
1189
+ description: string;
1190
+ };
1191
+ rateLimitMax: {
1192
+ type: string;
1193
+ nullable: boolean;
1194
+ description: string;
1195
+ };
1196
+ rateLimitTimeWindow: {
1197
+ type: string;
1198
+ nullable: boolean;
1199
+ description: string;
1200
+ };
1201
+ remaining: {
1202
+ type: string;
1203
+ nullable: boolean;
1204
+ description: string;
1205
+ };
1206
+ refillAmount: {
1207
+ type: string;
1208
+ nullable: boolean;
1209
+ description: string;
1210
+ };
1211
+ refillInterval: {
1212
+ type: string;
1213
+ nullable: boolean;
1214
+ description: string;
1215
+ };
1216
+ rateLimitEnabled: {
1217
+ type: string;
1218
+ description: string;
1219
+ };
1220
+ requestCount: {
1221
+ type: string;
1222
+ description: string;
1223
+ };
1224
+ permissions: {
1225
+ type: string;
1226
+ nullable: boolean;
1227
+ additionalProperties: {
1228
+ type: string;
1229
+ items: {
1230
+ type: string;
1231
+ };
1232
+ };
1233
+ description: string;
1234
+ };
1235
+ };
1236
+ required: string[];
1237
+ };
1238
+ };
1239
+ };
1240
+ };
1241
+ };
1242
+ };
1243
+ };
1244
+ }, {
973
1245
  key: string;
974
1246
  metadata: any;
975
1247
  permissions: any;
@@ -992,135 +1264,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
992
1264
  expiresAt: Date | null;
993
1265
  createdAt: Date;
994
1266
  updatedAt: Date;
995
- }, {
996
- openapi: {
997
- description: string;
998
- responses: {
999
- "200": {
1000
- description: string;
1001
- content: {
1002
- "application/json": {
1003
- schema: {
1004
- type: "object";
1005
- properties: {
1006
- id: {
1007
- type: string;
1008
- description: string;
1009
- };
1010
- createdAt: {
1011
- type: string;
1012
- format: string;
1013
- description: string;
1014
- };
1015
- updatedAt: {
1016
- type: string;
1017
- format: string;
1018
- description: string;
1019
- };
1020
- name: {
1021
- type: string;
1022
- nullable: boolean;
1023
- description: string;
1024
- };
1025
- prefix: {
1026
- type: string;
1027
- nullable: boolean;
1028
- description: string;
1029
- };
1030
- start: {
1031
- type: string;
1032
- nullable: boolean;
1033
- description: string;
1034
- };
1035
- key: {
1036
- type: string;
1037
- description: string;
1038
- };
1039
- enabled: {
1040
- type: string;
1041
- description: string;
1042
- };
1043
- expiresAt: {
1044
- type: string;
1045
- format: string;
1046
- nullable: boolean;
1047
- description: string;
1048
- };
1049
- referenceId: {
1050
- type: string;
1051
- description: string;
1052
- };
1053
- lastRefillAt: {
1054
- type: string;
1055
- format: string;
1056
- nullable: boolean;
1057
- description: string;
1058
- };
1059
- lastRequest: {
1060
- type: string;
1061
- format: string;
1062
- nullable: boolean;
1063
- description: string;
1064
- };
1065
- metadata: {
1066
- type: string;
1067
- nullable: boolean;
1068
- additionalProperties: boolean;
1069
- description: string;
1070
- };
1071
- rateLimitMax: {
1072
- type: string;
1073
- nullable: boolean;
1074
- description: string;
1075
- };
1076
- rateLimitTimeWindow: {
1077
- type: string;
1078
- nullable: boolean;
1079
- description: string;
1080
- };
1081
- remaining: {
1082
- type: string;
1083
- nullable: boolean;
1084
- description: string;
1085
- };
1086
- refillAmount: {
1087
- type: string;
1088
- nullable: boolean;
1089
- description: string;
1090
- };
1091
- refillInterval: {
1092
- type: string;
1093
- nullable: boolean;
1094
- description: string;
1095
- };
1096
- rateLimitEnabled: {
1097
- type: string;
1098
- description: string;
1099
- };
1100
- requestCount: {
1101
- type: string;
1102
- description: string;
1103
- };
1104
- permissions: {
1105
- type: string;
1106
- nullable: boolean;
1107
- additionalProperties: {
1108
- type: string;
1109
- items: {
1110
- type: string;
1111
- };
1112
- };
1113
- description: string;
1114
- };
1115
- };
1116
- required: string[];
1117
- };
1118
- };
1119
- };
1120
- };
1121
- };
1122
- };
1123
- }, undefined>;
1267
+ }>;
1124
1268
  /**
1125
1269
  * ### Endpoint
1126
1270
  *
@@ -1133,11 +1277,14 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1133
1277
  *
1134
1278
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-verify)
1135
1279
  */
1136
- verifyApiKey: Endpoint<string, "POST", {
1137
- key: string;
1138
- configId?: string | undefined;
1139
- permissions?: Record<string, string[]> | undefined;
1140
- }, Record<string, any> | undefined, [], {
1280
+ verifyApiKey: StrictEndpoint<string, {
1281
+ method: "POST";
1282
+ body: zod.ZodObject<{
1283
+ configId: zod.ZodOptional<zod.ZodString>;
1284
+ key: zod.ZodString;
1285
+ permissions: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>>;
1286
+ }, zod_v4_core0.$strip>;
1287
+ }, {
1141
1288
  valid: boolean;
1142
1289
  error: {
1143
1290
  message: better_auth0.RawError<"INVALID_API_KEY">;
@@ -1163,7 +1310,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1163
1310
  valid: boolean;
1164
1311
  error: null;
1165
1312
  key: Omit<ApiKey, "key"> | null;
1166
- }, undefined, undefined>;
1313
+ }>;
1167
1314
  /**
1168
1315
  * ### Endpoint
1169
1316
  *
@@ -1179,32 +1326,156 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1179
1326
  *
1180
1327
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-get)
1181
1328
  */
1182
- getApiKey: Endpoint<"/api-key/get", "GET", undefined, {
1183
- id: string;
1184
- configId?: string | undefined;
1185
- }, [Middleware<(inputContext: Record<string, any>) => Promise<{
1186
- session: {
1187
- session: Record<string, any> & {
1188
- id: string;
1189
- createdAt: Date;
1190
- updatedAt: Date;
1191
- userId: string;
1192
- expiresAt: Date;
1193
- token: string;
1194
- ipAddress?: string | null | undefined;
1195
- userAgent?: string | null | undefined;
1329
+ getApiKey: StrictEndpoint<"/api-key/get", {
1330
+ method: "GET";
1331
+ query: zod.ZodObject<{
1332
+ configId: zod.ZodOptional<zod.ZodString>;
1333
+ id: zod.ZodString;
1334
+ }, zod_v4_core0.$strip>;
1335
+ use: ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<{
1336
+ session: {
1337
+ session: Record<string, any> & {
1338
+ id: string;
1339
+ createdAt: Date;
1340
+ updatedAt: Date;
1341
+ userId: string;
1342
+ expiresAt: Date;
1343
+ token: string;
1344
+ ipAddress?: string | null | undefined;
1345
+ userAgent?: string | null | undefined;
1346
+ };
1347
+ user: Record<string, any> & {
1348
+ id: string;
1349
+ createdAt: Date;
1350
+ updatedAt: Date;
1351
+ email: string;
1352
+ emailVerified: boolean;
1353
+ name: string;
1354
+ image?: string | null | undefined;
1355
+ };
1196
1356
  };
1197
- user: Record<string, any> & {
1198
- id: string;
1199
- createdAt: Date;
1200
- updatedAt: Date;
1201
- email: string;
1202
- emailVerified: boolean;
1203
- name: string;
1204
- image?: string | null | undefined;
1357
+ }>)[];
1358
+ metadata: {
1359
+ openapi: {
1360
+ description: string;
1361
+ responses: {
1362
+ "200": {
1363
+ description: string;
1364
+ content: {
1365
+ "application/json": {
1366
+ schema: {
1367
+ type: "object";
1368
+ properties: {
1369
+ id: {
1370
+ type: string;
1371
+ description: string;
1372
+ };
1373
+ name: {
1374
+ type: string;
1375
+ nullable: boolean;
1376
+ description: string;
1377
+ };
1378
+ start: {
1379
+ type: string;
1380
+ nullable: boolean;
1381
+ description: string;
1382
+ };
1383
+ prefix: {
1384
+ type: string;
1385
+ nullable: boolean;
1386
+ description: string;
1387
+ };
1388
+ userId: {
1389
+ type: string;
1390
+ description: string;
1391
+ };
1392
+ refillInterval: {
1393
+ type: string;
1394
+ nullable: boolean;
1395
+ description: string;
1396
+ };
1397
+ refillAmount: {
1398
+ type: string;
1399
+ nullable: boolean;
1400
+ description: string;
1401
+ };
1402
+ lastRefillAt: {
1403
+ type: string;
1404
+ format: string;
1405
+ nullable: boolean;
1406
+ description: string;
1407
+ };
1408
+ enabled: {
1409
+ type: string;
1410
+ description: string;
1411
+ default: boolean;
1412
+ };
1413
+ rateLimitEnabled: {
1414
+ type: string;
1415
+ description: string;
1416
+ };
1417
+ rateLimitTimeWindow: {
1418
+ type: string;
1419
+ nullable: boolean;
1420
+ description: string;
1421
+ };
1422
+ rateLimitMax: {
1423
+ type: string;
1424
+ nullable: boolean;
1425
+ description: string;
1426
+ };
1427
+ requestCount: {
1428
+ type: string;
1429
+ description: string;
1430
+ };
1431
+ remaining: {
1432
+ type: string;
1433
+ nullable: boolean;
1434
+ description: string;
1435
+ };
1436
+ lastRequest: {
1437
+ type: string;
1438
+ format: string;
1439
+ nullable: boolean;
1440
+ description: string;
1441
+ };
1442
+ expiresAt: {
1443
+ type: string;
1444
+ format: string;
1445
+ nullable: boolean;
1446
+ description: string;
1447
+ };
1448
+ createdAt: {
1449
+ type: string;
1450
+ format: string;
1451
+ description: string;
1452
+ };
1453
+ updatedAt: {
1454
+ type: string;
1455
+ format: string;
1456
+ description: string;
1457
+ };
1458
+ metadata: {
1459
+ type: string;
1460
+ nullable: boolean;
1461
+ additionalProperties: boolean;
1462
+ description: string;
1463
+ };
1464
+ permissions: {
1465
+ type: string;
1466
+ nullable: boolean;
1467
+ description: string;
1468
+ };
1469
+ };
1470
+ required: string[];
1471
+ };
1472
+ };
1473
+ };
1474
+ };
1475
+ };
1205
1476
  };
1206
1477
  };
1207
- }>>], {
1478
+ }, {
1208
1479
  metadata: Record<string, any> | null;
1209
1480
  permissions: {
1210
1481
  [key: string]: string[];
@@ -1228,157 +1499,161 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1228
1499
  expiresAt: Date | null;
1229
1500
  createdAt: Date;
1230
1501
  updatedAt: Date;
1231
- }, {
1232
- openapi: {
1233
- description: string;
1234
- responses: {
1235
- "200": {
1236
- description: string;
1237
- content: {
1238
- "application/json": {
1239
- schema: {
1240
- type: "object";
1241
- properties: {
1242
- id: {
1243
- type: string;
1244
- description: string;
1245
- };
1246
- name: {
1247
- type: string;
1248
- nullable: boolean;
1249
- description: string;
1250
- };
1251
- start: {
1252
- type: string;
1253
- nullable: boolean;
1254
- description: string;
1255
- };
1256
- prefix: {
1257
- type: string;
1258
- nullable: boolean;
1259
- description: string;
1260
- };
1261
- userId: {
1262
- type: string;
1263
- description: string;
1264
- };
1265
- refillInterval: {
1266
- type: string;
1267
- nullable: boolean;
1268
- description: string;
1269
- };
1270
- refillAmount: {
1271
- type: string;
1272
- nullable: boolean;
1273
- description: string;
1274
- };
1275
- lastRefillAt: {
1276
- type: string;
1277
- format: string;
1278
- nullable: boolean;
1279
- description: string;
1280
- };
1281
- enabled: {
1282
- type: string;
1283
- description: string;
1284
- default: boolean;
1285
- };
1286
- rateLimitEnabled: {
1287
- type: string;
1288
- description: string;
1289
- };
1290
- rateLimitTimeWindow: {
1291
- type: string;
1292
- nullable: boolean;
1293
- description: string;
1294
- };
1295
- rateLimitMax: {
1296
- type: string;
1297
- nullable: boolean;
1298
- description: string;
1299
- };
1300
- requestCount: {
1301
- type: string;
1302
- description: string;
1303
- };
1304
- remaining: {
1305
- type: string;
1306
- nullable: boolean;
1307
- description: string;
1308
- };
1309
- lastRequest: {
1310
- type: string;
1311
- format: string;
1312
- nullable: boolean;
1313
- description: string;
1314
- };
1315
- expiresAt: {
1316
- type: string;
1317
- format: string;
1318
- nullable: boolean;
1319
- description: string;
1320
- };
1321
- createdAt: {
1322
- type: string;
1323
- format: string;
1324
- description: string;
1325
- };
1326
- updatedAt: {
1327
- type: string;
1328
- format: string;
1329
- description: string;
1330
- };
1331
- metadata: {
1332
- type: string;
1333
- nullable: boolean;
1334
- additionalProperties: boolean;
1335
- description: string;
1336
- };
1337
- permissions: {
1338
- type: string;
1339
- nullable: boolean;
1340
- description: string;
1502
+ }>;
1503
+ /**
1504
+ * ### Endpoint
1505
+ *
1506
+ * POST `/api-key/update`
1507
+ *
1508
+ * ### API Methods
1509
+ *
1510
+ * **server:**
1511
+ * `auth.api.updateApiKey`
1512
+ *
1513
+ * **client:**
1514
+ * `authClient.apiKey.update`
1515
+ *
1516
+ * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-update)
1517
+ */
1518
+ updateApiKey: StrictEndpoint<"/api-key/update", {
1519
+ method: "POST";
1520
+ body: zod.ZodObject<{
1521
+ configId: zod.ZodOptional<zod.ZodString>;
1522
+ keyId: zod.ZodString;
1523
+ userId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
1524
+ name: zod.ZodOptional<zod.ZodString>;
1525
+ enabled: zod.ZodOptional<zod.ZodBoolean>;
1526
+ remaining: zod.ZodOptional<zod.ZodNumber>;
1527
+ refillAmount: zod.ZodOptional<zod.ZodNumber>;
1528
+ refillInterval: zod.ZodOptional<zod.ZodNumber>;
1529
+ metadata: zod.ZodOptional<zod.ZodAny>;
1530
+ expiresIn: zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>;
1531
+ rateLimitEnabled: zod.ZodOptional<zod.ZodBoolean>;
1532
+ rateLimitTimeWindow: zod.ZodOptional<zod.ZodNumber>;
1533
+ rateLimitMax: zod.ZodOptional<zod.ZodNumber>;
1534
+ permissions: zod.ZodNullable<zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>>>;
1535
+ }, zod_v4_core0.$strip>;
1536
+ metadata: {
1537
+ openapi: {
1538
+ description: string;
1539
+ responses: {
1540
+ "200": {
1541
+ description: string;
1542
+ content: {
1543
+ "application/json": {
1544
+ schema: {
1545
+ type: "object";
1546
+ properties: {
1547
+ id: {
1548
+ type: string;
1549
+ description: string;
1550
+ };
1551
+ name: {
1552
+ type: string;
1553
+ nullable: boolean;
1554
+ description: string;
1555
+ };
1556
+ start: {
1557
+ type: string;
1558
+ nullable: boolean;
1559
+ description: string;
1560
+ };
1561
+ prefix: {
1562
+ type: string;
1563
+ nullable: boolean;
1564
+ description: string;
1565
+ };
1566
+ userId: {
1567
+ type: string;
1568
+ description: string;
1569
+ };
1570
+ refillInterval: {
1571
+ type: string;
1572
+ nullable: boolean;
1573
+ description: string;
1574
+ };
1575
+ refillAmount: {
1576
+ type: string;
1577
+ nullable: boolean;
1578
+ description: string;
1579
+ };
1580
+ lastRefillAt: {
1581
+ type: string;
1582
+ format: string;
1583
+ nullable: boolean;
1584
+ description: string;
1585
+ };
1586
+ enabled: {
1587
+ type: string;
1588
+ description: string;
1589
+ default: boolean;
1590
+ };
1591
+ rateLimitEnabled: {
1592
+ type: string;
1593
+ description: string;
1594
+ };
1595
+ rateLimitTimeWindow: {
1596
+ type: string;
1597
+ nullable: boolean;
1598
+ description: string;
1599
+ };
1600
+ rateLimitMax: {
1601
+ type: string;
1602
+ nullable: boolean;
1603
+ description: string;
1604
+ };
1605
+ requestCount: {
1606
+ type: string;
1607
+ description: string;
1608
+ };
1609
+ remaining: {
1610
+ type: string;
1611
+ nullable: boolean;
1612
+ description: string;
1613
+ };
1614
+ lastRequest: {
1615
+ type: string;
1616
+ format: string;
1617
+ nullable: boolean;
1618
+ description: string;
1619
+ };
1620
+ expiresAt: {
1621
+ type: string;
1622
+ format: string;
1623
+ nullable: boolean;
1624
+ description: string;
1625
+ };
1626
+ createdAt: {
1627
+ type: string;
1628
+ format: string;
1629
+ description: string;
1630
+ };
1631
+ updatedAt: {
1632
+ type: string;
1633
+ format: string;
1634
+ description: string;
1635
+ };
1636
+ metadata: {
1637
+ type: string;
1638
+ nullable: boolean;
1639
+ additionalProperties: boolean;
1640
+ description: string;
1641
+ };
1642
+ permissions: {
1643
+ type: string;
1644
+ nullable: boolean;
1645
+ description: string;
1646
+ };
1341
1647
  };
1648
+ required: string[];
1342
1649
  };
1343
- required: string[];
1344
1650
  };
1345
1651
  };
1346
1652
  };
1347
1653
  };
1348
1654
  };
1349
1655
  };
1350
- }, undefined>;
1351
- /**
1352
- * ### Endpoint
1353
- *
1354
- * POST `/api-key/update`
1355
- *
1356
- * ### API Methods
1357
- *
1358
- * **server:**
1359
- * `auth.api.updateApiKey`
1360
- *
1361
- * **client:**
1362
- * `authClient.apiKey.update`
1363
- *
1364
- * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-update)
1365
- */
1366
- updateApiKey: Endpoint<"/api-key/update", "POST", {
1367
- keyId: string;
1368
- configId?: string | undefined;
1369
- userId?: unknown;
1370
- name?: string | undefined;
1371
- enabled?: boolean | undefined;
1372
- remaining?: number | undefined;
1373
- refillAmount?: number | undefined;
1374
- refillInterval?: number | undefined;
1375
- metadata?: any;
1376
- expiresIn?: number | null | undefined;
1377
- rateLimitEnabled?: boolean | undefined;
1378
- rateLimitTimeWindow?: number | undefined;
1379
- rateLimitMax?: number | undefined;
1380
- permissions?: Record<string, string[]> | null | undefined;
1381
- }, Record<string, any> | undefined, [], {
1656
+ }, {
1382
1657
  metadata: Record<string, any> | null;
1383
1658
  permissions: {
1384
1659
  [key: string]: string[];
@@ -1402,126 +1677,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1402
1677
  expiresAt: Date | null;
1403
1678
  createdAt: Date;
1404
1679
  updatedAt: Date;
1405
- }, {
1406
- openapi: {
1407
- description: string;
1408
- responses: {
1409
- "200": {
1410
- description: string;
1411
- content: {
1412
- "application/json": {
1413
- schema: {
1414
- type: "object";
1415
- properties: {
1416
- id: {
1417
- type: string;
1418
- description: string;
1419
- };
1420
- name: {
1421
- type: string;
1422
- nullable: boolean;
1423
- description: string;
1424
- };
1425
- start: {
1426
- type: string;
1427
- nullable: boolean;
1428
- description: string;
1429
- };
1430
- prefix: {
1431
- type: string;
1432
- nullable: boolean;
1433
- description: string;
1434
- };
1435
- userId: {
1436
- type: string;
1437
- description: string;
1438
- };
1439
- refillInterval: {
1440
- type: string;
1441
- nullable: boolean;
1442
- description: string;
1443
- };
1444
- refillAmount: {
1445
- type: string;
1446
- nullable: boolean;
1447
- description: string;
1448
- };
1449
- lastRefillAt: {
1450
- type: string;
1451
- format: string;
1452
- nullable: boolean;
1453
- description: string;
1454
- };
1455
- enabled: {
1456
- type: string;
1457
- description: string;
1458
- default: boolean;
1459
- };
1460
- rateLimitEnabled: {
1461
- type: string;
1462
- description: string;
1463
- };
1464
- rateLimitTimeWindow: {
1465
- type: string;
1466
- nullable: boolean;
1467
- description: string;
1468
- };
1469
- rateLimitMax: {
1470
- type: string;
1471
- nullable: boolean;
1472
- description: string;
1473
- };
1474
- requestCount: {
1475
- type: string;
1476
- description: string;
1477
- };
1478
- remaining: {
1479
- type: string;
1480
- nullable: boolean;
1481
- description: string;
1482
- };
1483
- lastRequest: {
1484
- type: string;
1485
- format: string;
1486
- nullable: boolean;
1487
- description: string;
1488
- };
1489
- expiresAt: {
1490
- type: string;
1491
- format: string;
1492
- nullable: boolean;
1493
- description: string;
1494
- };
1495
- createdAt: {
1496
- type: string;
1497
- format: string;
1498
- description: string;
1499
- };
1500
- updatedAt: {
1501
- type: string;
1502
- format: string;
1503
- description: string;
1504
- };
1505
- metadata: {
1506
- type: string;
1507
- nullable: boolean;
1508
- additionalProperties: boolean;
1509
- description: string;
1510
- };
1511
- permissions: {
1512
- type: string;
1513
- nullable: boolean;
1514
- description: string;
1515
- };
1516
- };
1517
- required: string[];
1518
- };
1519
- };
1520
- };
1521
- };
1522
- };
1523
- };
1524
- }, undefined>;
1680
+ }>;
1525
1681
  /**
1526
1682
  * ### Endpoint
1527
1683
  *
@@ -1537,61 +1693,45 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1537
1693
  *
1538
1694
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete)
1539
1695
  */
1540
- deleteApiKey: Endpoint<"/api-key/delete", "POST", {
1541
- keyId: string;
1542
- configId?: string | undefined;
1543
- }, Record<string, any> | undefined, [Middleware<(inputContext: Record<string, any>) => Promise<{
1544
- session: {
1545
- session: Record<string, any> & {
1546
- id: string;
1547
- createdAt: Date;
1548
- updatedAt: Date;
1549
- userId: string;
1550
- expiresAt: Date;
1551
- token: string;
1552
- ipAddress?: string | null | undefined;
1553
- userAgent?: string | null | undefined;
1554
- };
1555
- user: Record<string, any> & {
1556
- id: string;
1557
- createdAt: Date;
1558
- updatedAt: Date;
1559
- email: string;
1560
- emailVerified: boolean;
1561
- name: string;
1562
- image?: string | null | undefined;
1563
- };
1564
- };
1565
- }>>], {
1566
- success: boolean;
1567
- }, {
1568
- openapi: {
1569
- description: string;
1570
- requestBody: {
1571
- content: {
1572
- "application/json": {
1573
- schema: {
1574
- type: "object";
1575
- properties: {
1576
- keyId: {
1577
- type: string;
1578
- description: string;
1579
- };
1580
- };
1581
- required: string[];
1582
- };
1583
- };
1696
+ deleteApiKey: StrictEndpoint<"/api-key/delete", {
1697
+ method: "POST";
1698
+ body: zod.ZodObject<{
1699
+ configId: zod.ZodOptional<zod.ZodString>;
1700
+ keyId: zod.ZodString;
1701
+ }, zod_v4_core0.$strip>;
1702
+ use: ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<{
1703
+ session: {
1704
+ session: Record<string, any> & {
1705
+ id: string;
1706
+ createdAt: Date;
1707
+ updatedAt: Date;
1708
+ userId: string;
1709
+ expiresAt: Date;
1710
+ token: string;
1711
+ ipAddress?: string | null | undefined;
1712
+ userAgent?: string | null | undefined;
1713
+ };
1714
+ user: Record<string, any> & {
1715
+ id: string;
1716
+ createdAt: Date;
1717
+ updatedAt: Date;
1718
+ email: string;
1719
+ emailVerified: boolean;
1720
+ name: string;
1721
+ image?: string | null | undefined;
1584
1722
  };
1585
1723
  };
1586
- responses: {
1587
- "200": {
1588
- description: string;
1724
+ }>)[];
1725
+ metadata: {
1726
+ openapi: {
1727
+ description: string;
1728
+ requestBody: {
1589
1729
  content: {
1590
1730
  "application/json": {
1591
1731
  schema: {
1592
1732
  type: "object";
1593
1733
  properties: {
1594
- success: {
1734
+ keyId: {
1595
1735
  type: string;
1596
1736
  description: string;
1597
1737
  };
@@ -1601,9 +1741,30 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1601
1741
  };
1602
1742
  };
1603
1743
  };
1744
+ responses: {
1745
+ "200": {
1746
+ description: string;
1747
+ content: {
1748
+ "application/json": {
1749
+ schema: {
1750
+ type: "object";
1751
+ properties: {
1752
+ success: {
1753
+ type: string;
1754
+ description: string;
1755
+ };
1756
+ };
1757
+ required: string[];
1758
+ };
1759
+ };
1760
+ };
1761
+ };
1762
+ };
1604
1763
  };
1605
1764
  };
1606
- }, undefined>;
1765
+ }, {
1766
+ success: boolean;
1767
+ }>;
1607
1768
  /**
1608
1769
  * ### Endpoint
1609
1770
  *
@@ -1619,36 +1780,186 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1619
1780
  *
1620
1781
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-list)
1621
1782
  */
1622
- listApiKeys: Endpoint<"/api-key/list", "GET", undefined, {
1623
- configId?: string | undefined;
1624
- organizationId?: string | undefined;
1625
- limit?: unknown;
1626
- offset?: unknown;
1627
- sortBy?: string | undefined;
1628
- sortDirection?: "asc" | "desc" | undefined;
1629
- } | undefined, [Middleware<(inputContext: Record<string, any>) => Promise<{
1630
- session: {
1631
- session: Record<string, any> & {
1632
- id: string;
1633
- createdAt: Date;
1634
- updatedAt: Date;
1635
- userId: string;
1636
- expiresAt: Date;
1637
- token: string;
1638
- ipAddress?: string | null | undefined;
1639
- userAgent?: string | null | undefined;
1783
+ listApiKeys: StrictEndpoint<"/api-key/list", {
1784
+ method: "GET";
1785
+ use: ((inputContext: MiddlewareInputContext<MiddlewareOptions>) => Promise<{
1786
+ session: {
1787
+ session: Record<string, any> & {
1788
+ id: string;
1789
+ createdAt: Date;
1790
+ updatedAt: Date;
1791
+ userId: string;
1792
+ expiresAt: Date;
1793
+ token: string;
1794
+ ipAddress?: string | null | undefined;
1795
+ userAgent?: string | null | undefined;
1796
+ };
1797
+ user: Record<string, any> & {
1798
+ id: string;
1799
+ createdAt: Date;
1800
+ updatedAt: Date;
1801
+ email: string;
1802
+ emailVerified: boolean;
1803
+ name: string;
1804
+ image?: string | null | undefined;
1805
+ };
1640
1806
  };
1641
- user: Record<string, any> & {
1642
- id: string;
1643
- createdAt: Date;
1644
- updatedAt: Date;
1645
- email: string;
1646
- emailVerified: boolean;
1647
- name: string;
1648
- image?: string | null | undefined;
1807
+ }>)[];
1808
+ query: zod.ZodOptional<zod.ZodObject<{
1809
+ configId: zod.ZodOptional<zod.ZodString>;
1810
+ organizationId: zod.ZodOptional<zod.ZodString>;
1811
+ limit: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
1812
+ offset: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
1813
+ sortBy: zod.ZodOptional<zod.ZodString>;
1814
+ sortDirection: zod.ZodOptional<zod.ZodEnum<{
1815
+ asc: "asc";
1816
+ desc: "desc";
1817
+ }>>;
1818
+ }, zod_v4_core0.$strip>>;
1819
+ metadata: {
1820
+ openapi: {
1821
+ description: string;
1822
+ responses: {
1823
+ "200": {
1824
+ description: string;
1825
+ content: {
1826
+ "application/json": {
1827
+ schema: {
1828
+ type: "object";
1829
+ properties: {
1830
+ apiKeys: {
1831
+ type: string;
1832
+ items: {
1833
+ type: string;
1834
+ properties: {
1835
+ id: {
1836
+ type: string;
1837
+ description: string;
1838
+ };
1839
+ name: {
1840
+ type: string;
1841
+ nullable: boolean;
1842
+ description: string;
1843
+ };
1844
+ start: {
1845
+ type: string;
1846
+ nullable: boolean;
1847
+ description: string;
1848
+ };
1849
+ prefix: {
1850
+ type: string;
1851
+ nullable: boolean;
1852
+ description: string;
1853
+ };
1854
+ userId: {
1855
+ type: string;
1856
+ description: string;
1857
+ };
1858
+ refillInterval: {
1859
+ type: string;
1860
+ nullable: boolean;
1861
+ description: string;
1862
+ };
1863
+ refillAmount: {
1864
+ type: string;
1865
+ nullable: boolean;
1866
+ description: string;
1867
+ };
1868
+ lastRefillAt: {
1869
+ type: string;
1870
+ format: string;
1871
+ nullable: boolean;
1872
+ description: string;
1873
+ };
1874
+ enabled: {
1875
+ type: string;
1876
+ description: string;
1877
+ default: boolean;
1878
+ };
1879
+ rateLimitEnabled: {
1880
+ type: string;
1881
+ description: string;
1882
+ };
1883
+ rateLimitTimeWindow: {
1884
+ type: string;
1885
+ nullable: boolean;
1886
+ description: string;
1887
+ };
1888
+ rateLimitMax: {
1889
+ type: string;
1890
+ nullable: boolean;
1891
+ description: string;
1892
+ };
1893
+ requestCount: {
1894
+ type: string;
1895
+ description: string;
1896
+ };
1897
+ remaining: {
1898
+ type: string;
1899
+ nullable: boolean;
1900
+ description: string;
1901
+ };
1902
+ lastRequest: {
1903
+ type: string;
1904
+ format: string;
1905
+ nullable: boolean;
1906
+ description: string;
1907
+ };
1908
+ expiresAt: {
1909
+ type: string;
1910
+ format: string;
1911
+ nullable: boolean;
1912
+ description: string;
1913
+ };
1914
+ createdAt: {
1915
+ type: string;
1916
+ format: string;
1917
+ description: string;
1918
+ };
1919
+ updatedAt: {
1920
+ type: string;
1921
+ format: string;
1922
+ description: string;
1923
+ };
1924
+ metadata: {
1925
+ type: string;
1926
+ nullable: boolean;
1927
+ additionalProperties: boolean;
1928
+ description: string;
1929
+ };
1930
+ permissions: {
1931
+ type: string;
1932
+ nullable: boolean;
1933
+ description: string;
1934
+ };
1935
+ };
1936
+ required: string[];
1937
+ };
1938
+ };
1939
+ total: {
1940
+ type: string;
1941
+ description: string;
1942
+ };
1943
+ limit: {
1944
+ type: string;
1945
+ nullable: boolean;
1946
+ description: string;
1947
+ };
1948
+ offset: {
1949
+ type: string;
1950
+ nullable: boolean;
1951
+ description: string;
1952
+ };
1953
+ };
1954
+ required: string[];
1955
+ };
1956
+ };
1957
+ };
1958
+ };
1959
+ };
1649
1960
  };
1650
1961
  };
1651
- }>>], {
1962
+ }, {
1652
1963
  apiKeys: {
1653
1964
  metadata: Record<string, any> | null;
1654
1965
  permissions: {
@@ -1677,149 +1988,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1677
1988
  total: number;
1678
1989
  limit: number | undefined;
1679
1990
  offset: number | undefined;
1680
- }, {
1681
- openapi: {
1682
- description: string;
1683
- responses: {
1684
- "200": {
1685
- description: string;
1686
- content: {
1687
- "application/json": {
1688
- schema: {
1689
- type: "object";
1690
- properties: {
1691
- apiKeys: {
1692
- type: string;
1693
- items: {
1694
- type: string;
1695
- properties: {
1696
- id: {
1697
- type: string;
1698
- description: string;
1699
- };
1700
- name: {
1701
- type: string;
1702
- nullable: boolean;
1703
- description: string;
1704
- };
1705
- start: {
1706
- type: string;
1707
- nullable: boolean;
1708
- description: string;
1709
- };
1710
- prefix: {
1711
- type: string;
1712
- nullable: boolean;
1713
- description: string;
1714
- };
1715
- userId: {
1716
- type: string;
1717
- description: string;
1718
- };
1719
- refillInterval: {
1720
- type: string;
1721
- nullable: boolean;
1722
- description: string;
1723
- };
1724
- refillAmount: {
1725
- type: string;
1726
- nullable: boolean;
1727
- description: string;
1728
- };
1729
- lastRefillAt: {
1730
- type: string;
1731
- format: string;
1732
- nullable: boolean;
1733
- description: string;
1734
- };
1735
- enabled: {
1736
- type: string;
1737
- description: string;
1738
- default: boolean;
1739
- };
1740
- rateLimitEnabled: {
1741
- type: string;
1742
- description: string;
1743
- };
1744
- rateLimitTimeWindow: {
1745
- type: string;
1746
- nullable: boolean;
1747
- description: string;
1748
- };
1749
- rateLimitMax: {
1750
- type: string;
1751
- nullable: boolean;
1752
- description: string;
1753
- };
1754
- requestCount: {
1755
- type: string;
1756
- description: string;
1757
- };
1758
- remaining: {
1759
- type: string;
1760
- nullable: boolean;
1761
- description: string;
1762
- };
1763
- lastRequest: {
1764
- type: string;
1765
- format: string;
1766
- nullable: boolean;
1767
- description: string;
1768
- };
1769
- expiresAt: {
1770
- type: string;
1771
- format: string;
1772
- nullable: boolean;
1773
- description: string;
1774
- };
1775
- createdAt: {
1776
- type: string;
1777
- format: string;
1778
- description: string;
1779
- };
1780
- updatedAt: {
1781
- type: string;
1782
- format: string;
1783
- description: string;
1784
- };
1785
- metadata: {
1786
- type: string;
1787
- nullable: boolean;
1788
- additionalProperties: boolean;
1789
- description: string;
1790
- };
1791
- permissions: {
1792
- type: string;
1793
- nullable: boolean;
1794
- description: string;
1795
- };
1796
- };
1797
- required: string[];
1798
- };
1799
- };
1800
- total: {
1801
- type: string;
1802
- description: string;
1803
- };
1804
- limit: {
1805
- type: string;
1806
- nullable: boolean;
1807
- description: string;
1808
- };
1809
- offset: {
1810
- type: string;
1811
- nullable: boolean;
1812
- description: string;
1813
- };
1814
- };
1815
- required: string[];
1816
- };
1817
- };
1818
- };
1819
- };
1820
- };
1821
- };
1822
- }, undefined>;
1991
+ }>;
1823
1992
  /**
1824
1993
  * ### Endpoint
1825
1994
  *
@@ -1832,10 +2001,12 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1832
2001
  *
1833
2002
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete-all-expired-api-keys)
1834
2003
  */
1835
- deleteAllExpiredApiKeys: Endpoint<string, "POST", undefined, Record<string, any> | undefined, [], {
2004
+ deleteAllExpiredApiKeys: StrictEndpoint<string, {
2005
+ method: "POST";
2006
+ }, {
1836
2007
  success: boolean;
1837
2008
  error: unknown;
1838
- }, undefined, undefined>;
2009
+ }>;
1839
2010
  };
1840
2011
  schema: {
1841
2012
  apikey: {