@better-auth/api-key 1.5.0 → 1.5.1-beta.2

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