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