better-auth 1.7.3 → 1.7.5
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/api/dispatch.mjs +4 -1
- package/dist/api/index.d.mts +6 -6
- package/dist/api/index.mjs +3 -1
- package/dist/api/routes/account.d.mts +1 -1
- package/dist/api/routes/sign-in.d.mts +2 -2
- package/dist/client/config.d.mts +2 -2
- package/dist/cookies/index.d.mts +3 -2
- package/dist/cookies/index.mjs +15 -36
- package/dist/db/get-migration.mjs +81 -60
- package/dist/db/with-hooks.mjs +2 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/admin/admin.d.mts +3 -3
- package/dist/plugins/captcha/index.mjs +1 -0
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +27 -8
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/organization/routes/crud-members.d.mts +3 -3
- package/dist/plugins/organization/schema.d.mts +2 -2
- package/dist/plugins/test-utils/auth-helpers.mjs +8 -3
- package/dist/plugins/test-utils/index.d.mts +1 -1
- package/dist/plugins/test-utils/types.d.mts +10 -9
- package/dist/plugins/username/index.d.mts +4 -4
- package/dist/plugins/username/schema.d.mts +4 -4
- package/dist/test-utils/http-test-instance.d.mts +2 -2
- package/package.json +12 -16
package/dist/api/dispatch.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { runWithEndpointContext } from "@better-auth/core/context";
|
|
|
4
4
|
import { shouldPublishLog } from "@better-auth/core/env";
|
|
5
5
|
import { APIError } from "@better-auth/core/error";
|
|
6
6
|
import { createDefu } from "defu";
|
|
7
|
-
import { ATTR_CONTEXT, ATTR_HOOK_TYPE, ATTR_HTTP_ROUTE, ATTR_OPERATION_ID,
|
|
7
|
+
import { ATTR_CONTEXT, ATTR_HOOK_TYPE, ATTR_HTTP_ROUTE, ATTR_OPERATION_ID, createWithSpan } from "@better-auth/core/instrumentation";
|
|
8
8
|
import { kAPIErrorHeaderSymbol, toResponse } from "better-call";
|
|
9
9
|
//#region src/api/dispatch.ts
|
|
10
10
|
const defuReplaceArrays = createDefu((obj, key, value) => {
|
|
@@ -62,6 +62,7 @@ function mergeAPIErrorHeaders(error) {
|
|
|
62
62
|
return headers;
|
|
63
63
|
}
|
|
64
64
|
async function runBeforeHooks(context, hooks, endpoint, operationId) {
|
|
65
|
+
const withSpan = createWithSpan(context.context.options);
|
|
65
66
|
let modifiedContext = {};
|
|
66
67
|
for (const hook of hooks) {
|
|
67
68
|
let matched = false;
|
|
@@ -105,6 +106,7 @@ async function runBeforeHooks(context, hooks, endpoint, operationId) {
|
|
|
105
106
|
return { context: modifiedContext };
|
|
106
107
|
}
|
|
107
108
|
async function runAfterHooks(context, hooks, endpoint, operationId) {
|
|
109
|
+
const withSpan = createWithSpan(context.context.options);
|
|
108
110
|
for (const hook of hooks) {
|
|
109
111
|
if (!hook.matcher(context)) continue;
|
|
110
112
|
const hookSource = hooksSourceWeakMap.get(hook.handler) ?? "unknown";
|
|
@@ -182,6 +184,7 @@ function getHooks(authContext) {
|
|
|
182
184
|
* @param input Input context whose `context` is an already-resolved `AuthContext`.
|
|
183
185
|
*/
|
|
184
186
|
async function dispatchAuthEndpoint(endpoint, input) {
|
|
187
|
+
const withSpan = createWithSpan(input.context.options);
|
|
185
188
|
const operationId = input.operationId ?? getOperationId(endpoint);
|
|
186
189
|
const route = endpoint.path ?? "/:virtual";
|
|
187
190
|
const endpointMethod = endpoint.options?.method;
|
package/dist/api/index.d.mts
CHANGED
|
@@ -93,7 +93,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
|
|
|
93
93
|
callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
94
94
|
newUserCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
95
95
|
errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
96
|
-
provider: _$zod.ZodType<(string & {}) | "
|
|
96
|
+
provider: _$zod.ZodType<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
|
|
97
97
|
disableRedirect: _$zod.ZodOptional<_$zod.ZodBoolean>;
|
|
98
98
|
idToken: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
99
99
|
token: _$zod.ZodString;
|
|
@@ -121,7 +121,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
|
|
|
121
121
|
callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
122
122
|
newUserCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
123
123
|
errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
124
|
-
provider: _$zod.ZodType<(string & {}) | "
|
|
124
|
+
provider: _$zod.ZodType<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
|
|
125
125
|
disableRedirect: _$zod.ZodOptional<_$zod.ZodBoolean>;
|
|
126
126
|
idToken: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
127
127
|
token: _$zod.ZodString;
|
|
@@ -1592,7 +1592,7 @@ declare function getEndpoints<Option extends BetterAuthOptions>(ctx: Awaitable<A
|
|
|
1592
1592
|
requireHeaders: true;
|
|
1593
1593
|
body: _$zod.ZodObject<{
|
|
1594
1594
|
callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
1595
|
-
provider: _$zod.ZodType<(string & {}) | "
|
|
1595
|
+
provider: _$zod.ZodType<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
|
|
1596
1596
|
idToken: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
1597
1597
|
token: _$zod.ZodString;
|
|
1598
1598
|
nonce: _$zod.ZodOptional<_$zod.ZodString>;
|
|
@@ -2107,7 +2107,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
|
|
|
2107
2107
|
callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2108
2108
|
newUserCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2109
2109
|
errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2110
|
-
provider: _$zod.ZodType<(string & {}) | "
|
|
2110
|
+
provider: _$zod.ZodType<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
|
|
2111
2111
|
disableRedirect: _$zod.ZodOptional<_$zod.ZodBoolean>;
|
|
2112
2112
|
idToken: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
2113
2113
|
token: _$zod.ZodString;
|
|
@@ -2135,7 +2135,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
|
|
|
2135
2135
|
callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2136
2136
|
newUserCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2137
2137
|
errorCallbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2138
|
-
provider: _$zod.ZodType<(string & {}) | "
|
|
2138
|
+
provider: _$zod.ZodType<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
|
|
2139
2139
|
disableRedirect: _$zod.ZodOptional<_$zod.ZodBoolean>;
|
|
2140
2140
|
idToken: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
2141
2141
|
token: _$zod.ZodString;
|
|
@@ -3606,7 +3606,7 @@ declare const router: <Option extends BetterAuthOptions>(ctx: AuthContext, optio
|
|
|
3606
3606
|
requireHeaders: true;
|
|
3607
3607
|
body: _$zod.ZodObject<{
|
|
3608
3608
|
callbackURL: _$zod.ZodOptional<_$zod.ZodString>;
|
|
3609
|
-
provider: _$zod.ZodType<(string & {}) | "
|
|
3609
|
+
provider: _$zod.ZodType<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, _$zod_v4_core0.$ZodTypeInternals<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
|
|
3610
3610
|
idToken: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
3611
3611
|
token: _$zod.ZodString;
|
|
3612
3612
|
nonce: _$zod.ZodOptional<_$zod.ZodString>;
|
package/dist/api/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ import { toAuthEndpoints } from "./to-auth-endpoints.mjs";
|
|
|
21
21
|
import { logger } from "@better-auth/core/env";
|
|
22
22
|
import { APIError } from "@better-auth/core/error";
|
|
23
23
|
import { getIP } from "@better-auth/core/utils/ip";
|
|
24
|
-
import { ATTR_CONTEXT, ATTR_HOOK_TYPE, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE,
|
|
24
|
+
import { ATTR_CONTEXT, ATTR_HOOK_TYPE, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE, createWithSpan } from "@better-auth/core/instrumentation";
|
|
25
25
|
import { normalizePathname } from "@better-auth/core/utils/url";
|
|
26
26
|
import { createRouter } from "better-call";
|
|
27
27
|
import { NO_STORE_HEADERS, createAuthEndpoint, createAuthMiddleware, optionsMiddleware } from "@better-auth/core/api";
|
|
@@ -82,6 +82,7 @@ To resolve this, you can:
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
function getEndpoints(ctx, options) {
|
|
85
|
+
const withSpan = createWithSpan(options);
|
|
85
86
|
const pluginEndpoints = options.plugins?.reduce((acc, plugin) => {
|
|
86
87
|
return {
|
|
87
88
|
...acc,
|
|
@@ -148,6 +149,7 @@ function getEndpoints(ctx, options) {
|
|
|
148
149
|
};
|
|
149
150
|
}
|
|
150
151
|
const router = (ctx, options) => {
|
|
152
|
+
const withSpan = createWithSpan(options);
|
|
151
153
|
const { api, middlewares } = getEndpoints(ctx, options);
|
|
152
154
|
const basePath = new URL(ctx.baseURL).pathname;
|
|
153
155
|
return createRouter(api, {
|
|
@@ -92,7 +92,7 @@ declare const linkSocialAccount: _$better_call0.StrictEndpoint<"/link-social", {
|
|
|
92
92
|
requireHeaders: true;
|
|
93
93
|
body: z.ZodObject<{
|
|
94
94
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
95
|
-
provider: z.ZodType<(string & {}) | "
|
|
95
|
+
provider: z.ZodType<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, z.core.$ZodTypeInternals<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
|
|
96
96
|
idToken: z.ZodOptional<z.ZodObject<{
|
|
97
97
|
token: z.ZodString;
|
|
98
98
|
nonce: z.ZodOptional<z.ZodString>;
|
|
@@ -8,7 +8,7 @@ declare const socialSignInBodySchema: z.ZodObject<{
|
|
|
8
8
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
9
9
|
newUserCallbackURL: z.ZodOptional<z.ZodString>;
|
|
10
10
|
errorCallbackURL: z.ZodOptional<z.ZodString>;
|
|
11
|
-
provider: z.ZodType<(string & {}) | "
|
|
11
|
+
provider: z.ZodType<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, z.core.$ZodTypeInternals<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
|
|
12
12
|
disableRedirect: z.ZodOptional<z.ZodBoolean>;
|
|
13
13
|
idToken: z.ZodOptional<z.ZodObject<{
|
|
14
14
|
token: z.ZodString;
|
|
@@ -37,7 +37,7 @@ declare const signInSocial: <O extends BetterAuthOptions>() => _$better_call0.St
|
|
|
37
37
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
38
38
|
newUserCallbackURL: z.ZodOptional<z.ZodString>;
|
|
39
39
|
errorCallbackURL: z.ZodOptional<z.ZodString>;
|
|
40
|
-
provider: z.ZodType<(string & {}) | "
|
|
40
|
+
provider: z.ZodType<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown, z.core.$ZodTypeInternals<(string & {}) | "github" | "apple" | "atlassian" | "cloudflare" | "cognito" | "discord" | "facebook" | "figma" | "microsoft" | "google" | "huggingface" | "slack" | "spotify" | "twitch" | "twitter" | "dropbox" | "kick" | "linear" | "linkedin" | "gitlab" | "tiktok" | "reddit" | "roblox" | "salesforce" | "vk" | "zoom" | "notion" | "kakao" | "naver" | "line" | "paybin" | "paypal" | "polar" | "railway" | "vercel" | "wechat", unknown>>;
|
|
41
41
|
disableRedirect: z.ZodOptional<z.ZodBoolean>;
|
|
42
42
|
idToken: z.ZodOptional<z.ZodObject<{
|
|
43
43
|
token: z.ZodString;
|
package/dist/client/config.d.mts
CHANGED
|
@@ -30,17 +30,17 @@ declare const getClientConfig: (options?: BetterAuthClientOptions | undefined, l
|
|
|
30
30
|
onResponse: ((context: _$_better_fetch_fetch0.ResponseContext) => Promise<Response | void | _$_better_fetch_fetch0.ResponseContext> | Response | _$_better_fetch_fetch0.ResponseContext | void) | undefined;
|
|
31
31
|
};
|
|
32
32
|
})[];
|
|
33
|
-
priority?: RequestPriority | undefined;
|
|
34
33
|
cache?: RequestCache | undefined;
|
|
35
34
|
credentials?: RequestCredentials;
|
|
36
35
|
integrity?: string | undefined;
|
|
37
36
|
keepalive?: boolean | undefined;
|
|
38
37
|
method: string;
|
|
39
38
|
mode?: RequestMode | undefined;
|
|
39
|
+
priority?: RequestPriority | undefined;
|
|
40
40
|
redirect?: RequestRedirect | undefined;
|
|
41
41
|
referrer?: string | undefined;
|
|
42
42
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
43
|
-
signal?:
|
|
43
|
+
signal?: AbortSignal | null;
|
|
44
44
|
window?: null | undefined;
|
|
45
45
|
onRetry?: ((response: _$_better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
|
|
46
46
|
hookOptions?: {
|
package/dist/cookies/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Session, User } from "../types/models.mjs";
|
|
2
2
|
import { CookieAttributes, HOST_COOKIE_PREFIX, SECURE_COOKIE_PREFIX, applySetCookies, cookieNameRegex, parseCookies, parseSetCookieHeader, setCookieToHeader, setRequestCookie, splitSetCookieHeader, stripSecureCookiePrefix, toCookieOptions } from "./cookie-utils.mjs";
|
|
3
3
|
import { createSessionStore, getAccountCookie, getChunkedCookie, setAccountCookie } from "./session-store.mjs";
|
|
4
|
-
import { BetterAuthCookie, BetterAuthCookies, BetterAuthOptions, CookieCachePayload, GenericEndpointContext } from "@better-auth/core";
|
|
4
|
+
import { Awaitable, BetterAuthCookie, BetterAuthCookies, BetterAuthOptions, CookieCachePayload, GenericEndpointContext } from "@better-auth/core";
|
|
5
5
|
import * as _$better_call0 from "better-call";
|
|
6
6
|
import { CookieOptions } from "better-call";
|
|
7
7
|
import { JSONWebKeySet } from "jose";
|
|
@@ -106,6 +106,7 @@ declare const getSessionCookie: (request: Request | Headers, config?: {
|
|
|
106
106
|
cookieName?: string;
|
|
107
107
|
path?: string;
|
|
108
108
|
} | undefined) => string | null;
|
|
109
|
+
type CookieCacheVersion = string | ((session: CookieCachePayload["session"], user: CookieCachePayload["user"]) => Awaitable<string>);
|
|
109
110
|
declare const getCookieCache: <S extends CookieCachePayload = CookieCachePayload>(request: Request | Headers, config?: {
|
|
110
111
|
cookiePrefix?: string;
|
|
111
112
|
cookieName?: string;
|
|
@@ -117,7 +118,7 @@ declare const getCookieCache: <S extends CookieCachePayload = CookieCachePayload
|
|
|
117
118
|
issuer?: string;
|
|
118
119
|
audience?: string;
|
|
119
120
|
} | undefined;
|
|
120
|
-
version?:
|
|
121
|
+
version?: CookieCacheVersion;
|
|
121
122
|
} | undefined) => Promise<S | null>;
|
|
122
123
|
//#endregion
|
|
123
124
|
export { CookieAttributes, EligibleCookies, HOST_COOKIE_PREFIX, SECURE_COOKIE_PREFIX, applySetCookies, cookieNameRegex, createCookieGetter, createSessionStore, decodeCookieCache, deleteSessionCookie, expireCookie, getAccountCookie, getChunkedCookie, getCookieCache, getCookies, getSessionCookie, parseCookies, parseSetCookieHeader, setAccountCookie, setCookieCache, setCookieToHeader, setRequestCookie, setSessionCookie, splitSetCookieHeader, stripSecureCookiePrefix, toCookieOptions };
|
package/dist/cookies/index.mjs
CHANGED
|
@@ -268,6 +268,10 @@ const getSessionCookie = (request, config) => {
|
|
|
268
268
|
if (sessionToken) return sessionToken;
|
|
269
269
|
return null;
|
|
270
270
|
};
|
|
271
|
+
async function matchesVersion(payload, version) {
|
|
272
|
+
const expectedVersion = typeof version === "string" ? version : await version(payload.session, payload.user);
|
|
273
|
+
return (payload.version || "1") === expectedVersion;
|
|
274
|
+
}
|
|
271
275
|
const getCookieCache = async (request, config) => {
|
|
272
276
|
const cookies = (request instanceof Headers || !("headers" in request) ? request : request.headers).get("cookie");
|
|
273
277
|
if (!cookies) return null;
|
|
@@ -297,21 +301,12 @@ const getCookieCache = async (request, config) => {
|
|
|
297
301
|
const secret = config?.secret || env.BETTER_AUTH_SECRET;
|
|
298
302
|
if (!secret) throw new BetterAuthError("getCookieCache requires a secret to be provided. Either pass it as an option or set the BETTER_AUTH_SECRET environment variable");
|
|
299
303
|
const payload = parseCookieCachePayload(await symmetricDecodeJWT(sessionData, secret, "better-auth-session"));
|
|
300
|
-
if (payload)
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
let expectedVersion = "1";
|
|
304
|
-
if (typeof config.version === "string") expectedVersion = config.version;
|
|
305
|
-
else if (typeof config.version === "function") {
|
|
306
|
-
const result = config.version(payload.session, payload.user);
|
|
307
|
-
expectedVersion = isPromise(result) ? await result : result;
|
|
308
|
-
}
|
|
309
|
-
if (cookieVersion !== expectedVersion) return null;
|
|
310
|
-
}
|
|
311
|
-
if (isEmbeddedSessionExpired(payload.session)) return null;
|
|
312
|
-
return payload;
|
|
304
|
+
if (!payload) return null;
|
|
305
|
+
if (config?.version) {
|
|
306
|
+
if (!await matchesVersion(payload, config.version)) return null;
|
|
313
307
|
}
|
|
314
|
-
return null;
|
|
308
|
+
if (isEmbeddedSessionExpired(payload.session)) return null;
|
|
309
|
+
return payload;
|
|
315
310
|
} else if (strategy === "jwt") {
|
|
316
311
|
const jwks = config?.jwt?.jwks;
|
|
317
312
|
let payload;
|
|
@@ -324,21 +319,12 @@ const getCookieCache = async (request, config) => {
|
|
|
324
319
|
if (!secret) throw new BetterAuthError("getCookieCache requires a secret to be provided. Either pass it as an option or set the BETTER_AUTH_SECRET environment variable");
|
|
325
320
|
payload = parseCookieCachePayload(await verifyJWT(sessionData, secret));
|
|
326
321
|
}
|
|
327
|
-
if (payload)
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
let expectedVersion = "1";
|
|
331
|
-
if (typeof config.version === "string") expectedVersion = config.version;
|
|
332
|
-
else if (typeof config.version === "function") {
|
|
333
|
-
const result = config.version(payload.session, payload.user);
|
|
334
|
-
expectedVersion = isPromise(result) ? await result : result;
|
|
335
|
-
}
|
|
336
|
-
if (cookieVersion !== expectedVersion) return null;
|
|
337
|
-
}
|
|
338
|
-
if (isEmbeddedSessionExpired(payload.session)) return null;
|
|
339
|
-
return payload;
|
|
322
|
+
if (!payload) return null;
|
|
323
|
+
if (config?.version) {
|
|
324
|
+
if (!await matchesVersion(payload, config.version)) return null;
|
|
340
325
|
}
|
|
341
|
-
return null;
|
|
326
|
+
if (isEmbeddedSessionExpired(payload.session)) return null;
|
|
327
|
+
return payload;
|
|
342
328
|
} else {
|
|
343
329
|
const secret = config?.secret || env.BETTER_AUTH_SECRET;
|
|
344
330
|
if (!secret) throw new BetterAuthError("getCookieCache requires a secret to be provided. Either pass it as an option or set the BETTER_AUTH_SECRET environment variable");
|
|
@@ -351,14 +337,7 @@ const getCookieCache = async (request, config) => {
|
|
|
351
337
|
const payload = parseCookieCachePayload(sessionDataPayload.session);
|
|
352
338
|
if (!payload) return null;
|
|
353
339
|
if (config?.version) {
|
|
354
|
-
|
|
355
|
-
let expectedVersion = "1";
|
|
356
|
-
if (typeof config.version === "string") expectedVersion = config.version;
|
|
357
|
-
else if (typeof config.version === "function") {
|
|
358
|
-
const result = config.version(payload.session, payload.user);
|
|
359
|
-
expectedVersion = isPromise(result) ? await result : result;
|
|
360
|
-
}
|
|
361
|
-
if (cookieVersion !== expectedVersion) return null;
|
|
340
|
+
if (!await matchesVersion(payload, config.version)) return null;
|
|
362
341
|
}
|
|
363
342
|
if (typeof sessionDataPayload.expiresAt === "number" && sessionDataPayload.expiresAt < Date.now()) return null;
|
|
364
343
|
if (isEmbeddedSessionExpired(payload.session)) return null;
|
|
@@ -115,10 +115,12 @@ function toDatabaseIndexMap(indexes) {
|
|
|
115
115
|
}];
|
|
116
116
|
}));
|
|
117
117
|
}
|
|
118
|
-
async function getDatabaseIndexMap(db,
|
|
118
|
+
async function getDatabaseIndexMap(db, target, tableNames, introspectIndexes) {
|
|
119
119
|
if (introspectIndexes) return toDatabaseIndexMap(await introspectIndexes(tableNames));
|
|
120
120
|
let rows;
|
|
121
|
-
|
|
121
|
+
switch (target.type) {
|
|
122
|
+
case "sqlite":
|
|
123
|
+
rows = (await sql`
|
|
122
124
|
SELECT
|
|
123
125
|
tables.name AS "tableName",
|
|
124
126
|
index_list.name AS "indexName",
|
|
@@ -131,7 +133,9 @@ async function getDatabaseIndexMap(db, dbType, schemaName, tableNames, introspec
|
|
|
131
133
|
INNER JOIN pragma_index_info(index_list.name) AS index_info
|
|
132
134
|
WHERE tables.type = 'table'
|
|
133
135
|
`.execute(db)).rows;
|
|
134
|
-
|
|
136
|
+
break;
|
|
137
|
+
case "postgres":
|
|
138
|
+
rows = (await sql`
|
|
135
139
|
SELECT
|
|
136
140
|
table_class.relname AS "tableName",
|
|
137
141
|
index_class.relname AS "indexName",
|
|
@@ -153,11 +157,13 @@ async function getDatabaseIndexMap(db, dbType, schemaName, tableNames, introspec
|
|
|
153
157
|
LEFT JOIN pg_attribute AS index_attribute
|
|
154
158
|
ON index_attribute.attrelid = table_class.oid
|
|
155
159
|
AND index_attribute.attnum = index_column.attribute_number
|
|
156
|
-
WHERE table_namespace.nspname = ${
|
|
160
|
+
WHERE table_namespace.nspname = ${target.schema}
|
|
157
161
|
AND table_class.relkind = 'r'
|
|
158
162
|
AND index_column.ordinality <= index_data.indnkeyatts
|
|
159
163
|
`.execute(db)).rows;
|
|
160
|
-
|
|
164
|
+
break;
|
|
165
|
+
case "mysql":
|
|
166
|
+
rows = (await sql`
|
|
161
167
|
SELECT
|
|
162
168
|
table_name AS tableName,
|
|
163
169
|
index_name AS indexName,
|
|
@@ -169,7 +175,9 @@ async function getDatabaseIndexMap(db, dbType, schemaName, tableNames, introspec
|
|
|
169
175
|
FROM information_schema.statistics
|
|
170
176
|
WHERE table_schema = DATABASE()
|
|
171
177
|
`.execute(db)).rows;
|
|
172
|
-
|
|
178
|
+
break;
|
|
179
|
+
case "mssql":
|
|
180
|
+
rows = (await sql`
|
|
173
181
|
SELECT
|
|
174
182
|
tables.name AS "tableName",
|
|
175
183
|
indexes.name AS "indexName",
|
|
@@ -190,10 +198,12 @@ async function getDatabaseIndexMap(db, dbType, schemaName, tableNames, introspec
|
|
|
190
198
|
INNER JOIN sys.columns AS columns
|
|
191
199
|
ON columns.object_id = index_columns.object_id
|
|
192
200
|
AND columns.column_id = index_columns.column_id
|
|
193
|
-
WHERE table_schemas.name = ${
|
|
201
|
+
WHERE table_schemas.name = ${target.schema}
|
|
194
202
|
AND indexes.name IS NOT NULL
|
|
195
203
|
AND index_columns.key_ordinal > 0
|
|
196
204
|
`.execute(db)).rows;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
197
207
|
const indexMetadata = /* @__PURE__ */ new Map();
|
|
198
208
|
for (const row of rows) {
|
|
199
209
|
const table = row.tableName ?? row.table_name ?? row.TABLE_NAME ?? row.tablename ?? row.tbl_name;
|
|
@@ -228,46 +238,45 @@ async function getDatabaseIndexMap(db, dbType, schemaName, tableNames, introspec
|
|
|
228
238
|
}
|
|
229
239
|
return toDatabaseIndexMap([...indexMetadata.values()]);
|
|
230
240
|
}
|
|
231
|
-
async function getDatabaseColumnBounds(db,
|
|
232
|
-
if (dbType !== "mysql" && dbType !== "mssql") return /* @__PURE__ */ new Map();
|
|
241
|
+
async function getDatabaseColumnBounds(db, target) {
|
|
233
242
|
let rows;
|
|
234
|
-
|
|
243
|
+
switch (target.type) {
|
|
244
|
+
case "postgres":
|
|
245
|
+
case "sqlite": return /* @__PURE__ */ new Map();
|
|
246
|
+
case "mysql":
|
|
247
|
+
rows = (await sql`
|
|
235
248
|
SELECT
|
|
236
249
|
table_name AS tableName,
|
|
237
250
|
column_name AS columnName,
|
|
238
|
-
|
|
239
|
-
character_maximum_length AS characterMaximumLength
|
|
251
|
+
character_octet_length AS maxIndexBytes
|
|
240
252
|
FROM information_schema.columns
|
|
241
253
|
WHERE table_schema = DATABASE()
|
|
242
254
|
`.execute(db)).rows;
|
|
243
|
-
|
|
255
|
+
break;
|
|
256
|
+
case "mssql":
|
|
257
|
+
rows = (await sql`
|
|
244
258
|
SELECT
|
|
245
259
|
tables.name AS "tableName",
|
|
246
260
|
columns.name AS "columnName",
|
|
247
|
-
|
|
248
|
-
columns.max_length AS "maxLength"
|
|
261
|
+
columns.max_length AS "maxIndexBytes"
|
|
249
262
|
FROM sys.columns AS columns
|
|
250
263
|
INNER JOIN sys.tables AS tables
|
|
251
264
|
ON tables.object_id = columns.object_id
|
|
252
265
|
INNER JOIN sys.schemas AS table_schemas
|
|
253
266
|
ON table_schemas.schema_id = tables.schema_id
|
|
254
|
-
|
|
255
|
-
ON types.user_type_id = columns.user_type_id
|
|
256
|
-
WHERE table_schemas.name = ${schemaName}
|
|
267
|
+
WHERE table_schemas.name = ${target.schema}
|
|
257
268
|
`.execute(db)).rows;
|
|
258
|
-
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
const bounds = /* @__PURE__ */ new Map();
|
|
272
|
+
for (const row of rows) {
|
|
259
273
|
const table = row.tableName ?? row.TABLE_NAME;
|
|
260
274
|
const column = row.columnName ?? row.COLUMN_NAME;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return [[createDatabaseColumnKey(table, column), { maxIndexBytes }]];
|
|
267
|
-
}
|
|
268
|
-
const maxLength = Number(row.maxLength ?? -1);
|
|
269
|
-
return [[createDatabaseColumnKey(table, column), { maxIndexBytes: maxLength < 0 ? null : maxLength }]];
|
|
270
|
-
}));
|
|
275
|
+
if (!table || !column) continue;
|
|
276
|
+
const maxIndexBytes = Number(row.maxIndexBytes ?? row.MAX_INDEX_BYTES ?? -1);
|
|
277
|
+
bounds.set(createDatabaseColumnKey(table, column), { maxIndexBytes: maxIndexBytes < 0 ? null : maxIndexBytes });
|
|
278
|
+
}
|
|
279
|
+
return bounds;
|
|
271
280
|
}
|
|
272
281
|
function assertExistingTableIndexFits({ columnBounds, dbType, existingColumns, fields, indexes, index, table }) {
|
|
273
282
|
const byteBudget = dbType === "mysql" ? 3072 : 1700;
|
|
@@ -341,7 +350,7 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
|
|
|
341
350
|
if (throwOnUnsafe) throw new UnsafeMigrationError(message);
|
|
342
351
|
unsafeChanges.push(message);
|
|
343
352
|
};
|
|
344
|
-
let { kysely: db, databaseType: dbType, introspectIndexes } = await createKyselyAdapter(config);
|
|
353
|
+
let { kysely: db, databaseType: dbType, introspectIndexes, schemaName } = await createKyselyAdapter(config);
|
|
345
354
|
if (!dbType) {
|
|
346
355
|
logger.warn("Could not determine database type, defaulting to sqlite. Please provide a type in the database options to avoid this.");
|
|
347
356
|
dbType = "sqlite";
|
|
@@ -350,39 +359,50 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
|
|
|
350
359
|
logger.error("Only kysely adapter is supported for migrations. You can use `generate` command to generate the schema, if you're using a different adapter.");
|
|
351
360
|
process.exit(1);
|
|
352
361
|
}
|
|
353
|
-
let currentSchema = dbType === "mssql" ? await getMssqlSchema(db) : "public";
|
|
354
|
-
if (dbType === "postgres") {
|
|
355
|
-
currentSchema = await getPostgresSchema(db);
|
|
356
|
-
logger.debug(`PostgreSQL migration: Using schema '${currentSchema}' (from search_path)`);
|
|
357
|
-
try {
|
|
358
|
-
const schemaCheck = await sql`
|
|
359
|
-
SELECT schema_name
|
|
360
|
-
FROM information_schema.schemata
|
|
361
|
-
WHERE schema_name = ${currentSchema}
|
|
362
|
-
`.execute(db);
|
|
363
|
-
if (!(schemaCheck.rows[0]?.schema_name ?? schemaCheck.rows[0]?.schemaName)) logger.warn(`Schema '${currentSchema}' does not exist. Tables will be inspected from available schemas. Consider creating the schema first or checking your database configuration.`);
|
|
364
|
-
} catch (error) {
|
|
365
|
-
logger.debug(`Could not verify schema existence: ${error instanceof Error ? error.message : String(error)}`);
|
|
366
|
-
}
|
|
367
|
-
} else if (dbType === "mssql") logger.debug(`SQL Server migration: Using schema '${currentSchema}' (from the current user's default schema)`);
|
|
368
362
|
const allTableMetadata = await db.introspection.getTables();
|
|
369
|
-
|
|
370
|
-
const databaseColumnBounds = await getDatabaseColumnBounds(db, dbType, currentSchema);
|
|
363
|
+
let target;
|
|
371
364
|
let tableMetadata = allTableMetadata;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
365
|
+
switch (dbType) {
|
|
366
|
+
case "postgres": {
|
|
367
|
+
const schema = schemaName ?? await getPostgresSchema(db);
|
|
368
|
+
target = {
|
|
369
|
+
type: "postgres",
|
|
370
|
+
schema
|
|
371
|
+
};
|
|
372
|
+
logger.debug(`PostgreSQL migration: Using schema '${schema}' (${schemaName ? "from database.schemaName" : "from search_path"})`);
|
|
373
|
+
try {
|
|
374
|
+
if (!(await db.introspection.getSchemas()).some(({ name }) => name === schema)) if (schemaName) logger.debug(`Schema '${schema}' does not exist yet. The migration creates it before creating tables.`);
|
|
375
|
+
else logger.warn(`Schema '${schema}' does not exist. Create it before running migrations or check your database configuration.`);
|
|
376
|
+
} catch (error) {
|
|
377
|
+
logger.debug(`Could not verify schema existence: ${error instanceof Error ? error.message : String(error)}`);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Kysely 0.28 does not expose `isForeign`, while 0.29 adds foreign table metadata.
|
|
381
|
+
* @see https://github.com/kysely-org/kysely/pull/1494
|
|
382
|
+
*/
|
|
383
|
+
tableMetadata = allTableMetadata.filter((table) => table.schema === schema && !table.isView && !("isForeign" in table && table.isForeign));
|
|
384
|
+
logger.debug(`Found ${tableMetadata.length} table(s) in schema '${schema}': ${tableMetadata.map((table) => table.name).join(", ") || "(none)"}`);
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
case "mssql": {
|
|
388
|
+
const schema = await getMssqlSchema(db);
|
|
389
|
+
target = {
|
|
390
|
+
type: "mssql",
|
|
391
|
+
schema
|
|
392
|
+
};
|
|
393
|
+
logger.debug(`SQL Server migration: Using schema '${schema}' (from the current user's default schema)`);
|
|
394
|
+
tableMetadata = allTableMetadata.filter((table) => table.schema === schema);
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
case "mysql":
|
|
398
|
+
target = { type: "mysql" };
|
|
399
|
+
break;
|
|
400
|
+
case "sqlite":
|
|
401
|
+
target = { type: "sqlite" };
|
|
402
|
+
break;
|
|
384
403
|
}
|
|
385
|
-
|
|
404
|
+
const databaseIndexMap = await getDatabaseIndexMap(db, target, allTableMetadata.map((table) => table.name), introspectIndexes);
|
|
405
|
+
const databaseColumnBounds = await getDatabaseColumnBounds(db, target);
|
|
386
406
|
const schemaProblems = diffSchema(toPhysicalSchema(db, betterAuthSchema), toIntrospectedTables(tableMetadata)).filter((finding) => finding.kind === "unexpected-required-column").map((finding) => formatSchemaFinding(finding, "database"));
|
|
387
407
|
const toBeCreated = [];
|
|
388
408
|
const toBeAdded = [];
|
|
@@ -464,6 +484,7 @@ async function getMigrations(config, { throwOnUnsafe = true } = {}) {
|
|
|
464
484
|
});
|
|
465
485
|
}
|
|
466
486
|
const migrations = [];
|
|
487
|
+
if (schemaName && toBeCreated.length > 0) migrations.push(db.schema.createSchema(schemaName).ifNotExists());
|
|
467
488
|
const useUUIDs = config.advanced?.database?.generateId === "uuid";
|
|
468
489
|
const useNumberId = config.advanced?.database?.generateId === "serial";
|
|
469
490
|
function getType(field, fieldName, tableIndexStringLength) {
|
package/dist/db/with-hooks.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getCurrentAdapter, queueAfterTransactionHook, tryGetCurrentAuthEndpointContext } from "@better-auth/core/context";
|
|
2
|
-
import { ATTR_CONTEXT, ATTR_DB_COLLECTION_NAME, ATTR_HOOK_TYPE,
|
|
2
|
+
import { ATTR_CONTEXT, ATTR_DB_COLLECTION_NAME, ATTR_HOOK_TYPE, createWithSpan } from "@better-auth/core/instrumentation";
|
|
3
3
|
//#region src/db/with-hooks.ts
|
|
4
4
|
function getWithHooks(adapter, ctx) {
|
|
5
|
+
const withSpan = createWithSpan(ctx.options);
|
|
5
6
|
const hooksEntries = ctx.hooks;
|
|
6
7
|
async function createWithHooks(data, model, customCreateFn) {
|
|
7
8
|
const context = tryGetCurrentAuthEndpointContext();
|
package/dist/package.mjs
CHANGED
|
@@ -297,13 +297,13 @@ declare const admin: <O extends AdminOptions>(options?: O | undefined) => {
|
|
|
297
297
|
filterField: _$zod.ZodOptional<_$zod.ZodString>;
|
|
298
298
|
filterValue: _$zod.ZodOptional<_$zod.ZodUnion<[_$zod.ZodUnion<[_$zod.ZodUnion<[_$zod.ZodUnion<[_$zod.ZodString, _$zod.ZodNumber]>, _$zod.ZodBoolean]>, _$zod.ZodArray<_$zod.ZodString>]>, _$zod.ZodArray<_$zod.ZodNumber>]>>;
|
|
299
299
|
filterOperator: _$zod.ZodOptional<_$zod.ZodEnum<{
|
|
300
|
+
in: "in";
|
|
301
|
+
lte: "lte";
|
|
300
302
|
eq: "eq";
|
|
301
303
|
ne: "ne";
|
|
304
|
+
lt: "lt";
|
|
302
305
|
gt: "gt";
|
|
303
306
|
gte: "gte";
|
|
304
|
-
lt: "lt";
|
|
305
|
-
lte: "lte";
|
|
306
|
-
in: "in";
|
|
307
307
|
not_in: "not_in";
|
|
308
308
|
contains: "contains";
|
|
309
309
|
starts_with: "starts_with";
|
|
@@ -42,6 +42,7 @@ const captcha = (options) => ({
|
|
|
42
42
|
};
|
|
43
43
|
if (options.provider === Providers.CLOUDFLARE_TURNSTILE) return await cloudflareTurnstile({
|
|
44
44
|
...handlerParams,
|
|
45
|
+
logger: ctx.logger,
|
|
45
46
|
expectedAction: options.expectedAction,
|
|
46
47
|
allowedHostnames: options.allowedHostnames
|
|
47
48
|
});
|
|
@@ -3,7 +3,7 @@ import { CAPTCHA_VERIFY_TIMEOUT_MS } from "../constants.mjs";
|
|
|
3
3
|
import { EXTERNAL_ERROR_CODES, INTERNAL_ERROR_CODES } from "../error-codes.mjs";
|
|
4
4
|
import { betterFetch } from "@better-fetch/fetch";
|
|
5
5
|
//#region src/plugins/captcha/verify-handlers/cloudflare-turnstile.ts
|
|
6
|
-
const cloudflareTurnstile = async ({ siteVerifyURL, captchaResponse, secretKey, remoteIP, expectedAction, allowedHostnames }) => {
|
|
6
|
+
const cloudflareTurnstile = async ({ siteVerifyURL, captchaResponse, secretKey, logger, remoteIP, expectedAction, allowedHostnames }) => {
|
|
7
7
|
const response = await betterFetch(siteVerifyURL, {
|
|
8
8
|
method: "POST",
|
|
9
9
|
timeout: CAPTCHA_VERIFY_TIMEOUT_MS,
|
|
@@ -15,14 +15,33 @@ const cloudflareTurnstile = async ({ siteVerifyURL, captchaResponse, secretKey,
|
|
|
15
15
|
})
|
|
16
16
|
});
|
|
17
17
|
if (!response.data || response.error) throw new Error(INTERNAL_ERROR_CODES.SERVICE_UNAVAILABLE.message);
|
|
18
|
-
const verificationFailed = () =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const verificationFailed = (details) => {
|
|
19
|
+
logger.warn("Cloudflare Turnstile verification failed", {
|
|
20
|
+
provider: "cloudflare-turnstile",
|
|
21
|
+
...details
|
|
22
|
+
});
|
|
23
|
+
return middlewareResponse({
|
|
24
|
+
message: EXTERNAL_ERROR_CODES.VERIFICATION_FAILED.message,
|
|
25
|
+
code: EXTERNAL_ERROR_CODES.VERIFICATION_FAILED.code,
|
|
26
|
+
status: 403
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
if (!response.data.success) return verificationFailed({
|
|
30
|
+
reason: "siteverify_rejected",
|
|
31
|
+
errorCodes: response.data["error-codes"] ?? [],
|
|
32
|
+
...response.data.hostname && { hostname: response.data.hostname },
|
|
33
|
+
...response.data.action && { action: response.data.action }
|
|
34
|
+
});
|
|
35
|
+
if (expectedAction && response.data.action !== expectedAction) return verificationFailed({
|
|
36
|
+
reason: "action_mismatch",
|
|
37
|
+
expectedAction,
|
|
38
|
+
actualAction: response.data.action
|
|
39
|
+
});
|
|
40
|
+
if (allowedHostnames && allowedHostnames.length > 0 && !(response.data.hostname && allowedHostnames.includes(response.data.hostname))) return verificationFailed({
|
|
41
|
+
reason: "hostname_mismatch",
|
|
42
|
+
allowedHostnames,
|
|
43
|
+
actualHostname: response.data.hostname
|
|
22
44
|
});
|
|
23
|
-
if (!response.data.success) return verificationFailed();
|
|
24
|
-
if (expectedAction && response.data.action !== expectedAction) return verificationFailed();
|
|
25
|
-
if (allowedHostnames && allowedHostnames.length > 0 && !(response.data.hostname && allowedHostnames.includes(response.data.hostname))) return verificationFailed();
|
|
26
45
|
};
|
|
27
46
|
//#endregion
|
|
28
47
|
export { cloudflareTurnstile };
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -53,7 +53,7 @@ import { OpenAPIOptions, openAPI } from "./open-api/index.mjs";
|
|
|
53
53
|
import { PhoneNumberOptions, UserWithPhoneNumber } from "./phone-number/types.mjs";
|
|
54
54
|
import { phoneNumber } from "./phone-number/index.mjs";
|
|
55
55
|
import { SIWEPluginOptions, siwe } from "./siwe/index.mjs";
|
|
56
|
-
import { LoginResult, TestCookie, TestHelpers, TestUtilsOptions } from "./test-utils/types.mjs";
|
|
56
|
+
import { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions } from "./test-utils/types.mjs";
|
|
57
57
|
import { testUtils } from "./test-utils/index.mjs";
|
|
58
58
|
import { BackupCodeOptions, backupCode2fa, encodeBackupCodes, generateBackupCodes, getBackupCodes, verifyBackupCode } from "./two-factor/backup-codes/index.mjs";
|
|
59
59
|
import { OTPOptions, otp2fa } from "./two-factor/otp/index.mjs";
|
|
@@ -66,4 +66,4 @@ import { USERNAME_ERROR_CODES } from "./username/error-codes.mjs";
|
|
|
66
66
|
import { UsernameOptions, UsernamePlugin, UsernamePluginWithoutDisplayUsername, username } from "./username/index.mjs";
|
|
67
67
|
import { hasPermission } from "./organization/has-permission.mjs";
|
|
68
68
|
import { DefaultOrganizationPlugin, DynamicAccessControlEndpoints, OrganizationCreator, OrganizationEndpoints, OrganizationPlugin, TeamEndpoints, organization, parseRoles } from "./organization/organization.mjs";
|
|
69
|
-
export { AccessControl, AdminOptions, AnonymousOptions, AnonymousSession, ArrayElement, Auth0Options, AuthorizeResponse, BackupCodeOptions, BaseCaptchaOptions, BaseOAuthProviderOptions, BearerOptions, CaptchaFoxOptions, CaptchaOptions, CloudflareTurnstileOptions, CustomSessionPluginOptions, DefaultOrganizationPlugin, DeviceAuthorizationGrant, DeviceAuthorizationGrantAuthorization, DeviceAuthorizationOptions, DeviceAuthorizationPluginOptions, DeviceAuthorizationRequest, DeviceCode, DeviceCodeRedemptionAuthorization, DeviceCodeRedemptionResult, DynamicAccessControlEndpoints, MULTI_SESSION_ERROR_CODES as ERROR_CODES, EmailOTPOptions, ExactRoleStatements, FieldSchema, GenericOAuthConfig, GenericOAuthOptions, GenericOAuthUserInfo, GoogleRecaptchaOptions, GumroadOptions, HCaptchaOptions, HIDE_METADATA, HaveIBeenPwnedOptions, HubSpotOptions, InferAdminRolesFromOption, InferInvitation, InferMember, InferOptionSchema, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginContext, InferPluginErrorCodes, InferPluginIDs, InferTeam, Invitation, InvitationInput, InvitationStatus, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, KeycloakOptions, LastLoginMethodOptions, LineOptions, LoginResult, MagicLinkOptions, Member, MemberInput, MicrosoftEntraIdOptions, MultiSessionConfig, OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, OAuthPopupData, OAuthPopupMessage, OAuthProxyOptions, OTPOptions, OktaOptions, OneTapOptions, OneTimeTokenOptions, OpenAPIModelSchema, OpenAPIOptions, OpenAPIParameter, OpenAPISchema, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, POPUP_MARKER_COOKIE, Path, PatreonOptions, PhoneNumberOptions, Provider, ResolvedSigningKey, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, SIWEPluginOptions, SessionWithImpersonatedBy, SlackOptions, Statements, SubArray, Subset, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, TestCookie, TestHelpers, TestUtilsOptions, TimeString, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UserWithAnonymous, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, UsernameOptions, UsernamePlugin, UsernamePluginWithoutDisplayUsername, YandexOptions, admin, anonymous, auth0, backupCode2fa, bearer, captcha, createAccessControl, createJwk, customSession, defaultRolesSchema, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, encodeBackupCodes, generateBackupCodes, generateExportedKeyPair, generator, genericOAuth, getBackupCodes, getJwtToken, getOrgAdapter, gumroad, hasPermission, haveIBeenPwned, hubspot, invitationSchema, invitationStatus, isPasswordCompromised, jwt, keycloak, lastLoginMethod, line, magicLink, memberSchema, microsoftEntraId, ms, multiSession, oAuthProxy, oauthPopup, okta, oneTap, oneTimeToken, openAPI, organization, organizationRoleSchema, organizationSchema, otp2fa, parseRoles, patreon, phoneNumber, redeemDeviceCode, resolveSigningKey, role, roleSchema, sec, signJWT, siwe, slack, teamMemberSchema, teamSchema, testUtils, toExpJWT, totp2fa, twoFactor, twoFactorClient, username, verifyBackupCode, verifyJWT, yandex };
|
|
69
|
+
export { AccessControl, AdminOptions, AnonymousOptions, AnonymousSession, ArrayElement, Auth0Options, AuthorizeResponse, BackupCodeOptions, BaseCaptchaOptions, BaseOAuthProviderOptions, BearerOptions, CaptchaFoxOptions, CaptchaOptions, CloudflareTurnstileOptions, CustomSessionPluginOptions, DefaultOrganizationPlugin, DeviceAuthorizationGrant, DeviceAuthorizationGrantAuthorization, DeviceAuthorizationOptions, DeviceAuthorizationPluginOptions, DeviceAuthorizationRequest, DeviceCode, DeviceCodeRedemptionAuthorization, DeviceCodeRedemptionResult, DynamicAccessControlEndpoints, MULTI_SESSION_ERROR_CODES as ERROR_CODES, EmailOTPOptions, ExactRoleStatements, FieldSchema, GenericOAuthConfig, GenericOAuthOptions, GenericOAuthUserInfo, GoogleRecaptchaOptions, GumroadOptions, HCaptchaOptions, HIDE_METADATA, HaveIBeenPwnedOptions, HubSpotOptions, InferAdminRolesFromOption, InferInvitation, InferMember, InferOptionSchema, InferOrganization, InferOrganizationRolesFromOption, InferOrganizationZodRolesFromOption, InferPluginContext, InferPluginErrorCodes, InferPluginIDs, InferTeam, Invitation, InvitationInput, InvitationStatus, JWKOptions, JWSAlgorithms, Jwk, JwtOptions, KeycloakOptions, LastLoginMethodOptions, LineOptions, LoginResult, MagicLinkOptions, Member, MemberInput, MicrosoftEntraIdOptions, MultiSessionConfig, OAUTH_POPUP_COMPLETE_SCRIPT, OAUTH_POPUP_DATA_ELEMENT_ID, OAUTH_POPUP_ERROR_CODES, OAUTH_POPUP_MESSAGE_TYPE, OAUTH_POPUP_SCRIPT_CSP_HASH, OAuthPopupData, OAuthPopupMessage, OAuthProxyOptions, OTPOptions, OktaOptions, OneTapOptions, OneTimeTokenOptions, OpenAPIModelSchema, OpenAPIOptions, OpenAPIParameter, OpenAPISchema, Organization, OrganizationCreator, OrganizationEndpoints, OrganizationInput, OrganizationOptions, OrganizationPlugin, OrganizationRole, OrganizationSchema, POPUP_MARKER_COOKIE, Path, PatreonOptions, PhoneNumberOptions, Provider, ResolvedSigningKey, Role, RoleAuthorizeRequest, RoleInput, RoleStatements, SIWEPluginOptions, SessionWithImpersonatedBy, SlackOptions, Statements, SubArray, Subset, TOTPOptions, TWO_FACTOR_ERROR_CODES, Team, TeamEndpoints, TeamInput, TeamMember, TeamMemberInput, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions, TimeString, TwoFactorOptions, TwoFactorProvider, TwoFactorTable, USERNAME_ERROR_CODES, UserWithAnonymous, UserWithPhoneNumber, UserWithRole, UserWithTwoFactor, UsernameOptions, UsernamePlugin, UsernamePluginWithoutDisplayUsername, YandexOptions, admin, anonymous, auth0, backupCode2fa, bearer, captcha, createAccessControl, createJwk, customSession, defaultRolesSchema, deviceAuthorization, deviceAuthorizationOptionsSchema, emailOTP, encodeBackupCodes, generateBackupCodes, generateExportedKeyPair, generator, genericOAuth, getBackupCodes, getJwtToken, getOrgAdapter, gumroad, hasPermission, haveIBeenPwned, hubspot, invitationSchema, invitationStatus, isPasswordCompromised, jwt, keycloak, lastLoginMethod, line, magicLink, memberSchema, microsoftEntraId, ms, multiSession, oAuthProxy, oauthPopup, okta, oneTap, oneTimeToken, openAPI, organization, organizationRoleSchema, organizationSchema, otp2fa, parseRoles, patreon, phoneNumber, redeemDeviceCode, resolveSigningKey, role, roleSchema, sec, signJWT, siwe, slack, teamMemberSchema, teamSchema, testUtils, toExpJWT, totp2fa, twoFactor, twoFactorClient, username, verifyBackupCode, verifyJWT, yandex };
|
|
@@ -736,13 +736,13 @@ declare const listMembers: <O extends OrganizationOptions>(options: O) => _$bett
|
|
|
736
736
|
filterField: z.ZodOptional<z.ZodString>;
|
|
737
737
|
filterValue: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber]>, z.ZodBoolean]>, z.ZodArray<z.ZodString>]>, z.ZodArray<z.ZodNumber>]>>;
|
|
738
738
|
filterOperator: z.ZodOptional<z.ZodEnum<{
|
|
739
|
+
in: "in";
|
|
740
|
+
lte: "lte";
|
|
739
741
|
eq: "eq";
|
|
740
742
|
ne: "ne";
|
|
743
|
+
lt: "lt";
|
|
741
744
|
gt: "gt";
|
|
742
745
|
gte: "gte";
|
|
743
|
-
lt: "lt";
|
|
744
|
-
lte: "lte";
|
|
745
|
-
in: "in";
|
|
746
746
|
not_in: "not_in";
|
|
747
747
|
contains: "contains";
|
|
748
748
|
starts_with: "starts_with";
|
|
@@ -244,10 +244,10 @@ type OrganizationSchema<O extends OrganizationOptions> = (O["dynamicAccessContro
|
|
|
244
244
|
};
|
|
245
245
|
declare const roleSchema: z.ZodString;
|
|
246
246
|
declare const invitationStatus: z.ZodDefault<z.ZodEnum<{
|
|
247
|
-
canceled: "canceled";
|
|
248
247
|
pending: "pending";
|
|
249
248
|
accepted: "accepted";
|
|
250
249
|
rejected: "rejected";
|
|
250
|
+
canceled: "canceled";
|
|
251
251
|
}>>;
|
|
252
252
|
declare const organizationSchema: z.ZodObject<{
|
|
253
253
|
id: z.ZodDefault<z.ZodString>;
|
|
@@ -270,10 +270,10 @@ declare const invitationSchema: z.ZodObject<{
|
|
|
270
270
|
email: z.ZodString;
|
|
271
271
|
role: z.ZodString;
|
|
272
272
|
status: z.ZodDefault<z.ZodEnum<{
|
|
273
|
-
canceled: "canceled";
|
|
274
273
|
pending: "pending";
|
|
275
274
|
accepted: "accepted";
|
|
276
275
|
rejected: "rejected";
|
|
276
|
+
canceled: "canceled";
|
|
277
277
|
}>>;
|
|
278
278
|
teamId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
279
279
|
inviterId: z.ZodString;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { createCookieHeaders, createTestCookie } from "./cookie-builder.mjs";
|
|
2
|
+
import { sessionSchema } from "@better-auth/core/db";
|
|
2
3
|
//#region src/plugins/test-utils/auth-helpers.ts
|
|
4
|
+
function createSession(ctx, opts) {
|
|
5
|
+
const additionalFields = Object.fromEntries(Object.entries(opts.session ?? {}).filter(([key]) => !Object.hasOwn(sessionSchema.shape, key)));
|
|
6
|
+
return ctx.internalAdapter.createSession(opts.userId, false, additionalFields, true);
|
|
7
|
+
}
|
|
3
8
|
function createLogin(ctx) {
|
|
4
9
|
return async (opts) => {
|
|
5
10
|
const user = await ctx.internalAdapter.findUserById(opts.userId);
|
|
6
11
|
if (!user) throw new Error(`User not found: ${opts.userId}`);
|
|
7
|
-
const session = await
|
|
12
|
+
const session = await createSession(ctx, opts);
|
|
8
13
|
return {
|
|
9
14
|
session,
|
|
10
15
|
user,
|
|
@@ -16,12 +21,12 @@ function createLogin(ctx) {
|
|
|
16
21
|
}
|
|
17
22
|
function createGetAuthHeaders(ctx) {
|
|
18
23
|
return async (opts) => {
|
|
19
|
-
return createCookieHeaders(ctx, (await
|
|
24
|
+
return createCookieHeaders(ctx, (await createSession(ctx, opts)).token);
|
|
20
25
|
};
|
|
21
26
|
}
|
|
22
27
|
function createGetCookies(ctx) {
|
|
23
28
|
return async (opts) => {
|
|
24
|
-
return createTestCookie(ctx, (await
|
|
29
|
+
return createTestCookie(ctx, (await createSession(ctx, opts)).token, opts.domain);
|
|
25
30
|
};
|
|
26
31
|
}
|
|
27
32
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoginResult, TestCookie, TestHelpers, TestUtilsOptions } from "./types.mjs";
|
|
1
|
+
import { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions } from "./types.mjs";
|
|
2
2
|
import * as _$_better_auth_core0 from "@better-auth/core";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/test-utils/index.d.ts
|
|
@@ -21,6 +21,12 @@ interface LoginResult {
|
|
|
21
21
|
cookies: TestCookie[];
|
|
22
22
|
token: string;
|
|
23
23
|
}
|
|
24
|
+
/** Options for creating a session with the test auth helpers. */
|
|
25
|
+
interface TestAuthOptions {
|
|
26
|
+
userId: string;
|
|
27
|
+
/** Additional session fields. Standard session fields are ignored. */
|
|
28
|
+
session?: Record<string, unknown>;
|
|
29
|
+
}
|
|
24
30
|
interface TestHelpers {
|
|
25
31
|
createUser(overrides?: Partial<User> & Record<string, unknown>): User;
|
|
26
32
|
createOrganization?(overrides?: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -33,18 +39,13 @@ interface TestHelpers {
|
|
|
33
39
|
}): Promise<Record<string, unknown>>;
|
|
34
40
|
deleteUser(userId: string): Promise<void>;
|
|
35
41
|
deleteOrganization?(orgId: string): Promise<void>;
|
|
36
|
-
login(opts:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
getAuthHeaders(opts: {
|
|
40
|
-
userId: string;
|
|
41
|
-
}): Promise<Headers>;
|
|
42
|
-
getCookies(opts: {
|
|
43
|
-
userId: string;
|
|
42
|
+
login(opts: TestAuthOptions): Promise<LoginResult>;
|
|
43
|
+
getAuthHeaders(opts: TestAuthOptions): Promise<Headers>;
|
|
44
|
+
getCookies(opts: TestAuthOptions & {
|
|
44
45
|
domain?: string;
|
|
45
46
|
}): Promise<TestCookie[]>;
|
|
46
47
|
getOTP?(identifier: string): string | undefined;
|
|
47
48
|
clearOTPs?(): void;
|
|
48
49
|
}
|
|
49
50
|
//#endregion
|
|
50
|
-
export { LoginResult, TestCookie, TestHelpers, TestUtilsOptions };
|
|
51
|
+
export { LoginResult, TestAuthOptions, TestCookie, TestHelpers, TestUtilsOptions };
|
|
@@ -266,14 +266,14 @@ declare const usernameImpl: <IncludeDisplayUsername extends boolean>(options: Us
|
|
|
266
266
|
unique: true;
|
|
267
267
|
returned: true;
|
|
268
268
|
transform: {
|
|
269
|
-
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> |
|
|
269
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
270
270
|
};
|
|
271
271
|
};
|
|
272
272
|
displayUsername: {
|
|
273
273
|
type: "string";
|
|
274
274
|
required: false;
|
|
275
275
|
transform: {
|
|
276
|
-
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> |
|
|
276
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
277
277
|
};
|
|
278
278
|
};
|
|
279
279
|
}, "username"> : {
|
|
@@ -284,14 +284,14 @@ declare const usernameImpl: <IncludeDisplayUsername extends boolean>(options: Us
|
|
|
284
284
|
unique: true;
|
|
285
285
|
returned: true;
|
|
286
286
|
transform: {
|
|
287
|
-
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> |
|
|
287
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
288
288
|
};
|
|
289
289
|
};
|
|
290
290
|
displayUsername: {
|
|
291
291
|
type: "string";
|
|
292
292
|
required: false;
|
|
293
293
|
transform: {
|
|
294
|
-
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> |
|
|
294
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
295
295
|
};
|
|
296
296
|
};
|
|
297
297
|
};
|
|
@@ -14,14 +14,14 @@ declare const getSchema: <IncludeDisplayUsername extends boolean = true>(normali
|
|
|
14
14
|
unique: true;
|
|
15
15
|
returned: true;
|
|
16
16
|
transform: {
|
|
17
|
-
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> |
|
|
17
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
displayUsername: {
|
|
21
21
|
type: "string";
|
|
22
22
|
required: false;
|
|
23
23
|
transform: {
|
|
24
|
-
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> |
|
|
24
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
}, "username"> : {
|
|
@@ -32,14 +32,14 @@ declare const getSchema: <IncludeDisplayUsername extends boolean = true>(normali
|
|
|
32
32
|
unique: true;
|
|
33
33
|
returned: true;
|
|
34
34
|
transform: {
|
|
35
|
-
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> |
|
|
35
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
displayUsername: {
|
|
39
39
|
type: "string";
|
|
40
40
|
required: false;
|
|
41
41
|
transform: {
|
|
42
|
-
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | Record<string, unknown> |
|
|
42
|
+
input(value: _$_better_auth_core_db0.DBPrimitive): string | number | boolean | Date | unknown[] | Record<string, unknown> | null | undefined;
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
45
|
};
|
|
@@ -88,17 +88,17 @@ declare function getHttpTestInstance<O extends Partial<BetterAuthOptions>, C ext
|
|
|
88
88
|
onResponse: ((context: _$_better_fetch_fetch0.ResponseContext) => Promise<Response | void | _$_better_fetch_fetch0.ResponseContext> | Response | _$_better_fetch_fetch0.ResponseContext | void) | undefined;
|
|
89
89
|
};
|
|
90
90
|
})[];
|
|
91
|
-
priority?: RequestPriority | undefined;
|
|
92
91
|
cache?: RequestCache | undefined;
|
|
93
92
|
credentials?: RequestCredentials;
|
|
94
93
|
integrity?: string | undefined;
|
|
95
94
|
keepalive?: boolean | undefined;
|
|
96
95
|
method: string;
|
|
97
96
|
mode?: RequestMode | undefined;
|
|
97
|
+
priority?: RequestPriority | undefined;
|
|
98
98
|
redirect?: RequestRedirect | undefined;
|
|
99
99
|
referrer?: string | undefined;
|
|
100
100
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
101
|
-
signal?:
|
|
101
|
+
signal?: AbortSignal | null;
|
|
102
102
|
window?: null | undefined;
|
|
103
103
|
onRetry?: ((response: _$_better_fetch_fetch0.ResponseContext) => Promise<void> | void) | undefined;
|
|
104
104
|
hookOptions?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "The most comprehensive authentication framework for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -464,7 +464,7 @@
|
|
|
464
464
|
},
|
|
465
465
|
"dependencies": {
|
|
466
466
|
"@better-auth/utils": "0.4.2",
|
|
467
|
-
"@better-fetch/fetch": "1.3.
|
|
467
|
+
"@better-fetch/fetch": "1.3.2",
|
|
468
468
|
"@noble/ciphers": "^2.2.0",
|
|
469
469
|
"@noble/hashes": "^2.2.0",
|
|
470
470
|
"better-call": "1.4.0",
|
|
@@ -473,13 +473,13 @@
|
|
|
473
473
|
"kysely": "^0.28.17 || ^0.29.0",
|
|
474
474
|
"nanostores": "^1.3.0",
|
|
475
475
|
"zod": "^4.5.4",
|
|
476
|
-
"@better-auth/core": "1.7.
|
|
477
|
-
"@better-auth/drizzle-adapter": "1.7.
|
|
478
|
-
"@better-auth/kysely-adapter": "1.7.
|
|
479
|
-
"@better-auth/memory-adapter": "1.7.
|
|
480
|
-
"@better-auth/mongo-adapter": "1.7.
|
|
481
|
-
"@better-auth/prisma-adapter": "1.7.
|
|
482
|
-
"@better-auth/telemetry": "1.7.
|
|
476
|
+
"@better-auth/core": "1.7.5",
|
|
477
|
+
"@better-auth/drizzle-adapter": "1.7.5",
|
|
478
|
+
"@better-auth/kysely-adapter": "1.7.5",
|
|
479
|
+
"@better-auth/memory-adapter": "1.7.5",
|
|
480
|
+
"@better-auth/mongo-adapter": "1.7.5",
|
|
481
|
+
"@better-auth/prisma-adapter": "1.7.5",
|
|
482
|
+
"@better-auth/telemetry": "1.7.5"
|
|
483
483
|
},
|
|
484
484
|
"devDependencies": {
|
|
485
485
|
"@lynx-js/react": "^0.121.2",
|
|
@@ -496,7 +496,7 @@
|
|
|
496
496
|
"@types/react-dom": "^19.2.3",
|
|
497
497
|
"happy-dom": "^20.8.9",
|
|
498
498
|
"msw": "^2.14.6",
|
|
499
|
-
"next": "^16.
|
|
499
|
+
"next": "^16.3.4",
|
|
500
500
|
"oauth2-mock-server": "^9.0.0",
|
|
501
501
|
"react": "^19.2.7",
|
|
502
502
|
"react-dom": "^19.2.7",
|
|
@@ -504,7 +504,7 @@
|
|
|
504
504
|
"tsdown": "0.21.10",
|
|
505
505
|
"type-fest": "^5.7.0",
|
|
506
506
|
"typescript": "^6.0.3",
|
|
507
|
-
"vitest": "^
|
|
507
|
+
"vitest": "^5.0.0",
|
|
508
508
|
"vue": "^3.5.29"
|
|
509
509
|
},
|
|
510
510
|
"peerDependencies": {
|
|
@@ -513,7 +513,6 @@
|
|
|
513
513
|
"@sveltejs/kit": "^2.0.0",
|
|
514
514
|
"@tanstack/react-start": "^1.0.0",
|
|
515
515
|
"@tanstack/solid-start": "^1.0.0",
|
|
516
|
-
"better-sqlite3": "^12.0.0",
|
|
517
516
|
"drizzle-kit": ">=0.31.4 || >=1.0.0-beta.1",
|
|
518
517
|
"drizzle-orm": "^0.45.2 || >=1.0.0-rc.1 <2.0.0",
|
|
519
518
|
"mongodb": "^6.0.0 || ^7.0.0",
|
|
@@ -525,7 +524,7 @@
|
|
|
525
524
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
526
525
|
"solid-js": "^1.0.0",
|
|
527
526
|
"svelte": "^4.0.0 || ^5.0.0",
|
|
528
|
-
"vitest": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
|
527
|
+
"vitest": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
|
|
529
528
|
"vue": "^3.0.0"
|
|
530
529
|
},
|
|
531
530
|
"peerDependenciesMeta": {
|
|
@@ -580,9 +579,6 @@
|
|
|
580
579
|
"prisma": {
|
|
581
580
|
"optional": true
|
|
582
581
|
},
|
|
583
|
-
"better-sqlite3": {
|
|
584
|
-
"optional": true
|
|
585
|
-
},
|
|
586
582
|
"vitest": {
|
|
587
583
|
"optional": true
|
|
588
584
|
}
|