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
Match FunCaptcha fallback service hosts
Emre Sokullu9dd3cef9af76
diff --git a/docs/captcha-provider-coverage.md b/docs/captcha-provider-coverage.mdindex 30c9419e3..c0ed9fcd3 100644--- a/docs/captcha-provider-coverage.md+++ b/docs/captcha-provider-coverage.md@@ -138,6 +138,7 @@ 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.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-native-providers.js b/src/chrome/src/agent/captcha-native-providers.jsindex 43b6b2a01..01aec9ebe 100644--- a/src/chrome/src/agent/captcha-native-providers.js+++ b/src/chrome/src/agent/captcha-native-providers.js@@ -202,8 +202,24 @@ function proxyIdentity(task) {}return JSON.stringify([scheme.toLowerCase(), String(host).toLowerCase(), Number(port), String(login), String(password)]);}+function funcaptchaServiceHost(value) {+ try {+ const url = new URL(value.includes('://') ? value : `https://${value}`);+ if (!['http:', 'https:'].includes(url.protocol) || !url.hostname || url.pathname !== '/' || url.search || url.hash) throw new Error();+ return url.host.toLowerCase();+ } catch { throw new Error('Fallback FunCaptcha tasks must use comparable service hosts.'); }+}function validateFallbackIdentifiers(built) {const family = built[0].contract.family;+ if (family === 'funcaptcha' && built.length > 1) {+ const services = built.map(({ task }) => task.funcaptchaApiJSSubdomain || task.surl);+ if (services.some(usable)) {+ if (services.some(value => !usable(value))+ || new Set(services.map(funcaptchaServiceHost)).size > 1) {+ throw new Error('Fallback FunCaptcha tasks must use the same observed service host.');+ }+ }+ }if (built.length > 1) {const proxies = built.map(({ task }) => proxyIdentity(task));const present = proxies.filter(Boolean);diff --git a/src/firefox/src/agent/captcha-native-providers.js b/src/firefox/src/agent/captcha-native-providers.jsindex 43b6b2a01..01aec9ebe 100644--- a/src/firefox/src/agent/captcha-native-providers.js+++ b/src/firefox/src/agent/captcha-native-providers.js@@ -202,8 +202,24 @@ function proxyIdentity(task) {}return JSON.stringify([scheme.toLowerCase(), String(host).toLowerCase(), Number(port), String(login), String(password)]);}+function funcaptchaServiceHost(value) {+ try {+ const url = new URL(value.includes('://') ? value : `https://${value}`);+ if (!['http:', 'https:'].includes(url.protocol) || !url.hostname || url.pathname !== '/' || url.search || url.hash) throw new Error();+ return url.host.toLowerCase();+ } catch { throw new Error('Fallback FunCaptcha tasks must use comparable service hosts.'); }+}function validateFallbackIdentifiers(built) {const family = built[0].contract.family;+ if (family === 'funcaptcha' && built.length > 1) {+ const services = built.map(({ task }) => task.funcaptchaApiJSSubdomain || task.surl);+ if (services.some(usable)) {+ if (services.some(value => !usable(value))+ || new Set(services.map(funcaptchaServiceHost)).size > 1) {+ throw new Error('Fallback FunCaptcha tasks must use the same observed service host.');+ }+ }+ }if (built.length > 1) {const proxies = built.map(({ task }) => proxyIdentity(task));const present = proxies.filter(Boolean);diff --git a/test/captcha-native-providers.mjs b/test/captcha-native-providers.mjsindex eda288a8b..3e352f0ca 100644--- a/test/captcha-native-providers.mjs+++ b/test/captcha-native-providers.mjs@@ -332,6 +332,20 @@ for (const browser of ['chrome', 'firefox']) {assert.throws(() => native.prepareNativeCaptchaTasks(enabled, entries), /same observed reCAPTCHA visibility mode/);assert.equal(calls.length, 0);});+ test(`${browser}: FunCaptcha service host agrees across subdomain and URL formats`, t => {+ const calls = mockApi(t, () => { throw new Error('Must not dispatch'); });+ const entries = [+ { provider: '2captcha', method: 'FunCaptchaTaskProxyless', parameters: { websiteURL: url, websitePublicKey: 'site', funcaptchaApiJSSubdomain: 'sample-api.arkoselabs.com' } },+ { provider: 'solvecaptcha', method: 'funcaptcha', parameters: { pageurl: url, publickey: 'site', surl: 'https://sample-api.arkoselabs.com' } },+ ];+ const enabled = entries.map(entry => ({ id: entry.provider, apiKey: 'key' }));+ assert.equal(native.prepareNativeCaptchaTasks(enabled, entries).length, 2);+ entries[1].parameters.surl = 'https://other-api.arkoselabs.com';+ assert.throws(() => native.prepareNativeCaptchaTasks(enabled, entries), /same observed service host/);+ delete entries[1].parameters.surl;+ assert.throws(() => native.prepareNativeCaptchaTasks(enabled, entries), /same observed service host/);+ assert.equal(calls.length, 0);+ });const recognitionPairs = [['coordinates body', ['2captcha', 'CoordinatesTask', { body: 'image-A' }], ['solvecaptcha', 'coordinates', { body: 'image-A' }], task => { task.body = 'image-B'; }],['image-to-text array alias', ['2captcha', 'ImageToTextTask', { body: 'image-A' }], ['nopecha', 'recognition/textcaptcha', { image_data: ['image-A'] }], task => { task.image_data = ['image-B']; }],