export const recaptchaConfig = { id: 'recaptcha', name: 'reCAPTCHA', description: 'Protect your site from bots and spam with Google reCAPTCHA', category: 'spam', } export const recaptchaVersions = { v2: { id: 'v2', name: 'reCAPTCHA v2', description: 'Checkbox or invisible challenge', modes: [ { id: 'checkbox', name: 'I\'m not a robot', description: 'Users click a checkbox to verify they are human', }, { id: 'invisible', name: 'Invisible', description: 'reCAPTCHA runs in the background without user interaction', }, ], }, v3: { id: 'v3', name: 'reCAPTCHA v3', description: 'Score-based verification without user interaction', modes: [ { id: 'score', name: 'Score-based', description: 'Returns a score (0.0 - 1.0) indicating likelihood of human interaction', }, ], displayOptions: [ { id: 'badge', name: 'Badge', description: 'Show reCAPTCHA badge in corner of page', }, { id: 'hidden', name: 'Hidden', description: 'Hide the badge (requires attribution in privacy policy)', }, ], }, } // Location configuration interface interface RecaptchaLocationConfig { id: string name: string description: string requiresWooCommerce: boolean isPro?: boolean } // Location IDs match the PHP backend export const recaptchaLocations: RecaptchaLocationConfig[] = [ { id: 'wpLogin', name: 'WordPress Login', description: 'WordPress admin login page (wp-login.php)', requiresWooCommerce: false, }, { id: 'wpRegister', name: 'WordPress Registration', description: 'WordPress registration page', requiresWooCommerce: false, }, { id: 'lostPassword', name: 'Lost Password Form', description: 'Password reset request page', requiresWooCommerce: false, }, { id: 'wcLogin', name: 'WooCommerce Login', description: 'WooCommerce My Account login form', requiresWooCommerce: true, }, { id: 'wcRegister', name: 'WooCommerce Registration', description: 'WooCommerce My Account registration form', requiresWooCommerce: true, }, { id: 'checkout', name: 'Checkout Page', description: 'WooCommerce checkout form', requiresWooCommerce: true, }, { id: 'comments', name: 'Comment Forms', description: 'Blog post comment submissions', requiresWooCommerce: false, }, { id: 'wcPaymentMethod', name: 'Add Payment Method', description: 'When adding a new payment method in My Account', requiresWooCommerce: true, isPro: true, }, { id: 'wcProductReview', name: 'Product Reviews', description: 'WooCommerce product review form', requiresWooCommerce: true, isPro: true, }, ] // Pro-only appearance settings export const recaptchaThemes = [ { id: 'light', name: 'Light', description: 'Light theme (default)' }, { id: 'dark', name: 'Dark', description: 'Dark theme for dark backgrounds' }, ] export const recaptchaSizes = [ { id: 'normal', name: 'Normal', description: 'Full-size captcha' }, { id: 'compact', name: 'Compact', description: 'Smaller, more compact captcha' }, ] export type RecaptchaTheme = 'light' | 'dark' export type RecaptchaSize = 'normal' | 'compact' export type CaptchaProvider = 'google-recaptcha' | 'cloudflare-turnstile' | 'hcaptcha' | '' export type RecaptchaVersion = 'v2' | 'v3' export type RecaptchaV2Mode = 'checkbox' | 'invisible' export type RecaptchaV3Display = 'badge' | 'hidden' export type TurnstileAppearance = 'always' | 'execute' | 'interaction-only' export type HcaptchaMode = 'visible' | 'invisible' export type RecaptchaLocation = 'wpLogin' | 'wpRegister' | 'lostPassword' | 'wcLogin' | 'wcRegister' | 'checkout' | 'comments' | 'wcPaymentMethod' | 'wcProductReview' export interface RecaptchaLocations { wpLogin: boolean wpRegister: boolean lostPassword: boolean wcLogin: boolean wcRegister: boolean checkout: boolean comments: boolean wcPaymentMethod: boolean wcProductReview: boolean } export interface RecaptchaState { enabled: boolean provider: CaptchaProvider version: RecaptchaVersion // V2 specific v2SiteKey: string v2SecretKey: string v2Mode: RecaptchaV2Mode // V3 specific v3SiteKey: string v3SecretKey: string v3Display: RecaptchaV3Display v3Threshold: number // Legacy keys (for backward compatibility) siteKey: string secretKey: string // Locations locations: RecaptchaLocations // Pro settings theme: RecaptchaTheme size: RecaptchaSize ipWhitelist: string bypassRoles: string[] // Pro provider keys turnstileSiteKey: string turnstileSecretKey: string turnstileAppearance: TurnstileAppearance hcaptchaSiteKey: string hcaptchaSecretKey: string hcaptchaMode: HcaptchaMode } // User role options for bypass setting export const captchaRoleOptions = [ { value: 'administrator', label: 'Administrator' }, { value: 'editor', label: 'Editor' }, { value: 'author', label: 'Author' }, { value: 'contributor', label: 'Contributor' }, { value: 'subscriber', label: 'Subscriber' }, { value: 'customer', label: 'Customer (WooCommerce)' }, { value: 'shop_manager', label: 'Shop Manager (WooCommerce)' }, ] // Analytics data types (Pro feature) export interface CaptchaAnalyticsEntry { id: number location: string ip_address: string result: 'passed' | 'failed' fail_reason: string score: number | null provider: string user_agent: string created_at: string } export interface CaptchaAnalyticsSummary { totalChecks: number totalPassed: number totalFailed: number failRate: number byLocation: Record byDay: Array<{ date: string; passed: number; failed: number }> topBlockedIPs: Array<{ ip: string; count: number }> recentFailures: CaptchaAnalyticsEntry[] } export const defaultRecaptchaState: RecaptchaState = { enabled: false, provider: '', version: 'v2', // V2 specific v2SiteKey: '', v2SecretKey: '', v2Mode: 'checkbox', // V3 specific v3SiteKey: '', v3SecretKey: '', v3Display: 'badge', v3Threshold: 0.5, // Legacy (will be synced with version-specific keys) siteKey: '', secretKey: '', // Locations locations: { wpLogin: true, wpRegister: true, lostPassword: true, wcLogin: false, wcRegister: false, checkout: false, comments: false, wcPaymentMethod: false, wcProductReview: false, }, // Pro settings theme: 'light', size: 'normal', ipWhitelist: '', bypassRoles: [], // Pro provider keys turnstileSiteKey: '', turnstileSecretKey: '', turnstileAppearance: 'always', hcaptchaSiteKey: '', hcaptchaSecretKey: '', hcaptchaMode: 'visible', }