better-auth 1.7.5 → 1.7.7
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/rate-limiter/index.mjs +4 -1
- package/dist/api/routes/callback.mjs +16 -64
- package/dist/api/routes/password.mjs +3 -5
- package/dist/api/routes/sign-in.mjs +4 -1
- package/dist/api/routes/sign-up.mjs +3 -10
- package/dist/api/routes/update-user.mjs +7 -20
- package/dist/client/config.mjs +3 -4
- package/dist/client/query-atom.mjs +13 -0
- package/dist/client/query.mjs +37 -27
- package/dist/client/react/react-store.mjs +2 -1
- package/dist/client/session-atom.mjs +2 -1
- package/dist/context/create-context.mjs +3 -2
- package/dist/crypto/purpose.mjs +19 -0
- package/dist/index.mjs +1 -0
- package/dist/oauth2/index.d.mts +2 -2
- package/dist/oauth2/index.mjs +2 -2
- package/dist/oauth2/link-account.d.mts +42 -14
- package/dist/oauth2/link-account.mjs +61 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/admin/admin.mjs +3 -1
- package/dist/plugins/admin/routes.mjs +4 -10
- package/dist/plugins/admin/types.d.mts +4 -1
- package/dist/plugins/captcha/constants.d.mts +1 -0
- package/dist/plugins/captcha/constants.mjs +2 -1
- package/dist/plugins/captcha/index.d.mts +2 -2
- package/dist/plugins/captcha/index.mjs +6 -0
- package/dist/plugins/captcha/types.d.mts +44 -2
- package/dist/plugins/captcha/utils.mjs +11 -1
- package/dist/plugins/captcha/verify-handlers/vercel-botid.mjs +27 -0
- package/dist/plugins/email-otp/routes.mjs +3 -4
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/magic-link/index.mjs +23 -4
- package/dist/plugins/oauth-proxy/index.d.mts +5 -6
- package/dist/plugins/oauth-proxy/index.mjs +30 -15
- package/dist/plugins/open-api/index.mjs +1 -0
- package/dist/plugins/organization/client.mjs +2 -1
- package/dist/plugins/phone-number/routes.mjs +5 -4
- package/dist/plugins/username/index.mjs +2 -0
- package/dist/state.mjs +9 -6
- package/dist/utils/hashing.mjs +1 -1
- package/dist/utils/index.mjs +5 -0
- package/dist/utils/middleware-response.mjs +4 -1
- package/dist/utils/password.mjs +16 -2
- package/package.json +9 -8
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
const middlewareResponse = ({ message, status, code }) => ({ response: new Response(JSON.stringify({
|
|
3
3
|
message,
|
|
4
4
|
code
|
|
5
|
-
}), {
|
|
5
|
+
}), {
|
|
6
|
+
status,
|
|
7
|
+
headers: { "Content-Type": "application/json" }
|
|
8
|
+
}) });
|
|
6
9
|
//#endregion
|
|
7
10
|
export { middlewareResponse };
|
package/dist/utils/password.mjs
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error";
|
|
2
2
|
//#region src/utils/password.ts
|
|
3
|
+
function assertPasswordNotTooShort(ctx, password) {
|
|
4
|
+
if (password.length < ctx.context.password.config.minPasswordLength) {
|
|
5
|
+
ctx.context.logger.warn("Password is too short");
|
|
6
|
+
throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.PASSWORD_TOO_SHORT);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function assertPasswordNotTooLong(ctx, password) {
|
|
10
|
+
if (password.length > ctx.context.password.config.maxPasswordLength) {
|
|
11
|
+
ctx.context.logger.warn("Password is too long");
|
|
12
|
+
throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.PASSWORD_TOO_LONG);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
3
15
|
async function validatePassword(ctx, data) {
|
|
16
|
+
assertPasswordNotTooLong(ctx, data.password);
|
|
4
17
|
const credentialAccount = await ctx.context.internalAdapter.findCredentialAccount(data.userId);
|
|
5
18
|
const currentPassword = credentialAccount?.password;
|
|
6
19
|
if (!credentialAccount || !currentPassword) return false;
|
|
@@ -10,9 +23,10 @@ async function validatePassword(ctx, data) {
|
|
|
10
23
|
});
|
|
11
24
|
}
|
|
12
25
|
async function checkPassword(userId, c) {
|
|
26
|
+
const password = c.body.password;
|
|
27
|
+
if (typeof password === "string") assertPasswordNotTooLong(c, password);
|
|
13
28
|
const credentialAccount = await c.context.internalAdapter.findCredentialAccount(userId);
|
|
14
29
|
const currentPassword = credentialAccount?.password;
|
|
15
|
-
const password = c.body.password;
|
|
16
30
|
if (!credentialAccount || !currentPassword || !password) {
|
|
17
31
|
if (password) await c.context.password.hash(password);
|
|
18
32
|
throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.INVALID_PASSWORD);
|
|
@@ -29,4 +43,4 @@ async function shouldRequirePassword(ctx, userId, allowPasswordless) {
|
|
|
29
43
|
return Boolean(credentialAccount?.password);
|
|
30
44
|
}
|
|
31
45
|
//#endregion
|
|
32
|
-
export { checkPassword, shouldRequirePassword, validatePassword };
|
|
46
|
+
export { assertPasswordNotTooLong, assertPasswordNotTooShort, checkPassword, shouldRequirePassword, validatePassword };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-auth",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.7",
|
|
4
4
|
"description": "The most comprehensive authentication framework for TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -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.7",
|
|
477
|
+
"@better-auth/drizzle-adapter": "1.7.7",
|
|
478
|
+
"@better-auth/kysely-adapter": "1.7.7",
|
|
479
|
+
"@better-auth/memory-adapter": "1.7.7",
|
|
480
|
+
"@better-auth/mongo-adapter": "1.7.7",
|
|
481
|
+
"@better-auth/prisma-adapter": "1.7.7",
|
|
482
|
+
"@better-auth/telemetry": "1.7.7"
|
|
483
483
|
},
|
|
484
484
|
"devDependencies": {
|
|
485
485
|
"@lynx-js/react": "^0.121.2",
|
|
@@ -494,6 +494,7 @@
|
|
|
494
494
|
"@types/pg": "^8.20.0",
|
|
495
495
|
"@types/react": "^19.2.17",
|
|
496
496
|
"@types/react-dom": "^19.2.3",
|
|
497
|
+
"botid": "^1.5.10",
|
|
497
498
|
"happy-dom": "^20.8.9",
|
|
498
499
|
"msw": "^2.14.6",
|
|
499
500
|
"next": "^16.3.4",
|