
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
@mochi.js/challenges
Advanced tools
Convenience layer for Cloudflare Turnstile auto-click — opt-in, behavioral-synth-backed, no new fingerprint surface.
Convenience layer for common bot-defense challenge widgets in mochi.
v0.2 scope: Cloudflare Turnstile visible-checkbox auto-click only.
Out of scope (deferred):
onEscalationThis is not a captcha solver. The visible Turnstile checkbox is a behavioral test: Cloudflare watches the cursor trajectory, the dwell, and a few hundred other signals around the click. The hard part is the behavioral profile, which mochi already does (@mochi.js/behavioral's Bezier+Fitts synth, the inject pipeline's matrix consistency, the wreq TLS fingerprint). The actual click is the easy part — this package exists so you don't have to write page.humanClick('iframe[src*="challenges.cloudflare.com"]') yourself in every flow.
For escalated variants (image / audio / managed-failed), this package fires onEscalation(reason) and bails. It will not click randomly into a challenge iframe.
This package ships with @mochi.js/core v0.2+. You don't add it to your project directly.
import { mochi } from "@mochi.js/core";
const session = await mochi.launch({
profile: "...",
seed: "...",
challenges: {
turnstile: {
autoClick: true,
timeout: 30_000,
onSolved: (token) => console.log("turnstile passed:", token.slice(0, 8) + "…"),
onEscalation: (reason) => console.warn("turnstile escalation:", reason),
},
},
});
// Every page from this session auto-clicks Turnstile.
const page = await session.newPage();
await page.goto("https://example.com");
installTurnstileAutoClickimport { installTurnstileAutoClick } from "@mochi.js/challenges";
const session = await mochi.launch({ profile: "...", seed: "..." });
const page = await session.newPage();
const dispose = installTurnstileAutoClick(page, {
timeout: 30_000,
onSolved: () => console.log("turnstile passed"),
onEscalation: (reason) => console.warn("escalation:", reason),
});
await page.goto("https://example.com");
// ... do stuff ...
dispose();
Page.addScriptToEvaluateOnNewDocument({ runImmediately: true, worldName: "" }) (PLAN.md §8.4). The script installs a MutationObserver filtered to iframe inserts only — it does not fire on every DOM mutation.console.debug({__mochi_event:"turnstile-detected", …}) event and exposes a Symbol-keyed snapshot reader on document (the only externally observable surface; non-enumerable + non-configurable so page script can't tamper).DOM.getBoxModel, and dispatches a click via page.humanClick(...) — the same Bezier+Fitts synth the rest of the framework uses. We never reinvent the synth.cf-turnstile-response field. When a token appears, onSolved(token) fires.src matches /challenge.html (image/audio) or /managed.html (failed-bot variant), or the token doesn't appear within opts.timeout, onEscalation(reason) fires and we bail on that widget.@mochi.js/behavioral. No new fingerprint surface.document. The Symbol is non-enumerable, writable:false, configurable:false.window.Runtime.enable. Detection is poll-based via Runtime.callFunctionOn against the document objectId.worldName: "") for the inject script. Any non-empty world name is detectable.Roughly: the visible-checkbox flow covers the common case. If your target consistently escalates to image / audio challenges, that's a signal that mochi's stealth posture isn't passing the bot heuristics — fix the upstream signal first, then reach for a solver.
The onEscalation callback receives "image-challenge" | "managed" | "timeout" and lets you fire your solver of choice. v0.3 will ship a first-party solver hook surface.
tasks/0220-turnstile-auto-click.md — the briefdocs/limits.md — what's deferred to v0.3FAQs
Convenience layer for Cloudflare Turnstile auto-click — opt-in, behavioral-synth-backed, no new fingerprint surface.
The npm package @mochi.js/challenges receives a total of 11 weekly downloads. As such, @mochi.js/challenges popularity was classified as not popular.
We found that @mochi.js/challenges demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.