Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat(auth): choose the login bot check with BOT_PROTECTION — BotID or Turnstile (#1728)
Sid5ba005208b53
diff --git a/.claude/rules/authentication-system.md b/.claude/rules/authentication-system.mdindex 7d5d2ca893..0d9fbec0d5 100644--- a/.claude/rules/authentication-system.md+++ b/.claude/rules/authentication-system.md@@ -34,26 +34,31 @@ Export subpaths (`package.json`): `.` (`index.ts`), `./auth.server`, `./session.## Login (`apps/erp/app/routes/_public+/login.tsx`)Magic link is the primary flow. The action rate-limits by IP (Upstash via `@carbon/kv`,-`RATE_LIMIT` env default **5 / hour**), runs Vercel BotID (`verifyBotId`), then:--- `DEV_BYPASS_EMAIL` match + active user → `signInWithBypassEmail` (local dev only).-- Existing active user → `sendMagicLink` (Supabase OTP email).--**Bot protection (Vercel BotID).** `botIdEnabled` (`auth.server.ts`) is true only for-the Cloud edition running ON Vercel (`IS_VERCEL`, from Vercel's own `VERCEL=1`, which-SST/Docker/local never set; they set `VERCEL_ENV` by hand). Every login loader-(erp, mes, academy, starter) returns it, and the page calls-`useBotIdProtection("/login", botIdEnabled)` (`@carbon/react`). That hook runs-`initBotId`, which patches `window.fetch` so a POST to `/login` or `/login.data` (React-Router's action URL) carries the invisible challenge. The action calls-`verifyBotId(ip, email)` → `checkBotId()`. Both sides read the one flag on purpose:-off Vercel the challenge script (served through the `apps/*/vercel.json` rewrites) 404s-and the patched fetch rejects, so the client must never init where the server cannot-verify. A `checkBotId` THROW (e.g. the project's OIDC token is off) fails OPEN and logs.-It is a platform misconfiguration, not a verdict, and failing closed would lock out every-Cloud user. The rate limit and lockout still apply. Supabase Auth captcha (Attack Protection)-must stay OFF: GoTrue only verifies hCaptcha/Turnstile tokens, and the magic-link call-sends none.+`RATE_LIMIT` env default **5 / hour**), runs the bot check (`verifyBotProtection`), then:++**Bot protection.** `botProtection` (`bot-protection.server.ts`, re-exported from+`auth.server.ts`) picks ONE provider per process from `BOT_PROTECTION`: `"botid"` (only+ON Vercel — `IS_VERCEL`, from Vercel's own `VERCEL=1`, which SST/Docker/the BYOC chart+never set) or `"turnstile"` (needs both `CLOUDFLARE_TURNSTILE_SITE_KEY` and+`_SECRET_KEY`). Unset: BotID for Cloud on Vercel, else Turnstile when both keys are set,+else `null` (no check). It is explicit because the Turnstile keys can be present for+something else (GoTrue, another form) while login uses BotID. An explicit value that+cannot work (botid off Vercel, turnstile without keys, anything else) throws at boot.+Every login loader (erp, mes, academy, starter) returns it, and the page calls+`useBotProtection("/login", botProtection)` (`@carbon/react`), which returns+`{ token, ready, challenge }`: render `challenge` in the form, post `token` as the hidden+`botToken`, and disable submit until `ready`. For BotID the hook runs `initBotId`, which+patches `window.fetch` so a POST to `/login` or `/login.data` carries the invisible+challenge, and `challenge` is null. For Turnstile it renders the widget and `ready` waits+on its token. The action calls `verifyBotProtection({ token: botToken, ip, actor })`.+Both sides read the one value on purpose: off Vercel the BotID script (served through the+`apps/*/vercel.json` rewrites) 404s and the patched fetch rejects, so the client must+never init BotID where the server cannot verify it. Failure modes differ deliberately: a+`checkBotId` THROW fails OPEN and logs (a platform misconfiguration would otherwise lock+out every Cloud user), while an unreachable Turnstile siteverify fails CLOSED (an operator+chose Turnstile by setting its keys). The rate limit and lockout apply either way.+Turnstile is verified in-app only; Supabase Auth captcha (Attack Protection) must stay OFF,+because the magic-link call forwards no token to GoTrue.- Unknown user (non-Enterprise) → `sendVerificationCode`, redirect to `/verify` (emailverification-code signup). Enterprise edition rejects unknown users.@@ -397,7 +402,7 @@ ERP exposes an OAuth 2.0 AS for use as a remote Claude/MCP connector. Routes und`SUPABASE_URL`, `SUPABASE_ANON_KEY`, `SUPABASE_SERVICE_ROLE_KEY`, `SUPABASE_JWT_SECRET`,`SESSION_SECRET`, `SESSION_KEY` (`"auth"`), `SESSION_MAX_AGE`,`REFRESH_ACCESS_TOKEN_THRESHOLD`, `DOMAIN`, `RATE_LIMIT`, `CarbonEdition`,-`STRIPE_BYPASS_COMPANY_IDS`, `IS_VERCEL`, OAuth-provider keys.+`STRIPE_BYPASS_COMPANY_IDS`, `IS_VERCEL`, Turnstile + OAuth-provider keys.## Gotchas@@ -413,4 +418,4 @@ ERP exposes an OAuth 2.0 AS for use as a remote Claude/MCP connector. Routes und- Service-role clients bypass RLS — only use behind `bypassRls` + employee role.- API key `scopes: {}` denies, not grants. Don't assume empty = full access.- Edition matters: Enterprise rejects unknown-user login; Cloud gates API keys by plan- and enforces BotID (on Vercel only).+ and enforces the bot check (BotID on Vercel, Turnstile elsewhere).diff --git a/.claude/rules/environment-configuration.md b/.claude/rules/environment-configuration.mdindex 8513d8c7e2..127ff8884d 100644--- a/.claude/rules/environment-configuration.md+++ b/.claude/rules/environment-configuration.md@@ -70,8 +70,10 @@ secret), `SUPABASE_JWT_SECRET` (optional), plus**Auth / session** — `SESSION_SECRET` (required; also signs the short-lived,single-use `carbon-oauth-state` cookie in `@carbon/auth/oauth-state.server`), `AUTH_PROVIDERS`(`email,google,azure,passkey,sso`; gate via `isAuthProviderEnabled`),-`RATE_LIMIT`. `IS_VERCEL` reads Vercel's own `VERCEL=1` and gates-login BotID (see `authentication-system.md`).+`CLOUDFLARE_TURNSTILE_SITE_KEY` / `_SECRET_KEY`, `RATE_LIMIT`. `IS_VERCEL` reads+Vercel's own `VERCEL=1`. `BOT_PROTECTION` (`botid` | `turnstile`, unset = BotID for+Cloud on Vercel, else Turnstile if keyed) picks the login bot check (see+`authentication-system.md`).`SAML_ENABLED` / `SAML_PRIVATE_KEY` are NOT `@carbon/env` vars — they live inroot `.env` and reach GoTrue via docker-compose substitution (`GOTRUE_SAML_*`).Both `crbn up` and `crbn reload` preload `.env.local` then `.env` intodiff --git a/.claude/rules/sst-deployment-infrastructure.md b/.claude/rules/sst-deployment-infrastructure.mdindex 65373afffe..6fb1595e61 100644--- a/.claude/rules/sst-deployment-infrastructure.md+++ b/.claude/rules/sst-deployment-infrastructure.md@@ -122,7 +122,8 @@ job instead — see [the self-host deployment README](../../contrib/deploying/si## Env vars passed to the services (`sst.config.ts` `environment`)Both services get Supabase (`SUPABASE_URL`/`ANON_KEY`/`SERVICE_ROLE_KEY`/`JWT_SECRET`/`DB_URL`), `SESSION_SECRET`, `REDIS_URL`, `INNGEST_*`, `RESEND_*`, `EXCHANGE_RATES_API_KEY`,-`POSTHOG_*`, `CARBON_EDITION`, `CONTROLLED_ENVIRONMENT`, `DOMAIN`, `ERP_URL`/`MES_URL`,+`POSTHOG_*`, `CARBON_EDITION`, `BOT_PROTECTION`, `CLOUDFLARE_TURNSTILE_*`,+`CONTROLLED_ENVIRONMENT`, `DOMAIN`, `ERP_URL`/`MES_URL`,`NODE_ENV=production`, `VERCEL_ENV=production`, `VERCEL_URL` (set to the app host —there is no real Vercel deploy, this is just an env shim). ERP additionally gets`OPENAI_API_KEY`, `GOOGLE_PLACES_API_KEY`, `STRIPE_*`,diff --git a/.env.example b/.env.exampleindex e874df522e..141b26c07e 100644--- a/.env.example+++ b/.env.example@@ -47,6 +47,15 @@ SMTP_FROM="Carbon <[email protected]>"# INNGEST_SIGNING_KEY="signkey-****-********************"# INNGEST_EVENT_KEY="********************"+# Cloudflare Turnstile — the login bot check off Vercel (on Vercel, BotID runs+# instead). Both keys or neither. The pair below is Cloudflare's always-pass+# test pair, for exercising the widget locally.+# CLOUDFLARE_TURNSTILE_SITE_KEY="1x00000000000000000000AA"+# CLOUDFLARE_TURNSTILE_SECRET_KEY="1x0000000000000000000000000000000AA"+# Which check guards login: "botid" (Vercel only) or "turnstile". Unset picks+# BotID for Cloud on Vercel, else Turnstile when the keys above are set.+# BOT_PROTECTION="turnstile"+# SlackSLACK_BOT_TOKEN="***********************"diff --git a/apps/academy/app/routes/_auth+/login.tsx b/apps/academy/app/routes/_auth+/login.tsxindex d61f742929..e61794462e 100644--- a/apps/academy/app/routes/_auth+/login.tsx+++ b/apps/academy/app/routes/_auth+/login.tsx@@ -8,11 +8,11 @@ import {SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID} from "@carbon/auth";import {- botIdEnabled,+ botProtection,getMagicLinkErrorMessage,sendMagicLink,verifyAuthSession,- verifyBotId+ verifyBotProtection} from "@carbon/auth/auth.server";import { flash, getAuthSession } from "@carbon/auth/session.server";import { getUserByEmail } from "@carbon/auth/users.server";@@ -26,7 +26,7 @@ import {Heading,Separator,toast,- useBotIdProtection,+ useBotProtection,VStack} from "@carbon/react";import { LuCircleAlert } from "react-icons/lu";@@ -58,7 +58,7 @@ export async function loader({ request }: LoaderFunctionArgs) {return {hasOutlookAuth: !!SUPABASE_AUTH_EXTERNAL_AZURE_CLIENT_ID,hasGoogleAuth: !!SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID,- botIdEnabled+ botProtection};}@@ -87,9 +87,13 @@ export async function action({ request }: ActionFunctionArgs) {return error(validation.error, "Invalid email address");}- const { email } = validation.data;+ const { email, botToken } = validation.data;- const botError = await verifyBotId(ip, email);+ const botError = await verifyBotProtection({+ token: botToken,+ ip,+ actor: email+ });if (botError) {return data(error(null, botError),@@ -120,15 +124,15 @@ export async function action({ request }: ActionFunctionArgs) {}export default function LoginRoute() {- const { hasOutlookAuth, hasGoogleAuth, botIdEnabled } =+ const { hasOutlookAuth, hasGoogleAuth, botProtection } =useLoaderData<typeof loader>();- useBotIdProtection("/login", botIdEnabled);const [searchParams] = useSearchParams();const redirectTo = searchParams.get("redirectTo") ?? undefined;const fetcher = useFetcher<{ success: true } | { success: false; message: string }>();+ const bot = useBotProtection("/login", botProtection, fetcher.data);const onSignInWithGoogle = async () => {const { error } = await carbonClient.auth.signInWithOAuth({@@ -184,6 +188,7 @@ export default function LoginRoute() {method="post"><Hidden name="redirectTo" value={redirectTo} type="hidden" />+ <Hidden name="botToken" value={bot.token} /><VStack spacing={2}>{fetcher.data?.success === false && fetcher.data?.message && (<Alert variant="destructive">@@ -229,7 +234,7 @@ export default function LoginRoute() {<Input name="email" label="" placeholder="Email Address" /><Submit- isDisabled={fetcher.state !== "idle"}+ isDisabled={fetcher.state !== "idle" || !bot.ready}isLoading={fetcher.state === "submitting"}size="lg"className="w-full"@@ -238,6 +243,7 @@ export default function LoginRoute() {>Sign in with Email</Submit>+ {bot.challenge}</VStack></ValidatedForm>)}diff --git a/apps/erp/app/modules/agent/kb/docs/platform/self-hosting/environment-variables.md b/apps/erp/app/modules/agent/kb/docs/platform/self-hosting/environment-variables.mdindex 470dd1fb9b..89c2dd2fdf 100644--- a/apps/erp/app/modules/agent/kb/docs/platform/self-hosting/environment-variables.md+++ b/apps/erp/app/modules/agent/kb/docs/platform/self-hosting/environment-variables.md@@ -44,9 +44,12 @@ Enterprise `docs/reference/single-sign-on` adds two more:Turns on the SAML engine in the auth service.SAML signing key — base64-encoded PKCS#1 DER RSA, minimum 2048-bit; the generation command is in `.env.example`.-Carbon Cloud protects sign-in with Vercel BotID. It runs only on a Vercel deployment of-the Cloud edition and needs no environment variables, so a self-hosted instance has no-bot check on sign-in. The per-IP rate limit and per-account lockout still apply.+Sign-in bot protection is Cloudflare Turnstile off Vercel: set both+`CLOUDFLARE_TURNSTILE_SITE_KEY` and `CLOUDFLARE_TURNSTILE_SECRET_KEY` and every login form+shows the widget and verifies its token. With neither set there is no bot check, and the+per-IP rate limit and per-account lockout are all that apply. `BOT_PROTECTION`+chooses explicitly: `turnstile`, or `botid` for Vercel BotID, which is invisible but runs+only on Vercel.## Jobs & cachediff --git a/apps/erp/app/routes/_public+/login.tsx b/apps/erp/app/routes/_public+/login.tsxindex 0c0c9a9a98..5c82082b9e 100644--- a/apps/erp/app/routes/_public+/login.tsx+++ b/apps/erp/app/routes/_public+/login.tsx@@ -9,13 +9,13 @@ import {RATE_LIMIT} from "@carbon/auth";import {- botIdEnabled,+ botProtection,getMagicLinkErrorMessage,logAuthEvent,sendMagicLink,signInWithBypassEmail,verifyAuthSession,- verifyBotId+ verifyBotProtection} from "@carbon/auth/auth.server";import { getCarbonServiceRole } from "@carbon/auth/client.server";import {@@ -44,7 +44,7 @@ import {ItarLoginDisclaimer,Separator,toast,- useBotIdProtection,+ useBotProtection,useMount,VStack} from "@carbon/react";@@ -93,7 +93,7 @@ export async function loader({ request }: LoaderFunctionArgs) {hasGoogleAuth,hasPasskeyAuth,hasSsoAuth,- botIdEnabled+ botProtection},{ headers: cookieHeaders });@@ -104,7 +104,7 @@ export async function loader({ request }: LoaderFunctionArgs) {hasGoogleAuth,hasPasskeyAuth,hasSsoAuth,- botIdEnabled+ botProtection};}@@ -134,7 +134,7 @@ export async function action({ request }: ActionFunctionArgs) {return error(validation.error, "Invalid email address");}- const { email } = validation.data;+ const { email, botToken } = validation.data;// Per-account lockout (NIST 800-171 3.1.8) — layered ON TOP of the IP limit// above. Keyed by the normalized email so an attacker rotating IPs, or@@ -159,7 +159,11 @@ export async function action({ request }: ActionFunctionArgs) {);}- const botError = await verifyBotId(ip, email);+ const botError = await verifyBotProtection({+ token: botToken,+ ip,+ actor: email+ });if (botError) {return data(error(null, botError),@@ -294,9 +298,8 @@ export default function LoginRoute() {hasGoogleAuth,hasPasskeyAuth,hasSsoAuth,- botIdEnabled+ botProtection} = useLoaderData<typeof loader>();- useBotIdProtection("/login", botIdEnabled);const [searchParams] = useSearchParams();const redirectTo = searchParams.get("redirectTo") ?? undefined;@@ -323,6 +326,7 @@ export default function LoginRoute() {}, [logoutReason]);const fetcher = useFetcher<Result & { mode?: string; email?: string }>();+ const bot = useBotProtection("/login", botProtection, fetcher.data);useEffect(() => {if (fetcher.data?.success && fetcher.data.mode) {@@ -606,6 +610,7 @@ export default function LoginRoute() {onSubmit={onSubmitEmail}><Hidden name="redirectTo" value={redirectTo} type="hidden" />+ <Hidden name="botToken" value={bot.token} /><VStack spacing={2}>{((fetcher.data?.success === false && fetcher.data?.message) ||ssoError) && (@@ -677,7 +682,9 @@ export default function LoginRoute() {/><Submit- isDisabled={fetcher.state !== "idle" || ssoLoading}+ isDisabled={+ fetcher.state !== "idle" || ssoLoading || !bot.ready+ }isLoading={fetcher.state === "submitting" || ssoLoading}hideShortcutKeysize="lg"@@ -687,6 +694,7 @@ export default function LoginRoute() {><Trans>Continue</Trans></Submit>+ {bot.challenge}</VStack></ValidatedForm>)}diff --git a/apps/mes/app/routes/_public+/login.tsx b/apps/mes/app/routes/_public+/login.tsxindex ac40e8e53a..152fbe0824 100644--- a/apps/mes/app/routes/_public+/login.tsx+++ b/apps/mes/app/routes/_public+/login.tsx@@ -10,13 +10,13 @@ import {RATE_LIMIT} from "@carbon/auth";import {- botIdEnabled,+ botProtection,getMagicLinkErrorMessage,logAuthEvent,sendMagicLink,signInWithBypassEmail,verifyAuthSession,- verifyBotId+ verifyBotProtection} from "@carbon/auth/auth.server";import { getCarbonServiceRole } from "@carbon/auth/client.server";import {@@ -38,7 +38,7 @@ import {ItarLoginDisclaimer,Separator,toast,- useBotIdProtection,+ useBotProtection,useMount,VStack} from "@carbon/react";@@ -87,7 +87,7 @@ export async function loader({ request }: LoaderFunctionArgs) {hasGoogleAuth,hasPasskeyAuth,hasSsoAuth,- botIdEnabled+ botProtection},{ headers: cookieHeaders });@@ -98,7 +98,7 @@ export async function loader({ request }: LoaderFunctionArgs) {hasGoogleAuth,hasPasskeyAuth,hasSsoAuth,- botIdEnabled+ botProtection};}@@ -127,9 +127,13 @@ export async function action({ request }: ActionFunctionArgs) {return error(validation.error, "Invalid email address");}- const { email } = validation.data;+ const { email, botToken } = validation.data;- const botError = await verifyBotId(ip, email);+ const botError = await verifyBotProtection({+ token: botToken,+ ip,+ actor: email+ });if (botError) {return data(error(null, botError),@@ -241,9 +245,8 @@ export default function LoginRoute() {hasGoogleAuth,hasPasskeyAuth,hasSsoAuth,- botIdEnabled+ botProtection} = useLoaderData<typeof loader>();- useBotIdProtection("/login", botIdEnabled);const [searchParams] = useSearchParams();const redirectTo = searchParams.get("redirectTo") ?? undefined;@@ -252,6 +255,7 @@ export default function LoginRoute() {const fetcher = useFetcher<{ success: true } | { success: false; message: string }>();+ const bot = useBotProtection("/login", botProtection, fetcher.data);const [passkeySupported, setPasskeySupported] = useState(false);const [passkeyLoading, setPasskeyLoading] = useState(false);@@ -497,6 +501,7 @@ export default function LoginRoute() {onSubmit={onSubmitEmail}><Hidden name="redirectTo" value={redirectTo} type="hidden" />+ <Hidden name="botToken" value={bot.token} /><VStack spacing={2}>{((fetcher.data?.success === false && fetcher.data?.message) ||ssoError) && (@@ -571,7 +576,9 @@ export default function LoginRoute() {/><Submit- isDisabled={fetcher.state !== "idle" || ssoLoading}+ isDisabled={+ fetcher.state !== "idle" || ssoLoading || !bot.ready+ }isLoading={fetcher.state === "submitting" || ssoLoading}hideShortcutKeysize="lg"@@ -581,6 +588,7 @@ export default function LoginRoute() {><Trans>Continue</Trans></Submit>+ {bot.challenge}</VStack></ValidatedForm>)}diff --git a/apps/starter/app/routes/_public+/login.tsx b/apps/starter/app/routes/_public+/login.tsxindex 1cbd12b1cf..2fd0512db8 100644--- a/apps/starter/app/routes/_public+/login.tsx+++ b/apps/starter/app/routes/_public+/login.tsx@@ -8,11 +8,11 @@ import {SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID} from "@carbon/auth";import {- botIdEnabled,+ botProtection,getMagicLinkErrorMessage,sendMagicLink,verifyAuthSession,- verifyBotId+ verifyBotProtection} from "@carbon/auth/auth.server";import { flash, getAuthSession } from "@carbon/auth/session.server";import { getUserByEmail } from "@carbon/auth/users.server";@@ -26,7 +26,7 @@ import {Heading,Separator,toast,- useBotIdProtection,+ useBotProtection,VStack} from "@carbon/react";import { LuCircleAlert } from "react-icons/lu";@@ -58,7 +58,7 @@ export async function loader({ request }: LoaderFunctionArgs) {return {hasOutlookAuth: !!SUPABASE_AUTH_EXTERNAL_AZURE_CLIENT_ID,hasGoogleAuth: !!SUPABASE_AUTH_EXTERNAL_GOOGLE_CLIENT_ID,- botIdEnabled+ botProtection};}@@ -87,9 +87,13 @@ export async function action({ request }: ActionFunctionArgs) {return error(validation.error, "Invalid email address");}- const { email } = validation.data;+ const { email, botToken } = validation.data;- const botError = await verifyBotId(ip, email);+ const botError = await verifyBotProtection({+ token: botToken,+ ip,+ actor: email+ });if (botError) {return data(error(null, botError),@@ -120,15 +124,15 @@ export async function action({ request }: ActionFunctionArgs) {}export default function LoginRoute() {- const { hasOutlookAuth, hasGoogleAuth, botIdEnabled } =+ const { hasOutlookAuth, hasGoogleAuth, botProtection } =useLoaderData<typeof loader>();- useBotIdProtection("/login", botIdEnabled);const [searchParams] = useSearchParams();const redirectTo = searchParams.get("redirectTo") ?? undefined;const fetcher = useFetcher<{ success: true } | { success: false; message: string }>();+ const bot = useBotProtection("/login", botProtection, fetcher.data);const onSignInWithGoogle = async () => {const { error } = await carbonClient.auth.signInWithOAuth({@@ -193,6 +197,7 @@ export default function LoginRoute() {method="post"><Hidden name="redirectTo" value={redirectTo} type="hidden" />+ <Hidden name="botToken" value={bot.token} /><VStack spacing={2}>{fetcher.data?.success === false && fetcher.data?.message && (<Alert variant="destructive">@@ -238,7 +243,7 @@ export default function LoginRoute() {<Input name="email" label="" placeholder="Email Address" /><Submit- isDisabled={fetcher.state !== "idle"}+ isDisabled={fetcher.state !== "idle" || !bot.ready}isLoading={fetcher.state === "submitting"}size="lg"className="w-full"@@ -247,6 +252,7 @@ export default function LoginRoute() {>Sign in with Email</Submit>+ {bot.challenge}</VStack></ValidatedForm>)}diff --git a/ci/src/deploy.ts b/ci/src/deploy.tsindex ccd761f0dc..21b60e45c1 100644--- a/ci/src/deploy.ts+++ b/ci/src/deploy.ts@@ -40,6 +40,8 @@ export type Workspace = {// App Configurationauth_providers: string | null;carbon_edition: string | null;+ cloudflare_turnstile_secret_key: string | null;+ cloudflare_turnstile_site_key: string | null;controlled_environment: string | null;exchange_rates_api_key: string | null;google_places_api_key: string | null;@@ -120,6 +122,8 @@ async function deploy(): Promise<void> {carbon_edition,cert_arn_erp,cert_arn_mes,+ cloudflare_turnstile_secret_key,+ cloudflare_turnstile_site_key,controlled_environment,database_connection_pooler_url,database_password,@@ -284,6 +288,10 @@ async function deploy(): Promise<void> {CARBON_EDITION: carbon_edition ?? "enterprise",CERT_ARN_ERP: cert_arn_erp,CERT_ARN_MES: cert_arn_mes,+ CLOUDFLARE_TURNSTILE_SECRET_KEY:+ cloudflare_turnstile_secret_key ?? undefined,+ CLOUDFLARE_TURNSTILE_SITE_KEY:+ cloudflare_turnstile_site_key ?? undefined,CONTROLLED_ENVIRONMENT: controlled_environment ?? undefined,DOMAIN: domain_name,EXCHANGE_RATES_API_KEY: exchange_rates_api_key ?? undefined,diff --git a/docs/content/docs/platform/self-hosting/environment-variables.mdx b/docs/content/docs/platform/self-hosting/environment-variables.mdxindex ef7842d7c8..d86c18c86c 100644--- a/docs/content/docs/platform/self-hosting/environment-variables.mdx+++ b/docs/content/docs/platform/self-hosting/environment-variables.mdx@@ -53,9 +53,12 @@ Enterprise [SAML single sign-on](/docs/reference/single-sign-on) adds two more:<EnvVar name="SAML_PRIVATE_KEY" type="string">SAML signing key — base64-encoded PKCS#1 DER RSA, minimum 2048-bit; the generation command is in `.env.example`.</EnvVar></EnvVars>-Carbon Cloud protects sign-in with Vercel BotID. It runs only on a Vercel deployment of-the Cloud edition and needs no environment variables, so a self-hosted instance has no-bot check on sign-in. The per-IP rate limit and per-account lockout still apply.+Sign-in bot protection is Cloudflare Turnstile off Vercel: set both+`CLOUDFLARE_TURNSTILE_SITE_KEY` and `CLOUDFLARE_TURNSTILE_SECRET_KEY` and every login form+shows the widget and verifies its token. With neither set there is no bot check, and the+per-IP rate limit and per-account lockout are all that apply. `BOT_PROTECTION`+chooses explicitly: `turnstile`, or `botid` for Vercel BotID, which is invisible but runs+only on Vercel.## Jobs & cachediff --git a/packages/auth/src/services/auth.server.ts b/packages/auth/src/services/auth.server.tsindex 1c042cc27a..afc78e9c4f 100644--- a/packages/auth/src/services/auth.server.ts+++ b/packages/auth/src/services/auth.server.ts@@ -11,14 +11,12 @@ import type {AuthSession as SupabaseAuthSession,SupabaseClient} from "@supabase/supabase-js";-import { checkBotId } from "botid/server";import { createHash } from "crypto";import { redirect } from "react-router";import {CarbonEdition,CONTROLLED_ENVIRONMENT,IS_LOCAL_DEV,- IS_VERCEL,REFRESH_ACCESS_TOKEN_THRESHOLD,SESSION_IDLE_LOCK_MS,STRIPE_BYPASS_COMPANY_IDS,@@ -458,15 +456,6 @@ export async function sendInviteByEmail(});}-const BOT_BLOCKED_MESSAGE = "Bot verification failed. Please try again.";--// Vercel BotID guards login on Cloud. It only works on a Vercel deployment:-// the client challenge script is served through Vercel rewrites (vercel.json)-// and checkBotId() needs Vercel's request context and OIDC token, so the SST,-// Docker and local stacks never enable it. Login loaders pass this flag to-// useBotIdProtection so the client and server can never disagree.-export const botIdEnabled = CarbonEdition === Edition.Cloud && IS_VERCEL;-export async function sendMagicLink(email: string,// The app's own origin. VERCEL_URL is only correct for the app it was set@@ -483,27 +472,11 @@ export async function sendMagicLink(});}-// Returns a user-facing message when BotID classifies the request as a bot,-// null when the gate passes. A request that skipped the client challenge-// arrives without the x-is-human header and is classified as a bot.-export async function verifyBotId(- ip: string,- actor?: string-): Promise<string | null> {- if (!botIdEnabled) return null;- try {- const { isBot } = await checkBotId();- if (!isBot) return null;- logAuthEvent("login_failed", { actor, ip, reason: "bot detected" });- return BOT_BLOCKED_MESSAGE;- } catch (e) {- // A throw is a platform misconfiguration (e.g. OIDC disabled on the- // project), not a verdict on the caller — fail open so it cannot lock- // every Cloud user out; the IP rate limit and account lockout still apply.- log.error("BotID check failed", { error: e });- return null;- }-}+export {+ type BotProtection,+ botProtection,+ verifyBotProtection+} from "./bot-protection.server";export function getMagicLinkErrorMessage(error: { code?: string }): string {switch (error.code) {diff --git a/packages/auth/src/services/bot-protection.server.ts b/packages/auth/src/services/bot-protection.server.tsnew file mode 100644index 0000000000..20f356b00c--- /dev/null+++ b/packages/auth/src/services/bot-protection.server.ts@@ -0,0 +1,129 @@+import { getLogger } from "@carbon/logger";+import { Edition } from "@carbon/utils";+import { checkBotId } from "botid/server";+import {+ BOT_PROTECTION,+ CarbonEdition,+ CLOUDFLARE_TURNSTILE_SECRET_KEY,+ CLOUDFLARE_TURNSTILE_SITE_KEY,+ IS_VERCEL+} from "../config/env";+import { logAuthEvent } from "./auth-events.server";++const log = getLogger("auth");++const BOT_BLOCKED_MESSAGE = "Bot verification failed. Please try again.";++// Which bot check guards login, decided once per process so the loader (which+// sets up the client half) and the action (which verifies) can never disagree.+//+// BOT_PROTECTION chooses. BotID is invisible but only works on Vercel: the+// challenge script is served through the rewrites in apps/*/vercel.json and+// checkBotId() needs Vercel's request context. Turnstile works anywhere with+// its two keys; the BYOC console's Integrations tab is where a self-hosted+// operator sets them. Unset: BotID for Cloud on Vercel, else Turnstile if its+// keys are set, else no check (the IP rate limit and lockout still stand).+//+// An explicit choice that cannot work stops the process at boot rather than+// leaving login unguarded without anyone noticing.+export type BotProtection =+ | { provider: "botid" }+ | { provider: "turnstile"; siteKey: string }+ | null;++function resolveBotProtection(): BotProtection {+ const turnstile: BotProtection =+ CLOUDFLARE_TURNSTILE_SITE_KEY && CLOUDFLARE_TURNSTILE_SECRET_KEY+ ? { provider: "turnstile", siteKey: CLOUDFLARE_TURNSTILE_SITE_KEY }+ : null;++ switch (BOT_PROTECTION) {+ case "botid":+ if (!IS_VERCEL) {+ throw new Error("BOT_PROTECTION=botid only works on Vercel");+ }+ return { provider: "botid" };+ case "turnstile":+ if (!turnstile) {+ throw new Error(+ "BOT_PROTECTION=turnstile needs CLOUDFLARE_TURNSTILE_SITE_KEY and CLOUDFLARE_TURNSTILE_SECRET_KEY"+ );+ }+ return turnstile;+ case undefined:+ case "":+ return CarbonEdition === Edition.Cloud && IS_VERCEL+ ? { provider: "botid" }+ : turnstile;+ default:+ throw new Error(+ `BOT_PROTECTION must be "botid" or "turnstile", got "${BOT_PROTECTION}"`+ );+ }+}++export const botProtection = resolveBotProtection();++// Returns a user-facing message when the request looks automated, null when+// the gate passes. `token` is the Turnstile response the form posted; BotID+// needs none, it reads the header its patched fetch added.+export async function verifyBotProtection({+ token,+ ip,+ actor+}: {+ token?: string;+ ip: string;+ actor?: string;+}): Promise<string | null> {+ if (!botProtection) return null;+ const isBot =+ botProtection.provider === "botid"+ ? await checkBotIdSafely()+ : !(await verifyTurnstileToken(token, ip));+ if (!isBot) return null;+ logAuthEvent("login_failed", { actor, ip, reason: "bot detected" });+ return BOT_BLOCKED_MESSAGE;+}++async function checkBotIdSafely(): Promise<boolean> {+ try {+ return (await checkBotId()).isBot;+ } catch (e) {+ // A throw is a platform misconfiguration (e.g. OIDC disabled on the+ // project), not a verdict on the caller — fail open so it cannot lock+ // every Cloud user out; the IP rate limit and account lockout still apply.+ log.error("BotID check failed", { error: e });+ return false;+ }+}++// Fails closed, unlike BotID: an operator chose Turnstile by setting its keys,+// so an unreachable siteverify is a reason to retry, not to wave bots through.+async function verifyTurnstileToken(+ token: string | undefined,+ remoteip: string+): Promise<boolean> {+ if (!token) return false;+ try {+ const response = await fetch(+ "https://challenges.cloudflare.com/turnstile/v0/siteverify",+ {+ method: "POST",+ signal: AbortSignal.timeout(5000),+ headers: { "Content-Type": "application/x-www-form-urlencoded" },+ body: new URLSearchParams({+ secret: CLOUDFLARE_TURNSTILE_SECRET_KEY ?? "",+ response: token,+ // the client address, not the full x-forwarded-for proxy chain+ remoteip: remoteip.split(",")[0]?.trim() ?? ""+ })+ }+ );+ const result = await response.json();+ return Boolean(result.success);+ } catch (e) {+ log.error("Turnstile siteverify request failed", { error: e });+ return false;+ }+}diff --git a/packages/auth/src/services/bot-protection.test.ts b/packages/auth/src/services/bot-protection.test.tsnew file mode 100644index 0000000000..c0ad0fdbf8--- /dev/null+++ b/packages/auth/src/services/bot-protection.test.ts@@ -0,0 +1,134 @@+import { afterEach, describe, expect, it, vi } from "vitest";++// botProtection is decided at import time from env, so each case sets the env+// stub, resets the module registry and imports the module fresh.+const env = vi.hoisted(() => ({+ CarbonEdition: "community",+ IS_VERCEL: false,+ BOT_PROTECTION: undefined as string | undefined,+ CLOUDFLARE_TURNSTILE_SITE_KEY: undefined as string | undefined,+ CLOUDFLARE_TURNSTILE_SECRET_KEY: undefined as string | undefined+}));+vi.mock("../config/env", () => env);++const checkBotId = vi.hoisted(() => vi.fn());+vi.mock("botid/server", () => ({ checkBotId }));+vi.mock("./auth-events.server", () => ({ logAuthEvent: vi.fn() }));++async function load(overrides: Partial<typeof env>) {+ Object.assign(env, {+ CarbonEdition: "community",+ IS_VERCEL: false,+ BOT_PROTECTION: undefined,+ CLOUDFLARE_TURNSTILE_SITE_KEY: undefined,+ CLOUDFLARE_TURNSTILE_SECRET_KEY: undefined,+ ...overrides+ });+ vi.resetModules();+ return import("./bot-protection.server");+}++const turnstileKeys = {+ CLOUDFLARE_TURNSTILE_SITE_KEY: "site",+ CLOUDFLARE_TURNSTILE_SECRET_KEY: "secret"+};++afterEach(() => {+ vi.unstubAllGlobals();+ checkBotId.mockReset();+});++describe("botProtection", () => {+ it("defaults to BotID for Cloud on Vercel, even with Turnstile keys set", async () => {+ const auth = await load({+ CarbonEdition: "cloud",+ IS_VERCEL: true,+ ...turnstileKeys+ });+ expect(auth.botProtection).toEqual({ provider: "botid" });+ });++ it("defaults to Turnstile off Vercel when both keys are set", async () => {+ const auth = await load({ CarbonEdition: "cloud", ...turnstileKeys });+ expect(auth.botProtection).toEqual({+ provider: "turnstile",+ siteKey: "site"+ });+ });++ it("defaults to no check with only a site key", async () => {+ const auth = await load({ CLOUDFLARE_TURNSTILE_SITE_KEY: "site" });+ expect(auth.botProtection).toBeNull();+ });++ it("uses BotID when chosen, though Turnstile keys are set for GoTrue", async () => {+ const auth = await load({+ IS_VERCEL: true,+ BOT_PROTECTION: "botid",+ ...turnstileKeys+ });+ expect(auth.botProtection).toEqual({ provider: "botid" });+ });++ it("uses Turnstile when chosen on Vercel Cloud", async () => {+ const auth = await load({+ CarbonEdition: "cloud",+ IS_VERCEL: true,+ BOT_PROTECTION: "turnstile",+ ...turnstileKeys+ });+ expect(auth.botProtection).toEqual({+ provider: "turnstile",+ siteKey: "site"+ });+ });++ it.each([+ ["botid off Vercel", { BOT_PROTECTION: "botid" }],+ ["turnstile without keys", { BOT_PROTECTION: "turnstile" }],+ ["an unknown value", { BOT_PROTECTION: "hcaptcha" }]+ ])("refuses to boot with %s", async (_, overrides) => {+ await expect(load(overrides)).rejects.toThrow(/BOT_PROTECTION/);+ });+});++describe("verifyBotProtection", () => {+ it("blocks a Turnstile login that posted no token", async () => {+ const auth = await load(turnstileKeys);+ const fetch = vi.fn();+ vi.stubGlobal("fetch", fetch);+ expect(await auth.verifyBotProtection({ ip: "1.2.3.4" })).not.toBeNull();+ expect(fetch).not.toHaveBeenCalled();+ });++ it("passes a token siteverify accepts", async () => {+ const auth = await load(turnstileKeys);+ vi.stubGlobal(+ "fetch",+ vi.fn().mockResolvedValue({ json: async () => ({ success: true }) })+ );+ expect(+ await auth.verifyBotProtection({ token: "t", ip: "1.2.3.4" })+ ).toBeNull();+ });++ it("fails closed when siteverify is unreachable", async () => {+ const auth = await load(turnstileKeys);+ vi.stubGlobal("fetch", vi.fn().mockRejectedValue(new Error("down")));+ expect(+ await auth.verifyBotProtection({ token: "t", ip: "1.2.3.4" })+ ).not.toBeNull();+ });++ it("fails open when BotID itself throws", async () => {+ const auth = await load({ CarbonEdition: "cloud", IS_VERCEL: true });+ checkBotId.mockRejectedValue(new Error("no OIDC token"));+ expect(await auth.verifyBotProtection({ ip: "1.2.3.4" })).toBeNull();+ });++ it("blocks what BotID calls a bot", async () => {+ const auth = await load({ CarbonEdition: "cloud", IS_VERCEL: true });+ checkBotId.mockResolvedValue({ isBot: true });+ expect(await auth.verifyBotProtection({ ip: "1.2.3.4" })).not.toBeNull();+ });+});diff --git a/packages/auth/src/validators.ts b/packages/auth/src/validators.tsindex 1004f5fbdc..69a596667e 100644--- a/packages/auth/src/validators.ts+++ b/packages/auth/src/validators.ts@@ -29,7 +29,9 @@ export const magicLinkValidator = z.object({.string().min(1, { message: "Email is required" }).email("Must be a valid email"),- redirectTo: zfd.text(z.string().optional())+ redirectTo: zfd.text(z.string().optional()),+ // The Turnstile response, when Turnstile is the bot check (see botProtection)+ botToken: zfd.text(z.string().optional())});export const passwordLoginValidator = z.object({diff --git a/packages/env/src/index.ts b/packages/env/src/index.tsindex 7b85a119a8..19ab99ff3e 100644--- a/packages/env/src/index.ts+++ b/packages/env/src/index.ts@@ -35,6 +35,8 @@ declare global {interface ProcessEnv {CARBON_EDITION: string;CARBON_API_URL: string;+ CLOUDFLARE_TURNSTILE_SITE_KEY: string;+ CLOUDFLARE_TURNSTILE_SECRET_KEY: string;DOMAIN: string;ERP_URL: string;JIRA_CLIENT_ID: string;@@ -160,6 +162,17 @@ export const CARBON_API_URL =isSecret: false}) ?? getEnv("SUPABASE_URL", { isSecret: false });+// Turnstile guards login wherever BotID can't run (anything not on Vercel).+// Both keys or neither: a site key alone would render a widget nobody checks.+export const CLOUDFLARE_TURNSTILE_SITE_KEY = getEnv(+ "CLOUDFLARE_TURNSTILE_SITE_KEY",+ { isRequired: false, isSecret: false }+);+export const CLOUDFLARE_TURNSTILE_SECRET_KEY = getEnv(+ "CLOUDFLARE_TURNSTILE_SECRET_KEY",+ { isRequired: false }+);+export const DOMAIN = getEnv("DOMAIN", { isRequired: false }); // preview environments need no domainexport const EXCHANGE_RATES_API_KEY = getEnv("EXCHANGE_RATES_API_KEY", {@@ -477,6 +490,15 @@ export const IS_LOCAL_DEV =export const IS_VERCEL =getEnv("VERCEL", { isRequired: false, isSecret: true }) === "1";+// Which check guards login: "botid" or "turnstile". Unset picks one — BotID+// for the Cloud edition on Vercel, else Turnstile when its keys are set. Set it+// when the keys are there for something else (GoTrue, another form) and login+// should still use BotID. Vercel exposes no variable of its own for BotID.+export const BOT_PROTECTION = getEnv("BOT_PROTECTION", {+ isRequired: false,+ isSecret: false+});+export const POSTHOG_API_HOST = getEnv("POSTHOG_API_HOST", {isSecret: false});diff --git a/packages/react/package.json b/packages/react/package.jsonindex 1b62500c21..a635d4d695 100644--- a/packages/react/package.json+++ b/packages/react/package.json@@ -122,6 +122,7 @@"peerDependencies": {"@internationalized/date": "catalog:","@lingui/react": "catalog:",+ "@marsidev/react-turnstile": "catalog:","framer-motion": "catalog:","react": "catalog:","react-dom": "catalog:",diff --git a/packages/react/src/BotId.tsx b/packages/react/src/BotId.tsxdeleted file mode 100644index 75810149ca..0000000000--- a/packages/react/src/BotId.tsx+++ /dev/null@@ -1,22 +0,0 @@-import { initBotId } from "botid/client/core";-import { useEffect } from "react";--let initialized = false;--// Vercel BotID: patches window.fetch so POSTs to `path` carry an invisible-// challenge that checkBotId() verifies on the server. React Router submits an-// action to `${path}.data`, so both forms are protected. Pass the server's-// `botIdEnabled` — off Vercel the challenge script 404s and the patched fetch-// would reject every submission.-export function useBotIdProtection(path: string, enabled: boolean) {- useEffect(() => {- if (!enabled || initialized) return;- initialized = true;- initBotId({- protect: [- { path, method: "POST" },- { path: `${path}.data`, method: "POST" }- ]- });- }, [path, enabled]);-}diff --git a/packages/react/src/BotProtection.tsx b/packages/react/src/BotProtection.tsxnew file mode 100644index 0000000000..8b7c33ae7a--- /dev/null+++ b/packages/react/src/BotProtection.tsx@@ -0,0 +1,77 @@+import { Turnstile, type TurnstileInstance } from "@marsidev/react-turnstile";+import { initBotId } from "botid/client/core";+import { type ReactNode, useEffect, useRef, useState } from "react";+import { useMode } from "./hooks/useMode";++// Mirrors BotProtection in @carbon/auth/auth.server — the login loader passes+// the server's value straight through, so client and server always agree.+export type BotProtectionConfig =+ | { provider: "botid" }+ | { provider: "turnstile"; siteKey: string }+ | null;++let botIdInitialized = false;++/**+ * The client half of the login bot check. Render `challenge` inside the form,+ * post `token` as `botToken`, and hold submit until `ready`.+ *+ * - BotID patches window.fetch so POSTs to `path` (and `${path}.data`, where+ * React Router submits an action) carry an invisible challenge. Nothing to+ * render, nothing to wait for.+ * - Turnstile renders a widget; its token is single-use, so the form stays+ * disabled until one arrives and again after it expires.+ *+ * Pass the form's latest response (`fetcher.data`) as `response`: the server+ * spent the Turnstile token on that submit, so each response asks the widget+ * for a fresh one — otherwise a retry after a failed login re-sends a spent+ * token and fails the bot check.+ */+export function useBotProtection(+ path: string,+ config: BotProtectionConfig,+ response?: unknown+): { token: string; ready: boolean; challenge: ReactNode } {+ const mode = useMode();+ const [token, setToken] = useState("");+ const widget = useRef<TurnstileInstance>(null);++ useEffect(() => {+ if (response === undefined) return;+ setToken("");+ widget.current?.reset();+ }, [response]);++ const provider = config?.provider;+ useEffect(() => {+ if (provider !== "botid" || botIdInitialized) return;+ botIdInitialized = true;+ initBotId({+ protect: [+ { path, method: "POST" },+ { path: `${path}.data`, method: "POST" }+ ]+ });+ }, [path, provider]);++ if (config?.provider !== "turnstile") {+ return { token: "", ready: true, challenge: null };+ }++ return {+ token,+ ready: Boolean(token),+ challenge: (+ <div className="w-full flex justify-center">+ <Turnstile+ ref={widget}+ siteKey={config.siteKey}+ onSuccess={setToken}+ onError={() => setToken("")}+ onExpire={() => setToken("")}+ options={{ theme: mode === "dark" ? "dark" : "light" }}+ />+ </div>+ )+ };+}diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsxindex b4614abd69..75378e0c4a 100644--- a/packages/react/src/index.tsx+++ b/packages/react/src/index.tsx@@ -27,7 +27,7 @@ import {import type { BadgeProps } from "./Badge";import { Badge, BadgeCloseButton } from "./Badge";import { BarProgress } from "./BarProgress";-import { useBotIdProtection } from "./BotId";+import { useBotProtection } from "./BotProtection";import {BottomSheet,BottomSheetBody,@@ -655,7 +655,7 @@ export {reactNodeToString,shortcutKeyVariants,toast,- useBotIdProtection,+ useBotProtection,useModalCardType,useModalDrawerType,useOperatingSystem,diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex fb3153e15b..bd7641bf45 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -51,6 +51,9 @@ catalogs:'@logtape/testing':specifier: 2.2.3version: 2.2.3+ '@marsidev/react-turnstile':+ specifier: 1.5.0+ version: 1.5.0'@nanostores/react':specifier: 0.7.3version: 0.7.3@@ -3209,6 +3212,9 @@ importers:'@lingui/react':specifier: 'catalog:'version: 5.9.4(@lingui/[email protected]([email protected])([email protected]))([email protected])([email protected])+ '@marsidev/react-turnstile':+ specifier: 'catalog:''@nanostores/react':specifier: 'catalog:'version: 0.7.3([email protected])([email protected])@@ -5656,6 +5662,12 @@ packages:react-native-uuid: ^2tiny-invariant: ^1+ '@marsidev/[email protected]':+ resolution: {integrity: sha512-Ph6mcj8u9WBDsBO7s9jKPsyRDz1sBPBJwrk+Ngx09vFInvKsQ6U6kW5amEcGq4dHOreB6DgFrOJk7/fy318YlQ==}+ peerDependencies:+ react: 18.3.1+ react-dom: 18.3.1+'@mdx-js/[email protected]':resolution: {integrity: sha512-f6ZO2ifpwAQIpzGWaBQT2TXxPv6z3RBzQKpVftEWN78Vl/YweF1uwussDx8ECAXVtr3Rs89fKyG9YlzUs9DyGQ==}@@ -18682,6 +18694,11 @@ snapshots:optionalDependencies:'@rollup/rollup-linux-x64-gnu': 4.9.5+ dependencies:+ react: 18.3.1+ react-dom: 18.3.1([email protected])+'@mdx-js/[email protected]':dependencies:'@types/estree': 1.0.8diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex 06a28ee2e1..251d5bc697 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -65,6 +65,7 @@ catalog:'@lingui/macro': 5.9.4'@lingui/react': 5.9.4'@lingui/vite-plugin': 5.9.4+ '@marsidev/react-turnstile': 1.5.0'@logtape/logtape': 2.2.3'@logtape/redaction': 2.2.3'@logtape/testing': 2.2.3diff --git a/sst.config.ts b/sst.config.tsindex 9198bafe57..10290fb120 100644--- a/sst.config.ts+++ b/sst.config.ts@@ -51,7 +51,12 @@ export default $config({ASSEMBLER_SERVICE_API_KEY: process.env.ASSEMBLER_SERVICE_API_KEY,ASSEMBLER_SERVICE_URL: process.env.ASSEMBLER_SERVICE_URL,AUTH_PROVIDERS: process.env.AUTH_PROVIDERS,+ BOT_PROTECTION: process.env.BOT_PROTECTION,CARBON_EDITION: process.env.CARBON_EDITION,+ CLOUDFLARE_TURNSTILE_SECRET_KEY:+ process.env.CLOUDFLARE_TURNSTILE_SECRET_KEY,+ CLOUDFLARE_TURNSTILE_SITE_KEY:+ process.env.CLOUDFLARE_TURNSTILE_SITE_KEY,CONTROLLED_ENVIRONMENT: process.env.CONTROLLED_ENVIRONMENT,DOMAIN: process.env.DOMAIN ?? "carbon.ms",ERP_URL: process.env.URL_ERP ? `https://${process.env.URL_ERP}` : "https://itar.carbon.ms",@@ -159,7 +164,12 @@ export default $config({ASSEMBLER_SERVICE_API_KEY: process.env.ASSEMBLER_SERVICE_API_KEY,ASSEMBLER_SERVICE_URL: process.env.ASSEMBLER_SERVICE_URL,AUTH_PROVIDERS: process.env.AUTH_PROVIDERS,+ BOT_PROTECTION: process.env.BOT_PROTECTION,CARBON_EDITION: process.env.CARBON_EDITION,+ CLOUDFLARE_TURNSTILE_SECRET_KEY:+ process.env.CLOUDFLARE_TURNSTILE_SECRET_KEY,+ CLOUDFLARE_TURNSTILE_SITE_KEY:+ process.env.CLOUDFLARE_TURNSTILE_SITE_KEY,CONTROLLED_ENVIRONMENT: process.env.CONTROLLED_ENVIRONMENT,DOMAIN: process.env.DOMAIN ?? "carbon.ms",ERP_URL: process.env.URL_ERP ? `https://${process.env.URL_ERP}` : "https://itar.carbon.ms",