mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-29 09:58:27 +00:00
20 lines
542 B
JavaScript
20 lines
542 B
JavaScript
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;
|
|
}
|