Download src/hooks/useRecaptcha.ts from felix-fx/fx-1: direct link, hf CLI and curl.
- Browser
- Download file 772 Bytes
-
https://huggingface.co/felix-fx/fx-1/resolve/main/src/hooks/useRecaptcha.ts
- Command line
-
hf download hf://felix-fx/fx-1/src/hooks/useRecaptcha.ts
-
curl -L -o useRecaptcha.ts https://huggingface.co/felix-fx/fx-1/resolve/main/src/hooks/useRecaptcha.ts
772 Bytes
| /** | |
| * 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<string>; | |
| }; | |
| } | |
| } | |
| export const executeRecaptcha = (action: string): Promise<string> => { | |
| 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); | |
| }); | |
| }); | |
| }; | |