Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Compare reCAPTCHA session cookies before fallback
Emre Sokullu00f8440210d7
diff --git a/docs/captcha-method-reference.md b/docs/captcha-method-reference.mdindex 2bfafb85d..f8d70447c 100644--- a/docs/captcha-method-reference.md+++ b/docs/captcha-method-reference.md@@ -35,7 +35,7 @@ Family: `mtcaptcha`. [Official contract](https://docs.capsolver.com/en/guide/capFamily: `recaptcha_v2`. [Official contract](https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/).- Required: `websiteURL` (string), `websiteKey` (string).-- Optional: `cookies` (string), `proxy` (string), `pageAction` (string), `recaptchaDataSValue` (string), `enterprisePayload` (object), `isInvisible` (boolean), `isSession` (boolean), `apiDomain` (string).+- Optional: `cookies` (array), `proxy` (string), `pageAction` (string), `recaptchaDataSValue` (string), `enterprisePayload` (object), `isInvisible` (boolean), `isSession` (boolean), `apiDomain` (string).- Fixed wire values: `{"type":"ReCaptchaV2TaskProxyLess"}`.### ReCaptchaV2EnterpriseTask@@ -43,7 +43,7 @@ Family: `recaptcha_v2`. [Official contract](https://docs.capsolver.com/en/guide/Family: `recaptcha_v2_enterprise`. [Official contract](https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/).- Required: `websiteURL` (string), `websiteKey` (string), `proxy` (string).-- Optional: `cookies` (string), `pageAction` (string), `recaptchaDataSValue` (string), `enterprisePayload` (object), `isInvisible` (boolean), `isSession` (boolean), `apiDomain` (string).+- Optional: `cookies` (array), `pageAction` (string), `recaptchaDataSValue` (string), `enterprisePayload` (object), `isInvisible` (boolean), `isSession` (boolean), `apiDomain` (string).- Fixed wire values: `{"type":"ReCaptchaV2EnterpriseTask"}`.### ReCaptchaV2EnterpriseTaskProxyLess@@ -51,7 +51,7 @@ Family: `recaptcha_v2_enterprise`. [Official contract](https://docs.capsolver.coFamily: `recaptcha_v2_enterprise`. [Official contract](https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/).- Required: `websiteURL` (string), `websiteKey` (string).-- Optional: `cookies` (string), `proxy` (string), `pageAction` (string), `recaptchaDataSValue` (string), `enterprisePayload` (object), `isInvisible` (boolean), `isSession` (boolean), `apiDomain` (string).+- Optional: `cookies` (array), `proxy` (string), `pageAction` (string), `recaptchaDataSValue` (string), `enterprisePayload` (object), `isInvisible` (boolean), `isSession` (boolean), `apiDomain` (string).- Fixed wire values: `{"type":"ReCaptchaV2EnterpriseTaskProxyLess"}`.### ReCaptchaV2Task@@ -59,7 +59,7 @@ Family: `recaptcha_v2_enterprise`. [Official contract](https://docs.capsolver.coFamily: `recaptcha_v2`. [Official contract](https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/).- Required: `websiteURL` (string), `websiteKey` (string), `proxy` (string).-- Optional: `cookies` (string), `pageAction` (string), `recaptchaDataSValue` (string), `enterprisePayload` (object), `isInvisible` (boolean), `isSession` (boolean), `apiDomain` (string).+- Optional: `cookies` (array), `pageAction` (string), `recaptchaDataSValue` (string), `enterprisePayload` (object), `isInvisible` (boolean), `isSession` (boolean), `apiDomain` (string).- Fixed wire values: `{"type":"ReCaptchaV2Task"}`.### ReCaptchaV3Taskdiff --git a/docs/captcha-provider-coverage.md b/docs/captcha-provider-coverage.mdindex c0ed9fcd3..feb44e713 100644--- a/docs/captcha-provider-coverage.md+++ b/docs/captcha-provider-coverage.md@@ -137,8 +137,8 @@ Use observed page parameters to prepare fallback tasks. Method IDs are WebBrainSaved weights determine execution order, regardless of array order. Supply a task for each enabled provider that can solve that family and for which the required inputs are available. The tool does not invent another provider's parameters. Page URLs must belong to the active tab or an observed frame. Native methods do not automatically scrape every site's internal configuration.-Provider-specific identifiers (for example `appId`/`app_id` and `miseryKey`/`misery_key`) must agree across fallback entries before any paid request. Recognition fallbacks must use the same image/audio and selection instruction; TSPD fallbacks must use the same captured page. reCAPTCHA v2 fallbacks must agree on `data-s` and visible/invisible mode, and reCAPTCHA v3 fallbacks on action and minimum score, when supplied.-FunCaptcha fallbacks compare the Arkose service host even when one provider takes a subdomain and another takes a full `surl` URL.+Provider-specific identifiers (for example `appId`/`app_id` and `miseryKey`/`misery_key`) must agree across fallback entries before any paid request. Recognition fallbacks compare the image/audio, instructions and answer constraints such as click counts and text length. TSPD fallbacks compare the captured page; Cloudflare Challenge fallbacks compare task mode and the exact HTML snapshot. AWS WAF fallbacks compare API, challenge and CAPTCHA script identifiers. reCAPTCHA v2 fallbacks must agree on `data-s` and visible/invisible mode, and reCAPTCHA v3 fallbacks on action and minimum score, when supplied. All reCAPTCHA fallbacks compare explicitly supplied session cookies after normalizing each provider's documented format; a scoped NopeCHA cookie array cannot be equated to a scope-free cookie string.+FunCaptcha fallbacks compare the Arkose service host even when one provider takes a subdomain and another takes a full `surl` URL. The native dispatch lock is stored before contacting a paid provider. An unexpired answer is stored for worker recovery; if a solve was dispatched but its answer is unavailable after restart, the gate requires manual completion rather than a second paid call.The native adapter rejects undeclared nested fields in schemas with enumerated children, such as CapMonster `metadata`. Provider-documented free-form option objects, including NopeCHA Enterprise `data`, remain available.diff --git a/src/chrome/src/agent/captcha-catalog.js b/src/chrome/src/agent/captcha-catalog.jsindex bdc238bf2..0c0766e1c 100644--- a/src/chrome/src/agent/captcha-catalog.js+++ b/src/chrome/src/agent/captcha-catalog.js@@ -93,10 +93,10 @@ export const CAPTCHA_CATALOG = [{"provider":"capsolver","method":"GeeTestTaskProxyLess","family":"geetest","fields":{"websiteURL":{"type":"string","required":true},"gt":{"type":"string","required":false},"challenge":{"type":"string","required":false},"captchaId":{"type":"string","required":false},"riskType":{"type":"string","required":false},"geetestApiServerSubdomain":{"type":"string","required":false}},"fixed":{"type":"GeeTestTaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/Geetest/"},{"provider":"capsolver","method":"MtCaptchaTask","family":"mtcaptcha","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true}},"fixed":{"type":"MtCaptchaTask"},"docs":"https://docs.capsolver.com/en/guide/captcha/MtCaptcha/"},{"provider":"capsolver","method":"MtCaptchaTaskProxyLess","family":"mtcaptcha","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false}},"fixed":{"type":"MtCaptchaTaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/MtCaptcha/"},- {"provider":"capsolver","method":"ReCaptchaV2TaskProxyLess","family":"recaptcha_v2","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV2TaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},- {"provider":"capsolver","method":"ReCaptchaV2EnterpriseTask","family":"recaptcha_v2_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV2EnterpriseTask"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},- {"provider":"capsolver","method":"ReCaptchaV2EnterpriseTaskProxyLess","family":"recaptcha_v2_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV2EnterpriseTaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},- {"provider":"capsolver","method":"ReCaptchaV2Task","family":"recaptcha_v2","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV2Task"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},+ {"provider":"capsolver","method":"ReCaptchaV2TaskProxyLess","family":"recaptcha_v2","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"array","required":false}},"fixed":{"type":"ReCaptchaV2TaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},+ {"provider":"capsolver","method":"ReCaptchaV2EnterpriseTask","family":"recaptcha_v2_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"array","required":false}},"fixed":{"type":"ReCaptchaV2EnterpriseTask"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},+ {"provider":"capsolver","method":"ReCaptchaV2EnterpriseTaskProxyLess","family":"recaptcha_v2_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"array","required":false}},"fixed":{"type":"ReCaptchaV2EnterpriseTaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},+ {"provider":"capsolver","method":"ReCaptchaV2Task","family":"recaptcha_v2","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"array","required":false}},"fixed":{"type":"ReCaptchaV2Task"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},{"provider":"capsolver","method":"ReCaptchaV3Task","family":"recaptcha_v3","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV3Task"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV3/"},{"provider":"capsolver","method":"ReCaptchaV3TaskProxyLess","family":"recaptcha_v3","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV3TaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV3/"},{"provider":"capsolver","method":"ReCaptchaV3EnterpriseTask","family":"recaptcha_v3_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV3EnterpriseTask"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV3/"},diff --git a/src/chrome/src/agent/captcha-native-providers.js b/src/chrome/src/agent/captcha-native-providers.jsindex 0ca75966f..0fd52cc69 100644--- a/src/chrome/src/agent/captcha-native-providers.js+++ b/src/chrome/src/agent/captcha-native-providers.js@@ -231,8 +231,43 @@ function cloudflareChallengeSignature({ contract, task }) {}throw new Error('Fallback Cloudflare challenge requires a comparable task mode.');}+function recaptchaCookieSignature({ contract, task }) {+ const input = task.cookie ?? task.cookies;+ if (!usable(input)) return null;+ let cookies;+ if (typeof input === 'string') {+ const delimiter = contract.provider === 'solvecaptcha' ? ':' : '=';+ cookies = input.split(';').map(part => part.trim()).filter(Boolean).map(part => {+ const separator = part.indexOf(delimiter);+ if (separator <= 0) throw new Error('Fallback reCAPTCHA cookies must use comparable name/value pairs.');+ return { name: part.slice(0, separator).trim(), value: part.slice(separator + 1).trim() };+ });+ } else if (Array.isArray(input)) {+ cookies = input;+ } else {+ throw new Error('Fallback reCAPTCHA cookies must use comparable name/value pairs.');+ }+ if (cookies.some(cookie => !object(cookie) || typeof cookie.name !== 'string'+ || !cookie.name.trim() || typeof cookie.value !== 'string')) {+ throw new Error('Fallback reCAPTCHA cookies must use comparable name/value pairs.');+ }+ const names = cookies.map(cookie => cookie.name.trim());+ if (new Set(names).size !== names.length) throw new Error('Fallback reCAPTCHA cookies must have unique names.');+ const pairs = cookies.map(cookie => [cookie.name.trim(), cookie.value]).sort(([a], [b]) => a.localeCompare(b));+ // NopeCHA's cookie objects include domain/path/security scope. A plain+ // cookie string cannot prove those attributes, so it cannot share a fallback.+ const scope = contract.provider === 'nopecha'+ ? cookies.map(cookie => [cookie.name.trim(), cookie.domain, cookie.path,+ cookie.hostOnly, cookie.httpOnly, cookie.secure, cookie.session, cookie.expirationDate ?? null])+ .sort(([a], [b]) => a.localeCompare(b)) : null;+ return JSON.stringify([pairs, scope]);+}function validateFallbackIdentifiers(built) {const family = built[0].contract.family;+ if (family.startsWith('recaptcha_v') && built.length > 1+ && new Set(built.map(recaptchaCookieSignature)).size > 1) {+ throw new Error('Fallback reCAPTCHA tasks must use the same observed cookie set.');+ }if (family === 'cloudflare_challenge' && built.length > 1&& new Set(built.map(cloudflareChallengeSignature)).size > 1) {throw new Error('Fallback Cloudflare tasks must use the same challenge mode and observed page snapshot.');diff --git a/src/firefox/src/agent/captcha-catalog.js b/src/firefox/src/agent/captcha-catalog.jsindex bdc238bf2..0c0766e1c 100644--- a/src/firefox/src/agent/captcha-catalog.js+++ b/src/firefox/src/agent/captcha-catalog.js@@ -93,10 +93,10 @@ export const CAPTCHA_CATALOG = [{"provider":"capsolver","method":"GeeTestTaskProxyLess","family":"geetest","fields":{"websiteURL":{"type":"string","required":true},"gt":{"type":"string","required":false},"challenge":{"type":"string","required":false},"captchaId":{"type":"string","required":false},"riskType":{"type":"string","required":false},"geetestApiServerSubdomain":{"type":"string","required":false}},"fixed":{"type":"GeeTestTaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/Geetest/"},{"provider":"capsolver","method":"MtCaptchaTask","family":"mtcaptcha","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true}},"fixed":{"type":"MtCaptchaTask"},"docs":"https://docs.capsolver.com/en/guide/captcha/MtCaptcha/"},{"provider":"capsolver","method":"MtCaptchaTaskProxyLess","family":"mtcaptcha","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false}},"fixed":{"type":"MtCaptchaTaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/MtCaptcha/"},- {"provider":"capsolver","method":"ReCaptchaV2TaskProxyLess","family":"recaptcha_v2","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV2TaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},- {"provider":"capsolver","method":"ReCaptchaV2EnterpriseTask","family":"recaptcha_v2_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV2EnterpriseTask"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},- {"provider":"capsolver","method":"ReCaptchaV2EnterpriseTaskProxyLess","family":"recaptcha_v2_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV2EnterpriseTaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},- {"provider":"capsolver","method":"ReCaptchaV2Task","family":"recaptcha_v2","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV2Task"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},+ {"provider":"capsolver","method":"ReCaptchaV2TaskProxyLess","family":"recaptcha_v2","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"array","required":false}},"fixed":{"type":"ReCaptchaV2TaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},+ {"provider":"capsolver","method":"ReCaptchaV2EnterpriseTask","family":"recaptcha_v2_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"array","required":false}},"fixed":{"type":"ReCaptchaV2EnterpriseTask"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},+ {"provider":"capsolver","method":"ReCaptchaV2EnterpriseTaskProxyLess","family":"recaptcha_v2_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"array","required":false}},"fixed":{"type":"ReCaptchaV2EnterpriseTaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},+ {"provider":"capsolver","method":"ReCaptchaV2Task","family":"recaptcha_v2","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"recaptchaDataSValue":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isInvisible":{"type":"boolean","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false},"cookies":{"type":"array","required":false}},"fixed":{"type":"ReCaptchaV2Task"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV2/"},{"provider":"capsolver","method":"ReCaptchaV3Task","family":"recaptcha_v3","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV3Task"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV3/"},{"provider":"capsolver","method":"ReCaptchaV3TaskProxyLess","family":"recaptcha_v3","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":false},"pageAction":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV3TaskProxyLess"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV3/"},{"provider":"capsolver","method":"ReCaptchaV3EnterpriseTask","family":"recaptcha_v3_enterprise","fields":{"websiteURL":{"type":"string","required":true},"websiteKey":{"type":"string","required":true},"proxy":{"type":"string","required":true},"pageAction":{"type":"string","required":false},"enterprisePayload":{"type":"object","required":false},"isSession":{"type":"boolean","required":false},"apiDomain":{"type":"string","required":false}},"fixed":{"type":"ReCaptchaV3EnterpriseTask"},"docs":"https://docs.capsolver.com/en/guide/captcha/ReCaptchaV3/"},diff --git a/src/firefox/src/agent/captcha-native-providers.js b/src/firefox/src/agent/captcha-native-providers.jsindex 0ca75966f..0fd52cc69 100644--- a/src/firefox/src/agent/captcha-native-providers.js+++ b/src/firefox/src/agent/captcha-native-providers.js@@ -231,8 +231,43 @@ function cloudflareChallengeSignature({ contract, task }) {}throw new Error('Fallback Cloudflare challenge requires a comparable task mode.');}+function recaptchaCookieSignature({ contract, task }) {+ const input = task.cookie ?? task.cookies;+ if (!usable(input)) return null;+ let cookies;+ if (typeof input === 'string') {+ const delimiter = contract.provider === 'solvecaptcha' ? ':' : '=';+ cookies = input.split(';').map(part => part.trim()).filter(Boolean).map(part => {+ const separator = part.indexOf(delimiter);+ if (separator <= 0) throw new Error('Fallback reCAPTCHA cookies must use comparable name/value pairs.');+ return { name: part.slice(0, separator).trim(), value: part.slice(separator + 1).trim() };+ });+ } else if (Array.isArray(input)) {+ cookies = input;+ } else {+ throw new Error('Fallback reCAPTCHA cookies must use comparable name/value pairs.');+ }+ if (cookies.some(cookie => !object(cookie) || typeof cookie.name !== 'string'+ || !cookie.name.trim() || typeof cookie.value !== 'string')) {+ throw new Error('Fallback reCAPTCHA cookies must use comparable name/value pairs.');+ }+ const names = cookies.map(cookie => cookie.name.trim());+ if (new Set(names).size !== names.length) throw new Error('Fallback reCAPTCHA cookies must have unique names.');+ const pairs = cookies.map(cookie => [cookie.name.trim(), cookie.value]).sort(([a], [b]) => a.localeCompare(b));+ // NopeCHA's cookie objects include domain/path/security scope. A plain+ // cookie string cannot prove those attributes, so it cannot share a fallback.+ const scope = contract.provider === 'nopecha'+ ? cookies.map(cookie => [cookie.name.trim(), cookie.domain, cookie.path,+ cookie.hostOnly, cookie.httpOnly, cookie.secure, cookie.session, cookie.expirationDate ?? null])+ .sort(([a], [b]) => a.localeCompare(b)) : null;+ return JSON.stringify([pairs, scope]);+}function validateFallbackIdentifiers(built) {const family = built[0].contract.family;+ if (family.startsWith('recaptcha_v') && built.length > 1+ && new Set(built.map(recaptchaCookieSignature)).size > 1) {+ throw new Error('Fallback reCAPTCHA tasks must use the same observed cookie set.');+ }if (family === 'cloudflare_challenge' && built.length > 1&& new Set(built.map(cloudflareChallengeSignature)).size > 1) {throw new Error('Fallback Cloudflare tasks must use the same challenge mode and observed page snapshot.');diff --git a/test/captcha-native-providers.mjs b/test/captcha-native-providers.mjsindex 35f7d8e51..4e5309e2e 100644--- a/test/captcha-native-providers.mjs+++ b/test/captcha-native-providers.mjs@@ -101,6 +101,35 @@ for (const browser of ['chrome','firefox']) {assert.throws(() => native.prepareNativeCaptchaTasks(providers, [capsolver, token]), /same challenge mode/);assert.equal(calls.length, 0);});+ test(`${browser}: reCAPTCHA fallback preserves observed session cookies across provider formats`, t => {+ const calls = mockApi(t, () => { throw new Error('Must not dispatch'); });+ const twoCaptcha = { provider: '2captcha', method: 'RecaptchaV2TaskProxyless', parameters: {+ websiteURL: url, websiteKey: 'site', cookies: 'SID=A; PREF=one=two',+ } };+ const solveCaptcha = { provider: 'solvecaptcha', method: 'recaptcha_v2', parameters: {+ pageurl: url, googlekey: 'site', cookies: 'PREF:one=two; SID:A;',+ } };+ const capsolver = { provider: 'capsolver', method: 'ReCaptchaV2TaskProxyLess', parameters: {+ websiteURL: url, websiteKey: 'site', cookies: [+ { name: 'PREF', value: 'one=two' }, { name: 'SID', value: 'A' },+ ],+ } };+ assert.equal(native.prepareNativeCaptchaTasks(providers, [twoCaptcha, solveCaptcha, capsolver]).length, 3);+ assert.throws(() => native.prepareNativeCaptchaTasks(providers, [twoCaptcha, {+ ...solveCaptcha, parameters: { ...solveCaptcha.parameters, cookies: 'SID:B; PREF:one=two' },+ }]), /same observed cookie set/);+ assert.throws(() => native.prepareNativeCaptchaTasks(providers, [twoCaptcha, {+ ...solveCaptcha, parameters: { pageurl: url, googlekey: 'site' },+ }]), /same observed cookie set/);+ assert.throws(() => native.prepareNativeCaptchaTasks(providers, [twoCaptcha, {+ provider: 'nopecha', method: 'token/recaptcha2', parameters: { sitekey: 'site', url,+ cookie: [{ name: 'SID', value: 'A', domain: 'example.test', path: '/',+ hostOnly: true, httpOnly: false, secure: true, session: true }] },+ }]), /same observed cookie set/);+ assert.throws(() => native.buildNativeCaptchaTask({ ...capsolver,+ parameters: { ...capsolver.parameters, cookies: 'SID=A' } }), /must be array/);+ assert.equal(calls.length, 0);+ });test(`${browser}: AWS WAF fallback compares API, challenge, and CAPTCHA scripts before dispatch`, t => {const calls = mockApi(t, () => { throw new Error('Must not dispatch'); });const twoCaptcha = { provider: '2captcha', method: 'AmazonTaskProxyless', parameters: {