qarpeo 0.1.29 → 0.1.30

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 { fileURLToPath } from 'node:url';
9
9
  import { mkdir, writeFile, readFile } from 'node:fs/promises';
10
10
  import { defu } from 'defu';
11
11
 
12
- const version = "0.1.29";
12
+ const version = "0.1.30";
13
13
 
14
14
  function scanSchemaExports(schemaFiles) {
15
15
  const types = [];
@@ -4,12 +4,16 @@ import { ensureAuthTables } from "../../../utils/auth.mjs";
4
4
  import { getQarpeoConfig } from "../../../utils/config.mjs";
5
5
  import { verifyMagicLinkToken } from "../../../utils/passwordless.mjs";
6
6
  import { createDeviceSession, setAuthSession } from "../../../utils/session.mjs";
7
+ import { safeRedirect } from "../../../utils/string.mjs";
7
8
  export default defineEventHandler(async (event) => {
8
9
  const query = getQuery(event);
9
10
  const token = query?.token;
10
11
  const authConfig = getQarpeoConfig(event).auth;
11
- const loginRedirect = authConfig.redirect?.login || "/login";
12
- const successRedirect = authConfig.redirect?.success || "/dashboard";
12
+ const loginRedirect = safeRedirect(authConfig.redirect?.login, "/login");
13
+ const successRedirect = safeRedirect(
14
+ query?.redirect || authConfig.redirect?.success,
15
+ "/dashboard"
16
+ );
13
17
  if (!token || typeof token !== "string") {
14
18
  return sendRedirect(event, `${loginRedirect}?error=invalid_magic_link`);
15
19
  }
@@ -41,21 +45,20 @@ export default defineEventHandler(async (event) => {
41
45
  } else if (!dbUser.email_verified) {
42
46
  await d1.prepare("UPDATE user SET email_verified = 1, updated_at = ? WHERE id = ?").bind(now, dbUser.id).run();
43
47
  }
44
- } catch {
48
+ } catch (err) {
49
+ console.error("[qarpeo:magic-link] Database error resolving user:", err?.message);
50
+ return sendRedirect(event, `${loginRedirect}?error=database_error`);
51
+ }
52
+ if (!dbUser) {
53
+ return sendRedirect(event, `${loginRedirect}?error=user_creation_failed`);
45
54
  }
46
- const finalUser = dbUser ? {
55
+ const finalUser = {
47
56
  id: dbUser.id,
48
57
  email: dbUser.email,
49
58
  name: dbUser.name,
50
59
  avatarUrl: dbUser.image || dbUser.avatar_url,
51
60
  emailVerified: true,
52
61
  role: dbUser.role || "user"
53
- } : {
54
- id: crypto.randomUUID(),
55
- email: cleanEmail,
56
- name: cleanEmail.split("@")[0],
57
- emailVerified: true,
58
- role: "user"
59
62
  };
60
63
  const sessionConfig = authConfig.session || {};
61
64
  let sessionId;
@@ -8,12 +8,13 @@ import {
8
8
  import { getD1Binding } from "../../../../db.mjs";
9
9
  import { getKVBinding } from "../../../../kv.mjs";
10
10
  import { buildSAMLAuthnRequestUrl, buildOIDCAuthUrl } from "../../../utils/sso.mjs";
11
+ import { safeRedirect } from "../../../utils/string.mjs";
11
12
  export default defineEventHandler(async (event) => {
12
13
  const query = getQuery(event);
13
14
  const domain = query.domain?.toLowerCase()?.trim();
14
15
  const orgSlug = query.org?.toLowerCase()?.trim();
15
16
  const connectionId = query.connectionId;
16
- const redirect = query.redirect || "/dashboard";
17
+ const redirect = safeRedirect(query.redirect, "/dashboard");
17
18
  if (!domain && !orgSlug && !connectionId) {
18
19
  throw createError({
19
20
  statusCode: 400,
@@ -9,6 +9,7 @@ import { getD1Binding } from "../../../../../db.mjs";
9
9
  import { getKVBinding } from "../../../../../kv.mjs";
10
10
  import { setAuthSession, createDeviceSession } from "../../../../utils/session.mjs";
11
11
  import { exchangeOIDCCode } from "../../../../utils/sso.mjs";
12
+ import { safeRedirect } from "../../../../utils/string.mjs";
12
13
  export default defineEventHandler(async (event) => {
13
14
  const query = getQuery(event);
14
15
  const code = query.code;
@@ -28,7 +29,7 @@ export default defineEventHandler(async (event) => {
28
29
  const stateData = await kv.get(`sso:state:${stateId}`, { type: "json" });
29
30
  if (stateData) {
30
31
  connectionId = stateData.connectionId || null;
31
- finalRedirect = stateData.redirect || "/dashboard";
32
+ finalRedirect = safeRedirect(stateData.redirect, "/dashboard");
32
33
  await kv.delete(`sso:state:${stateId}`);
33
34
  }
34
35
  } catch {
@@ -8,6 +8,7 @@ import { getD1Binding } from "../../../../../db.mjs";
8
8
  import { getKVBinding } from "../../../../../kv.mjs";
9
9
  import { setAuthSession, createDeviceSession } from "../../../../utils/session.mjs";
10
10
  import { parseSAMLResponse, verifySAMLSignature } from "../../../../utils/sso.mjs";
11
+ import { safeRedirect } from "../../../../utils/string.mjs";
11
12
  export default defineEventHandler(async (event) => {
12
13
  const body = await readBody(event);
13
14
  const samlResponse = body?.SAMLResponse;
@@ -37,7 +38,7 @@ export default defineEventHandler(async (event) => {
37
38
  const stateData = await kv.get(`sso:state:${relayState}`, { type: "json" });
38
39
  if (stateData) {
39
40
  connectionId = stateData.connectionId || null;
40
- finalRedirect = stateData.redirect || "/dashboard";
41
+ finalRedirect = safeRedirect(stateData.redirect, "/dashboard");
41
42
  await kv.delete(`sso:state:${relayState}`);
42
43
  }
43
44
  } catch {
@@ -50,37 +51,25 @@ export default defineEventHandler(async (event) => {
50
51
  if (connectionId) {
51
52
  connection = await d1.prepare("SELECT * FROM _qarpeo_sso_connections WHERE id = ? LIMIT 1").bind(connectionId).first();
52
53
  }
53
- if (connection?.cert) {
54
- const sigResult = await verifySAMLSignature(rawXml, connection.cert);
55
- if (sigResult === false) {
56
- throw createError({
57
- statusCode: 401,
58
- statusMessage: "Unauthorized",
59
- message: "SAML response signature verification failed. The response may have been tampered with."
60
- });
61
- }
62
- if (sigResult === null) {
63
- console.warn(
64
- "[qarpeo:saml] SAMLResponse from connection %s contains no XML digital signature. Ensure your IdP is configured to sign assertions or the response envelope.",
65
- connectionId
66
- );
67
- }
68
- } else if (!connection) {
69
- }
70
54
  const assertion = parseSAMLResponse(samlResponse);
71
55
  const email = assertion.email;
72
56
  if (!connection && assertion.issuer) {
73
- connection = await d1.prepare("SELECT * FROM _qarpeo_sso_connections WHERE issuer = ? LIMIT 1").bind(assertion.issuer).first();
74
- if (connection?.cert) {
75
- const sigResult = await verifySAMLSignature(rawXml, connection.cert);
76
- if (sigResult === false) {
77
- throw createError({
78
- statusCode: 401,
79
- statusMessage: "Unauthorized",
80
- message: "SAML response signature verification failed."
81
- });
82
- }
83
- }
57
+ connection = await d1.prepare("SELECT * FROM _qarpeo_sso_connections WHERE issuer = ? AND enabled = 1 LIMIT 1").bind(assertion.issuer).first();
58
+ }
59
+ if (!connection || !connection.cert) {
60
+ throw createError({
61
+ statusCode: 401,
62
+ statusMessage: "Unauthorized",
63
+ message: "No active SSO connection or IdP certificate found to verify SAML assertion."
64
+ });
65
+ }
66
+ const sigResult = await verifySAMLSignature(rawXml, connection.cert);
67
+ if (sigResult !== true) {
68
+ throw createError({
69
+ statusCode: 401,
70
+ statusMessage: "Unauthorized",
71
+ message: sigResult === null ? "Unsigned SAML assertions are not permitted. Your IdP must sign assertions or the response." : "SAML response signature verification failed. The response may have been tampered with."
72
+ });
84
73
  }
85
74
  let user = await d1.prepare("SELECT * FROM user WHERE email = ? LIMIT 1").bind(email).first();
86
75
  if (!user) {
@@ -1,7 +1,8 @@
1
1
  import { defineEventHandler, getQuery, deleteCookie, sendRedirect } from "nuxt/server";
2
+ import { safeRedirect } from "../../../utils/string.mjs";
2
3
  export default defineEventHandler((event) => {
3
4
  const query = getQuery(event);
4
- const redirect = String(query.redirect || "/");
5
+ const redirect = safeRedirect(query.redirect, "/");
5
6
  deleteCookie(event, "qarpeo_preview", {
6
7
  path: "/"
7
8
  });
@@ -1,12 +1,14 @@
1
1
  import { defineEventHandler, getQuery, setCookie, sendRedirect, createError } from "nuxt/server";
2
2
  import { verifyPreviewToken } from "../../../utils/cms.mjs";
3
+ import { safeRedirect } from "../../../utils/string.mjs";
3
4
  export default defineEventHandler(async (event) => {
4
5
  const query = getQuery(event);
5
6
  const collection = String(query.collection || "");
6
7
  const slug = String(query.slug || query.id || "");
7
8
  const token = String(query.token || query.preview_token || "");
8
9
  const expires = String(query.expires || "");
9
- const redirect = String(query.redirect || (slug ? `/${collection}/${slug}` : "/"));
10
+ const defaultPath = slug ? `/${collection}/${slug}` : "/";
11
+ const redirect = safeRedirect(query.redirect || defaultPath, defaultPath);
10
12
  if (!collection || !slug || !token || !expires) {
11
13
  throw createError({
12
14
  statusCode: 400,
@@ -21,8 +21,11 @@ export async function queryAnalytics(sql, options = {}) {
21
21
  const env = getCloudflareEnv();
22
22
  const accountId = options.accountId || env.CLOUDFLARE_ACCOUNT_ID || env.CF_ACCOUNT_ID || process.env.CLOUDFLARE_ACCOUNT_ID || process.env.CF_ACCOUNT_ID;
23
23
  const apiToken = options.apiToken || env.CLOUDFLARE_API_TOKEN || env.CF_API_TOKEN || process.env.CLOUDFLARE_API_TOKEN || process.env.CF_API_TOKEN;
24
+ const isDev = Boolean(
25
+ import.meta.dev || process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test" || env.NODE_ENV === "development"
26
+ );
24
27
  if (!accountId || !apiToken) {
25
- if (process.env.NODE_ENV !== "production") {
28
+ if (isDev) {
26
29
  return [];
27
30
  }
28
31
  throw new Error(
@@ -41,11 +44,11 @@ export async function queryAnalytics(sql, options = {}) {
41
44
  body: sql
42
45
  });
43
46
  } catch (err) {
44
- if (process.env.NODE_ENV !== "production") return [];
47
+ if (isDev) return [];
45
48
  throw new Error(`[qarpeo/analytics] Network error querying AE SQL API: ${err.message}`);
46
49
  }
47
50
  if (!res.ok) {
48
- if (process.env.NODE_ENV !== "production") return [];
51
+ if (isDev) return [];
49
52
  const body = await res.text().catch(() => "");
50
53
  throw new Error(`[qarpeo/analytics] AE SQL API error ${res.status}: ${body}`);
51
54
  }
@@ -2,13 +2,14 @@ import { drizzleAdapter } from "@better-auth/drizzle-adapter";
2
2
  import { betterAuth } from "better-auth";
3
3
  import { createError } from "nuxt/server";
4
4
  import * as authSchema from "#qarpeo/auth/schema";
5
+ import { getSessionSecret } from "./config.mjs";
5
6
  import { useDrizzle } from "./drizzle.mjs";
6
7
  const _authCache = /* @__PURE__ */ new Map();
7
8
  export function serverAuth(event) {
8
9
  const cfEnv = event?.context?.cloudflare?.env;
9
10
  const secret = cfEnv?.BETTER_AUTH_SECRET || cfEnv?.NUXT_BETTER_AUTH_SECRET || cfEnv?.NUXT_APP_SECRET || process.env.BETTER_AUTH_SECRET || process.env.NUXT_BETTER_AUTH_SECRET || process.env.NUXT_APP_SECRET || null;
10
11
  if (!secret) {
11
- const isDev = globalThis.process?.env?.NODE_ENV === "development" || cfEnv?.NODE_ENV === "development";
12
+ const isDev = Boolean(import.meta.dev) || globalThis.process?.env?.NODE_ENV === "development" || cfEnv?.NODE_ENV === "development";
12
13
  if (!isDev) {
13
14
  throw createError({
14
15
  statusCode: 500,
@@ -17,7 +18,7 @@ export function serverAuth(event) {
17
18
  });
18
19
  }
19
20
  }
20
- const effectiveSecret = secret || "qarpeo-auth-dev-secret-change-before-deploy-32c";
21
+ const effectiveSecret = secret || getSessionSecret(event);
21
22
  const cached = _authCache.get(effectiveSecret);
22
23
  if (cached) return cached;
23
24
  const db = useDrizzle(void 0, event);
@@ -1,4 +1,4 @@
1
- import { createError, getCookie, useRuntimeConfig } from "nuxt/server";
1
+ import { createError, getCookie } from "nuxt/server";
2
2
  import { parse as parseYaml } from "yaml";
3
3
  import { getKVBinding } from "../../kv.mjs";
4
4
  import { fireCMSWebhooks, fireCMSDeployTrigger } from "./cms-events.mjs";
@@ -28,6 +28,7 @@ import {
28
28
  extractTOC
29
29
  } from "./cms/path.mjs";
30
30
  import { registerEnsureCMSSynced } from "./cms/search.mjs";
31
+ import { getSessionSecret } from "./config.mjs";
31
32
  import { getAuthContext } from "./context.mjs";
32
33
  export * from "./cms/common.mjs";
33
34
  export * from "./cms/path.mjs";
@@ -1288,8 +1289,7 @@ export async function pruneRevisions(event, entryId, max) {
1288
1289
  ).bind(entryId, entryId, max).run();
1289
1290
  }
1290
1291
  async function getCMSSecret(event) {
1291
- const rc = useRuntimeConfig(event);
1292
- const secret = rc.appSecret || rc.qarpeo?.sessionPassword || rc.sessionPassword || rc.session?.password || globalThis.process?.env?.NUXT_APP_SECRET || globalThis.process?.env?.NUXT_SESSION_PASSWORD || "qarpeo-cms-preview-secret";
1292
+ const secret = getSessionSecret(event);
1293
1293
  const enc = new TextEncoder();
1294
1294
  return crypto.subtle.importKey(
1295
1295
  "raw",
@@ -52,8 +52,10 @@ export function getSessionSecret(event, fallback) {
52
52
  if (fallback && fallback !== "qarpeo-storage-secret-key-salt") {
53
53
  return fallback;
54
54
  }
55
- const isProd = globalThis.process?.env?.NODE_ENV === "production";
56
- if (isProd) {
55
+ const isDevOrTest = Boolean(
56
+ import.meta.dev || globalThis.process?.env?.NODE_ENV === "development" || globalThis.process?.env?.NODE_ENV === "test" || env.NODE_ENV === "development"
57
+ );
58
+ if (!isDevOrTest) {
57
59
  throw new Error(
58
60
  "[qarpeo] Missing required secret: NUXT_APP_SECRET or NUXT_SESSION_PASSWORD must be configured in production for secure token and signature generation."
59
61
  );
@@ -1,3 +1,4 @@
1
+ import { getSessionSecret } from "./config.mjs";
1
2
  export function timingSafeEqualString(a, b) {
2
3
  if (typeof a !== "string" || typeof b !== "string") return false;
3
4
  const encoder = new TextEncoder();
@@ -18,10 +19,7 @@ export function timingSafeEqualString(a, b) {
18
19
  export const constantTimeEqual = timingSafeEqualString;
19
20
  const ENC_PREFIX = "enc:";
20
21
  function resolveTokenSecret(event) {
21
- const ev = event;
22
- return ev?.context?.cloudflare?.env?.NUXT_APP_SECRET || globalThis.process?.env?.NUXT_APP_SECRET || ev?.context?.cloudflare?.env?.NUXT_SESSION_PASSWORD || globalThis.process?.env?.NUXT_SESSION_PASSWORD || // Dev-only fallback — in production NUXT_APP_SECRET must be set
23
- // (enforced by the auth startup guard in serverAuth())
24
- "qarpeo-auth-internal-dev-salt-key-32b";
22
+ return getSessionSecret(event);
25
23
  }
26
24
  async function deriveAesGcmKey(password, usage) {
27
25
  const encoder = new TextEncoder();
@@ -139,15 +139,19 @@ export async function registerCustomDomain(tenantId, rawDomain, options = {}, ev
139
139
  value: cfResult.ownership_verification.value
140
140
  });
141
141
  } else if (!cfResult) {
142
+ const tokenBytes = new Uint8Array(16);
143
+ crypto.getRandomValues(tokenBytes);
144
+ const tokenHex = Array.from(tokenBytes, (b) => b.toString(16).padStart(2, "0")).join("");
142
145
  verificationRecords.push({
143
146
  type: "txt",
144
147
  name: `_cf-custom-hostname.${domain}`,
145
- value: `qarpeo-verify-${Math.random().toString(36).slice(2, 10)}`
148
+ value: `qarpeo-verify-${tokenHex}`
146
149
  });
147
150
  }
148
151
  const now = Date.now();
152
+ const randomSuffix = crypto.randomUUID().slice(0, 8);
149
153
  const record = {
150
- id: cfResult?.id || `dom_${now}_${Math.random().toString(36).slice(2, 8)}`,
154
+ id: cfResult?.id || `dom_${now}_${randomSuffix}`,
151
155
  tenantId,
152
156
  domain,
153
157
  status: cfResult?.status || "pending",
@@ -17,7 +17,13 @@ export async function sendOTPCode(event, email, options = {}) {
17
17
  }).catch((err) => {
18
18
  if (err?.statusCode === 429) throw err;
19
19
  });
20
- const code = Math.floor(1e5 + Math.random() * 9e5).toString();
20
+ const buf = new Uint32Array(1);
21
+ const maxRange = 9e5;
22
+ const limit = Math.floor(4294967295 / maxRange) * maxRange;
23
+ do {
24
+ crypto.getRandomValues(buf);
25
+ } while (buf[0] >= limit);
26
+ const code = (1e5 + buf[0] % maxRange).toString();
21
27
  const codeHash = await hashSessionToken(code);
22
28
  const authConfig = getQarpeoConfig(event).auth;
23
29
  const otpCfg = typeof authConfig.passwordless?.otp === "object" ? authConfig.passwordless.otp : void 0;
@@ -7,17 +7,69 @@ function pemToDer(pem) {
7
7
  for (let i = 0; i < binary.length; i++) view[i] = binary.charCodeAt(i);
8
8
  return buf;
9
9
  }
10
+ function parseAsn1Length(bytes, offset) {
11
+ const first = bytes[offset];
12
+ if (first === void 0) return { len: 0, headerLen: 0 };
13
+ if ((first & 128) === 0) {
14
+ return { len: first, headerLen: 1 };
15
+ }
16
+ const numOctets = first & 127;
17
+ let len = 0;
18
+ for (let i = 0; i < numOctets; i++) {
19
+ len = len << 8 | (bytes[offset + 1 + i] || 0);
20
+ }
21
+ return { len, headerLen: 1 + numOctets };
22
+ }
23
+ function extractSpkiFromX509Der(derBuf) {
24
+ try {
25
+ const bytes = new Uint8Array(derBuf);
26
+ if (bytes[0] !== 48) return null;
27
+ const outer = parseAsn1Length(bytes, 1);
28
+ let pos = 1 + outer.headerLen;
29
+ if (bytes[pos] !== 48) return null;
30
+ const tbs = parseAsn1Length(bytes, pos + 1);
31
+ pos = pos + 1 + tbs.headerLen;
32
+ if (bytes[pos] === 160) {
33
+ const v = parseAsn1Length(bytes, pos + 1);
34
+ pos += 1 + v.headerLen + v.len;
35
+ }
36
+ if (bytes[pos] === 2) {
37
+ const s = parseAsn1Length(bytes, pos + 1);
38
+ pos += 1 + s.headerLen + s.len;
39
+ }
40
+ if (bytes[pos] === 48) {
41
+ const a = parseAsn1Length(bytes, pos + 1);
42
+ pos += 1 + a.headerLen + a.len;
43
+ }
44
+ if (bytes[pos] === 48) {
45
+ const iss = parseAsn1Length(bytes, pos + 1);
46
+ pos += 1 + iss.headerLen + iss.len;
47
+ }
48
+ if (bytes[pos] === 48) {
49
+ const val = parseAsn1Length(bytes, pos + 1);
50
+ pos += 1 + val.headerLen + val.len;
51
+ }
52
+ if (bytes[pos] === 48) {
53
+ const sub = parseAsn1Length(bytes, pos + 1);
54
+ pos += 1 + sub.headerLen + sub.len;
55
+ }
56
+ if (bytes[pos] === 48) {
57
+ const spki = parseAsn1Length(bytes, pos + 1);
58
+ const spkiTotal = 1 + spki.headerLen + spki.len;
59
+ return bytes.slice(pos, pos + spkiTotal).buffer;
60
+ }
61
+ } catch {
62
+ }
63
+ return null;
64
+ }
10
65
  async function importCertPublicKey(certPem) {
11
66
  try {
12
- const normalized = certPem.includes("BEGIN") ? certPem : `-----BEGIN CERTIFICATE-----
13
- ${certPem}
14
- -----END CERTIFICATE-----`;
15
- const der = pemToDer(normalized);
16
- const cert = await crypto.subtle.importKey("raw", der, { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }, false, ["verify"]).catch(() => null);
17
- if (cert) return cert;
67
+ const der = pemToDer(certPem);
68
+ const spki = extractSpkiFromX509Der(der);
69
+ const keyDer = spki || der;
18
70
  return await crypto.subtle.importKey(
19
71
  "spki",
20
- der,
72
+ keyDer,
21
73
  { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },
22
74
  false,
23
75
  ["verify"]
@@ -4,3 +4,8 @@ export declare function slugify(text: string): string;
4
4
  export declare function escapeHtml(str: string): string;
5
5
  /** Sanitizes a URL to prevent javascript: or data: injection. */
6
6
  export declare function sanitizeUrl(url: string): string;
7
+ /**
8
+ * Validates a redirect URL to ensure it is a safe local/relative path, preventing open redirect
9
+ * phishing attacks (e.g. `//evil.com`, `https://evil.com`, `/\evil.com`).
10
+ */
11
+ export declare function safeRedirect(url: unknown, fallback?: string): string;
@@ -12,3 +12,13 @@ export function sanitizeUrl(url) {
12
12
  }
13
13
  return "#";
14
14
  }
15
+ export function safeRedirect(url, fallback = "/") {
16
+ if (typeof url !== "string") return fallback;
17
+ const trimmed = url.trim();
18
+ if (!trimmed) return fallback;
19
+ if (trimmed.startsWith("/") && !trimmed.startsWith("//") && !trimmed.startsWith("/\\") && !trimmed.startsWith("\\")) {
20
+ if (/[\r\n\0]/.test(trimmed)) return fallback;
21
+ return trimmed;
22
+ }
23
+ return fallback;
24
+ }
@@ -13,9 +13,13 @@ export async function verifyTurnstileToken(event, token, remoteIp) {
13
13
  }
14
14
  const authConfig = getQarpeoConfig(event).auth || {};
15
15
  const turnstileConfig = typeof authConfig.turnstile === "object" ? authConfig.turnstile : {};
16
- const secretKey = globalThis.process?.env?.NUXT_TURNSTILE_SECRET_KEY || globalThis.process?.env?.TURNSTILE_SECRET_KEY || turnstileConfig.secretKey;
16
+ const cfEnv = event?.context?.cloudflare?.env;
17
+ const secretKey = cfEnv?.NUXT_TURNSTILE_SECRET_KEY || cfEnv?.TURNSTILE_SECRET_KEY || globalThis.process?.env?.NUXT_TURNSTILE_SECRET_KEY || globalThis.process?.env?.TURNSTILE_SECRET_KEY || turnstileConfig.secretKey;
17
18
  if (!secretKey) {
18
- if (globalThis.process?.env?.NODE_ENV !== "production") {
19
+ const isDev = Boolean(
20
+ import.meta.dev || globalThis.process?.env?.NODE_ENV === "development" || globalThis.process?.env?.NODE_ENV === "test" || cfEnv?.NODE_ENV === "development"
21
+ );
22
+ if (isDev) {
19
23
  console.warn(
20
24
  "[qarpeo:turnstile] NUXT_TURNSTILE_SECRET_KEY is not set. Allowing request in development mode."
21
25
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qarpeo",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "description": "Zero-config Cloudflare Edge Platform for Nuxt",
5
5
  "keywords": [
6
6
  "analytics-engine",