/** * Hook for Google reCAPTCHA v3 (invisible, score-based) * If score is low, triggers fallback to custom CAPTCHA */ const RECAPTCHA_SITE_KEY = '6LeMr4wsAAAAAHVy6EPzSHVjMdvuExr6Naky3KQS'; declare global { interface Window { grecaptcha: { ready: (cb: () => void) => void; execute: (siteKey: string, options: { action: string }) => Promise; }; } } export const executeRecaptcha = (action: string): Promise => { return new Promise((resolve, reject) => { if (!window.grecaptcha) { reject(new Error('reCAPTCHA not loaded')); return; } window.grecaptcha.ready(() => { window.grecaptcha .execute(RECAPTCHA_SITE_KEY, { action }) .then(resolve) .catch(reject); }); }); };