zendriver_cloudflare/lib.rs
1//! Cloudflare Turnstile bypass for `zendriver`.
2//!
3//! See the [Cloudflare chapter](https://turtiesocks.github.io/zendriver-rs/cloudflare.html)
4//! of the [zendriver-rs user guide](https://turtiesocks.github.io/zendriver-rs/)
5//! for end-to-end usage, timeout tuning, and detection-failure diagnostics.
6//!
7//! Drives the Turnstile checkbox click flow:
8//!
9//! 1. Detect the Turnstile iframe via a shadow-DOM-aware walk of the page's
10//! main world.
11//! 2. Dispatch a raw left-click at the 15% × 50% offset inside the iframe
12//! bbox (the canonical Turnstile checkbox location).
13//! 3. Poll for either the `cf-turnstile-response` input gaining a token, or
14//! the challenge container disappearing entirely.
15//!
16//! Most users go through `zendriver`'s `Tab::cloudflare()` (feature-gated)
17//! rather than constructing the bypass directly. The
18//! [`CloudflareBypass`] type is the underlying driver.
19//!
20//! ```no_run
21//! # async fn ex(tab: &zendriver_transport::SessionHandle)
22//! # -> Result<(), zendriver_cloudflare::CloudflareError> {
23//! use std::time::Duration;
24//! use zendriver_cloudflare::{CloudflareBypass, ClearanceOutcome};
25//!
26//! let outcome = CloudflareBypass::new(tab)
27//! .wait_for_clearance(Duration::from_secs(30))
28//! .await?;
29//! match outcome {
30//! ClearanceOutcome::TokenAcquired(token) => println!("got token: {token}"),
31//! ClearanceOutcome::ChallengeGone => println!("challenge cleared"),
32//! }
33//! # Ok(()) }
34//! ```
35
36pub mod bypass;
37pub mod click;
38pub mod detection;
39pub mod error;
40
41pub use bypass::{ClearanceOutcome, CloudflareBypass};
42pub use error::CloudflareError;