@better-auth/api-key 1.5.7-beta.1 → 1.6.0-beta.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.
@@ -1,8 +1,706 @@
1
- import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-BR70O3Q3.mjs";
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 better_call0 from "better-call";
4
3
  import { HookEndpointContext } from "@better-auth/core";
5
4
 
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
+ };
94
+ //#endregion
95
+ //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/standard-schema.d.mts
96
+ //#region src/standard-schema.d.ts
97
+ /** The Standard Schema interface. */
98
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
99
+ /** The Standard Schema properties. */
100
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
101
+ }
102
+ declare namespace StandardSchemaV1 {
103
+ /** The Standard Schema properties interface. */
104
+ interface Props<Input = unknown, Output = Input> {
105
+ /** The version number of the standard. */
106
+ readonly version: 1;
107
+ /** The vendor name of the schema library. */
108
+ readonly vendor: string;
109
+ /** Validates unknown input values. */
110
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
111
+ /** Inferred types associated with the schema. */
112
+ readonly types?: Types<Input, Output> | undefined;
113
+ }
114
+ /** The result interface of the validate function. */
115
+ type Result<Output> = SuccessResult<Output> | FailureResult;
116
+ /** The result interface if validation succeeds. */
117
+ interface SuccessResult<Output> {
118
+ /** The typed output value. */
119
+ readonly value: Output;
120
+ /** The non-existent issues. */
121
+ readonly issues?: undefined;
122
+ }
123
+ /** The result interface if validation fails. */
124
+ interface FailureResult {
125
+ /** The issues of failed validation. */
126
+ readonly issues: ReadonlyArray<Issue>;
127
+ }
128
+ /** The issue interface of the failure output. */
129
+ interface Issue {
130
+ /** The error message of the issue. */
131
+ readonly message: string;
132
+ /** The path of the issue, if any. */
133
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
134
+ }
135
+ /** The path segment interface of the issue. */
136
+ interface PathSegment {
137
+ /** The key representing a path segment. */
138
+ readonly key: PropertyKey;
139
+ }
140
+ /** The Standard Schema types interface. */
141
+ interface Types<Input = unknown, Output = Input> {
142
+ /** The input type of the schema. */
143
+ readonly input: Input;
144
+ /** The output type of the schema. */
145
+ readonly output: Output;
146
+ }
147
+ /** Infers the input type of a Standard Schema. */
148
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
149
+ /** Infers the output type of a Standard Schema. */
150
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
151
+ } //#endregion
152
+ //#endregion
153
+ //#region ../../node_modules/.pnpm/better-call@2.0.3_zod@4.3.6/node_modules/better-call/dist/error.d.mts
154
+ declare const statusCodes: {
155
+ OK: number;
156
+ CREATED: number;
157
+ ACCEPTED: number;
158
+ NO_CONTENT: number;
159
+ MULTIPLE_CHOICES: number;
160
+ MOVED_PERMANENTLY: number;
161
+ FOUND: number;
162
+ SEE_OTHER: number;
163
+ NOT_MODIFIED: number;
164
+ TEMPORARY_REDIRECT: number;
165
+ BAD_REQUEST: number;
166
+ UNAUTHORIZED: number;
167
+ PAYMENT_REQUIRED: number;
168
+ FORBIDDEN: number;
169
+ NOT_FOUND: number;
170
+ METHOD_NOT_ALLOWED: number;
171
+ NOT_ACCEPTABLE: number;
172
+ PROXY_AUTHENTICATION_REQUIRED: number;
173
+ REQUEST_TIMEOUT: number;
174
+ CONFLICT: number;
175
+ GONE: number;
176
+ LENGTH_REQUIRED: number;
177
+ PRECONDITION_FAILED: number;
178
+ PAYLOAD_TOO_LARGE: number;
179
+ URI_TOO_LONG: number;
180
+ UNSUPPORTED_MEDIA_TYPE: number;
181
+ RANGE_NOT_SATISFIABLE: number;
182
+ EXPECTATION_FAILED: number;
183
+ "I'M_A_TEAPOT": number;
184
+ MISDIRECTED_REQUEST: number;
185
+ UNPROCESSABLE_ENTITY: number;
186
+ LOCKED: number;
187
+ FAILED_DEPENDENCY: number;
188
+ TOO_EARLY: number;
189
+ UPGRADE_REQUIRED: number;
190
+ PRECONDITION_REQUIRED: number;
191
+ TOO_MANY_REQUESTS: number;
192
+ REQUEST_HEADER_FIELDS_TOO_LARGE: number;
193
+ UNAVAILABLE_FOR_LEGAL_REASONS: number;
194
+ INTERNAL_SERVER_ERROR: number;
195
+ NOT_IMPLEMENTED: number;
196
+ BAD_GATEWAY: number;
197
+ SERVICE_UNAVAILABLE: number;
198
+ GATEWAY_TIMEOUT: number;
199
+ HTTP_VERSION_NOT_SUPPORTED: number;
200
+ VARIANT_ALSO_NEGOTIATES: number;
201
+ INSUFFICIENT_STORAGE: number;
202
+ LOOP_DETECTED: number;
203
+ NOT_EXTENDED: number;
204
+ NETWORK_AUTHENTICATION_REQUIRED: number;
205
+ };
206
+ type Status = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
207
+ declare class InternalAPIError extends Error {
208
+ status: keyof typeof statusCodes | Status;
209
+ body: ({
210
+ message?: string;
211
+ code?: string;
212
+ cause?: unknown;
213
+ } & Record<string, any>) | undefined;
214
+ headers: HeadersInit;
215
+ statusCode: number;
216
+ constructor(status?: keyof typeof statusCodes | Status, body?: ({
217
+ message?: string;
218
+ code?: string;
219
+ cause?: unknown;
220
+ } & Record<string, any>) | undefined, headers?: HeadersInit, statusCode?: number);
221
+ }
222
+ type APIError = InstanceType<typeof InternalAPIError>;
223
+ declare const APIError: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED" | undefined, body?: ({
224
+ message?: string;
225
+ code?: string;
226
+ cause?: unknown;
227
+ } & Record<string, any>) | undefined, headers?: HeadersInit | undefined, statusCode?: number | undefined) => InternalAPIError & {
228
+ errorStack: string | undefined;
229
+ }; //#endregion
230
+ //#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 = {}> = {
240
+ /**
241
+ * Method
242
+ *
243
+ * The request method
244
+ */
245
+ method: string;
246
+ /**
247
+ * Path
248
+ *
249
+ * The path of the endpoint
250
+ */
251
+ path: string;
252
+ /**
253
+ * Body
254
+ *
255
+ * The body object will be the parsed JSON from the request and validated
256
+ * against the body schema if it exists
257
+ */
258
+ body: any;
259
+ /**
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
264
+ */
265
+ query: Record<string, any> | undefined;
266
+ /**
267
+ * Params
268
+ *
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 }`
274
+ */
275
+ params: Record<string, any> | undefined;
276
+ /**
277
+ * Request object
278
+ *
279
+ * If `requireRequest` is set to true in the endpoint options this will be
280
+ * required
281
+ */
282
+ request: Request | undefined;
283
+ /**
284
+ * Headers
285
+ *
286
+ * If `requireHeaders` is set to true in the endpoint options this will be
287
+ * required
288
+ */
289
+ headers: Headers | undefined;
290
+ /**
291
+ * Set header
292
+ *
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
302
+ *
303
+ * If it's called outside of a request it will just return null
304
+ *
305
+ * @param key - The key of the header
306
+ */
307
+ getHeader: (key: string) => string | null;
308
+ /**
309
+ * Get a cookie value from the request
310
+ *
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
314
+ */
315
+ getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
316
+ /**
317
+ * Get a signed cookie value from the request
318
+ *
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
327
+ *
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
332
+ */
333
+ setCookie: (key: string, value: string, options?: CookieOptions) => string;
334
+ /**
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
342
+ */
343
+ setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
344
+ /**
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
354
+ */
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;
361
+ /**
362
+ * Middleware context
363
+ */
364
+ context: Prettify<Context>;
365
+ /**
366
+ * Redirect to a new URL
367
+ */
368
+ redirect: (url: string) => APIError;
369
+ /**
370
+ * Return error
371
+ */
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 {
472
+ /**
473
+ * Open API definition
474
+ */
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"?: {
498
+ schema: {
499
+ type?: OpenAPISchemaType;
500
+ properties?: Record<string, any>;
501
+ required?: string[];
502
+ $ref?: string;
503
+ };
504
+ };
505
+ "text/plain"?: {
506
+ schema?: {
507
+ type?: OpenAPISchemaType;
508
+ properties?: Record<string, any>;
509
+ required?: string[];
510
+ $ref?: string;
511
+ };
512
+ };
513
+ "text/html"?: {
514
+ schema?: {
515
+ type?: OpenAPISchemaType;
516
+ properties?: Record<string, any>;
517
+ required?: string[];
518
+ $ref?: string;
519
+ };
520
+ };
521
+ };
522
+ };
523
+ };
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
+ /**
547
+ * Body
548
+ */
549
+ body?: any;
550
+ /**
551
+ * Query
552
+ */
553
+ query?: Record<string, any>;
554
+ /**
555
+ * Error
556
+ */
557
+ error?: any;
558
+ };
559
+ /**
560
+ * If enabled, endpoint won't be exposed over a router
561
+ * @deprecated Use path-less endpoints instead
562
+ */
563
+ SERVER_ONLY?: boolean;
564
+ /**
565
+ * If enabled, endpoint won't be exposed as an action to the client
566
+ * @deprecated Use path-less endpoints instead
567
+ */
568
+ isAction?: boolean;
569
+ /**
570
+ * Defines the places where the endpoint will be available
571
+ *
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"
577
+ */
578
+ scope?: "rpc" | "server" | "http";
579
+ /**
580
+ * List of allowed media types (MIME types) for the endpoint
581
+ *
582
+ * if provided, only the media types in the list will be allowed to be passed in the body
583
+ *
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
+ * ```
593
+ */
594
+ allowedMediaTypes?: string[];
595
+ /**
596
+ * Extra metadata
597
+ */
598
+ [key: string]: any;
599
+ }
600
+ interface EndpointRuntimeOptions {
601
+ method: string | string[];
602
+ body?: StandardSchemaV1;
603
+ /**
604
+ * Query Schema
605
+ */
606
+ query?: StandardSchemaV1;
607
+ /**
608
+ * Error Schema
609
+ */
610
+ error?: StandardSchemaV1;
611
+ /**
612
+ * If true headers will be required to be passed in the context
613
+ */
614
+ requireHeaders?: boolean;
615
+ /**
616
+ * If true request object will be required
617
+ */
618
+ requireRequest?: boolean;
619
+ /**
620
+ * Clone the request object from the router
621
+ */
622
+ cloneRequest?: boolean;
623
+ /**
624
+ * If true the body will be undefined
625
+ */
626
+ disableBody?: boolean;
627
+ /**
628
+ * Endpoint metadata
629
+ */
630
+ metadata?: EndpointMetadata;
631
+ /**
632
+ * List of middlewares to use
633
+ */
634
+ use?: Middleware[];
635
+ /**
636
+ * A callback to run before any API error is thrown or returned
637
+ *
638
+ * @param e - The API error
639
+ */
640
+ onAPIError?: (e: APIError) => void | Promise<void>;
641
+ /**
642
+ * A callback to run before a validation error is thrown.
643
+ * You can customize the validation error message by throwing your own APIError.
644
+ */
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> & {
652
+ asResponse: true;
653
+ }): Promise<Response>;
654
+ (context: InputContext<Path, Method, Body, Query, false, false> & {
655
+ returnHeaders: true;
656
+ returnStatus: true;
657
+ }): Promise<{
658
+ headers: Headers;
659
+ status: number;
660
+ response: Awaited<R>;
661
+ }>;
662
+ (context: InputContext<Path, Method, Body, Query, false, false> & {
663
+ returnHeaders: true;
664
+ }): Promise<{
665
+ headers: Headers;
666
+ response: Awaited<R>;
667
+ }>;
668
+ (context: InputContext<Path, Method, Body, Query, false, false> & {
669
+ returnStatus: true;
670
+ }): Promise<{
671
+ status: number;
672
+ response: Awaited<R>;
673
+ }>;
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;
680
+ };
681
+ //#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;
701
+ };
702
+ }
703
+ //#endregion
6
704
  //#region src/error-codes.d.ts
7
705
  declare const API_KEY_ERROR_CODES: {
8
706
  INVALID_METADATA_TYPE: better_auth0.RawError<"INVALID_METADATA_TYPE">;
@@ -50,6 +748,7 @@ declare const defaultKeyHasher: (key: string) => Promise<string>;
50
748
  declare const API_KEY_TABLE_NAME = "apikey";
51
749
  declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOptions) | ApiKeyConfigurationOptions[] | undefined, _options?: ApiKeyOptions | undefined): {
52
750
  id: "api-key";
751
+ version: string;
53
752
  $ERROR_CODES: {
54
753
  INVALID_METADATA_TYPE: better_auth0.RawError<"INVALID_METADATA_TYPE">;
55
754
  REFILL_AMOUNT_AND_INTERVAL_REQUIRED: better_auth0.RawError<"REFILL_AMOUNT_AND_INTERVAL_REQUIRED">;
@@ -86,7 +785,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
86
785
  hooks: {
87
786
  before: {
88
787
  matcher: (ctx: HookEndpointContext) => boolean;
89
- handler: better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
788
+ handler: Middleware<(inputContext: Record<string, any>) => Promise<{
90
789
  user: {
91
790
  id: string;
92
791
  createdAt: Date;
@@ -107,7 +806,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
107
806
  expiresAt: Date;
108
807
  };
109
808
  } | {
110
- context: better_call0.MiddlewareContext<{
809
+ context: MiddlewareContext<{
111
810
  returned?: unknown | undefined;
112
811
  responseHeaders?: Headers | undefined;
113
812
  } & better_auth0.PluginContext<better_auth0.BetterAuthOptions> & better_auth0.InfoContext & {
@@ -195,7 +894,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
195
894
  } & Omit<better_auth0.BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
196
895
  adapter: better_auth0.DBAdapter<better_auth0.BetterAuthOptions>;
197
896
  internalAdapter: better_auth0.InternalAdapter<better_auth0.BetterAuthOptions>;
198
- createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) => better_auth0.BetterAuthCookie;
897
+ createAuthCookie: (cookieName: string, overrideAttributes?: Partial<CookieOptions> | undefined) => better_auth0.BetterAuthCookie;
199
898
  secret: string;
200
899
  secretConfig: string | better_auth0.SecretConfig;
201
900
  sessionConfig: {
@@ -255,7 +954,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
255
954
  *
256
955
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-create)
257
956
  */
258
- createApiKey: better_call0.Endpoint<"/api-key/create", "POST", {
957
+ createApiKey: Endpoint<"/api-key/create", "POST", {
259
958
  configId?: string | undefined;
260
959
  name?: string | undefined;
261
960
  expiresIn?: number | null | undefined;
@@ -434,7 +1133,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
434
1133
  *
435
1134
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-verify)
436
1135
  */
437
- verifyApiKey: better_call0.Endpoint<string, "POST", {
1136
+ verifyApiKey: Endpoint<string, "POST", {
438
1137
  key: string;
439
1138
  configId?: string | undefined;
440
1139
  permissions?: Record<string, string[]> | undefined;
@@ -480,10 +1179,10 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
480
1179
  *
481
1180
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-get)
482
1181
  */
483
- getApiKey: better_call0.Endpoint<"/api-key/get", "GET", undefined, {
1182
+ getApiKey: Endpoint<"/api-key/get", "GET", undefined, {
484
1183
  id: string;
485
1184
  configId?: string | undefined;
486
- }, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
1185
+ }, [Middleware<(inputContext: Record<string, any>) => Promise<{
487
1186
  session: {
488
1187
  session: Record<string, any> & {
489
1188
  id: string;
@@ -664,7 +1363,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
664
1363
  *
665
1364
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-update)
666
1365
  */
667
- updateApiKey: better_call0.Endpoint<"/api-key/update", "POST", {
1366
+ updateApiKey: Endpoint<"/api-key/update", "POST", {
668
1367
  keyId: string;
669
1368
  configId?: string | undefined;
670
1369
  userId?: unknown;
@@ -838,10 +1537,10 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
838
1537
  *
839
1538
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete)
840
1539
  */
841
- deleteApiKey: better_call0.Endpoint<"/api-key/delete", "POST", {
1540
+ deleteApiKey: Endpoint<"/api-key/delete", "POST", {
842
1541
  keyId: string;
843
1542
  configId?: string | undefined;
844
- }, Record<string, any> | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
1543
+ }, Record<string, any> | undefined, [Middleware<(inputContext: Record<string, any>) => Promise<{
845
1544
  session: {
846
1545
  session: Record<string, any> & {
847
1546
  id: string;
@@ -920,14 +1619,14 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
920
1619
  *
921
1620
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-list)
922
1621
  */
923
- listApiKeys: better_call0.Endpoint<"/api-key/list", "GET", undefined, {
1622
+ listApiKeys: Endpoint<"/api-key/list", "GET", undefined, {
924
1623
  configId?: string | undefined;
925
1624
  organizationId?: string | undefined;
926
1625
  limit?: unknown;
927
1626
  offset?: unknown;
928
1627
  sortBy?: string | undefined;
929
1628
  sortDirection?: "asc" | "desc" | undefined;
930
- } | undefined, [better_call0.Middleware<(inputContext: Record<string, any>) => Promise<{
1629
+ } | undefined, [Middleware<(inputContext: Record<string, any>) => Promise<{
931
1630
  session: {
932
1631
  session: Record<string, any> & {
933
1632
  id: string;
@@ -1133,7 +1832,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1133
1832
  *
1134
1833
  * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete-all-expired-api-keys)
1135
1834
  */
1136
- deleteAllExpiredApiKeys: better_call0.Endpoint<string, "POST", undefined, Record<string, any> | undefined, [], {
1835
+ deleteAllExpiredApiKeys: Endpoint<string, "POST", undefined, Record<string, any> | undefined, [], {
1137
1836
  success: boolean;
1138
1837
  error: unknown;
1139
1838
  }, undefined, undefined>;
@@ -1264,5 +1963,4 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
1264
1963
  };
1265
1964
  };
1266
1965
  //#endregion
1267
- export { API_KEY_ERROR_CODES as i, apiKey as n, defaultKeyHasher as r, API_KEY_TABLE_NAME as t };
1268
- //# sourceMappingURL=index-WXH3i1Uh.d.mts.map
1966
+ export { API_KEY_ERROR_CODES as i, apiKey as n, defaultKeyHasher as r, API_KEY_TABLE_NAME as t };