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.
Files changed (44) hide show
  1. package/dist/api/rate-limiter/index.mjs +4 -1
  2. package/dist/api/routes/callback.mjs +16 -64
  3. package/dist/api/routes/password.mjs +3 -5
  4. package/dist/api/routes/sign-in.mjs +4 -1
  5. package/dist/api/routes/sign-up.mjs +3 -10
  6. package/dist/api/routes/update-user.mjs +7 -20
  7. package/dist/client/config.mjs +3 -4
  8. package/dist/client/query-atom.mjs +13 -0
  9. package/dist/client/query.mjs +37 -27
  10. package/dist/client/react/react-store.mjs +2 -1
  11. package/dist/client/session-atom.mjs +2 -1
  12. package/dist/context/create-context.mjs +3 -2
  13. package/dist/crypto/purpose.mjs +19 -0
  14. package/dist/index.mjs +1 -0
  15. package/dist/oauth2/index.d.mts +2 -2
  16. package/dist/oauth2/index.mjs +2 -2
  17. package/dist/oauth2/link-account.d.mts +42 -14
  18. package/dist/oauth2/link-account.mjs +61 -1
  19. package/dist/package.mjs +1 -1
  20. package/dist/plugins/admin/admin.mjs +3 -1
  21. package/dist/plugins/admin/routes.mjs +4 -10
  22. package/dist/plugins/admin/types.d.mts +4 -1
  23. package/dist/plugins/captcha/constants.d.mts +1 -0
  24. package/dist/plugins/captcha/constants.mjs +2 -1
  25. package/dist/plugins/captcha/index.d.mts +2 -2
  26. package/dist/plugins/captcha/index.mjs +6 -0
  27. package/dist/plugins/captcha/types.d.mts +44 -2
  28. package/dist/plugins/captcha/utils.mjs +11 -1
  29. package/dist/plugins/captcha/verify-handlers/vercel-botid.mjs +27 -0
  30. package/dist/plugins/email-otp/routes.mjs +3 -4
  31. package/dist/plugins/index.d.mts +2 -2
  32. package/dist/plugins/magic-link/index.mjs +23 -4
  33. package/dist/plugins/oauth-proxy/index.d.mts +5 -6
  34. package/dist/plugins/oauth-proxy/index.mjs +30 -15
  35. package/dist/plugins/open-api/index.mjs +1 -0
  36. package/dist/plugins/organization/client.mjs +2 -1
  37. package/dist/plugins/phone-number/routes.mjs +5 -4
  38. package/dist/plugins/username/index.mjs +2 -0
  39. package/dist/state.mjs +9 -6
  40. package/dist/utils/hashing.mjs +1 -1
  41. package/dist/utils/index.mjs +5 -0
  42. package/dist/utils/middleware-response.mjs +4 -1
  43. package/dist/utils/password.mjs +16 -2
  44. 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
- }), { status }) });
5
+ }), {
6
+ status,
7
+ headers: { "Content-Type": "application/json" }
8
+ }) });
6
9
  //#endregion
7
10
  export { middlewareResponse };
@@ -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.5",
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.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"
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",