better-auth 1.6.31 → 1.6.32

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/package.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.6.31";
2
+ var version = "1.6.32";
3
3
  //#endregion
4
4
  export { version };
@@ -44,6 +44,7 @@ const captcha = (options) => ({
44
44
  };
45
45
  if (options.provider === Providers.CLOUDFLARE_TURNSTILE) return await cloudflareTurnstile({
46
46
  ...handlerParams,
47
+ logger: ctx.logger,
47
48
  expectedAction: options.expectedAction,
48
49
  allowedHostnames: options.allowedHostnames
49
50
  });
@@ -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 = () => middlewareResponse({
19
- message: EXTERNAL_ERROR_CODES.VERIFICATION_FAILED.message,
20
- code: EXTERNAL_ERROR_CODES.VERIFICATION_FAILED.code,
21
- status: 403
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth",
3
- "version": "1.6.31",
3
+ "version": "1.6.32",
4
4
  "description": "The most comprehensive authentication framework for TypeScript.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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.31",
493
- "@better-auth/drizzle-adapter": "1.6.31",
494
- "@better-auth/kysely-adapter": "1.6.31",
495
- "@better-auth/memory-adapter": "1.6.31",
496
- "@better-auth/mongo-adapter": "1.6.31",
497
- "@better-auth/prisma-adapter": "1.6.31",
498
- "@better-auth/telemetry": "1.6.31"
492
+ "@better-auth/core": "1.6.32",
493
+ "@better-auth/drizzle-adapter": "1.6.32",
494
+ "@better-auth/kysely-adapter": "1.6.32",
495
+ "@better-auth/memory-adapter": "1.6.32",
496
+ "@better-auth/mongo-adapter": "1.6.32",
497
+ "@better-auth/prisma-adapter": "1.6.32",
498
+ "@better-auth/telemetry": "1.6.32"
499
499
  },
500
500
  "devDependencies": {
501
501
  "@lynx-js/react": "^0.116.3",