the universal sandbox runtime for agents and humans.
pocketenv.io
sandbox
openclaw
agent
claude-code
vercel-sandbox
deno-sandbox
cloudflare-sandbox
atproto
sprites
daytona
1import { env } from "./env";
2
3export default async function validateTurnstile(
4 token: string,
5 remoteip: string,
6) {
7 try {
8 const response = await fetch(
9 "https://challenges.cloudflare.com/turnstile/v0/siteverify",
10 {
11 method: "POST",
12 headers: {
13 "Content-Type": "application/json",
14 },
15 body: JSON.stringify({
16 secret: env.CF_SECRET_KEY,
17 response: token,
18 remoteip: remoteip,
19 }),
20 },
21 );
22
23 const result = await response.json();
24 return result;
25 } catch (error) {
26 console.error("Turnstile validation error:", error);
27 return { success: false, "error-codes": ["internal-error"] };
28 }
29}