@delmaredigital/payload-better-auth 0.4.4 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,1061 +4,6 @@
4
4
  * @packageDocumentation
5
5
  */
6
6
  import type { BetterAuthOptions } from 'better-auth';
7
- import { apiKey as betterAuthApiKey } from 'better-auth/plugins';
8
- type ApiKeyPluginOptions = Parameters<typeof betterAuthApiKey>[0];
9
- /**
10
- * API Key plugin with sensible defaults for use with this package.
11
- *
12
- * Enables metadata storage by default so that scopes can be displayed
13
- * in the admin UI after key creation.
14
- *
15
- * @example
16
- * ```ts
17
- * import { apiKeyWithDefaults } from '@delmaredigital/payload-better-auth'
18
- *
19
- * export const betterAuthOptions = {
20
- * plugins: [
21
- * apiKeyWithDefaults(), // metadata enabled by default
22
- * ],
23
- * }
24
- * ```
25
- *
26
- * @example With custom options
27
- * ```ts
28
- * apiKeyWithDefaults({
29
- * rateLimit: { max: 100, window: 60 },
30
- * // enableMetadata is already true
31
- * })
32
- * ```
33
- */
34
- export declare function apiKeyWithDefaults(options?: ApiKeyPluginOptions): {
35
- id: "api-key";
36
- $ERROR_CODES: {
37
- readonly INVALID_METADATA_TYPE: "metadata must be an object or undefined";
38
- readonly REFILL_AMOUNT_AND_INTERVAL_REQUIRED: "refillAmount is required when refillInterval is provided";
39
- readonly REFILL_INTERVAL_AND_AMOUNT_REQUIRED: "refillInterval is required when refillAmount is provided";
40
- readonly USER_BANNED: "User is banned";
41
- readonly UNAUTHORIZED_SESSION: "Unauthorized or invalid session";
42
- readonly KEY_NOT_FOUND: "API Key not found";
43
- readonly KEY_DISABLED: "API Key is disabled";
44
- readonly KEY_EXPIRED: "API Key has expired";
45
- readonly USAGE_EXCEEDED: "API Key has reached its usage limit";
46
- readonly KEY_NOT_RECOVERABLE: "API Key is not recoverable";
47
- readonly EXPIRES_IN_IS_TOO_SMALL: "The expiresIn is smaller than the predefined minimum value.";
48
- readonly EXPIRES_IN_IS_TOO_LARGE: "The expiresIn is larger than the predefined maximum value.";
49
- readonly INVALID_REMAINING: "The remaining count is either too large or too small.";
50
- readonly INVALID_PREFIX_LENGTH: "The prefix length is either too large or too small.";
51
- readonly INVALID_NAME_LENGTH: "The name length is either too large or too small.";
52
- readonly METADATA_DISABLED: "Metadata is disabled.";
53
- readonly RATE_LIMIT_EXCEEDED: "Rate limit exceeded.";
54
- readonly NO_VALUES_TO_UPDATE: "No values to update.";
55
- readonly KEY_DISABLED_EXPIRATION: "Custom key expiration values are disabled.";
56
- readonly INVALID_API_KEY: "Invalid API key.";
57
- readonly INVALID_USER_ID_FROM_API_KEY: "The user id from the API key is invalid.";
58
- readonly INVALID_API_KEY_GETTER_RETURN_TYPE: "API Key getter returned an invalid key type. Expected string.";
59
- readonly SERVER_ONLY_PROPERTY: "The property you're trying to set can only be set from the server auth instance only.";
60
- readonly FAILED_TO_UPDATE_API_KEY: "Failed to update API key";
61
- readonly NAME_REQUIRED: "API Key name is required.";
62
- };
63
- hooks: {
64
- before: {
65
- matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
66
- handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
67
- user: {
68
- id: string;
69
- createdAt: Date;
70
- updatedAt: Date;
71
- email: string;
72
- emailVerified: boolean;
73
- name: string;
74
- image?: string | null | undefined;
75
- };
76
- session: {
77
- id: string;
78
- token: string;
79
- userId: string;
80
- userAgent: string | null;
81
- ipAddress: string | null;
82
- createdAt: Date;
83
- updatedAt: Date;
84
- expiresAt: Date;
85
- };
86
- } | {
87
- context: import("better-auth").MiddlewareContext<import("better-auth").MiddlewareOptions, {
88
- returned?: unknown | undefined;
89
- responseHeaders?: Headers | undefined;
90
- } & import("better-auth").PluginContext & import("better-auth").InfoContext & {
91
- options: BetterAuthOptions;
92
- appName: string;
93
- baseURL: string;
94
- trustedOrigins: string[];
95
- isTrustedOrigin: (url: string, settings?: {
96
- allowRelativePaths: boolean;
97
- }) => boolean;
98
- oauthConfig: {
99
- skipStateCookieCheck?: boolean | undefined;
100
- storeStateStrategy: "database" | "cookie";
101
- };
102
- newSession: {
103
- session: import("better-auth").Session & Record<string, any>;
104
- user: import("better-auth").User & Record<string, any>;
105
- } | null;
106
- session: {
107
- session: import("better-auth").Session & Record<string, any>;
108
- user: import("better-auth").User & Record<string, any>;
109
- } | null;
110
- setNewSession: (session: {
111
- session: import("better-auth").Session & Record<string, any>;
112
- user: import("better-auth").User & Record<string, any>;
113
- } | null) => void;
114
- socialProviders: import("better-auth").OAuthProvider[];
115
- authCookies: import("better-auth").BetterAuthCookies;
116
- logger: ReturnType<(options?: import("better-auth").Logger | undefined) => import("better-auth").InternalLogger>;
117
- rateLimit: {
118
- enabled: boolean;
119
- window: number;
120
- max: number;
121
- storage: "memory" | "database" | "secondary-storage";
122
- } & Omit<import("better-auth").BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
123
- adapter: import("better-auth").DBAdapter<BetterAuthOptions>;
124
- internalAdapter: import("better-auth").InternalAdapter<BetterAuthOptions>;
125
- createAuthCookie: (cookieName: string, overrideAttributes?: Partial<import("better-auth").CookieOptions> | undefined) => import("better-auth").BetterAuthCookie;
126
- secret: string;
127
- sessionConfig: {
128
- updateAge: number;
129
- expiresIn: number;
130
- freshAge: number;
131
- cookieRefreshCache: false | {
132
- enabled: true;
133
- updateAge: number;
134
- };
135
- };
136
- generateId: (options: {
137
- model: import("better-auth").ModelNames;
138
- size?: number | undefined;
139
- }) => string | false;
140
- secondaryStorage: import("better-auth").SecondaryStorage | undefined;
141
- password: {
142
- hash: (password: string) => Promise<string>;
143
- verify: (data: {
144
- password: string;
145
- hash: string;
146
- }) => Promise<boolean>;
147
- config: {
148
- minPasswordLength: number;
149
- maxPasswordLength: number;
150
- };
151
- checkPassword: (userId: string, ctx: import("better-auth").GenericEndpointContext<BetterAuthOptions>) => Promise<boolean>;
152
- };
153
- tables: import("better-auth").BetterAuthDBSchema;
154
- runMigrations: () => Promise<void>;
155
- publishTelemetry: (event: {
156
- type: string;
157
- anonymousId?: string | undefined;
158
- payload: Record<string, any>;
159
- }) => Promise<void>;
160
- skipOriginCheck: boolean | string[];
161
- skipCSRFCheck: boolean;
162
- runInBackground: (promise: Promise<unknown>) => void;
163
- runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("better-auth").Awaitable<unknown>;
164
- }>;
165
- }>;
166
- }[];
167
- };
168
- endpoints: {
169
- createApiKey: import("better-auth").StrictEndpoint<"/api-key/create", {
170
- method: "POST";
171
- body: import("better-auth").ZodObject<{
172
- name: import("better-auth").ZodOptional<import("better-auth").ZodString>;
173
- expiresIn: import("better-auth").ZodDefault<import("better-auth").ZodNullable<import("better-auth").ZodOptional<import("better-auth").ZodNumber>>>;
174
- userId: import("better-auth").ZodOptional<import("better-auth").ZodCoercedString<unknown>>;
175
- prefix: import("better-auth").ZodOptional<import("better-auth").ZodString>;
176
- remaining: import("better-auth").ZodDefault<import("better-auth").ZodNullable<import("better-auth").ZodOptional<import("better-auth").ZodNumber>>>;
177
- metadata: import("better-auth").ZodOptional<import("better-auth").ZodAny>;
178
- refillAmount: import("better-auth").ZodOptional<import("better-auth").ZodNumber>;
179
- refillInterval: import("better-auth").ZodOptional<import("better-auth").ZodNumber>;
180
- rateLimitTimeWindow: import("better-auth").ZodOptional<import("better-auth").ZodNumber>;
181
- rateLimitMax: import("better-auth").ZodOptional<import("better-auth").ZodNumber>;
182
- rateLimitEnabled: import("better-auth").ZodOptional<import("better-auth").ZodBoolean>;
183
- permissions: import("better-auth").ZodOptional<import("better-auth").ZodRecord<import("better-auth").ZodString, import("better-auth").ZodArray<import("better-auth").ZodString>>>;
184
- }, import("better-auth").$strip>;
185
- metadata: {
186
- openapi: {
187
- description: string;
188
- responses: {
189
- "200": {
190
- description: string;
191
- content: {
192
- "application/json": {
193
- schema: {
194
- type: "object";
195
- properties: {
196
- id: {
197
- type: string;
198
- description: string;
199
- };
200
- createdAt: {
201
- type: string;
202
- format: string;
203
- description: string;
204
- };
205
- updatedAt: {
206
- type: string;
207
- format: string;
208
- description: string;
209
- };
210
- name: {
211
- type: string;
212
- nullable: boolean;
213
- description: string;
214
- };
215
- prefix: {
216
- type: string;
217
- nullable: boolean;
218
- description: string;
219
- };
220
- start: {
221
- type: string;
222
- nullable: boolean;
223
- description: string;
224
- };
225
- key: {
226
- type: string;
227
- description: string;
228
- };
229
- enabled: {
230
- type: string;
231
- description: string;
232
- };
233
- expiresAt: {
234
- type: string;
235
- format: string;
236
- nullable: boolean;
237
- description: string;
238
- };
239
- userId: {
240
- type: string;
241
- description: string;
242
- };
243
- lastRefillAt: {
244
- type: string;
245
- format: string;
246
- nullable: boolean;
247
- description: string;
248
- };
249
- lastRequest: {
250
- type: string;
251
- format: string;
252
- nullable: boolean;
253
- description: string;
254
- };
255
- metadata: {
256
- type: string;
257
- nullable: boolean;
258
- additionalProperties: boolean;
259
- description: string;
260
- };
261
- rateLimitMax: {
262
- type: string;
263
- nullable: boolean;
264
- description: string;
265
- };
266
- rateLimitTimeWindow: {
267
- type: string;
268
- nullable: boolean;
269
- description: string;
270
- };
271
- remaining: {
272
- type: string;
273
- nullable: boolean;
274
- description: string;
275
- };
276
- refillAmount: {
277
- type: string;
278
- nullable: boolean;
279
- description: string;
280
- };
281
- refillInterval: {
282
- type: string;
283
- nullable: boolean;
284
- description: string;
285
- };
286
- rateLimitEnabled: {
287
- type: string;
288
- description: string;
289
- };
290
- requestCount: {
291
- type: string;
292
- description: string;
293
- };
294
- permissions: {
295
- type: string;
296
- nullable: boolean;
297
- additionalProperties: {
298
- type: string;
299
- items: {
300
- type: string;
301
- };
302
- };
303
- description: string;
304
- };
305
- };
306
- required: string[];
307
- };
308
- };
309
- };
310
- };
311
- };
312
- };
313
- };
314
- }, {
315
- key: string;
316
- metadata: any;
317
- permissions: any;
318
- id: string;
319
- name: string | null;
320
- start: string | null;
321
- prefix: string | null;
322
- userId: string;
323
- refillInterval: number | null;
324
- refillAmount: number | null;
325
- lastRefillAt: Date | null;
326
- enabled: boolean;
327
- rateLimitEnabled: boolean;
328
- rateLimitTimeWindow: number | null;
329
- rateLimitMax: number | null;
330
- requestCount: number;
331
- remaining: number | null;
332
- lastRequest: Date | null;
333
- expiresAt: Date | null;
334
- createdAt: Date;
335
- updatedAt: Date;
336
- }>;
337
- verifyApiKey: import("better-auth").StrictEndpoint<string, {
338
- method: "POST";
339
- body: import("better-auth").ZodObject<{
340
- key: import("better-auth").ZodString;
341
- permissions: import("better-auth").ZodOptional<import("better-auth").ZodRecord<import("better-auth").ZodString, import("better-auth").ZodArray<import("better-auth").ZodString>>>;
342
- }, import("better-auth").$strip>;
343
- }, {
344
- valid: boolean;
345
- error: {
346
- message: string | undefined;
347
- code: string;
348
- };
349
- key: null;
350
- } | {
351
- valid: boolean;
352
- error: null;
353
- key: Omit<import("better-auth/plugins").ApiKey, "key"> | null;
354
- }>;
355
- getApiKey: import("better-auth").StrictEndpoint<"/api-key/get", {
356
- method: "GET";
357
- query: import("better-auth").ZodObject<{
358
- id: import("better-auth").ZodString;
359
- }, import("better-auth").$strip>;
360
- use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
361
- session: {
362
- session: Record<string, any> & {
363
- id: string;
364
- createdAt: Date;
365
- updatedAt: Date;
366
- userId: string;
367
- expiresAt: Date;
368
- token: string;
369
- ipAddress?: string | null | undefined;
370
- userAgent?: string | null | undefined;
371
- };
372
- user: Record<string, any> & {
373
- id: string;
374
- createdAt: Date;
375
- updatedAt: Date;
376
- email: string;
377
- emailVerified: boolean;
378
- name: string;
379
- image?: string | null | undefined;
380
- };
381
- };
382
- }>)[];
383
- metadata: {
384
- openapi: {
385
- description: string;
386
- responses: {
387
- "200": {
388
- description: string;
389
- content: {
390
- "application/json": {
391
- schema: {
392
- type: "object";
393
- properties: {
394
- id: {
395
- type: string;
396
- description: string;
397
- };
398
- name: {
399
- type: string;
400
- nullable: boolean;
401
- description: string;
402
- };
403
- start: {
404
- type: string;
405
- nullable: boolean;
406
- description: string;
407
- };
408
- prefix: {
409
- type: string;
410
- nullable: boolean;
411
- description: string;
412
- };
413
- userId: {
414
- type: string;
415
- description: string;
416
- };
417
- refillInterval: {
418
- type: string;
419
- nullable: boolean;
420
- description: string;
421
- };
422
- refillAmount: {
423
- type: string;
424
- nullable: boolean;
425
- description: string;
426
- };
427
- lastRefillAt: {
428
- type: string;
429
- format: string;
430
- nullable: boolean;
431
- description: string;
432
- };
433
- enabled: {
434
- type: string;
435
- description: string;
436
- default: boolean;
437
- };
438
- rateLimitEnabled: {
439
- type: string;
440
- description: string;
441
- };
442
- rateLimitTimeWindow: {
443
- type: string;
444
- nullable: boolean;
445
- description: string;
446
- };
447
- rateLimitMax: {
448
- type: string;
449
- nullable: boolean;
450
- description: string;
451
- };
452
- requestCount: {
453
- type: string;
454
- description: string;
455
- };
456
- remaining: {
457
- type: string;
458
- nullable: boolean;
459
- description: string;
460
- };
461
- lastRequest: {
462
- type: string;
463
- format: string;
464
- nullable: boolean;
465
- description: string;
466
- };
467
- expiresAt: {
468
- type: string;
469
- format: string;
470
- nullable: boolean;
471
- description: string;
472
- };
473
- createdAt: {
474
- type: string;
475
- format: string;
476
- description: string;
477
- };
478
- updatedAt: {
479
- type: string;
480
- format: string;
481
- description: string;
482
- };
483
- metadata: {
484
- type: string;
485
- nullable: boolean;
486
- additionalProperties: boolean;
487
- description: string;
488
- };
489
- permissions: {
490
- type: string;
491
- nullable: boolean;
492
- description: string;
493
- };
494
- };
495
- required: string[];
496
- };
497
- };
498
- };
499
- };
500
- };
501
- };
502
- };
503
- }, {
504
- metadata: Record<string, any> | null;
505
- permissions: {
506
- [key: string]: string[];
507
- } | null;
508
- id: string;
509
- name: string | null;
510
- start: string | null;
511
- prefix: string | null;
512
- userId: string;
513
- refillInterval: number | null;
514
- refillAmount: number | null;
515
- lastRefillAt: Date | null;
516
- enabled: boolean;
517
- rateLimitEnabled: boolean;
518
- rateLimitTimeWindow: number | null;
519
- rateLimitMax: number | null;
520
- requestCount: number;
521
- remaining: number | null;
522
- lastRequest: Date | null;
523
- expiresAt: Date | null;
524
- createdAt: Date;
525
- updatedAt: Date;
526
- }>;
527
- updateApiKey: import("better-auth").StrictEndpoint<"/api-key/update", {
528
- method: "POST";
529
- body: import("better-auth").ZodObject<{
530
- keyId: import("better-auth").ZodString;
531
- userId: import("better-auth").ZodOptional<import("better-auth").ZodCoercedString<unknown>>;
532
- name: import("better-auth").ZodOptional<import("better-auth").ZodString>;
533
- enabled: import("better-auth").ZodOptional<import("better-auth").ZodBoolean>;
534
- remaining: import("better-auth").ZodOptional<import("better-auth").ZodNumber>;
535
- refillAmount: import("better-auth").ZodOptional<import("better-auth").ZodNumber>;
536
- refillInterval: import("better-auth").ZodOptional<import("better-auth").ZodNumber>;
537
- metadata: import("better-auth").ZodOptional<import("better-auth").ZodAny>;
538
- expiresIn: import("better-auth").ZodNullable<import("better-auth").ZodOptional<import("better-auth").ZodNumber>>;
539
- rateLimitEnabled: import("better-auth").ZodOptional<import("better-auth").ZodBoolean>;
540
- rateLimitTimeWindow: import("better-auth").ZodOptional<import("better-auth").ZodNumber>;
541
- rateLimitMax: import("better-auth").ZodOptional<import("better-auth").ZodNumber>;
542
- permissions: import("better-auth").ZodNullable<import("better-auth").ZodOptional<import("better-auth").ZodRecord<import("better-auth").ZodString, import("better-auth").ZodArray<import("better-auth").ZodString>>>>;
543
- }, import("better-auth").$strip>;
544
- metadata: {
545
- openapi: {
546
- description: string;
547
- responses: {
548
- "200": {
549
- description: string;
550
- content: {
551
- "application/json": {
552
- schema: {
553
- type: "object";
554
- properties: {
555
- id: {
556
- type: string;
557
- description: string;
558
- };
559
- name: {
560
- type: string;
561
- nullable: boolean;
562
- description: string;
563
- };
564
- start: {
565
- type: string;
566
- nullable: boolean;
567
- description: string;
568
- };
569
- prefix: {
570
- type: string;
571
- nullable: boolean;
572
- description: string;
573
- };
574
- userId: {
575
- type: string;
576
- description: string;
577
- };
578
- refillInterval: {
579
- type: string;
580
- nullable: boolean;
581
- description: string;
582
- };
583
- refillAmount: {
584
- type: string;
585
- nullable: boolean;
586
- description: string;
587
- };
588
- lastRefillAt: {
589
- type: string;
590
- format: string;
591
- nullable: boolean;
592
- description: string;
593
- };
594
- enabled: {
595
- type: string;
596
- description: string;
597
- default: boolean;
598
- };
599
- rateLimitEnabled: {
600
- type: string;
601
- description: string;
602
- };
603
- rateLimitTimeWindow: {
604
- type: string;
605
- nullable: boolean;
606
- description: string;
607
- };
608
- rateLimitMax: {
609
- type: string;
610
- nullable: boolean;
611
- description: string;
612
- };
613
- requestCount: {
614
- type: string;
615
- description: string;
616
- };
617
- remaining: {
618
- type: string;
619
- nullable: boolean;
620
- description: string;
621
- };
622
- lastRequest: {
623
- type: string;
624
- format: string;
625
- nullable: boolean;
626
- description: string;
627
- };
628
- expiresAt: {
629
- type: string;
630
- format: string;
631
- nullable: boolean;
632
- description: string;
633
- };
634
- createdAt: {
635
- type: string;
636
- format: string;
637
- description: string;
638
- };
639
- updatedAt: {
640
- type: string;
641
- format: string;
642
- description: string;
643
- };
644
- metadata: {
645
- type: string;
646
- nullable: boolean;
647
- additionalProperties: boolean;
648
- description: string;
649
- };
650
- permissions: {
651
- type: string;
652
- nullable: boolean;
653
- description: string;
654
- };
655
- };
656
- required: string[];
657
- };
658
- };
659
- };
660
- };
661
- };
662
- };
663
- };
664
- }, {
665
- metadata: Record<string, any> | null;
666
- permissions: {
667
- [key: string]: string[];
668
- } | null;
669
- id: string;
670
- name: string | null;
671
- start: string | null;
672
- prefix: string | null;
673
- userId: string;
674
- refillInterval: number | null;
675
- refillAmount: number | null;
676
- lastRefillAt: Date | null;
677
- enabled: boolean;
678
- rateLimitEnabled: boolean;
679
- rateLimitTimeWindow: number | null;
680
- rateLimitMax: number | null;
681
- requestCount: number;
682
- remaining: number | null;
683
- lastRequest: Date | null;
684
- expiresAt: Date | null;
685
- createdAt: Date;
686
- updatedAt: Date;
687
- }>;
688
- deleteApiKey: import("better-auth").StrictEndpoint<"/api-key/delete", {
689
- method: "POST";
690
- body: import("better-auth").ZodObject<{
691
- keyId: import("better-auth").ZodString;
692
- }, import("better-auth").$strip>;
693
- use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
694
- session: {
695
- session: Record<string, any> & {
696
- id: string;
697
- createdAt: Date;
698
- updatedAt: Date;
699
- userId: string;
700
- expiresAt: Date;
701
- token: string;
702
- ipAddress?: string | null | undefined;
703
- userAgent?: string | null | undefined;
704
- };
705
- user: Record<string, any> & {
706
- id: string;
707
- createdAt: Date;
708
- updatedAt: Date;
709
- email: string;
710
- emailVerified: boolean;
711
- name: string;
712
- image?: string | null | undefined;
713
- };
714
- };
715
- }>)[];
716
- metadata: {
717
- openapi: {
718
- description: string;
719
- requestBody: {
720
- content: {
721
- "application/json": {
722
- schema: {
723
- type: "object";
724
- properties: {
725
- keyId: {
726
- type: string;
727
- description: string;
728
- };
729
- };
730
- required: string[];
731
- };
732
- };
733
- };
734
- };
735
- responses: {
736
- "200": {
737
- description: string;
738
- content: {
739
- "application/json": {
740
- schema: {
741
- type: "object";
742
- properties: {
743
- success: {
744
- type: string;
745
- description: string;
746
- };
747
- };
748
- required: string[];
749
- };
750
- };
751
- };
752
- };
753
- };
754
- };
755
- };
756
- }, {
757
- success: boolean;
758
- }>;
759
- listApiKeys: import("better-auth").StrictEndpoint<"/api-key/list", {
760
- method: "GET";
761
- use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
762
- session: {
763
- session: Record<string, any> & {
764
- id: string;
765
- createdAt: Date;
766
- updatedAt: Date;
767
- userId: string;
768
- expiresAt: Date;
769
- token: string;
770
- ipAddress?: string | null | undefined;
771
- userAgent?: string | null | undefined;
772
- };
773
- user: Record<string, any> & {
774
- id: string;
775
- createdAt: Date;
776
- updatedAt: Date;
777
- email: string;
778
- emailVerified: boolean;
779
- name: string;
780
- image?: string | null | undefined;
781
- };
782
- };
783
- }>)[];
784
- metadata: {
785
- openapi: {
786
- description: string;
787
- responses: {
788
- "200": {
789
- description: string;
790
- content: {
791
- "application/json": {
792
- schema: {
793
- type: "array";
794
- items: {
795
- type: string;
796
- properties: {
797
- id: {
798
- type: string;
799
- description: string;
800
- };
801
- name: {
802
- type: string;
803
- nullable: boolean;
804
- description: string;
805
- };
806
- start: {
807
- type: string;
808
- nullable: boolean;
809
- description: string;
810
- };
811
- prefix: {
812
- type: string;
813
- nullable: boolean;
814
- description: string;
815
- };
816
- userId: {
817
- type: string;
818
- description: string;
819
- };
820
- refillInterval: {
821
- type: string;
822
- nullable: boolean;
823
- description: string;
824
- };
825
- refillAmount: {
826
- type: string;
827
- nullable: boolean;
828
- description: string;
829
- };
830
- lastRefillAt: {
831
- type: string;
832
- format: string;
833
- nullable: boolean;
834
- description: string;
835
- };
836
- enabled: {
837
- type: string;
838
- description: string;
839
- default: boolean;
840
- };
841
- rateLimitEnabled: {
842
- type: string;
843
- description: string;
844
- };
845
- rateLimitTimeWindow: {
846
- type: string;
847
- nullable: boolean;
848
- description: string;
849
- };
850
- rateLimitMax: {
851
- type: string;
852
- nullable: boolean;
853
- description: string;
854
- };
855
- requestCount: {
856
- type: string;
857
- description: string;
858
- };
859
- remaining: {
860
- type: string;
861
- nullable: boolean;
862
- description: string;
863
- };
864
- lastRequest: {
865
- type: string;
866
- format: string;
867
- nullable: boolean;
868
- description: string;
869
- };
870
- expiresAt: {
871
- type: string;
872
- format: string;
873
- nullable: boolean;
874
- description: string;
875
- };
876
- createdAt: {
877
- type: string;
878
- format: string;
879
- description: string;
880
- };
881
- updatedAt: {
882
- type: string;
883
- format: string;
884
- description: string;
885
- };
886
- metadata: {
887
- type: string;
888
- nullable: boolean;
889
- additionalProperties: boolean;
890
- description: string;
891
- };
892
- permissions: {
893
- type: string;
894
- nullable: boolean;
895
- description: string;
896
- };
897
- };
898
- required: string[];
899
- };
900
- };
901
- };
902
- };
903
- };
904
- };
905
- };
906
- };
907
- }, {
908
- metadata: Record<string, any> | null;
909
- permissions: {
910
- [key: string]: string[];
911
- } | null;
912
- id: string;
913
- name: string | null;
914
- start: string | null;
915
- prefix: string | null;
916
- userId: string;
917
- refillInterval: number | null;
918
- refillAmount: number | null;
919
- lastRefillAt: Date | null;
920
- enabled: boolean;
921
- rateLimitEnabled: boolean;
922
- rateLimitTimeWindow: number | null;
923
- rateLimitMax: number | null;
924
- requestCount: number;
925
- remaining: number | null;
926
- lastRequest: Date | null;
927
- expiresAt: Date | null;
928
- createdAt: Date;
929
- updatedAt: Date;
930
- }[]>;
931
- deleteAllExpiredApiKeys: import("better-auth").StrictEndpoint<string, {
932
- method: "POST";
933
- }, {
934
- success: boolean;
935
- error: unknown;
936
- }>;
937
- };
938
- schema: {
939
- apikey: {
940
- fields: {
941
- name: {
942
- type: "string";
943
- required: false;
944
- input: false;
945
- };
946
- start: {
947
- type: "string";
948
- required: false;
949
- input: false;
950
- };
951
- prefix: {
952
- type: "string";
953
- required: false;
954
- input: false;
955
- };
956
- key: {
957
- type: "string";
958
- required: true;
959
- input: false;
960
- index: true;
961
- };
962
- userId: {
963
- type: "string";
964
- references: {
965
- model: string;
966
- field: string;
967
- onDelete: "cascade";
968
- };
969
- required: true;
970
- input: false;
971
- index: true;
972
- };
973
- refillInterval: {
974
- type: "number";
975
- required: false;
976
- input: false;
977
- };
978
- refillAmount: {
979
- type: "number";
980
- required: false;
981
- input: false;
982
- };
983
- lastRefillAt: {
984
- type: "date";
985
- required: false;
986
- input: false;
987
- };
988
- enabled: {
989
- type: "boolean";
990
- required: false;
991
- input: false;
992
- defaultValue: true;
993
- };
994
- rateLimitEnabled: {
995
- type: "boolean";
996
- required: false;
997
- input: false;
998
- defaultValue: true;
999
- };
1000
- rateLimitTimeWindow: {
1001
- type: "number";
1002
- required: false;
1003
- input: false;
1004
- defaultValue: number;
1005
- };
1006
- rateLimitMax: {
1007
- type: "number";
1008
- required: false;
1009
- input: false;
1010
- defaultValue: number;
1011
- };
1012
- requestCount: {
1013
- type: "number";
1014
- required: false;
1015
- input: false;
1016
- defaultValue: number;
1017
- };
1018
- remaining: {
1019
- type: "number";
1020
- required: false;
1021
- input: false;
1022
- };
1023
- lastRequest: {
1024
- type: "date";
1025
- required: false;
1026
- input: false;
1027
- };
1028
- expiresAt: {
1029
- type: "date";
1030
- required: false;
1031
- input: false;
1032
- };
1033
- createdAt: {
1034
- type: "date";
1035
- required: true;
1036
- input: false;
1037
- };
1038
- updatedAt: {
1039
- type: "date";
1040
- required: true;
1041
- input: false;
1042
- };
1043
- permissions: {
1044
- type: "string";
1045
- required: false;
1046
- input: false;
1047
- };
1048
- metadata: {
1049
- type: "string";
1050
- required: false;
1051
- input: true;
1052
- transform: {
1053
- input(value: import("better-auth").DBPrimitive): string;
1054
- output(value: import("better-auth").DBPrimitive): any;
1055
- };
1056
- };
1057
- };
1058
- };
1059
- };
1060
- options: import("better-auth/plugins").ApiKeyOptions | undefined;
1061
- };
1062
7
  /**
1063
8
  * Applies sensible defaults to Better Auth options.
1064
9
  *
@@ -1100,4 +45,3 @@ export declare function apiKeyWithDefaults(options?: ApiKeyPluginOptions): {
1100
45
  * ```
1101
46
  */
1102
47
  export declare function withBetterAuthDefaults<T extends BetterAuthOptions>(options: T): T;
1103
- export {};