@better-auth/api-key 1.7.0-rc.0 → 1.7.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.mts +34 -36
- package/dist/client.mjs +1 -1
- package/dist/{index-K0I_tcSP.d.mts → index-BX4nCO8Y.d.mts} +147 -152
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +168 -2
- package/dist/{types-CbtANSbR.d.mts → types-BLGcz4fR.d.mts} +3 -8
- package/dist/types.d.mts +1 -1
- package/dist/{version-DvOZbzQP.mjs → version-DqzN9pOq.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-BLGcz4fR.mjs";
|
|
2
|
+
import { i as API_KEY_ERROR_CODES, n as apiKey } from "./index-BX4nCO8Y.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-BLGcz4fR.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-BLGcz4fR.mjs";
|
|
2
|
+
import { i as API_KEY_ERROR_CODES, n as apiKey, r as defaultKeyHasher, t as API_KEY_TABLE_NAME } from "./index-BX4nCO8Y.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-DqzN9pOq.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";
|
|
@@ -731,7 +731,9 @@ function createApiKey({ defaultKeyGenerator, configurations, schema, deleteAllEx
|
|
|
731
731
|
const keyGenerator = opts.customKeyGenerator || defaultKeyGenerator;
|
|
732
732
|
const session = await getSessionFromCtx(ctx, { disableCookieCache: true });
|
|
733
733
|
const isClientRequest = ctx.request || ctx.headers;
|
|
734
|
-
if (isClientRequest && (
|
|
734
|
+
if (isClientRequest && (() => {
|
|
735
|
+
return refillAmount !== void 0 || refillInterval !== void 0 || rateLimitMax !== void 0 || rateLimitTimeWindow !== void 0 || rateLimitEnabled !== void 0 || permissions !== void 0 || remaining !== null;
|
|
736
|
+
})()) throw APIError$1.from("BAD_REQUEST", API_KEY_ERROR_CODES.SERVER_ONLY_PROPERTY);
|
|
735
737
|
if (ctx.request && ctx.body.userId !== void 0) throw APIError$1.from("UNAUTHORIZED", API_KEY_ERROR_CODES.UNAUTHORIZED_SESSION);
|
|
736
738
|
const referencesType = opts.references ?? "user";
|
|
737
739
|
let referenceId;
|
|
@@ -2123,108 +2125,173 @@ const apiKeySchema = ({ defaultRateLimitMax, defaultTimeWindow }) => ({ apikey:
|
|
|
2123
2125
|
input: false,
|
|
2124
2126
|
index: true
|
|
2125
2127
|
},
|
|
2128
|
+
/**
|
|
2129
|
+
* The name of the key.
|
|
2130
|
+
*/
|
|
2126
2131
|
name: {
|
|
2127
2132
|
type: "string",
|
|
2128
2133
|
required: false,
|
|
2129
2134
|
input: false
|
|
2130
2135
|
},
|
|
2136
|
+
/**
|
|
2137
|
+
* Shows the first few characters of the API key
|
|
2138
|
+
* This allows you to show those few characters in the UI to make it easier for users to identify the API key.
|
|
2139
|
+
*/
|
|
2131
2140
|
start: {
|
|
2132
2141
|
type: "string",
|
|
2133
2142
|
required: false,
|
|
2134
2143
|
input: false
|
|
2135
2144
|
},
|
|
2145
|
+
/**
|
|
2146
|
+
* The ID of the entity that owns this key (userId or organizationId based on config's `references` setting).
|
|
2147
|
+
*/
|
|
2136
2148
|
referenceId: {
|
|
2137
2149
|
type: "string",
|
|
2138
2150
|
required: true,
|
|
2139
2151
|
input: false,
|
|
2140
2152
|
index: true
|
|
2141
2153
|
},
|
|
2154
|
+
/**
|
|
2155
|
+
* The prefix of the key.
|
|
2156
|
+
*/
|
|
2142
2157
|
prefix: {
|
|
2143
2158
|
type: "string",
|
|
2144
2159
|
required: false,
|
|
2145
2160
|
input: false
|
|
2146
2161
|
},
|
|
2162
|
+
/**
|
|
2163
|
+
* The hashed key value.
|
|
2164
|
+
*/
|
|
2147
2165
|
key: {
|
|
2148
2166
|
type: "string",
|
|
2149
2167
|
required: true,
|
|
2150
2168
|
input: false,
|
|
2151
2169
|
index: true
|
|
2152
2170
|
},
|
|
2171
|
+
/**
|
|
2172
|
+
* The interval to refill the key in milliseconds.
|
|
2173
|
+
*/
|
|
2153
2174
|
refillInterval: {
|
|
2154
2175
|
type: "number",
|
|
2155
2176
|
required: false,
|
|
2156
2177
|
input: false
|
|
2157
2178
|
},
|
|
2179
|
+
/**
|
|
2180
|
+
* The amount to refill the remaining count of the key.
|
|
2181
|
+
*/
|
|
2158
2182
|
refillAmount: {
|
|
2159
2183
|
type: "number",
|
|
2160
2184
|
required: false,
|
|
2161
2185
|
input: false
|
|
2162
2186
|
},
|
|
2187
|
+
/**
|
|
2188
|
+
* The date and time when the key was last refilled.
|
|
2189
|
+
*/
|
|
2163
2190
|
lastRefillAt: {
|
|
2164
2191
|
type: "date",
|
|
2165
2192
|
required: false,
|
|
2166
2193
|
input: false
|
|
2167
2194
|
},
|
|
2195
|
+
/**
|
|
2196
|
+
* Whether the key is enabled.
|
|
2197
|
+
*/
|
|
2168
2198
|
enabled: {
|
|
2169
2199
|
type: "boolean",
|
|
2170
2200
|
required: false,
|
|
2171
2201
|
input: false,
|
|
2172
2202
|
defaultValue: true
|
|
2173
2203
|
},
|
|
2204
|
+
/**
|
|
2205
|
+
* Whether the key has rate limiting enabled.
|
|
2206
|
+
*/
|
|
2174
2207
|
rateLimitEnabled: {
|
|
2175
2208
|
type: "boolean",
|
|
2176
2209
|
required: false,
|
|
2177
2210
|
input: false,
|
|
2178
2211
|
defaultValue: true
|
|
2179
2212
|
},
|
|
2213
|
+
/**
|
|
2214
|
+
* The time window in milliseconds for the rate limit.
|
|
2215
|
+
*/
|
|
2180
2216
|
rateLimitTimeWindow: {
|
|
2181
2217
|
type: "number",
|
|
2182
2218
|
required: false,
|
|
2183
2219
|
input: false,
|
|
2184
2220
|
defaultValue: defaultTimeWindow
|
|
2185
2221
|
},
|
|
2222
|
+
/**
|
|
2223
|
+
* The maximum number of requests allowed within the `rateLimitTimeWindow`.
|
|
2224
|
+
*/
|
|
2186
2225
|
rateLimitMax: {
|
|
2187
2226
|
type: "number",
|
|
2188
2227
|
required: false,
|
|
2189
2228
|
input: false,
|
|
2190
2229
|
defaultValue: defaultRateLimitMax
|
|
2191
2230
|
},
|
|
2231
|
+
/**
|
|
2232
|
+
* The number of requests made within the rate limit time window
|
|
2233
|
+
*/
|
|
2192
2234
|
requestCount: {
|
|
2193
2235
|
type: "number",
|
|
2194
2236
|
required: false,
|
|
2195
2237
|
input: false,
|
|
2196
2238
|
defaultValue: 0
|
|
2197
2239
|
},
|
|
2240
|
+
/**
|
|
2241
|
+
* The remaining number of requests before the key is revoked.
|
|
2242
|
+
*
|
|
2243
|
+
* If this is null, then the key is not revoked.
|
|
2244
|
+
*
|
|
2245
|
+
* If `refillInterval` & `refillAmount` are provided, than this will refill accordingly.
|
|
2246
|
+
*/
|
|
2198
2247
|
remaining: {
|
|
2199
2248
|
type: "number",
|
|
2200
2249
|
required: false,
|
|
2201
2250
|
input: false
|
|
2202
2251
|
},
|
|
2252
|
+
/**
|
|
2253
|
+
* The date and time of the last request made to the key.
|
|
2254
|
+
*/
|
|
2203
2255
|
lastRequest: {
|
|
2204
2256
|
type: "date",
|
|
2205
2257
|
required: false,
|
|
2206
2258
|
input: false
|
|
2207
2259
|
},
|
|
2260
|
+
/**
|
|
2261
|
+
* The date and time when the key will expire.
|
|
2262
|
+
*/
|
|
2208
2263
|
expiresAt: {
|
|
2209
2264
|
type: "date",
|
|
2210
2265
|
required: false,
|
|
2211
2266
|
input: false
|
|
2212
2267
|
},
|
|
2268
|
+
/**
|
|
2269
|
+
* The date and time when the key was created.
|
|
2270
|
+
*/
|
|
2213
2271
|
createdAt: {
|
|
2214
2272
|
type: "date",
|
|
2215
2273
|
required: true,
|
|
2216
2274
|
input: false
|
|
2217
2275
|
},
|
|
2276
|
+
/**
|
|
2277
|
+
* The date and time when the key was last updated.
|
|
2278
|
+
*/
|
|
2218
2279
|
updatedAt: {
|
|
2219
2280
|
type: "date",
|
|
2220
2281
|
required: true,
|
|
2221
2282
|
input: false
|
|
2222
2283
|
},
|
|
2284
|
+
/**
|
|
2285
|
+
* The permissions of the key.
|
|
2286
|
+
*/
|
|
2223
2287
|
permissions: {
|
|
2224
2288
|
type: "string",
|
|
2225
2289
|
required: false,
|
|
2226
2290
|
input: false
|
|
2227
2291
|
},
|
|
2292
|
+
/**
|
|
2293
|
+
* Any additional metadata you want to store with the key.
|
|
2294
|
+
*/
|
|
2228
2295
|
metadata: {
|
|
2229
2296
|
type: "string",
|
|
2230
2297
|
required: false,
|
|
@@ -2377,12 +2444,111 @@ function apiKey(_configurations, _options) {
|
|
|
2377
2444
|
})
|
|
2378
2445
|
}] },
|
|
2379
2446
|
endpoints: {
|
|
2447
|
+
/**
|
|
2448
|
+
* ### Endpoint
|
|
2449
|
+
*
|
|
2450
|
+
* POST `/api-key/create`
|
|
2451
|
+
*
|
|
2452
|
+
* ### API Methods
|
|
2453
|
+
*
|
|
2454
|
+
* **server:**
|
|
2455
|
+
* `auth.api.createApiKey`
|
|
2456
|
+
*
|
|
2457
|
+
* **client:**
|
|
2458
|
+
* `authClient.apiKey.create`
|
|
2459
|
+
*
|
|
2460
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-create)
|
|
2461
|
+
*/
|
|
2380
2462
|
createApiKey: routes.createApiKey,
|
|
2463
|
+
/**
|
|
2464
|
+
* ### Endpoint
|
|
2465
|
+
*
|
|
2466
|
+
* POST `/api-key/verify`
|
|
2467
|
+
*
|
|
2468
|
+
* ### API Methods
|
|
2469
|
+
*
|
|
2470
|
+
* **server:**
|
|
2471
|
+
* `auth.api.verifyApiKey`
|
|
2472
|
+
*
|
|
2473
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-verify)
|
|
2474
|
+
*/
|
|
2381
2475
|
verifyApiKey: routes.verifyApiKey,
|
|
2476
|
+
/**
|
|
2477
|
+
* ### Endpoint
|
|
2478
|
+
*
|
|
2479
|
+
* GET `/api-key/get`
|
|
2480
|
+
*
|
|
2481
|
+
* ### API Methods
|
|
2482
|
+
*
|
|
2483
|
+
* **server:**
|
|
2484
|
+
* `auth.api.getApiKey`
|
|
2485
|
+
*
|
|
2486
|
+
* **client:**
|
|
2487
|
+
* `authClient.apiKey.get`
|
|
2488
|
+
*
|
|
2489
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-get)
|
|
2490
|
+
*/
|
|
2382
2491
|
getApiKey: routes.getApiKey,
|
|
2492
|
+
/**
|
|
2493
|
+
* ### Endpoint
|
|
2494
|
+
*
|
|
2495
|
+
* POST `/api-key/update`
|
|
2496
|
+
*
|
|
2497
|
+
* ### API Methods
|
|
2498
|
+
*
|
|
2499
|
+
* **server:**
|
|
2500
|
+
* `auth.api.updateApiKey`
|
|
2501
|
+
*
|
|
2502
|
+
* **client:**
|
|
2503
|
+
* `authClient.apiKey.update`
|
|
2504
|
+
*
|
|
2505
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-update)
|
|
2506
|
+
*/
|
|
2383
2507
|
updateApiKey: routes.updateApiKey,
|
|
2508
|
+
/**
|
|
2509
|
+
* ### Endpoint
|
|
2510
|
+
*
|
|
2511
|
+
* POST `/api-key/delete`
|
|
2512
|
+
*
|
|
2513
|
+
* ### API Methods
|
|
2514
|
+
*
|
|
2515
|
+
* **server:**
|
|
2516
|
+
* `auth.api.deleteApiKey`
|
|
2517
|
+
*
|
|
2518
|
+
* **client:**
|
|
2519
|
+
* `authClient.apiKey.delete`
|
|
2520
|
+
*
|
|
2521
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete)
|
|
2522
|
+
*/
|
|
2384
2523
|
deleteApiKey: routes.deleteApiKey,
|
|
2524
|
+
/**
|
|
2525
|
+
* ### Endpoint
|
|
2526
|
+
*
|
|
2527
|
+
* GET `/api-key/list`
|
|
2528
|
+
*
|
|
2529
|
+
* ### API Methods
|
|
2530
|
+
*
|
|
2531
|
+
* **server:**
|
|
2532
|
+
* `auth.api.listApiKeys`
|
|
2533
|
+
*
|
|
2534
|
+
* **client:**
|
|
2535
|
+
* `authClient.apiKey.list`
|
|
2536
|
+
*
|
|
2537
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-list)
|
|
2538
|
+
*/
|
|
2385
2539
|
listApiKeys: routes.listApiKeys,
|
|
2540
|
+
/**
|
|
2541
|
+
* ### Endpoint
|
|
2542
|
+
*
|
|
2543
|
+
* POST `/api-key/delete-all-expired-api-keys`
|
|
2544
|
+
*
|
|
2545
|
+
* ### API Methods
|
|
2546
|
+
*
|
|
2547
|
+
* **server:**
|
|
2548
|
+
* `auth.api.deleteAllExpiredApiKeys`
|
|
2549
|
+
*
|
|
2550
|
+
* @see [Read our docs to learn more.](https://better-auth.com/docs/plugins/api-key#api-method-api-key-delete-all-expired-api-keys)
|
|
2551
|
+
*/
|
|
2386
2552
|
deleteAllExpiredApiKeys: routes.deleteAllExpiredApiKeys
|
|
2387
2553
|
},
|
|
2388
2554
|
schema
|
|
@@ -1,14 +1,9 @@
|
|
|
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 { SecondaryStorage } from "@better-auth/core/db";
|
|
5
4
|
import { InferOptionSchema } from "better-auth/types";
|
|
6
|
-
|
|
7
5
|
//#region src/schema.d.ts
|
|
8
|
-
declare const apiKeySchema: ({
|
|
9
|
-
defaultRateLimitMax,
|
|
10
|
-
defaultTimeWindow
|
|
11
|
-
}: {
|
|
6
|
+
declare const apiKeySchema: ({ defaultRateLimitMax, defaultTimeWindow }: {
|
|
12
7
|
defaultTimeWindow: number;
|
|
13
8
|
defaultRateLimitMax: number;
|
|
14
9
|
}) => {
|
|
@@ -193,8 +188,8 @@ declare const apiKeySchema: ({
|
|
|
193
188
|
required: false;
|
|
194
189
|
input: true;
|
|
195
190
|
transform: {
|
|
196
|
-
input(value:
|
|
197
|
-
output(value:
|
|
191
|
+
input(value: import("better-auth").DBPrimitive): string;
|
|
192
|
+
output(value: import("better-auth").DBPrimitive): any;
|
|
198
193
|
};
|
|
199
194
|
};
|
|
200
195
|
};
|
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-BLGcz4fR.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.7.0-rc.
|
|
3
|
+
"version": "1.7.0-rc.2",
|
|
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.7.0-rc.
|
|
65
|
-
"better-auth": "1.7.0-rc.
|
|
63
|
+
"tsdown": "0.22.7",
|
|
64
|
+
"@better-auth/core": "1.7.0-rc.2",
|
|
65
|
+
"better-auth": "1.7.0-rc.2"
|
|
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.7.0-rc.
|
|
71
|
-
"better-auth": "^1.7.0-rc.
|
|
70
|
+
"@better-auth/core": "^1.7.0-rc.2",
|
|
71
|
+
"better-auth": "^1.7.0-rc.2"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsdown",
|