Download api/src/security/turnstile.js from opencen/cobalt: direct link, hf CLI and curl.
- Browser
- Download file 542 Bytes
-
https://huggingface.co/spaces/opencen/cobalt/resolve/main/api/src/security/turnstile.js
- Command line
-
hf download hf://spaces/opencen/cobalt/api/src/security/turnstile.js
-
curl -L -o turnstile.js https://huggingface.co/spaces/opencen/cobalt/resolve/main/api/src/security/turnstile.js
542 Bytes
| import { env } from "../config.js"; | |
| export const verifyTurnstileToken = async (turnstileResponse, ip) => { | |
| const result = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json", | |
| }, | |
| body: JSON.stringify({ | |
| secret: env.turnstileSecret, | |
| response: turnstileResponse, | |
| remoteip: ip, | |
| }), | |
| }) | |
| .then(r => r.json()) | |
| .catch(() => {}); | |
| return !!result?.success; | |
| } | |