import { InjectionToken } from '@angular/core'; import * as i0 from "@angular/core"; /** * Detects the current platform environment */ type Platform = 'web' | 'capacitor-webview' | 'capacitor-native' | 'ssr'; /** * reCAPTCHA version type */ type RecaptchaVersion = 'v2' | 'v3' | 'enterprise'; /** * reCAPTCHA configuration for RecaptchaService * * Internal configuration interface used by RecaptchaService. * Use RecaptchaAngularConfig from tokens.ts for app configuration. */ export interface RecaptchaServiceConfig { enabled: boolean; version: RecaptchaVersion; siteKey: string; action?: string; autoLoadScript?: boolean; language?: string; } /** * Injection token for reCAPTCHA configuration */ export declare const RECAPTCHA_CONFIG: InjectionToken; /** * Google reCAPTCHA service for Angular applications. * * Provides lazy loading of reCAPTCHA script and platform-aware token generation. * Automatically detects platform (web, Capacitor WebView, Capacitor native, SSR) * and skips reCAPTCHA in environments where it's not supported or needed. * * Features: * - Lazy script loading (only loads when needed) * - v2 (checkbox) and v3 (invisible) support * - Platform detection (web, Capacitor, SSR) * - Automatic skip for Capacitor native mode * - Automatic skip for SSR * * @example v3 Automatic Mode * ```typescript * constructor(private recaptcha: RecaptchaService) {} * * async login() { * const token = await this.recaptcha.execute('login'); * await this.auth.login(email, password, token); * } * ``` * * @example v2 Manual Mode * ```typescript * ngOnInit() { * this.recaptcha.render('recaptcha-container', (token) => { * this.recaptchaToken = token; * }); * } * ``` */ export declare class RecaptchaService { private platformId; private config?; private scriptLoaded; private scriptLoading; private platform; private widgetId; constructor(platformId: string, config?: RecaptchaServiceConfig); /** * Detect the current platform environment. * * Detection priority: * 1. SSR (not in browser) → 'ssr' * 2. Capacitor native (no web view) → 'capacitor-native' * 3. Capacitor WebView → 'capacitor-webview' * 4. Web browser → 'web' * * @returns Detected platform type * * @example * ```typescript * const platform = this.detectPlatform(); * if (platform === 'capacitor-native') { * // Skip reCAPTCHA, use device attestation * } * ``` */ private detectPlatform; /** * Get the current platform. * * @returns Current platform type */ getPlatform(): Platform; /** * Check if reCAPTCHA should be skipped for current platform. * * Skips for: * - SSR (no window object) * - Capacitor native (use device attestation instead) * * @returns True if should skip reCAPTCHA */ shouldSkip(): boolean; /** * Load Google reCAPTCHA script if not already loaded. * * Script URL format: * - v2: https://www.google.com/recaptcha/api.js * - v3: https://www.google.com/recaptcha/api.js?render={siteKey} * - Enterprise: https://www.google.com/recaptcha/enterprise.js?render={siteKey} * * @returns Promise that resolves when script is loaded * * @throws Error if config is missing or script fails to load */ loadScript(): Promise; /** * Inject the reCAPTCHA script into the DOM. * * @returns Promise that resolves when script loads */ private injectScript; /** * Execute reCAPTCHA v3/Enterprise challenge (invisible). * * Automatically loads script if needed and generates a token. * Skips automatically for SSR and Capacitor native. * * @param action - Action name for v3 analytics (e.g., 'login', 'signup') * @returns Promise resolving to reCAPTCHA token, or undefined if skipped * * @throws Error if version is v2, config missing, or execution fails * * @example * ```typescript * const token = await this.recaptcha.execute('login'); * if (token) { * await this.auth.login(email, password, token); * } * ``` */ execute(action?: string): Promise; /** * Render reCAPTCHA v2 checkbox widget. * * @param containerId - DOM element ID or element to render in * @param callback - Callback when user completes challenge * @returns Promise resolving to widget ID * * @throws Error if version is not v2, config missing, or render fails * * @example * ```typescript * ngAfterViewInit() { * this.recaptcha.render('recaptcha-container', (token) => { * this.recaptchaToken = token; * this.loginForm.patchValue({ recaptchaToken: token }); * }); * } * ``` */ render(containerId: string, callback: (token: string) => void): Promise; /** * Get response token from v2 widget. * * @param widgetId - Widget ID (optional, uses last rendered widget if not provided) * @returns reCAPTCHA token or null if not completed * * @example * ```typescript * const token = this.recaptcha.getResponse(); * if (token) { * await this.auth.login(email, password, token); * } * ``` */ getResponse(widgetId?: number): string | null; /** * Reset v2 widget (clear response). * * @param widgetId - Widget ID (optional, uses last rendered widget if not provided) * * @example * ```typescript * // After failed login * this.recaptcha.reset(); * ``` */ reset(widgetId?: number): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } export {};