@better-auth/api-key 1.5.7-beta.1 → 1.6.0

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