api/security: jwt session token

This commit is contained in:
wukko
2024-08-16 23:28:03 +06:00
parent 33c2fee847
commit 16acf62886
4 changed files with 110 additions and 19 deletions

View File

@@ -1,19 +0,0 @@
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;
}