The public key for reCAPTCHA.
The action to verify (default is 'LOGIN').
A promise that resolves to the reCAPTCHA token.
import { getRecaptchaAnswer } from '@consumidor-positivo/ts-utils/operations';
async function verifyUser() {
const publicKey = 'your-public-key';
const action = 'LOGIN';
try {
const token = await getRecaptchaAnswer(publicKey, action);
console.log('reCAPTCHA token:', token);
} catch (error) {
console.error('reCAPTCHA verification failed:', error);
}
}
Executes a reCAPTCHA verification and retrieves the token.
This function uses the reCAPTCHA Enterprise API to execute a verification for a specific action. It requires the reCAPTCHA script to be loaded and ready in the browser.