/** * reCAPTCHA Handler * * Supports reCAPTCHA v2 (checkbox) and v3 (score-based, invisible) * * Test mode bypass uses Google's official test keys: * - Site key: 6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ- * - Secret key: 6Le-wvkSAAAAAGGOV5XwRZ0nLfwPgJZsYNiWBvvC * * These always return a valid token with predictable score (v3) or success (v2) * * @see https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do */ export interface RecaptchaV2Config { /** Site key for reCAPTCHA v2 */ siteKey?: string; /** Use test mode (always returns valid token) */ testMode?: boolean; /** CSS selector for the reCAPTCHA iframe */ selector?: string; /** Timeout for solving (ms) */ timeout?: number; } export interface RecaptchaV3Config { /** Site key for reCAPTCHA v3 */ siteKey?: string; /** Action name for the request */ action?: string; /** Use test mode (always returns score 0.9) */ testMode?: boolean; /** Minimum acceptable score (0.0 - 1.0) */ minScore?: number; /** Timeout for solving (ms) */ timeout?: number; } export interface RecaptchaTokenResponse { success: boolean; token: string; score?: number; action?: string; challengeTs?: string; hostname?: string; errorCodes?: string[]; } export declare const RECAPTCHA_V2_TEST_SITE_KEY = "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"; export declare const RECAPTCHA_V2_TEST_SECRET = "6Le-wvkSAAAAAGGOV5XwRZ0nLfwPgJZsYNiWBvvC"; export declare const RECAPTCHA_V3_TEST_SITE_KEY = "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"; export declare const RECAPTCHA_V3_TEST_SECRET = "6Le-wvkSAAAAAGGOV5XwRZ0nLfwPgJZsYNiWBvvC"; export declare class RecaptchaHandler { private testMode; private timeout; constructor(options?: { testMode?: boolean; timeout?: number; }); /** * Detect if reCAPTCHA is present on the page */ detectRecaptcha(page: any): Promise<{ present: boolean; version?: 'v2' | 'v3'; siteKey?: string; }>; /** * Solve reCAPTCHA v2 (checkbox) * * In test mode, injects a test token * In production, waits for user interaction */ solveV2(page: any, config?: RecaptchaV2Config): Promise; /** * Solve reCAPTCHA v2 in test mode */ private solveV2TestMode; /** * Solve reCAPTCHA v2 in production mode (requires human interaction) */ private solveV2Production; /** * Execute reCAPTCHA v3 (invisible, score-based) */ executeV3(page: any, config?: RecaptchaV3Config): Promise; /** * Verify a reCAPTCHA token (server-side simulation) * * In real usage, this would call Google's siteverify API: * POST https://www.google.com/recaptcha/api/siteverify */ verifyToken(token: string, secret?: string): Promise; /** * Wait for reCAPTCHA to be ready */ waitForReady(page: any, timeout?: number): Promise; /** * Inject test site key into page */ injectTestSiteKey(page: any, elementSelector: string): Promise; /** * Generate a test token for mocking */ private generateTestToken; private sleep; /** * Reset all reCAPTCHA widgets on the page */ reset(page: any): Promise; /** * Get the current response token from reCAPTCHA */ getResponse(page: any, widgetId?: string): Promise; } /** * Factory function to create a reCAPTCHA handler */ export declare function createRecaptchaHandler(options?: { testMode?: boolean; timeout?: number; }): RecaptchaHandler; export default RecaptchaHandler;