@better-auth/api-key 1.5.0-beta.19

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