@contentgrowth/content-auth 0.3.3 → 0.3.4

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.
@@ -9,7 +9,7 @@ import {
9
9
  normalizeEmail,
10
10
  schema_exports,
11
11
  verifyTurnstile
12
- } from "../chunk-HTFOOF6M.js";
12
+ } from "../chunk-SF5CUX53.js";
13
13
  import "../chunk-R5U7XKVJ.js";
14
14
  export {
15
15
  Hono,
@@ -33,11 +33,21 @@ async function verifyTurnstile(secretKey, token, remoteIp) {
33
33
  },
34
34
  body: formData.toString()
35
35
  });
36
+ let result;
37
+ try {
38
+ result = await response.json();
39
+ } catch (e) {
40
+ console.error(`[Turnstile] Failed to parse response: ${response.status}`);
41
+ return { success: false, error: "Security verification failed. Please try again." };
42
+ }
36
43
  if (!response.ok) {
37
- console.error(`[Turnstile] Siteverify API error: ${response.status}`);
38
- return { success: false, error: `API error: ${response.status}` };
44
+ const errorCodes = result["error-codes"] || [];
45
+ console.error(`[Turnstile] Siteverify API error ${response.status}: ${errorCodes.join(", ")}`);
46
+ if (errorCodes.length > 0) {
47
+ return { success: false, error: mapTurnstileError(errorCodes) };
48
+ }
49
+ return { success: false, error: "Security verification failed. Please try again." };
39
50
  }
40
- const result = await response.json();
41
51
  if (result.success) {
42
52
  return { success: true, hostname: result.hostname };
43
53
  } else {
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  normalizeEmail,
10
10
  schema_exports,
11
11
  verifyTurnstile
12
- } from "./chunk-HTFOOF6M.js";
12
+ } from "./chunk-SF5CUX53.js";
13
13
  import {
14
14
  AuthForm,
15
15
  CreateOrganizationForm,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentgrowth/content-auth",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Better Auth wrapper with UI components for Cloudflare Workers & Pages. Includes Turnstile bot protection and email normalization.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",