better-auth 1.6.16 → 1.6.18
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/index.d.mts +2 -2
- package/dist/api/index.mjs +3 -4
- package/dist/api/middlewares/origin-check.mjs +5 -1
- package/dist/api/rate-limiter/index.mjs +259 -73
- package/dist/api/routes/account.mjs +22 -7
- package/dist/api/routes/callback.mjs +2 -2
- package/dist/api/routes/index.d.mts +1 -1
- package/dist/api/routes/password.mjs +3 -4
- package/dist/api/routes/session.d.mts +12 -1
- package/dist/api/routes/session.mjs +13 -1
- package/dist/api/routes/sign-in.mjs +5 -5
- package/dist/api/routes/sign-up.mjs +2 -2
- package/dist/api/routes/update-session.mjs +2 -3
- package/dist/api/routes/update-user.mjs +10 -12
- package/dist/auth/base.mjs +11 -7
- package/dist/client/equality.d.mts +19 -0
- package/dist/client/equality.mjs +42 -0
- package/dist/client/index.d.mts +5 -4
- package/dist/client/index.mjs +2 -1
- package/dist/client/lynx/index.d.mts +4 -2
- package/dist/client/path-to-object.d.mts +5 -2
- package/dist/client/plugins/index.d.mts +4 -1
- package/dist/client/plugins/index.mjs +4 -1
- package/dist/client/query.d.mts +4 -3
- package/dist/client/query.mjs +27 -17
- package/dist/client/react/index.d.mts +4 -2
- package/dist/client/session-atom.mjs +129 -4
- package/dist/client/session-refresh.d.mts +3 -18
- package/dist/client/session-refresh.mjs +38 -49
- package/dist/client/solid/index.d.mts +4 -2
- package/dist/client/svelte/index.d.mts +4 -2
- package/dist/client/types.d.mts +27 -16
- package/dist/client/vanilla.d.mts +4 -2
- package/dist/client/vue/index.d.mts +4 -2
- package/dist/context/create-context.mjs +2 -1
- package/dist/context/store-capabilities.mjs +12 -0
- package/dist/cookies/index.mjs +25 -2
- package/dist/db/internal-adapter.mjs +51 -0
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.mjs +49 -19
- package/dist/plugins/admin/routes.mjs +10 -3
- package/dist/plugins/captcha/constants.mjs +8 -1
- package/dist/plugins/captcha/index.mjs +8 -2
- package/dist/plugins/captcha/types.d.mts +21 -0
- package/dist/plugins/captcha/verify-handlers/captchafox.mjs +2 -0
- package/dist/plugins/captcha/verify-handlers/cloudflare-turnstile.mjs +7 -2
- package/dist/plugins/captcha/verify-handlers/google-recaptcha.mjs +7 -2
- package/dist/plugins/captcha/verify-handlers/h-captcha.mjs +2 -0
- package/dist/plugins/device-authorization/routes.mjs +16 -9
- package/dist/plugins/email-otp/routes.mjs +22 -52
- package/dist/plugins/generic-oauth/index.mjs +7 -2
- package/dist/plugins/generic-oauth/routes.mjs +16 -12
- package/dist/plugins/haveibeenpwned/index.d.mts +1 -1
- package/dist/plugins/haveibeenpwned/index.mjs +5 -1
- package/dist/plugins/index.d.mts +6 -2
- package/dist/plugins/index.mjs +4 -1
- package/dist/plugins/jwt/index.mjs +2 -2
- package/dist/plugins/mcp/client/index.mjs +1 -0
- package/dist/plugins/mcp/index.mjs +8 -0
- package/dist/plugins/multi-session/index.mjs +7 -5
- package/dist/plugins/oauth-popup/client.d.mts +82 -0
- package/dist/plugins/oauth-popup/client.mjs +203 -0
- package/dist/plugins/oauth-popup/constants.d.mts +11 -0
- package/dist/plugins/oauth-popup/constants.mjs +11 -0
- package/dist/plugins/oauth-popup/error-codes.d.mts +11 -0
- package/dist/plugins/oauth-popup/error-codes.mjs +10 -0
- package/dist/plugins/oauth-popup/index.d.mts +67 -0
- package/dist/plugins/oauth-popup/index.mjs +227 -0
- package/dist/plugins/oauth-popup/types.d.mts +30 -0
- package/dist/plugins/oauth-proxy/index.mjs +2 -2
- package/dist/plugins/oauth-proxy/utils.mjs +16 -2
- package/dist/plugins/oidc-provider/index.mjs +10 -0
- package/dist/plugins/one-tap/client.mjs +12 -6
- package/dist/plugins/one-tap/index.d.mts +1 -0
- package/dist/plugins/one-tap/index.mjs +9 -5
- package/dist/plugins/one-time-token/index.mjs +1 -3
- package/dist/plugins/open-api/generator.d.mts +66 -57
- package/dist/plugins/open-api/generator.mjs +185 -67
- package/dist/plugins/open-api/index.d.mts +2 -2
- package/dist/plugins/organization/adapter.d.mts +29 -1
- package/dist/plugins/organization/adapter.mjs +66 -6
- package/dist/plugins/organization/routes/crud-invites.mjs +49 -34
- package/dist/plugins/organization/routes/crud-members.mjs +42 -6
- package/dist/plugins/organization/routes/crud-team.mjs +36 -3
- package/dist/plugins/phone-number/routes.mjs +41 -36
- package/dist/plugins/siwe/index.mjs +2 -3
- package/dist/plugins/two-factor/backup-codes/index.mjs +1 -1
- package/dist/plugins/two-factor/otp/index.mjs +11 -13
- package/dist/plugins/two-factor/totp/index.mjs +1 -1
- package/dist/plugins/two-factor/verify-two-factor.mjs +6 -2
- package/dist/plugins/username/index.mjs +6 -6
- package/dist/test-utils/test-instance.d.mts +26 -23
- package/package.json +9 -9
|
@@ -145,18 +145,18 @@ const username = (options) => {
|
|
|
145
145
|
} }
|
|
146
146
|
}, async (ctx) => {
|
|
147
147
|
if (!ctx.body.username || !ctx.body.password) {
|
|
148
|
-
ctx.context.logger.
|
|
148
|
+
ctx.context.logger.warn("Username or password not found");
|
|
149
149
|
throw APIError.from("UNAUTHORIZED", USERNAME_ERROR_CODES.INVALID_USERNAME_OR_PASSWORD);
|
|
150
150
|
}
|
|
151
151
|
const username = options?.validationOrder?.username === "pre-normalization" ? normalizer(ctx.body.username) : ctx.body.username;
|
|
152
152
|
const minUsernameLength = options?.minUsernameLength || 3;
|
|
153
153
|
const maxUsernameLength = options?.maxUsernameLength || 30;
|
|
154
154
|
if (username.length < minUsernameLength) {
|
|
155
|
-
ctx.context.logger.
|
|
155
|
+
ctx.context.logger.warn("Username too short");
|
|
156
156
|
throw APIError.from("UNPROCESSABLE_ENTITY", USERNAME_ERROR_CODES.USERNAME_TOO_SHORT);
|
|
157
157
|
}
|
|
158
158
|
if (username.length > maxUsernameLength) {
|
|
159
|
-
ctx.context.logger.
|
|
159
|
+
ctx.context.logger.warn("Username too long");
|
|
160
160
|
throw APIError.from("UNPROCESSABLE_ENTITY", USERNAME_ERROR_CODES.USERNAME_TOO_LONG);
|
|
161
161
|
}
|
|
162
162
|
if (!await (options?.usernameValidator || defaultUsernameValidator)(username)) throw APIError.from("UNPROCESSABLE_ENTITY", USERNAME_ERROR_CODES.INVALID_USERNAME);
|
|
@@ -169,7 +169,7 @@ const username = (options) => {
|
|
|
169
169
|
});
|
|
170
170
|
if (!user) {
|
|
171
171
|
await ctx.context.password.hash(ctx.body.password);
|
|
172
|
-
ctx.context.logger.
|
|
172
|
+
ctx.context.logger.warn("User not found");
|
|
173
173
|
throw APIError.from("UNAUTHORIZED", USERNAME_ERROR_CODES.INVALID_USERNAME_OR_PASSWORD);
|
|
174
174
|
}
|
|
175
175
|
const account = await ctx.context.adapter.findOne({
|
|
@@ -185,14 +185,14 @@ const username = (options) => {
|
|
|
185
185
|
if (!account) throw APIError.from("UNAUTHORIZED", USERNAME_ERROR_CODES.INVALID_USERNAME_OR_PASSWORD);
|
|
186
186
|
const currentPassword = account?.password;
|
|
187
187
|
if (!currentPassword) {
|
|
188
|
-
ctx.context.logger.
|
|
188
|
+
ctx.context.logger.warn("Password not found");
|
|
189
189
|
throw APIError.from("UNAUTHORIZED", USERNAME_ERROR_CODES.INVALID_USERNAME_OR_PASSWORD);
|
|
190
190
|
}
|
|
191
191
|
if (!await ctx.context.password.verify({
|
|
192
192
|
hash: currentPassword,
|
|
193
193
|
password: ctx.body.password
|
|
194
194
|
})) {
|
|
195
|
-
ctx.context.logger.
|
|
195
|
+
ctx.context.logger.warn("Invalid password");
|
|
196
196
|
throw APIError.from("UNAUTHORIZED", USERNAME_ERROR_CODES.INVALID_USERNAME_OR_PASSWORD);
|
|
197
197
|
}
|
|
198
198
|
if (ctx.context.options?.emailAndPassword?.requireEmailVerification && !user.emailVerified) {
|
|
@@ -5,7 +5,6 @@ import { InferAPI } from "../types/api.mjs";
|
|
|
5
5
|
import { Session, User } from "../types/models.mjs";
|
|
6
6
|
import { Auth } from "../types/auth.mjs";
|
|
7
7
|
import { setCookieToHeader } from "../cookies/cookie-utils.mjs";
|
|
8
|
-
import * as _better_auth_core0 from "@better-auth/core";
|
|
9
8
|
import { Awaitable, BetterAuthClientOptions, BetterAuthOptions } from "@better-auth/core";
|
|
10
9
|
import * as _better_auth_core_oauth20 from "@better-auth/core/oauth2";
|
|
11
10
|
import * as _better_auth_core_utils_error_codes0 from "@better-auth/core/utils/error-codes";
|
|
@@ -38,7 +37,9 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
38
37
|
};
|
|
39
38
|
} ? T extends {
|
|
40
39
|
plugins: Array<infer Plugin>;
|
|
41
|
-
} ? UnionToIntersection<Plugin extends
|
|
40
|
+
} ? UnionToIntersection<Plugin extends {
|
|
41
|
+
getAtoms?: infer GetAtoms;
|
|
42
|
+
} ? GetAtoms extends ((fetch: any) => infer Atoms) ? Atoms extends Record<string, any> ? { [key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key] } : {} : {} : {}> : {} : never : never> & UnionToIntersection<InferRoute<((C extends undefined ? {} : C) & {
|
|
42
43
|
baseURL: string | undefined;
|
|
43
44
|
fetchOptions: {
|
|
44
45
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
@@ -2010,10 +2011,10 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
2010
2011
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
2011
2012
|
};
|
|
2012
2013
|
})["plugins"] ? T_1 extends (infer Pl)[] ? UnionToIntersection<Pl extends {
|
|
2013
|
-
$InferServerPlugin
|
|
2014
|
+
$InferServerPlugin?: infer Plug;
|
|
2014
2015
|
} ? Plug extends {
|
|
2015
|
-
endpoints
|
|
2016
|
-
} ? Endpoints : {} : {}> : {} : never : never)> & (((C extends undefined ? {} : C) & {
|
|
2016
|
+
endpoints?: infer Endpoints;
|
|
2017
|
+
} ? Endpoints extends Record<string, unknown> ? Endpoints : {} : {} : {}> : {} : never : never)> & (((C extends undefined ? {} : C) & {
|
|
2017
2018
|
baseURL: string | undefined;
|
|
2018
2019
|
fetchOptions: {
|
|
2019
2020
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
@@ -2024,10 +2025,10 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
2024
2025
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
2025
2026
|
};
|
|
2026
2027
|
})["plugins"] ? T_2 extends (infer Pl)[] ? UnionToIntersection<Pl extends {
|
|
2027
|
-
$InferServerPlugin
|
|
2028
|
+
$InferServerPlugin?: infer Plug;
|
|
2028
2029
|
} ? Plug extends {
|
|
2029
|
-
endpoints
|
|
2030
|
-
} ? Endpoints : {} : {}> : {} : never : never) : InferAPI<Prettify$1<{
|
|
2030
|
+
endpoints?: infer Endpoints;
|
|
2031
|
+
} ? Endpoints extends Record<string, unknown> ? Endpoints : {} : {} : {}> : {} : never : never) : InferAPI<Prettify$1<{
|
|
2031
2032
|
readonly ok: better_call0.StrictEndpoint<"/ok", {
|
|
2032
2033
|
method: "GET";
|
|
2033
2034
|
metadata: {
|
|
@@ -3993,7 +3994,9 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
3993
3994
|
fetchOptions: {
|
|
3994
3995
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
3995
3996
|
};
|
|
3996
|
-
})["plugins"] extends (infer Plugin_1)[] ? UnionToIntersection<Plugin_1 extends
|
|
3997
|
+
})["plugins"] extends (infer Plugin_1)[] ? UnionToIntersection<Plugin_1 extends {
|
|
3998
|
+
getActions?: infer GetActions;
|
|
3999
|
+
} ? GetActions extends ((...args: any) => infer Actions) ? Actions : {} : {}> : {}) & UnionToIntersection<InferRoute<((C extends undefined ? {} : C) & {
|
|
3997
4000
|
baseURL: string | undefined;
|
|
3998
4001
|
fetchOptions: {
|
|
3999
4002
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
@@ -4001,8 +4004,8 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
4001
4004
|
})["$InferAuth"] extends {
|
|
4002
4005
|
plugins: infer Plugins;
|
|
4003
4006
|
} ? Plugins extends (infer Plugin_2)[] ? Plugin_2 extends {
|
|
4004
|
-
endpoints
|
|
4005
|
-
} ? Endpoints_1 : {} : {} : {}, (C extends undefined ? {} : C) & {
|
|
4007
|
+
endpoints?: infer Endpoints_1;
|
|
4008
|
+
} ? Endpoints_1 extends Record<string, unknown> ? Endpoints_1 : {} : {} : {} : {}, (C extends undefined ? {} : C) & {
|
|
4006
4009
|
baseURL: string | undefined;
|
|
4007
4010
|
fetchOptions: {
|
|
4008
4011
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
@@ -5981,10 +5984,10 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
5981
5984
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
5982
5985
|
};
|
|
5983
5986
|
})["plugins"] ? T_3 extends (infer Pl)[] ? UnionToIntersection<Pl extends {
|
|
5984
|
-
$InferServerPlugin
|
|
5987
|
+
$InferServerPlugin?: infer Plug;
|
|
5985
5988
|
} ? Plug extends {
|
|
5986
|
-
endpoints
|
|
5987
|
-
} ? Endpoints : {} : {}> : {} : never : never)> & (((C extends undefined ? {} : C) & {
|
|
5989
|
+
endpoints?: infer Endpoints;
|
|
5990
|
+
} ? Endpoints extends Record<string, unknown> ? Endpoints : {} : {} : {}> : {} : never : never)> & (((C extends undefined ? {} : C) & {
|
|
5988
5991
|
baseURL: string | undefined;
|
|
5989
5992
|
fetchOptions: {
|
|
5990
5993
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
@@ -5995,10 +5998,10 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
5995
5998
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
5996
5999
|
};
|
|
5997
6000
|
})["plugins"] ? T_4 extends (infer Pl)[] ? UnionToIntersection<Pl extends {
|
|
5998
|
-
$InferServerPlugin
|
|
6001
|
+
$InferServerPlugin?: infer Plug;
|
|
5999
6002
|
} ? Plug extends {
|
|
6000
|
-
endpoints
|
|
6001
|
-
} ? Endpoints : {} : {}> : {} : never : never) : InferAPI<Prettify$1<{
|
|
6003
|
+
endpoints?: infer Endpoints;
|
|
6004
|
+
} ? Endpoints extends Record<string, unknown> ? Endpoints : {} : {} : {}> : {} : never : never) : InferAPI<Prettify$1<{
|
|
6002
6005
|
readonly ok: better_call0.StrictEndpoint<"/ok", {
|
|
6003
6006
|
method: "GET";
|
|
6004
6007
|
metadata: {
|
|
@@ -10024,10 +10027,10 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
10024
10027
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
10025
10028
|
};
|
|
10026
10029
|
})["plugins"] ? T_5 extends (infer Pl)[] ? UnionToIntersection<Pl extends {
|
|
10027
|
-
$InferServerPlugin
|
|
10030
|
+
$InferServerPlugin?: infer Plug;
|
|
10028
10031
|
} ? Plug extends {
|
|
10029
|
-
endpoints
|
|
10030
|
-
} ? Endpoints : {} : {}> : {} : never : never)> & (((C extends undefined ? {} : C) & {
|
|
10032
|
+
endpoints?: infer Endpoints;
|
|
10033
|
+
} ? Endpoints extends Record<string, unknown> ? Endpoints : {} : {} : {}> : {} : never : never)> & (((C extends undefined ? {} : C) & {
|
|
10031
10034
|
baseURL: string | undefined;
|
|
10032
10035
|
fetchOptions: {
|
|
10033
10036
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
@@ -10038,10 +10041,10 @@ declare function getTestInstance<O extends Partial<BetterAuthOptions>, C extends
|
|
|
10038
10041
|
customFetchImpl: (url: string | URL | Request, init?: RequestInit | undefined) => Promise<Response>;
|
|
10039
10042
|
};
|
|
10040
10043
|
})["plugins"] ? T_6 extends (infer Pl)[] ? UnionToIntersection<Pl extends {
|
|
10041
|
-
$InferServerPlugin
|
|
10044
|
+
$InferServerPlugin?: infer Plug;
|
|
10042
10045
|
} ? Plug extends {
|
|
10043
|
-
endpoints
|
|
10044
|
-
} ? Endpoints : {} : {}> : {} : never : never) : InferAPI<Prettify$1<{
|
|
10046
|
+
endpoints?: infer Endpoints;
|
|
10047
|
+
} ? Endpoints extends Record<string, unknown> ? Endpoints : {} : {} : {}> : {} : never : never) : InferAPI<Prettify$1<{
|
|
10045
10048
|
readonly ok: better_call0.StrictEndpoint<"/ok", {
|
|
10046
10049
|
method: "GET";
|
|
10047
10050
|
metadata: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.18",
|
|
4
4
|
"description": "The most comprehensive authentication framework for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -480,7 +480,7 @@
|
|
|
480
480
|
},
|
|
481
481
|
"dependencies": {
|
|
482
482
|
"@better-auth/utils": "0.4.1",
|
|
483
|
-
"@better-fetch/fetch": "1.
|
|
483
|
+
"@better-fetch/fetch": "1.3.0",
|
|
484
484
|
"@noble/ciphers": "^2.1.1",
|
|
485
485
|
"@noble/hashes": "^2.0.1",
|
|
486
486
|
"better-call": "1.3.6",
|
|
@@ -489,13 +489,13 @@
|
|
|
489
489
|
"kysely": "^0.28.17 || ^0.29.0",
|
|
490
490
|
"nanostores": "^1.1.1",
|
|
491
491
|
"zod": "^4.3.6",
|
|
492
|
-
"@better-auth/core": "1.6.
|
|
493
|
-
"@better-auth/drizzle-adapter": "1.6.
|
|
494
|
-
"@better-auth/kysely-adapter": "1.6.
|
|
495
|
-
"@better-auth/memory-adapter": "1.6.
|
|
496
|
-
"@better-auth/mongo-adapter": "1.6.
|
|
497
|
-
"@better-auth/prisma-adapter": "1.6.
|
|
498
|
-
"@better-auth/telemetry": "1.6.
|
|
492
|
+
"@better-auth/core": "1.6.18",
|
|
493
|
+
"@better-auth/drizzle-adapter": "1.6.18",
|
|
494
|
+
"@better-auth/kysely-adapter": "1.6.18",
|
|
495
|
+
"@better-auth/memory-adapter": "1.6.18",
|
|
496
|
+
"@better-auth/mongo-adapter": "1.6.18",
|
|
497
|
+
"@better-auth/prisma-adapter": "1.6.18",
|
|
498
|
+
"@better-auth/telemetry": "1.6.18"
|
|
499
499
|
},
|
|
500
500
|
"devDependencies": {
|
|
501
501
|
"@lynx-js/react": "^0.116.3",
|