const fetch = require('node-fetch')

async function recaptchaVerify(token) {
    const secret = process.env.RECAPTCHA_SECRET_KEY
    const data = `?secret=${secret}&response=${token}`
    const url = process.env.RECAPTCHA_VERIFY_URL + data
    const fetchResult = await fetch(url)
    const result = await fetchResult.json()
    return result?.score
}

module.exports = {
    recaptchaVerify
}