2023-03-03 16:44:40 +00:00
|
|
|
const fetch = require('node-fetch')
|
|
|
|
|
|
|
|
async function checkCaptcha(response) {
|
2024-01-18 18:54:35 +00:00
|
|
|
const confirm = await (await fetch('https://challenges.cloudflare.com/turnstile/v0/siteverify', {
|
2023-03-03 16:44:40 +00:00
|
|
|
method: 'POST',
|
2024-01-18 18:54:35 +00:00
|
|
|
body: JSON.stringify({
|
2023-03-03 16:44:40 +00:00
|
|
|
'response': response,
|
|
|
|
'secret': process.env.CAPTCHA_SECRET
|
2024-01-18 18:54:35 +00:00
|
|
|
}),
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json'
|
|
|
|
}
|
2023-03-03 16:44:40 +00:00
|
|
|
})).json()
|
|
|
|
|
|
|
|
return confirm.success
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { checkCaptcha }
|