@better-auth/api-key 1.6.23 → 1.6.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.mts +34 -36
- package/dist/client.mjs +1 -1
- package/dist/{index-CI6mGUwK.d.mts → index-CgPDayNk.d.mts} +147 -152
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +168 -2
- package/dist/{types-BR70O3Q3.d.mts → types-BYqswa0N.d.mts} +3 -8
- package/dist/types.d.mts +1 -1
- package/dist/{version-Cd4fCeRN.mjs → version-9S9JtMJH.mjs} +1 -1
- package/package.json +6 -6
package/dist/client.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-
|
|
2
|
-
import { i as API_KEY_ERROR_CODES, n as apiKey } from "./index-
|
|
3
|
-
import * as better_auth0 from "better-auth";
|
|
4
|
-
|
|
1
|
+
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-BYqswa0N.mjs";
|
|
2
|
+
import { i as API_KEY_ERROR_CODES, n as apiKey } from "./index-CgPDayNk.mjs";
|
|
5
3
|
//#region src/client.d.ts
|
|
6
4
|
declare const apiKeyClient: () => {
|
|
7
5
|
id: "api-key";
|
|
@@ -13,39 +11,39 @@ declare const apiKeyClient: () => {
|
|
|
13
11
|
"/api-key/delete-all-expired-api-keys": "POST";
|
|
14
12
|
};
|
|
15
13
|
$ERROR_CODES: {
|
|
16
|
-
INVALID_METADATA_TYPE:
|
|
17
|
-
REFILL_AMOUNT_AND_INTERVAL_REQUIRED:
|
|
18
|
-
REFILL_INTERVAL_AND_AMOUNT_REQUIRED:
|
|
19
|
-
USER_BANNED:
|
|
20
|
-
UNAUTHORIZED_SESSION:
|
|
21
|
-
KEY_NOT_FOUND:
|
|
22
|
-
KEY_DISABLED:
|
|
23
|
-
KEY_EXPIRED:
|
|
24
|
-
USAGE_EXCEEDED:
|
|
25
|
-
KEY_NOT_RECOVERABLE:
|
|
26
|
-
EXPIRES_IN_IS_TOO_SMALL:
|
|
27
|
-
EXPIRES_IN_IS_TOO_LARGE:
|
|
28
|
-
INVALID_REMAINING:
|
|
29
|
-
INVALID_PREFIX_LENGTH:
|
|
30
|
-
INVALID_NAME_LENGTH:
|
|
31
|
-
METADATA_DISABLED:
|
|
32
|
-
RATE_LIMIT_EXCEEDED:
|
|
33
|
-
NO_VALUES_TO_UPDATE:
|
|
34
|
-
KEY_DISABLED_EXPIRATION:
|
|
35
|
-
INVALID_API_KEY:
|
|
36
|
-
INVALID_USER_ID_FROM_API_KEY:
|
|
37
|
-
INVALID_REFERENCE_ID_FROM_API_KEY:
|
|
38
|
-
INVALID_API_KEY_GETTER_RETURN_TYPE:
|
|
39
|
-
SERVER_ONLY_PROPERTY:
|
|
40
|
-
FAILED_TO_UPDATE_API_KEY:
|
|
41
|
-
NAME_REQUIRED:
|
|
42
|
-
ORGANIZATION_ID_REQUIRED:
|
|
43
|
-
USER_NOT_MEMBER_OF_ORGANIZATION:
|
|
44
|
-
INSUFFICIENT_API_KEY_PERMISSIONS:
|
|
45
|
-
NO_DEFAULT_API_KEY_CONFIGURATION_FOUND:
|
|
46
|
-
ORGANIZATION_PLUGIN_REQUIRED:
|
|
14
|
+
INVALID_METADATA_TYPE: import("better-auth").RawError<"INVALID_METADATA_TYPE">;
|
|
15
|
+
REFILL_AMOUNT_AND_INTERVAL_REQUIRED: import("better-auth").RawError<"REFILL_AMOUNT_AND_INTERVAL_REQUIRED">;
|
|
16
|
+
REFILL_INTERVAL_AND_AMOUNT_REQUIRED: import("better-auth").RawError<"REFILL_INTERVAL_AND_AMOUNT_REQUIRED">;
|
|
17
|
+
USER_BANNED: import("better-auth").RawError<"USER_BANNED">;
|
|
18
|
+
UNAUTHORIZED_SESSION: import("better-auth").RawError<"UNAUTHORIZED_SESSION">;
|
|
19
|
+
KEY_NOT_FOUND: import("better-auth").RawError<"KEY_NOT_FOUND">;
|
|
20
|
+
KEY_DISABLED: import("better-auth").RawError<"KEY_DISABLED">;
|
|
21
|
+
KEY_EXPIRED: import("better-auth").RawError<"KEY_EXPIRED">;
|
|
22
|
+
USAGE_EXCEEDED: import("better-auth").RawError<"USAGE_EXCEEDED">;
|
|
23
|
+
KEY_NOT_RECOVERABLE: import("better-auth").RawError<"KEY_NOT_RECOVERABLE">;
|
|
24
|
+
EXPIRES_IN_IS_TOO_SMALL: import("better-auth").RawError<"EXPIRES_IN_IS_TOO_SMALL">;
|
|
25
|
+
EXPIRES_IN_IS_TOO_LARGE: import("better-auth").RawError<"EXPIRES_IN_IS_TOO_LARGE">;
|
|
26
|
+
INVALID_REMAINING: import("better-auth").RawError<"INVALID_REMAINING">;
|
|
27
|
+
INVALID_PREFIX_LENGTH: import("better-auth").RawError<"INVALID_PREFIX_LENGTH">;
|
|
28
|
+
INVALID_NAME_LENGTH: import("better-auth").RawError<"INVALID_NAME_LENGTH">;
|
|
29
|
+
METADATA_DISABLED: import("better-auth").RawError<"METADATA_DISABLED">;
|
|
30
|
+
RATE_LIMIT_EXCEEDED: import("better-auth").RawError<"RATE_LIMIT_EXCEEDED">;
|
|
31
|
+
NO_VALUES_TO_UPDATE: import("better-auth").RawError<"NO_VALUES_TO_UPDATE">;
|
|
32
|
+
KEY_DISABLED_EXPIRATION: import("better-auth").RawError<"KEY_DISABLED_EXPIRATION">;
|
|
33
|
+
INVALID_API_KEY: import("better-auth").RawError<"INVALID_API_KEY">;
|
|
34
|
+
INVALID_USER_ID_FROM_API_KEY: import("better-auth").RawError<"INVALID_USER_ID_FROM_API_KEY">;
|
|
35
|
+
INVALID_REFERENCE_ID_FROM_API_KEY: import("better-auth").RawError<"INVALID_REFERENCE_ID_FROM_API_KEY">;
|
|
36
|
+
INVALID_API_KEY_GETTER_RETURN_TYPE: import("better-auth").RawError<"INVALID_API_KEY_GETTER_RETURN_TYPE">;
|
|
37
|
+
SERVER_ONLY_PROPERTY: import("better-auth").RawError<"SERVER_ONLY_PROPERTY">;
|
|
38
|
+
FAILED_TO_UPDATE_API_KEY: import("better-auth").RawError<"FAILED_TO_UPDATE_API_KEY">;
|
|
39
|
+
NAME_REQUIRED: import("better-auth").RawError<"NAME_REQUIRED">;
|
|
40
|
+
ORGANIZATION_ID_REQUIRED: import("better-auth").RawError<"ORGANIZATION_ID_REQUIRED">;
|
|
41
|
+
USER_NOT_MEMBER_OF_ORGANIZATION: import("better-auth").RawError<"USER_NOT_MEMBER_OF_ORGANIZATION">;
|
|
42
|
+
INSUFFICIENT_API_KEY_PERMISSIONS: import("better-auth").RawError<"INSUFFICIENT_API_KEY_PERMISSIONS">;
|
|
43
|
+
NO_DEFAULT_API_KEY_CONFIGURATION_FOUND: import("better-auth").RawError<"NO_DEFAULT_API_KEY_CONFIGURATION_FOUND">;
|
|
44
|
+
ORGANIZATION_PLUGIN_REQUIRED: import("better-auth").RawError<"ORGANIZATION_PLUGIN_REQUIRED">;
|
|
47
45
|
};
|
|
48
46
|
};
|
|
49
47
|
type ApiKeyClientPlugin = ReturnType<typeof apiKeyClient>;
|
|
50
48
|
//#endregion
|
|
51
|
-
export { API_KEY_ERROR_CODES, ApiKey, ApiKeyClientPlugin, ApiKeyConfigurationOptions, ApiKeyOptions, apiKeyClient };
|
|
49
|
+
export { API_KEY_ERROR_CODES, type ApiKey, ApiKeyClientPlugin, type ApiKeyConfigurationOptions, type ApiKeyOptions, apiKeyClient };
|
package/dist/client.mjs
CHANGED
|
@@ -1,43 +1,38 @@
|
|
|
1
|
-
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-
|
|
2
|
-
import * as better_auth0 from "better-auth";
|
|
3
|
-
import * as zod from "zod";
|
|
4
|
-
import * as better_call0 from "better-call";
|
|
5
|
-
import * as zod_v4_core0 from "zod/v4/core";
|
|
1
|
+
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-BYqswa0N.mjs";
|
|
6
2
|
import { HookEndpointContext } from "@better-auth/core";
|
|
7
|
-
|
|
8
3
|
//#region src/error-codes.d.ts
|
|
9
4
|
declare const API_KEY_ERROR_CODES: {
|
|
10
|
-
INVALID_METADATA_TYPE:
|
|
11
|
-
REFILL_AMOUNT_AND_INTERVAL_REQUIRED:
|
|
12
|
-
REFILL_INTERVAL_AND_AMOUNT_REQUIRED:
|
|
13
|
-
USER_BANNED:
|
|
14
|
-
UNAUTHORIZED_SESSION:
|
|
15
|
-
KEY_NOT_FOUND:
|
|
16
|
-
KEY_DISABLED:
|
|
17
|
-
KEY_EXPIRED:
|
|
18
|
-
USAGE_EXCEEDED:
|
|
19
|
-
KEY_NOT_RECOVERABLE:
|
|
20
|
-
EXPIRES_IN_IS_TOO_SMALL:
|
|
21
|
-
EXPIRES_IN_IS_TOO_LARGE:
|
|
22
|
-
INVALID_REMAINING:
|
|
23
|
-
INVALID_PREFIX_LENGTH:
|
|
24
|
-
INVALID_NAME_LENGTH:
|
|
25
|
-
METADATA_DISABLED:
|
|
26
|
-
RATE_LIMIT_EXCEEDED:
|
|
27
|
-
NO_VALUES_TO_UPDATE:
|
|
28
|
-
KEY_DISABLED_EXPIRATION:
|
|
29
|
-
INVALID_API_KEY:
|
|
30
|
-
INVALID_USER_ID_FROM_API_KEY:
|
|
31
|
-
INVALID_REFERENCE_ID_FROM_API_KEY:
|
|
32
|
-
INVALID_API_KEY_GETTER_RETURN_TYPE:
|
|
33
|
-
SERVER_ONLY_PROPERTY:
|
|
34
|
-
FAILED_TO_UPDATE_API_KEY:
|
|
35
|
-
NAME_REQUIRED:
|
|
36
|
-
ORGANIZATION_ID_REQUIRED:
|
|
37
|
-
USER_NOT_MEMBER_OF_ORGANIZATION:
|
|
38
|
-
INSUFFICIENT_API_KEY_PERMISSIONS:
|
|
39
|
-
NO_DEFAULT_API_KEY_CONFIGURATION_FOUND:
|
|
40
|
-
ORGANIZATION_PLUGIN_REQUIRED:
|
|
5
|
+
INVALID_METADATA_TYPE: import("better-auth").RawError<"INVALID_METADATA_TYPE">;
|
|
6
|
+
REFILL_AMOUNT_AND_INTERVAL_REQUIRED: import("better-auth").RawError<"REFILL_AMOUNT_AND_INTERVAL_REQUIRED">;
|
|
7
|
+
REFILL_INTERVAL_AND_AMOUNT_REQUIRED: import("better-auth").RawError<"REFILL_INTERVAL_AND_AMOUNT_REQUIRED">;
|
|
8
|
+
USER_BANNED: import("better-auth").RawError<"USER_BANNED">;
|
|
9
|
+
UNAUTHORIZED_SESSION: import("better-auth").RawError<"UNAUTHORIZED_SESSION">;
|
|
10
|
+
KEY_NOT_FOUND: import("better-auth").RawError<"KEY_NOT_FOUND">;
|
|
11
|
+
KEY_DISABLED: import("better-auth").RawError<"KEY_DISABLED">;
|
|
12
|
+
KEY_EXPIRED: import("better-auth").RawError<"KEY_EXPIRED">;
|
|
13
|
+
USAGE_EXCEEDED: import("better-auth").RawError<"USAGE_EXCEEDED">;
|
|
14
|
+
KEY_NOT_RECOVERABLE: import("better-auth").RawError<"KEY_NOT_RECOVERABLE">;
|
|
15
|
+
EXPIRES_IN_IS_TOO_SMALL: import("better-auth").RawError<"EXPIRES_IN_IS_TOO_SMALL">;
|
|
16
|
+
EXPIRES_IN_IS_TOO_LARGE: import("better-auth").RawError<"EXPIRES_IN_IS_TOO_LARGE">;
|
|
17
|
+
INVALID_REMAINING: import("better-auth").RawError<"INVALID_REMAINING">;
|
|
18
|
+
INVALID_PREFIX_LENGTH: import("better-auth").RawError<"INVALID_PREFIX_LENGTH">;
|
|
19
|
+
INVALID_NAME_LENGTH: import("better-auth").RawError<"INVALID_NAME_LENGTH">;
|
|
20
|
+
METADATA_DISABLED: import("better-auth").RawError<"METADATA_DISABLED">;
|
|
21
|
+
RATE_LIMIT_EXCEEDED: import("better-auth").RawError<"RATE_LIMIT_EXCEEDED">;
|
|
22
|
+
NO_VALUES_TO_UPDATE: import("better-auth").RawError<"NO_VALUES_TO_UPDATE">;
|
|
23
|
+
KEY_DISABLED_EXPIRATION: import("better-auth").RawError<"KEY_DISABLED_EXPIRATION">;
|
|
24
|
+
INVALID_API_KEY: import("better-auth").RawError<"INVALID_API_KEY">;
|
|
25
|
+
INVALID_USER_ID_FROM_API_KEY: import("better-auth").RawError<"INVALID_USER_ID_FROM_API_KEY">;
|
|
26
|
+
INVALID_REFERENCE_ID_FROM_API_KEY: import("better-auth").RawError<"INVALID_REFERENCE_ID_FROM_API_KEY">;
|
|
27
|
+
INVALID_API_KEY_GETTER_RETURN_TYPE: import("better-auth").RawError<"INVALID_API_KEY_GETTER_RETURN_TYPE">;
|
|
28
|
+
SERVER_ONLY_PROPERTY: import("better-auth").RawError<"SERVER_ONLY_PROPERTY">;
|
|
29
|
+
FAILED_TO_UPDATE_API_KEY: import("better-auth").RawError<"FAILED_TO_UPDATE_API_KEY">;
|
|
30
|
+
NAME_REQUIRED: import("better-auth").RawError<"NAME_REQUIRED">;
|
|
31
|
+
ORGANIZATION_ID_REQUIRED: import("better-auth").RawError<"ORGANIZATION_ID_REQUIRED">;
|
|
32
|
+
USER_NOT_MEMBER_OF_ORGANIZATION: import("better-auth").RawError<"USER_NOT_MEMBER_OF_ORGANIZATION">;
|
|
33
|
+
INSUFFICIENT_API_KEY_PERMISSIONS: import("better-auth").RawError<"INSUFFICIENT_API_KEY_PERMISSIONS">;
|
|
34
|
+
NO_DEFAULT_API_KEY_CONFIGURATION_FOUND: import("better-auth").RawError<"NO_DEFAULT_API_KEY_CONFIGURATION_FOUND">;
|
|
35
|
+
ORGANIZATION_PLUGIN_REQUIRED: import("better-auth").RawError<"ORGANIZATION_PLUGIN_REQUIRED">;
|
|
41
36
|
};
|
|
42
37
|
//#endregion
|
|
43
38
|
//#region src/index.d.ts
|
|
@@ -54,42 +49,42 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
54
49
|
id: "api-key";
|
|
55
50
|
version: string;
|
|
56
51
|
$ERROR_CODES: {
|
|
57
|
-
INVALID_METADATA_TYPE:
|
|
58
|
-
REFILL_AMOUNT_AND_INTERVAL_REQUIRED:
|
|
59
|
-
REFILL_INTERVAL_AND_AMOUNT_REQUIRED:
|
|
60
|
-
USER_BANNED:
|
|
61
|
-
UNAUTHORIZED_SESSION:
|
|
62
|
-
KEY_NOT_FOUND:
|
|
63
|
-
KEY_DISABLED:
|
|
64
|
-
KEY_EXPIRED:
|
|
65
|
-
USAGE_EXCEEDED:
|
|
66
|
-
KEY_NOT_RECOVERABLE:
|
|
67
|
-
EXPIRES_IN_IS_TOO_SMALL:
|
|
68
|
-
EXPIRES_IN_IS_TOO_LARGE:
|
|
69
|
-
INVALID_REMAINING:
|
|
70
|
-
INVALID_PREFIX_LENGTH:
|
|
71
|
-
INVALID_NAME_LENGTH:
|
|
72
|
-
METADATA_DISABLED:
|
|
73
|
-
RATE_LIMIT_EXCEEDED:
|
|
74
|
-
NO_VALUES_TO_UPDATE:
|
|
75
|
-
KEY_DISABLED_EXPIRATION:
|
|
76
|
-
INVALID_API_KEY:
|
|
77
|
-
INVALID_USER_ID_FROM_API_KEY:
|
|
78
|
-
INVALID_REFERENCE_ID_FROM_API_KEY:
|
|
79
|
-
INVALID_API_KEY_GETTER_RETURN_TYPE:
|
|
80
|
-
SERVER_ONLY_PROPERTY:
|
|
81
|
-
FAILED_TO_UPDATE_API_KEY:
|
|
82
|
-
NAME_REQUIRED:
|
|
83
|
-
ORGANIZATION_ID_REQUIRED:
|
|
84
|
-
USER_NOT_MEMBER_OF_ORGANIZATION:
|
|
85
|
-
INSUFFICIENT_API_KEY_PERMISSIONS:
|
|
86
|
-
NO_DEFAULT_API_KEY_CONFIGURATION_FOUND:
|
|
87
|
-
ORGANIZATION_PLUGIN_REQUIRED:
|
|
52
|
+
INVALID_METADATA_TYPE: import("better-auth").RawError<"INVALID_METADATA_TYPE">;
|
|
53
|
+
REFILL_AMOUNT_AND_INTERVAL_REQUIRED: import("better-auth").RawError<"REFILL_AMOUNT_AND_INTERVAL_REQUIRED">;
|
|
54
|
+
REFILL_INTERVAL_AND_AMOUNT_REQUIRED: import("better-auth").RawError<"REFILL_INTERVAL_AND_AMOUNT_REQUIRED">;
|
|
55
|
+
USER_BANNED: import("better-auth").RawError<"USER_BANNED">;
|
|
56
|
+
UNAUTHORIZED_SESSION: import("better-auth").RawError<"UNAUTHORIZED_SESSION">;
|
|
57
|
+
KEY_NOT_FOUND: import("better-auth").RawError<"KEY_NOT_FOUND">;
|
|
58
|
+
KEY_DISABLED: import("better-auth").RawError<"KEY_DISABLED">;
|
|
59
|
+
KEY_EXPIRED: import("better-auth").RawError<"KEY_EXPIRED">;
|
|
60
|
+
USAGE_EXCEEDED: import("better-auth").RawError<"USAGE_EXCEEDED">;
|
|
61
|
+
KEY_NOT_RECOVERABLE: import("better-auth").RawError<"KEY_NOT_RECOVERABLE">;
|
|
62
|
+
EXPIRES_IN_IS_TOO_SMALL: import("better-auth").RawError<"EXPIRES_IN_IS_TOO_SMALL">;
|
|
63
|
+
EXPIRES_IN_IS_TOO_LARGE: import("better-auth").RawError<"EXPIRES_IN_IS_TOO_LARGE">;
|
|
64
|
+
INVALID_REMAINING: import("better-auth").RawError<"INVALID_REMAINING">;
|
|
65
|
+
INVALID_PREFIX_LENGTH: import("better-auth").RawError<"INVALID_PREFIX_LENGTH">;
|
|
66
|
+
INVALID_NAME_LENGTH: import("better-auth").RawError<"INVALID_NAME_LENGTH">;
|
|
67
|
+
METADATA_DISABLED: import("better-auth").RawError<"METADATA_DISABLED">;
|
|
68
|
+
RATE_LIMIT_EXCEEDED: import("better-auth").RawError<"RATE_LIMIT_EXCEEDED">;
|
|
69
|
+
NO_VALUES_TO_UPDATE: import("better-auth").RawError<"NO_VALUES_TO_UPDATE">;
|
|
70
|
+
KEY_DISABLED_EXPIRATION: import("better-auth").RawError<"KEY_DISABLED_EXPIRATION">;
|
|
71
|
+
INVALID_API_KEY: import("better-auth").RawError<"INVALID_API_KEY">;
|
|
72
|
+
INVALID_USER_ID_FROM_API_KEY: import("better-auth").RawError<"INVALID_USER_ID_FROM_API_KEY">;
|
|
73
|
+
INVALID_REFERENCE_ID_FROM_API_KEY: import("better-auth").RawError<"INVALID_REFERENCE_ID_FROM_API_KEY">;
|
|
74
|
+
INVALID_API_KEY_GETTER_RETURN_TYPE: import("better-auth").RawError<"INVALID_API_KEY_GETTER_RETURN_TYPE">;
|
|
75
|
+
SERVER_ONLY_PROPERTY: import("better-auth").RawError<"SERVER_ONLY_PROPERTY">;
|
|
76
|
+
FAILED_TO_UPDATE_API_KEY: import("better-auth").RawError<"FAILED_TO_UPDATE_API_KEY">;
|
|
77
|
+
NAME_REQUIRED: import("better-auth").RawError<"NAME_REQUIRED">;
|
|
78
|
+
ORGANIZATION_ID_REQUIRED: import("better-auth").RawError<"ORGANIZATION_ID_REQUIRED">;
|
|
79
|
+
USER_NOT_MEMBER_OF_ORGANIZATION: import("better-auth").RawError<"USER_NOT_MEMBER_OF_ORGANIZATION">;
|
|
80
|
+
INSUFFICIENT_API_KEY_PERMISSIONS: import("better-auth").RawError<"INSUFFICIENT_API_KEY_PERMISSIONS">;
|
|
81
|
+
NO_DEFAULT_API_KEY_CONFIGURATION_FOUND: import("better-auth").RawError<"NO_DEFAULT_API_KEY_CONFIGURATION_FOUND">;
|
|
82
|
+
ORGANIZATION_PLUGIN_REQUIRED: import("better-auth").RawError<"ORGANIZATION_PLUGIN_REQUIRED">;
|
|
88
83
|
};
|
|
89
84
|
hooks: {
|
|
90
85
|
before: {
|
|
91
86
|
matcher: (ctx: HookEndpointContext) => boolean;
|
|
92
|
-
handler: (inputContext:
|
|
87
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
93
88
|
user: {
|
|
94
89
|
id: string;
|
|
95
90
|
createdAt: Date;
|
|
@@ -110,11 +105,11 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
110
105
|
expiresAt: Date;
|
|
111
106
|
};
|
|
112
107
|
} | {
|
|
113
|
-
context:
|
|
108
|
+
context: import("better-call").MiddlewareContext<import("better-call").MiddlewareOptions, {
|
|
114
109
|
returned?: unknown | undefined;
|
|
115
110
|
responseHeaders?: Headers | undefined;
|
|
116
|
-
} &
|
|
117
|
-
options:
|
|
111
|
+
} & import("better-auth").PluginContext<import("better-auth").BetterAuthOptions> & import("better-auth").InfoContext & {
|
|
112
|
+
options: import("better-auth").BetterAuthOptions;
|
|
118
113
|
trustedOrigins: string[];
|
|
119
114
|
trustedProviders: string[];
|
|
120
115
|
isTrustedOrigin: (url: string, settings?: {
|
|
@@ -187,20 +182,20 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
187
182
|
image?: string | null | undefined;
|
|
188
183
|
} & Record<string, any>;
|
|
189
184
|
} | null) => void;
|
|
190
|
-
socialProviders:
|
|
191
|
-
authCookies:
|
|
192
|
-
logger: ReturnType<typeof
|
|
185
|
+
socialProviders: import("better-auth").OAuthProvider[];
|
|
186
|
+
authCookies: import("better-auth").BetterAuthCookies;
|
|
187
|
+
logger: ReturnType<typeof import("better-auth").createLogger>;
|
|
193
188
|
rateLimit: {
|
|
194
189
|
enabled: boolean;
|
|
195
190
|
window: number;
|
|
196
191
|
max: number;
|
|
197
192
|
storage: "memory" | "database" | "secondary-storage";
|
|
198
|
-
} & Omit<
|
|
199
|
-
adapter:
|
|
200
|
-
internalAdapter:
|
|
201
|
-
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<
|
|
193
|
+
} & Omit<import("better-auth").BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
|
|
194
|
+
adapter: import("better-auth").DBAdapter<import("better-auth").BetterAuthOptions>;
|
|
195
|
+
internalAdapter: import("better-auth").InternalAdapter<import("better-auth").BetterAuthOptions>;
|
|
196
|
+
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<import("better-call").CookieOptions> | undefined) => import("better-auth").BetterAuthCookie;
|
|
202
197
|
secret: string;
|
|
203
|
-
secretConfig: string |
|
|
198
|
+
secretConfig: string | import("better-auth").SecretConfig;
|
|
204
199
|
sessionConfig: {
|
|
205
200
|
updateAge: number;
|
|
206
201
|
expiresIn: number;
|
|
@@ -211,10 +206,10 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
211
206
|
};
|
|
212
207
|
};
|
|
213
208
|
generateId: (options: {
|
|
214
|
-
model:
|
|
209
|
+
model: import("better-auth").ModelNames;
|
|
215
210
|
size?: number | undefined;
|
|
216
211
|
}) => string | false;
|
|
217
|
-
secondaryStorage:
|
|
212
|
+
secondaryStorage: import("better-auth").SecondaryStorage | undefined;
|
|
218
213
|
password: {
|
|
219
214
|
hash: (password: string) => Promise<string>;
|
|
220
215
|
verify: (data: {
|
|
@@ -225,9 +220,9 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
225
220
|
minPasswordLength: number;
|
|
226
221
|
maxPasswordLength: number;
|
|
227
222
|
};
|
|
228
|
-
checkPassword: (userId: string, ctx:
|
|
223
|
+
checkPassword: (userId: string, ctx: import("better-auth").GenericEndpointContext<import("better-auth").BetterAuthOptions>) => Promise<boolean>;
|
|
229
224
|
};
|
|
230
|
-
tables:
|
|
225
|
+
tables: import("better-auth").BetterAuthDBSchema;
|
|
231
226
|
runMigrations: () => Promise<void>;
|
|
232
227
|
publishTelemetry: (event: {
|
|
233
228
|
type: string;
|
|
@@ -237,7 +232,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
237
232
|
skipOriginCheck: boolean | string[];
|
|
238
233
|
skipCSRFCheck: boolean;
|
|
239
234
|
runInBackground: (promise: Promise<unknown>) => void;
|
|
240
|
-
runInBackgroundOrAwait: (promise: Promise<unknown> | void) =>
|
|
235
|
+
runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("better-auth").Awaitable<unknown>;
|
|
241
236
|
}>;
|
|
242
237
|
}>;
|
|
243
238
|
}[];
|
|
@@ -258,24 +253,24 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
258
253
|
*
|
|
259
254
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-create)
|
|
260
255
|
*/
|
|
261
|
-
createApiKey:
|
|
256
|
+
createApiKey: import("better-call").StrictEndpoint<"/api-key/create", {
|
|
262
257
|
method: "POST";
|
|
263
|
-
body: zod.ZodObject<{
|
|
264
|
-
configId: zod.ZodOptional<zod.ZodString>;
|
|
265
|
-
name: zod.ZodOptional<zod.ZodString>;
|
|
266
|
-
expiresIn: zod.ZodDefault<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
|
|
267
|
-
prefix: zod.ZodOptional<zod.ZodString>;
|
|
268
|
-
remaining: zod.ZodDefault<zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>>;
|
|
269
|
-
metadata: zod.ZodOptional<zod.ZodAny>;
|
|
270
|
-
refillAmount: zod.ZodOptional<zod.ZodNumber>;
|
|
271
|
-
refillInterval: zod.ZodOptional<zod.ZodNumber>;
|
|
272
|
-
rateLimitTimeWindow: zod.ZodOptional<zod.ZodNumber>;
|
|
273
|
-
rateLimitMax: zod.ZodOptional<zod.ZodNumber>;
|
|
274
|
-
rateLimitEnabled: zod.ZodOptional<zod.ZodBoolean>;
|
|
275
|
-
permissions: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>>;
|
|
276
|
-
userId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
|
|
277
|
-
organizationId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
|
|
278
|
-
},
|
|
258
|
+
body: import("zod").ZodObject<{
|
|
259
|
+
configId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
260
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
261
|
+
expiresIn: import("zod").ZodDefault<import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodNumber>>>;
|
|
262
|
+
prefix: import("zod").ZodOptional<import("zod").ZodString>;
|
|
263
|
+
remaining: import("zod").ZodDefault<import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodNumber>>>;
|
|
264
|
+
metadata: import("zod").ZodOptional<import("zod").ZodAny>;
|
|
265
|
+
refillAmount: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
266
|
+
refillInterval: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
267
|
+
rateLimitTimeWindow: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
268
|
+
rateLimitMax: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
269
|
+
rateLimitEnabled: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
270
|
+
permissions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>>;
|
|
271
|
+
userId: import("zod").ZodOptional<import("zod").ZodCoercedString<unknown>>;
|
|
272
|
+
organizationId: import("zod").ZodOptional<import("zod").ZodCoercedString<unknown>>;
|
|
273
|
+
}, import("zod/v4/core").$strip>;
|
|
279
274
|
metadata: {
|
|
280
275
|
openapi: {
|
|
281
276
|
description: string;
|
|
@@ -441,17 +436,17 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
441
436
|
*
|
|
442
437
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-verify)
|
|
443
438
|
*/
|
|
444
|
-
verifyApiKey:
|
|
439
|
+
verifyApiKey: import("better-call").StrictEndpoint<string, {
|
|
445
440
|
method: "POST";
|
|
446
|
-
body: zod.ZodObject<{
|
|
447
|
-
configId: zod.ZodOptional<zod.ZodString>;
|
|
448
|
-
key: zod.ZodString;
|
|
449
|
-
permissions: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>>;
|
|
450
|
-
},
|
|
441
|
+
body: import("zod").ZodObject<{
|
|
442
|
+
configId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
443
|
+
key: import("zod").ZodString;
|
|
444
|
+
permissions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>>;
|
|
445
|
+
}, import("zod/v4/core").$strip>;
|
|
451
446
|
}, {
|
|
452
447
|
valid: boolean;
|
|
453
448
|
error: {
|
|
454
|
-
message:
|
|
449
|
+
message: import("better-auth").RawError<"INVALID_API_KEY">;
|
|
455
450
|
code: "KEY_NOT_FOUND";
|
|
456
451
|
};
|
|
457
452
|
key: null;
|
|
@@ -466,7 +461,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
466
461
|
} | {
|
|
467
462
|
valid: boolean;
|
|
468
463
|
error: {
|
|
469
|
-
message:
|
|
464
|
+
message: import("better-auth").RawError<"INVALID_API_KEY">;
|
|
470
465
|
code: "INVALID_API_KEY";
|
|
471
466
|
};
|
|
472
467
|
key: null;
|
|
@@ -490,13 +485,13 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
490
485
|
*
|
|
491
486
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-get)
|
|
492
487
|
*/
|
|
493
|
-
getApiKey:
|
|
488
|
+
getApiKey: import("better-call").StrictEndpoint<"/api-key/get", {
|
|
494
489
|
method: "GET";
|
|
495
|
-
query: zod.ZodObject<{
|
|
496
|
-
configId: zod.ZodOptional<zod.ZodString>;
|
|
497
|
-
id: zod.ZodString;
|
|
498
|
-
},
|
|
499
|
-
use: ((inputContext:
|
|
490
|
+
query: import("zod").ZodObject<{
|
|
491
|
+
configId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
492
|
+
id: import("zod").ZodString;
|
|
493
|
+
}, import("zod/v4/core").$strip>;
|
|
494
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
500
495
|
session: {
|
|
501
496
|
session: Record<string, any> & {
|
|
502
497
|
id: string;
|
|
@@ -679,24 +674,24 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
679
674
|
*
|
|
680
675
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-update)
|
|
681
676
|
*/
|
|
682
|
-
updateApiKey:
|
|
677
|
+
updateApiKey: import("better-call").StrictEndpoint<"/api-key/update", {
|
|
683
678
|
method: "POST";
|
|
684
|
-
body: zod.ZodObject<{
|
|
685
|
-
configId: zod.ZodOptional<zod.ZodString>;
|
|
686
|
-
keyId: zod.ZodString;
|
|
687
|
-
userId: zod.ZodOptional<zod.ZodCoercedString<unknown>>;
|
|
688
|
-
name: zod.ZodOptional<zod.ZodString>;
|
|
689
|
-
enabled: zod.ZodOptional<zod.ZodBoolean>;
|
|
690
|
-
remaining: zod.ZodOptional<zod.ZodNumber>;
|
|
691
|
-
refillAmount: zod.ZodOptional<zod.ZodNumber>;
|
|
692
|
-
refillInterval: zod.ZodOptional<zod.ZodNumber>;
|
|
693
|
-
metadata: zod.ZodOptional<zod.ZodAny>;
|
|
694
|
-
expiresIn: zod.ZodNullable<zod.ZodOptional<zod.ZodNumber>>;
|
|
695
|
-
rateLimitEnabled: zod.ZodOptional<zod.ZodBoolean>;
|
|
696
|
-
rateLimitTimeWindow: zod.ZodOptional<zod.ZodNumber>;
|
|
697
|
-
rateLimitMax: zod.ZodOptional<zod.ZodNumber>;
|
|
698
|
-
permissions: zod.ZodNullable<zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodArray<zod.ZodString>>>>;
|
|
699
|
-
},
|
|
679
|
+
body: import("zod").ZodObject<{
|
|
680
|
+
configId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
681
|
+
keyId: import("zod").ZodString;
|
|
682
|
+
userId: import("zod").ZodOptional<import("zod").ZodCoercedString<unknown>>;
|
|
683
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
684
|
+
enabled: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
685
|
+
remaining: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
686
|
+
refillAmount: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
687
|
+
refillInterval: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
688
|
+
metadata: import("zod").ZodOptional<import("zod").ZodAny>;
|
|
689
|
+
expiresIn: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodNumber>>;
|
|
690
|
+
rateLimitEnabled: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
691
|
+
rateLimitTimeWindow: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
692
|
+
rateLimitMax: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
693
|
+
permissions: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>>>;
|
|
694
|
+
}, import("zod/v4/core").$strip>;
|
|
700
695
|
metadata: {
|
|
701
696
|
openapi: {
|
|
702
697
|
description: string;
|
|
@@ -857,13 +852,13 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
857
852
|
*
|
|
858
853
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete)
|
|
859
854
|
*/
|
|
860
|
-
deleteApiKey:
|
|
855
|
+
deleteApiKey: import("better-call").StrictEndpoint<"/api-key/delete", {
|
|
861
856
|
method: "POST";
|
|
862
|
-
body: zod.ZodObject<{
|
|
863
|
-
configId: zod.ZodOptional<zod.ZodString>;
|
|
864
|
-
keyId: zod.ZodString;
|
|
865
|
-
},
|
|
866
|
-
use: ((inputContext:
|
|
857
|
+
body: import("zod").ZodObject<{
|
|
858
|
+
configId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
859
|
+
keyId: import("zod").ZodString;
|
|
860
|
+
}, import("zod/v4/core").$strip>;
|
|
861
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
867
862
|
session: {
|
|
868
863
|
session: Record<string, any> & {
|
|
869
864
|
id: string;
|
|
@@ -944,9 +939,9 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
944
939
|
*
|
|
945
940
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-list)
|
|
946
941
|
*/
|
|
947
|
-
listApiKeys:
|
|
942
|
+
listApiKeys: import("better-call").StrictEndpoint<"/api-key/list", {
|
|
948
943
|
method: "GET";
|
|
949
|
-
use: ((inputContext:
|
|
944
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
950
945
|
session: {
|
|
951
946
|
session: Record<string, any> & {
|
|
952
947
|
id: string;
|
|
@@ -969,17 +964,17 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
969
964
|
};
|
|
970
965
|
};
|
|
971
966
|
}>)[];
|
|
972
|
-
query: zod.ZodOptional<zod.ZodObject<{
|
|
973
|
-
configId: zod.ZodOptional<zod.ZodString>;
|
|
974
|
-
organizationId: zod.ZodOptional<zod.ZodString>;
|
|
975
|
-
limit: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
|
|
976
|
-
offset: zod.ZodOptional<zod.ZodCoercedNumber<unknown>>;
|
|
977
|
-
sortBy: zod.ZodOptional<zod.ZodString>;
|
|
978
|
-
sortDirection: zod.ZodOptional<zod.ZodEnum<{
|
|
967
|
+
query: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
968
|
+
configId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
969
|
+
organizationId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
970
|
+
limit: import("zod").ZodOptional<import("zod").ZodCoercedNumber<unknown>>;
|
|
971
|
+
offset: import("zod").ZodOptional<import("zod").ZodCoercedNumber<unknown>>;
|
|
972
|
+
sortBy: import("zod").ZodOptional<import("zod").ZodString>;
|
|
973
|
+
sortDirection: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
979
974
|
asc: "asc";
|
|
980
975
|
desc: "desc";
|
|
981
976
|
}>>;
|
|
982
|
-
},
|
|
977
|
+
}, import("zod/v4/core").$strip>>;
|
|
983
978
|
metadata: {
|
|
984
979
|
openapi: {
|
|
985
980
|
description: string;
|
|
@@ -1165,7 +1160,7 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
1165
1160
|
*
|
|
1166
1161
|
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete-all-expired-api-keys)
|
|
1167
1162
|
*/
|
|
1168
|
-
deleteAllExpiredApiKeys:
|
|
1163
|
+
deleteAllExpiredApiKeys: import("better-call").StrictEndpoint<string, {
|
|
1169
1164
|
method: "POST";
|
|
1170
1165
|
}, {
|
|
1171
1166
|
success: boolean;
|
|
@@ -1289,8 +1284,8 @@ declare function apiKey(_configurations?: (ApiKeyConfigurationOptions & ApiKeyOp
|
|
|
1289
1284
|
required: false;
|
|
1290
1285
|
input: true;
|
|
1291
1286
|
transform: {
|
|
1292
|
-
input(value:
|
|
1293
|
-
output(value:
|
|
1287
|
+
input(value: import("better-auth").DBPrimitive): string;
|
|
1288
|
+
output(value: import("better-auth").DBPrimitive): any;
|
|
1294
1289
|
};
|
|
1295
1290
|
};
|
|
1296
1291
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-
|
|
2
|
-
import { i as API_KEY_ERROR_CODES, n as apiKey, r as defaultKeyHasher, t as API_KEY_TABLE_NAME } from "./index-
|
|
3
|
-
export { API_KEY_ERROR_CODES, API_KEY_TABLE_NAME, ApiKey, ApiKeyConfigurationOptions, ApiKeyOptions, apiKey, defaultKeyHasher };
|
|
1
|
+
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-BYqswa0N.mjs";
|
|
2
|
+
import { i as API_KEY_ERROR_CODES, n as apiKey, r as defaultKeyHasher, t as API_KEY_TABLE_NAME } from "./index-CgPDayNk.mjs";
|
|
3
|
+
export { API_KEY_ERROR_CODES, API_KEY_TABLE_NAME, type ApiKey, type ApiKeyConfigurationOptions, type ApiKeyOptions, apiKey, defaultKeyHasher };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as API_KEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { n as API_KEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-9S9JtMJH.mjs";
|
|
2
2
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
3
3
|
import { getIp } from "@better-auth/core/utils/ip";
|
|
4
4
|
import { base64Url } from "@better-auth/utils/base64";
|
|
@@ -732,7 +732,9 @@ function createApiKey({ defaultKeyGenerator, configurations, schema, deleteAllEx
|
|
|
732
732
|
const keyGenerator = opts.customKeyGenerator || defaultKeyGenerator;
|
|
733
733
|
const session = await getSessionFromCtx(ctx, { disableCookieCache: true });
|
|
734
734
|
const isClientRequest = ctx.request || ctx.headers;
|
|
735
|
-
if (isClientRequest && (
|
|
735
|
+
if (isClientRequest && (() => {
|
|
736
|
+
return refillAmount !== void 0 || refillInterval !== void 0 || rateLimitMax !== void 0 || rateLimitTimeWindow !== void 0 || rateLimitEnabled !== void 0 || permissions !== void 0 || remaining !== null;
|
|
737
|
+
})()) throw APIError$1.from("BAD_REQUEST", API_KEY_ERROR_CODES.SERVER_ONLY_PROPERTY);
|
|
736
738
|
if (ctx.request && ctx.body.userId !== void 0) throw APIError$1.from("UNAUTHORIZED", API_KEY_ERROR_CODES.UNAUTHORIZED_SESSION);
|
|
737
739
|
const referencesType = opts.references ?? "user";
|
|
738
740
|
let referenceId;
|
|
@@ -2124,108 +2126,173 @@ const apiKeySchema = ({ defaultRateLimitMax, defaultTimeWindow }) => ({ apikey:
|
|
|
2124
2126
|
input: false,
|
|
2125
2127
|
index: true
|
|
2126
2128
|
},
|
|
2129
|
+
/**
|
|
2130
|
+
* The name of the key.
|
|
2131
|
+
*/
|
|
2127
2132
|
name: {
|
|
2128
2133
|
type: "string",
|
|
2129
2134
|
required: false,
|
|
2130
2135
|
input: false
|
|
2131
2136
|
},
|
|
2137
|
+
/**
|
|
2138
|
+
* Shows the first few characters of the API key
|
|
2139
|
+
* This allows you to show those few characters in the UI to make it easier for users to identify the API key.
|
|
2140
|
+
*/
|
|
2132
2141
|
start: {
|
|
2133
2142
|
type: "string",
|
|
2134
2143
|
required: false,
|
|
2135
2144
|
input: false
|
|
2136
2145
|
},
|
|
2146
|
+
/**
|
|
2147
|
+
* The ID of the entity that owns this key (userId or organizationId based on config's `references` setting).
|
|
2148
|
+
*/
|
|
2137
2149
|
referenceId: {
|
|
2138
2150
|
type: "string",
|
|
2139
2151
|
required: true,
|
|
2140
2152
|
input: false,
|
|
2141
2153
|
index: true
|
|
2142
2154
|
},
|
|
2155
|
+
/**
|
|
2156
|
+
* The prefix of the key.
|
|
2157
|
+
*/
|
|
2143
2158
|
prefix: {
|
|
2144
2159
|
type: "string",
|
|
2145
2160
|
required: false,
|
|
2146
2161
|
input: false
|
|
2147
2162
|
},
|
|
2163
|
+
/**
|
|
2164
|
+
* The hashed key value.
|
|
2165
|
+
*/
|
|
2148
2166
|
key: {
|
|
2149
2167
|
type: "string",
|
|
2150
2168
|
required: true,
|
|
2151
2169
|
input: false,
|
|
2152
2170
|
index: true
|
|
2153
2171
|
},
|
|
2172
|
+
/**
|
|
2173
|
+
* The interval to refill the key in milliseconds.
|
|
2174
|
+
*/
|
|
2154
2175
|
refillInterval: {
|
|
2155
2176
|
type: "number",
|
|
2156
2177
|
required: false,
|
|
2157
2178
|
input: false
|
|
2158
2179
|
},
|
|
2180
|
+
/**
|
|
2181
|
+
* The amount to refill the remaining count of the key.
|
|
2182
|
+
*/
|
|
2159
2183
|
refillAmount: {
|
|
2160
2184
|
type: "number",
|
|
2161
2185
|
required: false,
|
|
2162
2186
|
input: false
|
|
2163
2187
|
},
|
|
2188
|
+
/**
|
|
2189
|
+
* The date and time when the key was last refilled.
|
|
2190
|
+
*/
|
|
2164
2191
|
lastRefillAt: {
|
|
2165
2192
|
type: "date",
|
|
2166
2193
|
required: false,
|
|
2167
2194
|
input: false
|
|
2168
2195
|
},
|
|
2196
|
+
/**
|
|
2197
|
+
* Whether the key is enabled.
|
|
2198
|
+
*/
|
|
2169
2199
|
enabled: {
|
|
2170
2200
|
type: "boolean",
|
|
2171
2201
|
required: false,
|
|
2172
2202
|
input: false,
|
|
2173
2203
|
defaultValue: true
|
|
2174
2204
|
},
|
|
2205
|
+
/**
|
|
2206
|
+
* Whether the key has rate limiting enabled.
|
|
2207
|
+
*/
|
|
2175
2208
|
rateLimitEnabled: {
|
|
2176
2209
|
type: "boolean",
|
|
2177
2210
|
required: false,
|
|
2178
2211
|
input: false,
|
|
2179
2212
|
defaultValue: true
|
|
2180
2213
|
},
|
|
2214
|
+
/**
|
|
2215
|
+
* The time window in milliseconds for the rate limit.
|
|
2216
|
+
*/
|
|
2181
2217
|
rateLimitTimeWindow: {
|
|
2182
2218
|
type: "number",
|
|
2183
2219
|
required: false,
|
|
2184
2220
|
input: false,
|
|
2185
2221
|
defaultValue: defaultTimeWindow
|
|
2186
2222
|
},
|
|
2223
|
+
/**
|
|
2224
|
+
* The maximum number of requests allowed within the `rateLimitTimeWindow`.
|
|
2225
|
+
*/
|
|
2187
2226
|
rateLimitMax: {
|
|
2188
2227
|
type: "number",
|
|
2189
2228
|
required: false,
|
|
2190
2229
|
input: false,
|
|
2191
2230
|
defaultValue: defaultRateLimitMax
|
|
2192
2231
|
},
|
|
2232
|
+
/**
|
|
2233
|
+
* The number of requests made within the rate limit time window
|
|
2234
|
+
*/
|
|
2193
2235
|
requestCount: {
|
|
2194
2236
|
type: "number",
|
|
2195
2237
|
required: false,
|
|
2196
2238
|
input: false,
|
|
2197
2239
|
defaultValue: 0
|
|
2198
2240
|
},
|
|
2241
|
+
/**
|
|
2242
|
+
* The remaining number of requests before the key is revoked.
|
|
2243
|
+
*
|
|
2244
|
+
* If this is null, then the key is not revoked.
|
|
2245
|
+
*
|
|
2246
|
+
* If `refillInterval` & `refillAmount` are provided, than this will refill accordingly.
|
|
2247
|
+
*/
|
|
2199
2248
|
remaining: {
|
|
2200
2249
|
type: "number",
|
|
2201
2250
|
required: false,
|
|
2202
2251
|
input: false
|
|
2203
2252
|
},
|
|
2253
|
+
/**
|
|
2254
|
+
* The date and time of the last request made to the key.
|
|
2255
|
+
*/
|
|
2204
2256
|
lastRequest: {
|
|
2205
2257
|
type: "date",
|
|
2206
2258
|
required: false,
|
|
2207
2259
|
input: false
|
|
2208
2260
|
},
|
|
2261
|
+
/**
|
|
2262
|
+
* The date and time when the key will expire.
|
|
2263
|
+
*/
|
|
2209
2264
|
expiresAt: {
|
|
2210
2265
|
type: "date",
|
|
2211
2266
|
required: false,
|
|
2212
2267
|
input: false
|
|
2213
2268
|
},
|
|
2269
|
+
/**
|
|
2270
|
+
* The date and time when the key was created.
|
|
2271
|
+
*/
|
|
2214
2272
|
createdAt: {
|
|
2215
2273
|
type: "date",
|
|
2216
2274
|
required: true,
|
|
2217
2275
|
input: false
|
|
2218
2276
|
},
|
|
2277
|
+
/**
|
|
2278
|
+
* The date and time when the key was last updated.
|
|
2279
|
+
*/
|
|
2219
2280
|
updatedAt: {
|
|
2220
2281
|
type: "date",
|
|
2221
2282
|
required: true,
|
|
2222
2283
|
input: false
|
|
2223
2284
|
},
|
|
2285
|
+
/**
|
|
2286
|
+
* The permissions of the key.
|
|
2287
|
+
*/
|
|
2224
2288
|
permissions: {
|
|
2225
2289
|
type: "string",
|
|
2226
2290
|
required: false,
|
|
2227
2291
|
input: false
|
|
2228
2292
|
},
|
|
2293
|
+
/**
|
|
2294
|
+
* Any additional metadata you want to store with the key.
|
|
2295
|
+
*/
|
|
2229
2296
|
metadata: {
|
|
2230
2297
|
type: "string",
|
|
2231
2298
|
required: false,
|
|
@@ -2378,12 +2445,111 @@ function apiKey(_configurations, _options) {
|
|
|
2378
2445
|
})
|
|
2379
2446
|
}] },
|
|
2380
2447
|
endpoints: {
|
|
2448
|
+
/**
|
|
2449
|
+
* ### Endpoint
|
|
2450
|
+
*
|
|
2451
|
+
* POST `/api-key/create`
|
|
2452
|
+
*
|
|
2453
|
+
* ### API Methods
|
|
2454
|
+
*
|
|
2455
|
+
* **server:**
|
|
2456
|
+
* `auth.api.createApiKey`
|
|
2457
|
+
*
|
|
2458
|
+
* **client:**
|
|
2459
|
+
* `authClient.apiKey.create`
|
|
2460
|
+
*
|
|
2461
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-create)
|
|
2462
|
+
*/
|
|
2381
2463
|
createApiKey: routes.createApiKey,
|
|
2464
|
+
/**
|
|
2465
|
+
* ### Endpoint
|
|
2466
|
+
*
|
|
2467
|
+
* POST `/api-key/verify`
|
|
2468
|
+
*
|
|
2469
|
+
* ### API Methods
|
|
2470
|
+
*
|
|
2471
|
+
* **server:**
|
|
2472
|
+
* `auth.api.verifyApiKey`
|
|
2473
|
+
*
|
|
2474
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-verify)
|
|
2475
|
+
*/
|
|
2382
2476
|
verifyApiKey: routes.verifyApiKey,
|
|
2477
|
+
/**
|
|
2478
|
+
* ### Endpoint
|
|
2479
|
+
*
|
|
2480
|
+
* GET `/api-key/get`
|
|
2481
|
+
*
|
|
2482
|
+
* ### API Methods
|
|
2483
|
+
*
|
|
2484
|
+
* **server:**
|
|
2485
|
+
* `auth.api.getApiKey`
|
|
2486
|
+
*
|
|
2487
|
+
* **client:**
|
|
2488
|
+
* `authClient.apiKey.get`
|
|
2489
|
+
*
|
|
2490
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-get)
|
|
2491
|
+
*/
|
|
2383
2492
|
getApiKey: routes.getApiKey,
|
|
2493
|
+
/**
|
|
2494
|
+
* ### Endpoint
|
|
2495
|
+
*
|
|
2496
|
+
* POST `/api-key/update`
|
|
2497
|
+
*
|
|
2498
|
+
* ### API Methods
|
|
2499
|
+
*
|
|
2500
|
+
* **server:**
|
|
2501
|
+
* `auth.api.updateApiKey`
|
|
2502
|
+
*
|
|
2503
|
+
* **client:**
|
|
2504
|
+
* `authClient.apiKey.update`
|
|
2505
|
+
*
|
|
2506
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-update)
|
|
2507
|
+
*/
|
|
2384
2508
|
updateApiKey: routes.updateApiKey,
|
|
2509
|
+
/**
|
|
2510
|
+
* ### Endpoint
|
|
2511
|
+
*
|
|
2512
|
+
* POST `/api-key/delete`
|
|
2513
|
+
*
|
|
2514
|
+
* ### API Methods
|
|
2515
|
+
*
|
|
2516
|
+
* **server:**
|
|
2517
|
+
* `auth.api.deleteApiKey`
|
|
2518
|
+
*
|
|
2519
|
+
* **client:**
|
|
2520
|
+
* `authClient.apiKey.delete`
|
|
2521
|
+
*
|
|
2522
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete)
|
|
2523
|
+
*/
|
|
2385
2524
|
deleteApiKey: routes.deleteApiKey,
|
|
2525
|
+
/**
|
|
2526
|
+
* ### Endpoint
|
|
2527
|
+
*
|
|
2528
|
+
* GET `/api-key/list`
|
|
2529
|
+
*
|
|
2530
|
+
* ### API Methods
|
|
2531
|
+
*
|
|
2532
|
+
* **server:**
|
|
2533
|
+
* `auth.api.listApiKeys`
|
|
2534
|
+
*
|
|
2535
|
+
* **client:**
|
|
2536
|
+
* `authClient.apiKey.list`
|
|
2537
|
+
*
|
|
2538
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-list)
|
|
2539
|
+
*/
|
|
2386
2540
|
listApiKeys: routes.listApiKeys,
|
|
2541
|
+
/**
|
|
2542
|
+
* ### Endpoint
|
|
2543
|
+
*
|
|
2544
|
+
* POST `/api-key/delete-all-expired-api-keys`
|
|
2545
|
+
*
|
|
2546
|
+
* ### API Methods
|
|
2547
|
+
*
|
|
2548
|
+
* **server:**
|
|
2549
|
+
* `auth.api.deleteAllExpiredApiKeys`
|
|
2550
|
+
*
|
|
2551
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete-all-expired-api-keys)
|
|
2552
|
+
*/
|
|
2387
2553
|
deleteAllExpiredApiKeys: routes.deleteAllExpiredApiKeys
|
|
2388
2554
|
},
|
|
2389
2555
|
schema
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import * as better_auth0 from "better-auth";
|
|
2
1
|
import { Statements } from "better-auth/plugins/access";
|
|
3
2
|
import { Awaitable, GenericEndpointContext, HookEndpointContext, LiteralString } from "@better-auth/core";
|
|
4
3
|
import { InferOptionSchema } from "better-auth/types";
|
|
5
|
-
|
|
6
4
|
//#region src/schema.d.ts
|
|
7
|
-
declare const apiKeySchema: ({
|
|
8
|
-
defaultRateLimitMax,
|
|
9
|
-
defaultTimeWindow
|
|
10
|
-
}: {
|
|
5
|
+
declare const apiKeySchema: ({ defaultRateLimitMax, defaultTimeWindow }: {
|
|
11
6
|
defaultTimeWindow: number;
|
|
12
7
|
defaultRateLimitMax: number;
|
|
13
8
|
}) => {
|
|
@@ -192,8 +187,8 @@ declare const apiKeySchema: ({
|
|
|
192
187
|
required: false;
|
|
193
188
|
input: true;
|
|
194
189
|
transform: {
|
|
195
|
-
input(value:
|
|
196
|
-
output(value:
|
|
190
|
+
input(value: import("better-auth").DBPrimitive): string;
|
|
191
|
+
output(value: import("better-auth").DBPrimitive): any;
|
|
197
192
|
};
|
|
198
193
|
};
|
|
199
194
|
};
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-
|
|
1
|
+
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-BYqswa0N.mjs";
|
|
2
2
|
export { ApiKey, ApiKeyConfigurationOptions, ApiKeyOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/api-key",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.24",
|
|
4
4
|
"description": "API Key plugin for Better Auth.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,15 +60,15 @@
|
|
|
60
60
|
"zod": "^4.3.6"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"tsdown": "0.
|
|
64
|
-
"@better-auth/core": "1.6.
|
|
65
|
-
"better-auth": "1.6.
|
|
63
|
+
"tsdown": "0.22.7",
|
|
64
|
+
"@better-auth/core": "1.6.24",
|
|
65
|
+
"better-auth": "1.6.24"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@better-auth/utils": "0.4.2",
|
|
69
69
|
"better-call": "1.3.7",
|
|
70
|
-
"@better-auth/core": "^1.6.
|
|
71
|
-
"better-auth": "^1.6.
|
|
70
|
+
"@better-auth/core": "^1.6.24",
|
|
71
|
+
"better-auth": "^1.6.24"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsdown",
|