Skip to content

Comments

Fix CAPTCHA support with postMessage handling and challenge function stubs#45

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-captcha-support-issues
Draft

Fix CAPTCHA support with postMessage handling and challenge function stubs#45
Copilot wants to merge 4 commits intomainfrom
copilot/fix-captcha-support-issues

Conversation

Copy link
Contributor

Copilot AI commented Nov 26, 2025

CAPTCHA providers (reCAPTCHA, hCaptcha, Cloudflare Turnstile) fail in the proxy environment due to DataCloneError when postMessage attempts to transfer MessagePorts without proper transfer semantics, and ReferenceError for missing challenge functions like solveSimpleChallenge.

Changes

New shared utility (src/utils/post-message-fix.ts)

  • Wraps window.postMessage to filter valid transferables and retry without transfer on DataCloneError
  • Handles both legacy (message, origin, transfer) and modern (message, options) signatures

CAPTCHA handler enhancements (src/utils/captcha-handler.ts)

  • Imports shared postMessage fix
  • Adds global stubs for solveSimpleChallenge, __cf_chl_opt, __cf_chl_ctx
  • Registers placeholder implementations for grecaptcha, hcaptcha, turnstile (overwritten when real scripts load)
  • Extends CAPTCHA domain allowlist

Iframe interceptor updates (src/utils/iframe-interceptor.ts)

  • Skips interception for CAPTCHA-related window.open calls
  • Applies postMessage fix to iframe content windows

Service worker injection (public/sw.js)

  • Injects postMessage fix and challenge stubs into proxied HTML responses
  • Extends allowed origins for cross-origin CAPTCHA messaging
// Before: DataCloneError thrown
window.postMessage(msg, origin, [messagePort]);

// After: MessagePort properly filtered/transferred, fallback on error
window.postMessage(msg, origin, filterValidTransferables([messagePort]));

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/Radius/Radius/node_modules/.bin/astro build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

fix captia support with all capta providers and browser varifacation. be sure to also alow for the orgin and fix these sterotipical errors and Anything that would prevent the capta from loading injected interceptor
hwtss9/,wtw-glodlf.on/poqrz/jnge{?omtjnve>hwtss9/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E8usyIRywy@nNHvgYgWgisGNUdbahB6AiUPr\j3N6QlDPlJrGiKp2DSM10YA3YDRFGOtoDO3OQsBhoqv\hWtle7da69[Pjel-1IYHMke3ADUNO{yhDAN\j.dKgY3ZRIQfita;KhNO8qzaC.HqxuObL2A5TY6kbBBG_7oJr4kri:XZTpBG1JETbGbWRdIra1bvl@9ocQG1HYGNlqwTNoOE-RaH6FO4V4j7g@q2wsObQ67z8Q9@1Ht3JndZ7Vco{sgRIFdMOB2rpo3h.Ya6V4vAyg{lE7lBboePUk;O4WzPmSu9sIGT4jixsCI:C14fr3Y22;wqvdzZR\FtQzl{mz_uz:Jzps5ZdTmb6@Yog&25sfi&3GlhsmaerDO5Cfw;cSzaPV4Ro%q>EdRIyFqmGIe[nkDIiC@cfTKicKfW1Q8aXj2{0GMPJ[a:drWQ52J:zhrnVb6quuWnJ4YNVuNwcqQT_tlv8zAUJbAVM:60 Uncaught DataCloneError: Failed to execute 'postMessage' on 'Window': A MessagePort could not be cloned because it was not transferred.
at window.postMessage (hwtss9/,wtw-glodlf.on/poqrz/jnge{?omtjnve>hwtss9/,wtw-glodlf.on/pebrh&3Eq&3Gk&25sd_ps&3GSA@aBE4yBAaOwOht4rQ94XucyHvUQB7EBDRBFAqZ2L40@Jn3R12rVKl7LhpSIhStH5GKwZU4BFRuiyI1ApnBgHfftGlgqVI8eXEe7ZuHNABEKg{H1lBA0FAKJ6uu_DKtPzS.nadwHj9w7oc4YBh0m4QKr4bEY31BbZ3oLQXhz[Jew4QU2ROEr@RsgzyaYNr;U63FXRm7oDngpGDZu5e@ow7qb5yK5ZZY9SbNcfxZC1SloreZZogiUTQs9IN{zKK\vJ2g4fgP1oFopEkN2e0wPti;knXJJyLdVfV:4E8Kw@Wb1if{EOBJ0\rQs6CRQPmeE5K{meaeJspYiGinD0UQz08TigeUSK8MY{6qbRQMPHjKpM5hBpuqp{mM9@jM5KdhhHqn8Bi7VeV[qhfNoRPRVwvuDi1@HZTn0Wh5O.4dkTqe6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:1:51818
at VM555 hwtss9/,wtw-gptbtjc-clm,rfcbpwcka,rflfapep/WkbcZOgEIbgB\JiX;01TNeq9,rfcbpwcka_fn-jp:1570:431
at VM555 hwtss9/,wtw-gptbtjc-clm,rfcbpwcka,rflfapep/WkbcZOgEIbgB\JiX;01TNeq9,rfcbpwcka_fn-jp:1583:363
VM548 hwtss9/,wtw-glodlf.on/qeasthb/fnweqpqipe,amckoq?br>1%k>6OdOLJMaABABAJl.KOj:p2eShN-7L@CGbitILrRL&o>aKR3cKM5Lz90d0cvZ19uZ1xoLnNubWo3NGM-&kl>em&u=WkbcZOgEIbgB\JiX;01TNeq9%sjzf=moqmbl%s>9IJ@8{d5YaTDzezKYtt2N0-hrb8fZoHNb5ArTaPvpxvCDqsaQtkYhDK-sFkOEptsLg[HmY4EA:wJm14E7ME58gSpCMQ6XegNxMALuBkZUd-vT3RdiFO@JLpDYVwuNBL2G[t6nKbply0lIJ8JMGSNe@OFnuOGoYPkBqBd1n0Aqn1id{u{HHw@7\PHrhabaJeS_ZWB-;ig6o90jneYOBXDXIm7Bzu4_pLVlQaWFq2RhPmyr0uUM5FBy.MZXVi6xDKHn:eqgNKAmo5Qv28FsKg7DdAUJSU:A%amckoq-ns>23030%e{euwe.mp=25303&b>w{frm5jkhic;:59 Uncaught DataCloneError: Failed to execute 'postMessage' on 'Window': A MessagePort could not be cloned because it was not transferred.
at window.postMessage (VM548 hwtss9/,wtw-glodlf.on/qeasthb/fnweqpqipe,amckoq?br>1%k>6OdOLJMaABABAJl.KOj:p2eShN-7L@CGbitILrRL&o>aKR3cKM5Lz90d0cvZ19uZ1xoLnNubWo3NGM-&kl>em&u=WkbcZOgEIbgB\JiX;01TNeq9%sjzf=moqmbl%s>9IJ@8{d5YaTDzezKYtt2N0-hrb8fZoHNb5ArTaPvpxvCDqsaQtkYhDK-sFkOEptsLg[HmY4EA:wJm14E7ME58gSpCMQ6XegNxMALuBkZUd-vT3RdiFO@JLpDYVwuNBL2G[t6nKbply0lIJ8JMGSNe@OFnuOGoYPkBqBd1n0Aqn1id{u{HHw@7\PHrhabaJeS_ZWB-;ig6o90jneYOBXDXIm7Bzu4_pLVlQaWFq2RhPmyr0uUM5FBy.M...


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@codesandbox
Copy link

codesandbox bot commented Nov 26, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copilot AI and others added 3 commits November 26, 2025 19:19
Co-authored-by: sriail <225764385+sriail@users.noreply.github.com>
Co-authored-by: sriail <225764385+sriail@users.noreply.github.com>
Co-authored-by: sriail <225764385+sriail@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix captcha support with all providers and browser verification Fix CAPTCHA support with postMessage handling and challenge function stubs Nov 26, 2025
Copilot AI requested a review from sriail November 26, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants