mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-13 19:30:36 -05:00
- Delete apps/web/app/api/lib/utils.ts as it only contained a no-op function - Remove handleBillingLimitsCheck calls from all response creation endpoints - Function was a placeholder with no actual implementation
30 lines
809 B
TypeScript
30 lines
809 B
TypeScript
export const verifyTurnstileToken = async (secretKey: string, token: string): Promise<boolean> => {
|
|
const controller = new AbortController();
|
|
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
|
|
|
try {
|
|
const response = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
secret: secretKey,
|
|
response: token,
|
|
}),
|
|
signal: controller.signal,
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Verification failed with status: ${response.status}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
return data.success === true;
|
|
} catch (error) {
|
|
return false;
|
|
} finally {
|
|
clearTimeout(timeoutId);
|
|
}
|
|
};
|