@better-auth/api-key 1.5.5 → 1.5.7-beta.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,1308 +0,0 @@
1
- import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-CCe5L05Y.mjs";
2
- import * as better_auth0 from "better-auth";
3
- import * as zod from "zod";
4
- import * as better_call0 from "better-call";
5
- import { Awaitable, HookEndpointContext } from "@better-auth/core";
6
-
7
- //#region src/routes/index.d.ts
8
- type PredefinedApiKeyOptions = ApiKeyConfigurationOptions & Required<Pick<ApiKeyConfigurationOptions, "apiKeyHeaders" | "defaultKeyLength" | "keyExpiration" | "rateLimit" | "maximumPrefixLength" | "minimumPrefixLength" | "maximumNameLength" | "disableKeyHashing" | "minimumNameLength" | "requireName" | "enableMetadata" | "enableSessionForAPIKeys" | "startingCharactersConfig" | "storage" | "fallbackToDatabase" | "deferUpdates">> & {
9
- keyExpiration: Required<NonNullable<ApiKeyConfigurationOptions["keyExpiration"]>>;
10
- startingCharactersConfig: Required<NonNullable<ApiKeyConfigurationOptions["startingCharactersConfig"]>>;
11
- rateLimit: Required<NonNullable<ApiKeyConfigurationOptions["rateLimit"]>>;
12
- };
13
- //#endregion
14
- //#region src/error-codes.d.ts
15
- declare const API_KEY_ERROR_CODES: {
16
- INVALID_METADATA_TYPE: better_auth0.RawError<"INVALID_METADATA_TYPE">;
17
- REFILL_AMOUNT_AND_INTERVAL_REQUIRED: better_auth0.RawError<"REFILL_AMOUNT_AND_INTERVAL_REQUIRED">;
18
- REFILL_INTERVAL_AND_AMOUNT_REQUIRED: better_auth0.RawError<"REFILL_INTERVAL_AND_AMOUNT_REQUIRED">;
19
- USER_BANNED: better_auth0.RawError<"USER_BANNED">;
20
- UNAUTHORIZED_SESSION: better_auth0.RawError<"UNAUTHORIZED_SESSION">;
21
- KEY_NOT_FOUND: better_auth0.RawError<"KEY_NOT_FOUND">;
22
- KEY_DISABLED: better_auth0.RawError<"KEY_DISABLED">;
23
- KEY_EXPIRED: better_auth0.RawError<"KEY_EXPIRED">;
24
- USAGE_EXCEEDED: better_auth0.RawError<"USAGE_EXCEEDED">;
25
- KEY_NOT_RECOVERABLE: better_auth0.RawError<"KEY_NOT_RECOVERABLE">;
26
- EXPIRES_IN_IS_TOO_SMALL: better_auth0.RawError<"EXPIRES_IN_IS_TOO_SMALL">;
27
- EXPIRES_IN_IS_TOO_LARGE: better_auth0.RawError<"EXPIRES_IN_IS_TOO_LARGE">;
28
- INVALID_REMAINING: better_auth0.RawError<"INVALID_REMAINING">;
29
- INVALID_PREFIX_LENGTH: better_auth0.RawError<"INVALID_PREFIX_LENGTH">;
30
- INVALID_NAME_LENGTH: better_auth0.RawError<"INVALID_NAME_LENGTH">;
31
- METADATA_DISABLED: better_auth0.RawError<"METADATA_DISABLED">;
32
- RATE_LIMIT_EXCEEDED: better_auth0.RawError<"RATE_LIMIT_EXCEEDED">;
33
- NO_VALUES_TO_UPDATE: better_auth0.RawError<"NO_VALUES_TO_UPDATE">;
34
- KEY_DISABLED_EXPIRATION: better_auth0.RawError<"KEY_DISABLED_EXPIRATION">;
35
- INVALID_API_KEY: better_auth0.RawError<"INVALID_API_KEY">;
36
- INVALID_USER_ID_FROM_API_KEY: better_auth0.RawError<"INVALID_USER_ID_FROM_API_KEY">;
37
- INVALID_REFERENCE_ID_FROM_API_KEY: better_auth0.RawError<"INVALID_REFERENCE_ID_FROM_API_KEY">;
38
- INVALID_API_KEY_GETTER_RETURN_TYPE: better_auth0.RawError<"INVALID_API_KEY_GETTER_RETURN_TYPE">;
39
- SERVER_ONLY_PROPERTY: better_auth0.RawError<"SERVER_ONLY_PROPERTY">;
40
- FAILED_TO_UPDATE_API_KEY: better_auth0.RawError<"FAILED_TO_UPDATE_API_KEY">;
41
- NAME_REQUIRED: better_auth0.RawError<"NAME_REQUIRED">;
42
- ORGANIZATION_ID_REQUIRED: better_auth0.RawError<"ORGANIZATION_ID_REQUIRED">;
43
- USER_NOT_MEMBER_OF_ORGANIZATION: better_auth0.RawError<"USER_NOT_MEMBER_OF_ORGANIZATION">;
44
- INSUFFICIENT_API_KEY_PERMISSIONS: better_auth0.RawError<"INSUFFICIENT_API_KEY_PERMISSIONS">;
45
- NO_DEFAULT_API_KEY_CONFIGURATION_FOUND: better_auth0.RawError<"NO_DEFAULT_API_KEY_CONFIGURATION_FOUND">;
46
- ORGANIZATION_PLUGIN_REQUIRED: better_auth0.RawError<"ORGANIZATION_PLUGIN_REQUIRED">;
47
- };
48
- //#endregion
49
- //#region src/index.d.ts
50
- declare module "@better-auth/core" {
51
- interface BetterAuthPluginRegistry<AuthOptions, Options> {
52
- "api-key": {
53
- creator: typeof apiKey;
54
- };
55
- }
56
- }
57
- declare const defaultKeyHasher: (key: string) => Promise<string>;
58
- declare const API_KEY_TABLE_NAME = "apikey";
59
- declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOptions) | ApiKeyConfigurationOptions[] | undefined, _options?: ApiKeyOptions | undefined): {
60
- id: "api-key";
61
- $ERROR_CODES: {
62
- INVALID_METADATA_TYPE: better_auth0.RawError<"INVALID_METADATA_TYPE">;
63
- REFILL_AMOUNT_AND_INTERVAL_REQUIRED: better_auth0.RawError<"REFILL_AMOUNT_AND_INTERVAL_REQUIRED">;
64
- REFILL_INTERVAL_AND_AMOUNT_REQUIRED: better_auth0.RawError<"REFILL_INTERVAL_AND_AMOUNT_REQUIRED">;
65
- USER_BANNED: better_auth0.RawError<"USER_BANNED">;
66
- UNAUTHORIZED_SESSION: better_auth0.RawError<"UNAUTHORIZED_SESSION">;
67
- KEY_NOT_FOUND: better_auth0.RawError<"KEY_NOT_FOUND">;
68
- KEY_DISABLED: better_auth0.RawError<"KEY_DISABLED">;
69
- KEY_EXPIRED: better_auth0.RawError<"KEY_EXPIRED">;
70
- USAGE_EXCEEDED: better_auth0.RawError<"USAGE_EXCEEDED">;
71
- KEY_NOT_RECOVERABLE: better_auth0.RawError<"KEY_NOT_RECOVERABLE">;
72
- EXPIRES_IN_IS_TOO_SMALL: better_auth0.RawError<"EXPIRES_IN_IS_TOO_SMALL">;
73
- EXPIRES_IN_IS_TOO_LARGE: better_auth0.RawError<"EXPIRES_IN_IS_TOO_LARGE">;
74
- INVALID_REMAINING: better_auth0.RawError<"INVALID_REMAINING">;
75
- INVALID_PREFIX_LENGTH: better_auth0.RawError<"INVALID_PREFIX_LENGTH">;
76
- INVALID_NAME_LENGTH: better_auth0.RawError<"INVALID_NAME_LENGTH">;
77
- METADATA_DISABLED: better_auth0.RawError<"METADATA_DISABLED">;
78
- RATE_LIMIT_EXCEEDED: better_auth0.RawError<"RATE_LIMIT_EXCEEDED">;
79
- NO_VALUES_TO_UPDATE: better_auth0.RawError<"NO_VALUES_TO_UPDATE">;
80
- KEY_DISABLED_EXPIRATION: better_auth0.RawError<"KEY_DISABLED_EXPIRATION">;
81
- INVALID_API_KEY: better_auth0.RawError<"INVALID_API_KEY">;
82
- INVALID_USER_ID_FROM_API_KEY: better_auth0.RawError<"INVALID_USER_ID_FROM_API_KEY">;
83
- INVALID_REFERENCE_ID_FROM_API_KEY: better_auth0.RawError<"INVALID_REFERENCE_ID_FROM_API_KEY">;
84
- INVALID_API_KEY_GETTER_RETURN_TYPE: better_auth0.RawError<"INVALID_API_KEY_GETTER_RETURN_TYPE">;
85
- SERVER_ONLY_PROPERTY: better_auth0.RawError<"SERVER_ONLY_PROPERTY">;
86
- FAILED_TO_UPDATE_API_KEY: better_auth0.RawError<"FAILED_TO_UPDATE_API_KEY">;
87
- NAME_REQUIRED: better_auth0.RawError<"NAME_REQUIRED">;
88
- ORGANIZATION_ID_REQUIRED: better_auth0.RawError<"ORGANIZATION_ID_REQUIRED">;
89
- USER_NOT_MEMBER_OF_ORGANIZATION: better_auth0.RawError<"USER_NOT_MEMBER_OF_ORGANIZATION">;
90
- INSUFFICIENT_API_KEY_PERMISSIONS: better_auth0.RawError<"INSUFFICIENT_API_KEY_PERMISSIONS">;
91
- NO_DEFAULT_API_KEY_CONFIGURATION_FOUND: better_auth0.RawError<"NO_DEFAULT_API_KEY_CONFIGURATION_FOUND">;
92
- ORGANIZATION_PLUGIN_REQUIRED: better_auth0.RawError<"ORGANIZATION_PLUGIN_REQUIRED">;
93
- };
94
- hooks: {
95
- before: {
96
- matcher: (ctx: HookEndpointContext) => boolean;
97
- handler: (inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
98
- user: {
99
- id: string;
100
- createdAt: Date;
101
- updatedAt: Date;
102
- email: string;
103
- emailVerified: boolean;
104
- name: string;
105
- image?: string | null | undefined;
106
- };
107
- session: {
108
- id: string;
109
- token: string;
110
- userId: string;
111
- userAgent: string | null;
112
- ipAddress: string | null;
113
- createdAt: Date;
114
- updatedAt: Date;
115
- expiresAt: Date;
116
- };
117
- } | {
118
- context: better_call0.MiddlewareContext<better_call0.MiddlewareOptions, {
119
- returned?: unknown | undefined;
120
- responseHeaders?: Headers | undefined;
121
- } & better_auth0.PluginContext<better_auth0.BetterAuthOptions> & better_auth0.InfoContext & {
122
- options: better_auth0.BetterAuthOptions;
123
- trustedOrigins: string[];
124
- trustedProviders: string[];
125
- isTrustedOrigin: (url: string, settings?: {
126
- allowRelativePaths: boolean;
127
- }) => boolean;
128
- oauthConfig: {
129
- skipStateCookieCheck?: boolean | undefined;
130
- storeStateStrategy: "database" | "cookie";
131
- };
132
- newSession: {
133
- session: {
134
- id: string;
135
- createdAt: Date;
136
- updatedAt: Date;
137
- userId: string;
138
- expiresAt: Date;
139
- token: string;
140
- ipAddress?: string | null | undefined;
141
- userAgent?: string | null | undefined;
142
- } & Record<string, any>;
143
- user: {
144
- id: string;
145
- createdAt: Date;
146
- updatedAt: Date;
147
- email: string;
148
- emailVerified: boolean;
149
- name: string;
150
- image?: string | null | undefined;
151
- } & Record<string, any>;
152
- } | null;
153
- session: {
154
- session: {
155
- id: string;
156
- createdAt: Date;
157
- updatedAt: Date;
158
- userId: string;
159
- expiresAt: Date;
160
- token: string;
161
- ipAddress?: string | null | undefined;
162
- userAgent?: string | null | undefined;
163
- } & Record<string, any>;
164
- user: {
165
- id: string;
166
- createdAt: Date;
167
- updatedAt: Date;
168
- email: string;
169
- emailVerified: boolean;
170
- name: string;
171
- image?: string | null | undefined;
172
- } & Record<string, any>;
173
- } | null;
174
- setNewSession: (session: {
175
- session: {
176
- id: string;
177
- createdAt: Date;
178
- updatedAt: Date;
179
- userId: string;
180
- expiresAt: Date;
181
- token: string;
182
- ipAddress?: string | null | undefined;
183
- userAgent?: string | null | undefined;
184
- } & Record<string, any>;
185
- user: {
186
- id: string;
187
- createdAt: Date;
188
- updatedAt: Date;
189
- email: string;
190
- emailVerified: boolean;
191
- name: string;
192
- image?: string | null | undefined;
193
- } & Record<string, any>;
194
- } | null) => void;
195
- socialProviders: better_auth0.OAuthProvider[];
196
- authCookies: better_auth0.BetterAuthCookies;
197
- logger: ReturnType<typeof better_auth0.createLogger>;
198
- rateLimit: {
199
- enabled: boolean;
200
- window: number;
201
- max: number;
202
- storage: "memory" | "database" | "secondary-storage";
203
- } & Omit<better_auth0.BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
204
- adapter: better_auth0.DBAdapter<better_auth0.BetterAuthOptions>;
205
- internalAdapter: better_auth0.InternalAdapter<better_auth0.BetterAuthOptions>;
206
- createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) => better_auth0.BetterAuthCookie;
207
- secret: string;
208
- secretConfig: string | better_auth0.SecretConfig;
209
- sessionConfig: {
210
- updateAge: number;
211
- expiresIn: number;
212
- freshAge: number;
213
- cookieRefreshCache: false | {
214
- enabled: true;
215
- updateAge: number;
216
- };
217
- };
218
- generateId: (options: {
219
- model: better_auth0.ModelNames;
220
- size?: number | undefined;
221
- }) => string | false;
222
- secondaryStorage: better_auth0.SecondaryStorage | undefined;
223
- password: {
224
- hash: (password: string) => Promise<string>;
225
- verify: (data: {
226
- password: string;
227
- hash: string;
228
- }) => Promise<boolean>;
229
- config: {
230
- minPasswordLength: number;
231
- maxPasswordLength: number;
232
- };
233
- checkPassword: (userId: string, ctx: better_auth0.GenericEndpointContext<better_auth0.BetterAuthOptions>) => Promise<boolean>;
234
- };
235
- tables: better_auth0.BetterAuthDBSchema;
236
- runMigrations: () => Promise<void>;
237
- publishTelemetry: (event: {
238
- type: string;
239
- anonymousId?: string | undefined;
240
- payload: Record<string, any>;
241
- }) => Promise<void>;
242
- skipOriginCheck: boolean | string[];
243
- skipCSRFCheck: boolean;
244
- runInBackground: (promise: Promise<unknown>) => void;
245
- runInBackgroundOrAwait: (promise: Promise<unknown> | void) => better_auth0.Awaitable<unknown>;
246
- }>;
247
- }>;
248
- }[];
249
- };
250
- endpoints: {
251
- /**
252
- * ### Endpoint
253
- *
254
- * POST `/api-key/create`
255
- *
256
- * ### API Methods
257
- *
258
- * **server:**
259
- * `auth.api.createApiKey`
260
- *
261
- * **client:**
262
- * `authClient.apiKey.create`
263
- *
264
- * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-create)
265
- */
266
- createApiKey: better_call0.StrictEndpoint<"/api-key/create", {
267
- method: "POST";
268
- body: zod.ZodObject<{
269
- configId: zod.ZodOptional<zod.ZodString>;
270
- name: zod.ZodOptional<zod.ZodString>;
271
- expiresIn: zod.ZodDefault<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
272
- prefix: zod.ZodOptional<zod.ZodString>;
273
- remaining: zod.ZodDefault<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
274
- metadata: zod.ZodOptional<zod.ZodAny>;
275
- refillAmount: zod.ZodOptional<zod.ZodNumber>;
276
- refillInterval: zod.ZodOptional<zod.ZodNumber>;
277
- rateLimitTimeWindow: zod.ZodOptional<zod.ZodNumber>;
278
- rateLimitMax: zod.ZodOptional<zod.ZodNumber>;
279
- rateLimitEnabled: zod.ZodOptional<zod.ZodBoolean>;
280
- permissions: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>>;
281
- userId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
282
- organizationId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
283
- }, better_auth0.$strip>;
284
- metadata: {
285
- openapi: {
286
- description: string;
287
- responses: {
288
- "200": {
289
- description: string;
290
- content: {
291
- "application/json": {
292
- schema: {
293
- type: "object";
294
- properties: {
295
- id: {
296
- type: string;
297
- description: string;
298
- };
299
- createdAt: {
300
- type: string;
301
- format: string;
302
- description: string;
303
- };
304
- updatedAt: {
305
- type: string;
306
- format: string;
307
- description: string;
308
- };
309
- name: {
310
- type: string;
311
- nullable: boolean;
312
- description: string;
313
- };
314
- prefix: {
315
- type: string;
316
- nullable: boolean;
317
- description: string;
318
- };
319
- start: {
320
- type: string;
321
- nullable: boolean;
322
- description: string;
323
- };
324
- key: {
325
- type: string;
326
- description: string;
327
- };
328
- enabled: {
329
- type: string;
330
- description: string;
331
- };
332
- expiresAt: {
333
- type: string;
334
- format: string;
335
- nullable: boolean;
336
- description: string;
337
- };
338
- referenceId: {
339
- type: string;
340
- description: string;
341
- };
342
- lastRefillAt: {
343
- type: string;
344
- format: string;
345
- nullable: boolean;
346
- description: string;
347
- };
348
- lastRequest: {
349
- type: string;
350
- format: string;
351
- nullable: boolean;
352
- description: string;
353
- };
354
- metadata: {
355
- type: string;
356
- nullable: boolean;
357
- additionalProperties: boolean;
358
- description: string;
359
- };
360
- rateLimitMax: {
361
- type: string;
362
- nullable: boolean;
363
- description: string;
364
- };
365
- rateLimitTimeWindow: {
366
- type: string;
367
- nullable: boolean;
368
- description: string;
369
- };
370
- remaining: {
371
- type: string;
372
- nullable: boolean;
373
- description: string;
374
- };
375
- refillAmount: {
376
- type: string;
377
- nullable: boolean;
378
- description: string;
379
- };
380
- refillInterval: {
381
- type: string;
382
- nullable: boolean;
383
- description: string;
384
- };
385
- rateLimitEnabled: {
386
- type: string;
387
- description: string;
388
- };
389
- requestCount: {
390
- type: string;
391
- description: string;
392
- };
393
- permissions: {
394
- type: string;
395
- nullable: boolean;
396
- additionalProperties: {
397
- type: string;
398
- items: {
399
- type: string;
400
- };
401
- };
402
- description: string;
403
- };
404
- };
405
- required: string[];
406
- };
407
- };
408
- };
409
- };
410
- };
411
- };
412
- };
413
- }, {
414
- key: string;
415
- metadata: any;
416
- permissions: any;
417
- id: string;
418
- configId: string;
419
- name: string | null;
420
- start: string | null;
421
- prefix: string | null;
422
- referenceId: string;
423
- refillInterval: number | null;
424
- refillAmount: number | null;
425
- lastRefillAt: Date | null;
426
- enabled: boolean;
427
- rateLimitEnabled: boolean;
428
- rateLimitTimeWindow: number | null;
429
- rateLimitMax: number | null;
430
- requestCount: number;
431
- remaining: number | null;
432
- lastRequest: Date | null;
433
- expiresAt: Date | null;
434
- createdAt: Date;
435
- updatedAt: Date;
436
- }>;
437
- /**
438
- * ### Endpoint
439
- *
440
- * POST `/api-key/verify`
441
- *
442
- * ### API Methods
443
- *
444
- * **server:**
445
- * `auth.api.verifyApiKey`
446
- *
447
- * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-verify)
448
- */
449
- verifyApiKey: better_call0.StrictEndpoint<string, {
450
- method: "POST";
451
- body: zod.ZodObject<{
452
- configId: zod.ZodOptional<zod.ZodString>;
453
- key: zod.ZodString;
454
- permissions: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>>;
455
- }, better_auth0.$strip>;
456
- }, {
457
- valid: boolean;
458
- error: {
459
- message: better_auth0.RawError<"INVALID_API_KEY">;
460
- code: "KEY_NOT_FOUND";
461
- };
462
- key: null;
463
- } | {
464
- valid: boolean;
465
- error: {
466
- message: string | undefined;
467
- code: string;
468
- cause?: unknown;
469
- };
470
- key: null;
471
- } | {
472
- valid: boolean;
473
- error: {
474
- message: better_auth0.RawError<"INVALID_API_KEY">;
475
- code: "INVALID_API_KEY";
476
- };
477
- key: null;
478
- } | {
479
- valid: boolean;
480
- error: null;
481
- key: Omit<ApiKey, "key"> | null;
482
- }>;
483
- /**
484
- * ### Endpoint
485
- *
486
- * GET `/api-key/get`
487
- *
488
- * ### API Methods
489
- *
490
- * **server:**
491
- * `auth.api.getApiKey`
492
- *
493
- * **client:**
494
- * `authClient.apiKey.get`
495
- *
496
- * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-get)
497
- */
498
- getApiKey: better_call0.StrictEndpoint<"/api-key/get", {
499
- method: "GET";
500
- query: zod.ZodObject<{
501
- configId: zod.ZodOptional<zod.ZodString>;
502
- id: zod.ZodString;
503
- }, better_auth0.$strip>;
504
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
505
- session: {
506
- session: Record<string, any> & {
507
- id: string;
508
- createdAt: Date;
509
- updatedAt: Date;
510
- userId: string;
511
- expiresAt: Date;
512
- token: string;
513
- ipAddress?: string | null | undefined;
514
- userAgent?: string | null | undefined;
515
- };
516
- user: Record<string, any> & {
517
- id: string;
518
- createdAt: Date;
519
- updatedAt: Date;
520
- email: string;
521
- emailVerified: boolean;
522
- name: string;
523
- image?: string | null | undefined;
524
- };
525
- };
526
- }>)[];
527
- metadata: {
528
- openapi: {
529
- description: string;
530
- responses: {
531
- "200": {
532
- description: string;
533
- content: {
534
- "application/json": {
535
- schema: {
536
- type: "object";
537
- properties: {
538
- id: {
539
- type: string;
540
- description: string;
541
- };
542
- name: {
543
- type: string;
544
- nullable: boolean;
545
- description: string;
546
- };
547
- start: {
548
- type: string;
549
- nullable: boolean;
550
- description: string;
551
- };
552
- prefix: {
553
- type: string;
554
- nullable: boolean;
555
- description: string;
556
- };
557
- userId: {
558
- type: string;
559
- description: string;
560
- };
561
- refillInterval: {
562
- type: string;
563
- nullable: boolean;
564
- description: string;
565
- };
566
- refillAmount: {
567
- type: string;
568
- nullable: boolean;
569
- description: string;
570
- };
571
- lastRefillAt: {
572
- type: string;
573
- format: string;
574
- nullable: boolean;
575
- description: string;
576
- };
577
- enabled: {
578
- type: string;
579
- description: string;
580
- default: boolean;
581
- };
582
- rateLimitEnabled: {
583
- type: string;
584
- description: string;
585
- };
586
- rateLimitTimeWindow: {
587
- type: string;
588
- nullable: boolean;
589
- description: string;
590
- };
591
- rateLimitMax: {
592
- type: string;
593
- nullable: boolean;
594
- description: string;
595
- };
596
- requestCount: {
597
- type: string;
598
- description: string;
599
- };
600
- remaining: {
601
- type: string;
602
- nullable: boolean;
603
- description: string;
604
- };
605
- lastRequest: {
606
- type: string;
607
- format: string;
608
- nullable: boolean;
609
- description: string;
610
- };
611
- expiresAt: {
612
- type: string;
613
- format: string;
614
- nullable: boolean;
615
- description: string;
616
- };
617
- createdAt: {
618
- type: string;
619
- format: string;
620
- description: string;
621
- };
622
- updatedAt: {
623
- type: string;
624
- format: string;
625
- description: string;
626
- };
627
- metadata: {
628
- type: string;
629
- nullable: boolean;
630
- additionalProperties: boolean;
631
- description: string;
632
- };
633
- permissions: {
634
- type: string;
635
- nullable: boolean;
636
- description: string;
637
- };
638
- };
639
- required: string[];
640
- };
641
- };
642
- };
643
- };
644
- };
645
- };
646
- };
647
- }, {
648
- metadata: Record<string, any> | null;
649
- permissions: {
650
- [key: string]: string[];
651
- } | null;
652
- id: string;
653
- configId: string;
654
- name: string | null;
655
- start: string | null;
656
- prefix: string | null;
657
- referenceId: string;
658
- refillInterval: number | null;
659
- refillAmount: number | null;
660
- lastRefillAt: Date | null;
661
- enabled: boolean;
662
- rateLimitEnabled: boolean;
663
- rateLimitTimeWindow: number | null;
664
- rateLimitMax: number | null;
665
- requestCount: number;
666
- remaining: number | null;
667
- lastRequest: Date | null;
668
- expiresAt: Date | null;
669
- createdAt: Date;
670
- updatedAt: Date;
671
- }>;
672
- /**
673
- * ### Endpoint
674
- *
675
- * POST `/api-key/update`
676
- *
677
- * ### API Methods
678
- *
679
- * **server:**
680
- * `auth.api.updateApiKey`
681
- *
682
- * **client:**
683
- * `authClient.apiKey.update`
684
- *
685
- * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-update)
686
- */
687
- updateApiKey: better_call0.StrictEndpoint<"/api-key/update", {
688
- method: "POST";
689
- body: zod.ZodObject<{
690
- configId: zod.ZodOptional<zod.ZodString>;
691
- keyId: zod.ZodString;
692
- userId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
693
- name: zod.ZodOptional<zod.ZodString>;
694
- enabled: zod.ZodOptional<zod.ZodBoolean>;
695
- remaining: zod.ZodOptional<zod.ZodNumber>;
696
- refillAmount: zod.ZodOptional<zod.ZodNumber>;
697
- refillInterval: zod.ZodOptional<zod.ZodNumber>;
698
- metadata: zod.ZodOptional<zod.ZodAny>;
699
- expiresIn: zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>;
700
- rateLimitEnabled: zod.ZodOptional<zod.ZodBoolean>;
701
- rateLimitTimeWindow: zod.ZodOptional<zod.ZodNumber>;
702
- rateLimitMax: zod.ZodOptional<zod.ZodNumber>;
703
- permissions: zod.ZodNullable<zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>>>;
704
- }, better_auth0.$strip>;
705
- metadata: {
706
- openapi: {
707
- description: string;
708
- responses: {
709
- "200": {
710
- description: string;
711
- content: {
712
- "application/json": {
713
- schema: {
714
- type: "object";
715
- properties: {
716
- id: {
717
- type: string;
718
- description: string;
719
- };
720
- name: {
721
- type: string;
722
- nullable: boolean;
723
- description: string;
724
- };
725
- start: {
726
- type: string;
727
- nullable: boolean;
728
- description: string;
729
- };
730
- prefix: {
731
- type: string;
732
- nullable: boolean;
733
- description: string;
734
- };
735
- userId: {
736
- type: string;
737
- description: string;
738
- };
739
- refillInterval: {
740
- type: string;
741
- nullable: boolean;
742
- description: string;
743
- };
744
- refillAmount: {
745
- type: string;
746
- nullable: boolean;
747
- description: string;
748
- };
749
- lastRefillAt: {
750
- type: string;
751
- format: string;
752
- nullable: boolean;
753
- description: string;
754
- };
755
- enabled: {
756
- type: string;
757
- description: string;
758
- default: boolean;
759
- };
760
- rateLimitEnabled: {
761
- type: string;
762
- description: string;
763
- };
764
- rateLimitTimeWindow: {
765
- type: string;
766
- nullable: boolean;
767
- description: string;
768
- };
769
- rateLimitMax: {
770
- type: string;
771
- nullable: boolean;
772
- description: string;
773
- };
774
- requestCount: {
775
- type: string;
776
- description: string;
777
- };
778
- remaining: {
779
- type: string;
780
- nullable: boolean;
781
- description: string;
782
- };
783
- lastRequest: {
784
- type: string;
785
- format: string;
786
- nullable: boolean;
787
- description: string;
788
- };
789
- expiresAt: {
790
- type: string;
791
- format: string;
792
- nullable: boolean;
793
- description: string;
794
- };
795
- createdAt: {
796
- type: string;
797
- format: string;
798
- description: string;
799
- };
800
- updatedAt: {
801
- type: string;
802
- format: string;
803
- description: string;
804
- };
805
- metadata: {
806
- type: string;
807
- nullable: boolean;
808
- additionalProperties: boolean;
809
- description: string;
810
- };
811
- permissions: {
812
- type: string;
813
- nullable: boolean;
814
- description: string;
815
- };
816
- };
817
- required: string[];
818
- };
819
- };
820
- };
821
- };
822
- };
823
- };
824
- };
825
- }, {
826
- metadata: Record<string, any> | null;
827
- permissions: {
828
- [key: string]: string[];
829
- } | null;
830
- id: string;
831
- configId: string;
832
- name: string | null;
833
- start: string | null;
834
- prefix: string | null;
835
- referenceId: string;
836
- refillInterval: number | null;
837
- refillAmount: number | null;
838
- lastRefillAt: Date | null;
839
- enabled: boolean;
840
- rateLimitEnabled: boolean;
841
- rateLimitTimeWindow: number | null;
842
- rateLimitMax: number | null;
843
- requestCount: number;
844
- remaining: number | null;
845
- lastRequest: Date | null;
846
- expiresAt: Date | null;
847
- createdAt: Date;
848
- updatedAt: Date;
849
- }>;
850
- /**
851
- * ### Endpoint
852
- *
853
- * POST `/api-key/delete`
854
- *
855
- * ### API Methods
856
- *
857
- * **server:**
858
- * `auth.api.deleteApiKey`
859
- *
860
- * **client:**
861
- * `authClient.apiKey.delete`
862
- *
863
- * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete)
864
- */
865
- deleteApiKey: better_call0.StrictEndpoint<"/api-key/delete", {
866
- method: "POST";
867
- body: zod.ZodObject<{
868
- configId: zod.ZodOptional<zod.ZodString>;
869
- keyId: zod.ZodString;
870
- }, better_auth0.$strip>;
871
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
872
- session: {
873
- session: Record<string, any> & {
874
- id: string;
875
- createdAt: Date;
876
- updatedAt: Date;
877
- userId: string;
878
- expiresAt: Date;
879
- token: string;
880
- ipAddress?: string | null | undefined;
881
- userAgent?: string | null | undefined;
882
- };
883
- user: Record<string, any> & {
884
- id: string;
885
- createdAt: Date;
886
- updatedAt: Date;
887
- email: string;
888
- emailVerified: boolean;
889
- name: string;
890
- image?: string | null | undefined;
891
- };
892
- };
893
- }>)[];
894
- metadata: {
895
- openapi: {
896
- description: string;
897
- requestBody: {
898
- content: {
899
- "application/json": {
900
- schema: {
901
- type: "object";
902
- properties: {
903
- keyId: {
904
- type: string;
905
- description: string;
906
- };
907
- };
908
- required: string[];
909
- };
910
- };
911
- };
912
- };
913
- responses: {
914
- "200": {
915
- description: string;
916
- content: {
917
- "application/json": {
918
- schema: {
919
- type: "object";
920
- properties: {
921
- success: {
922
- type: string;
923
- description: string;
924
- };
925
- };
926
- required: string[];
927
- };
928
- };
929
- };
930
- };
931
- };
932
- };
933
- };
934
- }, {
935
- success: boolean;
936
- }>;
937
- /**
938
- * ### Endpoint
939
- *
940
- * GET `/api-key/list`
941
- *
942
- * ### API Methods
943
- *
944
- * **server:**
945
- * `auth.api.listApiKeys`
946
- *
947
- * **client:**
948
- * `authClient.apiKey.list`
949
- *
950
- * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-list)
951
- */
952
- listApiKeys: better_call0.StrictEndpoint<"/api-key/list", {
953
- method: "GET";
954
- use: ((inputContext: better_call0.MiddlewareInputContext<better_call0.MiddlewareOptions>) => Promise<{
955
- session: {
956
- session: Record<string, any> & {
957
- id: string;
958
- createdAt: Date;
959
- updatedAt: Date;
960
- userId: string;
961
- expiresAt: Date;
962
- token: string;
963
- ipAddress?: string | null | undefined;
964
- userAgent?: string | null | undefined;
965
- };
966
- user: Record<string, any> & {
967
- id: string;
968
- createdAt: Date;
969
- updatedAt: Date;
970
- email: string;
971
- emailVerified: boolean;
972
- name: string;
973
- image?: string | null | undefined;
974
- };
975
- };
976
- }>)[];
977
- query: zod.ZodOptional<zod.ZodObject<{
978
- configId: zod.ZodOptional<zod.ZodString>;
979
- organizationId: zod.ZodOptional<zod.ZodString>;
980
- limit: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
981
- offset: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
982
- sortBy: zod.ZodOptional<zod.ZodString>;
983
- sortDirection: zod.ZodOptional<zod.ZodEnum<{
984
- asc: "asc";
985
- desc: "desc";
986
- }>>;
987
- }, better_auth0.$strip>>;
988
- metadata: {
989
- openapi: {
990
- description: string;
991
- responses: {
992
- "200": {
993
- description: string;
994
- content: {
995
- "application/json": {
996
- schema: {
997
- type: "object";
998
- properties: {
999
- apiKeys: {
1000
- type: string;
1001
- items: {
1002
- type: string;
1003
- properties: {
1004
- id: {
1005
- type: string;
1006
- description: string;
1007
- };
1008
- name: {
1009
- type: string;
1010
- nullable: boolean;
1011
- description: string;
1012
- };
1013
- start: {
1014
- type: string;
1015
- nullable: boolean;
1016
- description: string;
1017
- };
1018
- prefix: {
1019
- type: string;
1020
- nullable: boolean;
1021
- description: string;
1022
- };
1023
- userId: {
1024
- type: string;
1025
- description: string;
1026
- };
1027
- refillInterval: {
1028
- type: string;
1029
- nullable: boolean;
1030
- description: string;
1031
- };
1032
- refillAmount: {
1033
- type: string;
1034
- nullable: boolean;
1035
- description: string;
1036
- };
1037
- lastRefillAt: {
1038
- type: string;
1039
- format: string;
1040
- nullable: boolean;
1041
- description: string;
1042
- };
1043
- enabled: {
1044
- type: string;
1045
- description: string;
1046
- default: boolean;
1047
- };
1048
- rateLimitEnabled: {
1049
- type: string;
1050
- description: string;
1051
- };
1052
- rateLimitTimeWindow: {
1053
- type: string;
1054
- nullable: boolean;
1055
- description: string;
1056
- };
1057
- rateLimitMax: {
1058
- type: string;
1059
- nullable: boolean;
1060
- description: string;
1061
- };
1062
- requestCount: {
1063
- type: string;
1064
- description: string;
1065
- };
1066
- remaining: {
1067
- type: string;
1068
- nullable: boolean;
1069
- description: string;
1070
- };
1071
- lastRequest: {
1072
- type: string;
1073
- format: string;
1074
- nullable: boolean;
1075
- description: string;
1076
- };
1077
- expiresAt: {
1078
- type: string;
1079
- format: string;
1080
- nullable: boolean;
1081
- description: string;
1082
- };
1083
- createdAt: {
1084
- type: string;
1085
- format: string;
1086
- description: string;
1087
- };
1088
- updatedAt: {
1089
- type: string;
1090
- format: string;
1091
- description: string;
1092
- };
1093
- metadata: {
1094
- type: string;
1095
- nullable: boolean;
1096
- additionalProperties: boolean;
1097
- description: string;
1098
- };
1099
- permissions: {
1100
- type: string;
1101
- nullable: boolean;
1102
- description: string;
1103
- };
1104
- };
1105
- required: string[];
1106
- };
1107
- };
1108
- total: {
1109
- type: string;
1110
- description: string;
1111
- };
1112
- limit: {
1113
- type: string;
1114
- nullable: boolean;
1115
- description: string;
1116
- };
1117
- offset: {
1118
- type: string;
1119
- nullable: boolean;
1120
- description: string;
1121
- };
1122
- };
1123
- required: string[];
1124
- };
1125
- };
1126
- };
1127
- };
1128
- };
1129
- };
1130
- };
1131
- }, {
1132
- apiKeys: {
1133
- metadata: Record<string, any> | null;
1134
- permissions: {
1135
- [key: string]: string[];
1136
- } | null;
1137
- id: string;
1138
- configId: string;
1139
- name: string | null;
1140
- start: string | null;
1141
- prefix: string | null;
1142
- referenceId: string;
1143
- refillInterval: number | null;
1144
- refillAmount: number | null;
1145
- lastRefillAt: Date | null;
1146
- enabled: boolean;
1147
- rateLimitEnabled: boolean;
1148
- rateLimitTimeWindow: number | null;
1149
- rateLimitMax: number | null;
1150
- requestCount: number;
1151
- remaining: number | null;
1152
- lastRequest: Date | null;
1153
- expiresAt: Date | null;
1154
- createdAt: Date;
1155
- updatedAt: Date;
1156
- }[];
1157
- total: number;
1158
- limit: number | undefined;
1159
- offset: number | undefined;
1160
- }>;
1161
- /**
1162
- * ### Endpoint
1163
- *
1164
- * POST `/api-key/delete-all-expired-api-keys`
1165
- *
1166
- * ### API Methods
1167
- *
1168
- * **server:**
1169
- * `auth.api.deleteAllExpiredApiKeys`
1170
- *
1171
- * @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete-all-expired-api-keys)
1172
- */
1173
- deleteAllExpiredApiKeys: better_call0.StrictEndpoint<string, {
1174
- method: "POST";
1175
- }, {
1176
- success: boolean;
1177
- error: unknown;
1178
- }>;
1179
- };
1180
- schema: {
1181
- apikey: {
1182
- fields: {
1183
- configId: {
1184
- type: "string";
1185
- required: true;
1186
- defaultValue: string;
1187
- input: false;
1188
- index: true;
1189
- };
1190
- name: {
1191
- type: "string";
1192
- required: false;
1193
- input: false;
1194
- };
1195
- start: {
1196
- type: "string";
1197
- required: false;
1198
- input: false;
1199
- };
1200
- referenceId: {
1201
- type: "string";
1202
- required: true;
1203
- input: false;
1204
- index: true;
1205
- };
1206
- prefix: {
1207
- type: "string";
1208
- required: false;
1209
- input: false;
1210
- };
1211
- key: {
1212
- type: "string";
1213
- required: true;
1214
- input: false;
1215
- index: true;
1216
- };
1217
- refillInterval: {
1218
- type: "number";
1219
- required: false;
1220
- input: false;
1221
- };
1222
- refillAmount: {
1223
- type: "number";
1224
- required: false;
1225
- input: false;
1226
- };
1227
- lastRefillAt: {
1228
- type: "date";
1229
- required: false;
1230
- input: false;
1231
- };
1232
- enabled: {
1233
- type: "boolean";
1234
- required: false;
1235
- input: false;
1236
- defaultValue: true;
1237
- };
1238
- rateLimitEnabled: {
1239
- type: "boolean";
1240
- required: false;
1241
- input: false;
1242
- defaultValue: true;
1243
- };
1244
- rateLimitTimeWindow: {
1245
- type: "number";
1246
- required: false;
1247
- input: false;
1248
- defaultValue: number;
1249
- };
1250
- rateLimitMax: {
1251
- type: "number";
1252
- required: false;
1253
- input: false;
1254
- defaultValue: number;
1255
- };
1256
- requestCount: {
1257
- type: "number";
1258
- required: false;
1259
- input: false;
1260
- defaultValue: number;
1261
- };
1262
- remaining: {
1263
- type: "number";
1264
- required: false;
1265
- input: false;
1266
- };
1267
- lastRequest: {
1268
- type: "date";
1269
- required: false;
1270
- input: false;
1271
- };
1272
- expiresAt: {
1273
- type: "date";
1274
- required: false;
1275
- input: false;
1276
- };
1277
- createdAt: {
1278
- type: "date";
1279
- required: true;
1280
- input: false;
1281
- };
1282
- updatedAt: {
1283
- type: "date";
1284
- required: true;
1285
- input: false;
1286
- };
1287
- permissions: {
1288
- type: "string";
1289
- required: false;
1290
- input: false;
1291
- };
1292
- metadata: {
1293
- type: "string";
1294
- required: false;
1295
- input: true;
1296
- transform: {
1297
- input(value: better_auth0.DBPrimitive): string;
1298
- output(value: better_auth0.DBPrimitive): any;
1299
- };
1300
- };
1301
- };
1302
- };
1303
- };
1304
- configurations: PredefinedApiKeyOptions[];
1305
- };
1306
- //#endregion
1307
- export { API_KEY_ERROR_CODES as i, apiKey as n, defaultKeyHasher as r, API_KEY_TABLE_NAME as t };
1308
- //# sourceMappingURL=index-CP8iCAEj.d.mts.map