http_quik/lib.rs
1//! # http-quik
2//!
3//! High-fidelity stealth transport engine for Chrome network identity parity.
4//!
5//! `http-quik` provides low-level control over the entire protocol stack — from
6//! TLS handshakes through HTTP/2 frame signaling — to make every outbound
7//! connection indistinguishable from a genuine Chrome browser. It is the
8//! transport layer of the [Phantom Engine](https://github.com/polymit/phantom-engine)
9//! and is designed for production agentic navigation at scale.
10//!
11//! ## The Problem
12//!
13//! Modern anti-bot systems (Cloudflare, Akamai, DataDome) perform passive
14//! fingerprinting at multiple protocol layers:
15//!
16//! 1. **TLS (JA3/JA4)** — cipher suite order, extension IDs, elliptic curves.
17//! 2. **HTTP/2 (Akamai)** — SETTINGS values, pseudo-header ordering, stream priority.
18//! 3. **Client Hints** — `sec-ch-ua-platform` cross-checked against the TLS handshake.
19//!
20//! Standard HTTP libraries (`reqwest`, `hyper`) fail these checks because they
21//! use generic TLS stacks and default H2 settings. `http-quik` solves this with
22//! a BoringSSL backend and forensic-level protocol replication.
23//!
24//! ## Core Features
25//!
26//! - **BoringSSL Integration** — Full ClientHello control including GREASE, ECH,
27//! and extension permutation via raw FFI calls.
28//! - **Cross-Platform Profiles** — Pre-configured identities for Chrome 134 on
29//! macOS, Windows, and Linux with OS-specific ALPS payloads and Client Hints.
30//! - **OS Auto-Detection** — [`Client::new()`] selects a profile matched to the
31//! host kernel, eliminating p0f mismatch flags without configuration.
32//! - **Connection Pooling** — Managed H2 session reuse to maintain consistent
33//! behavioral fingerprints across request chains.
34//! - **Stealth Redirects** — A redirect state machine that handles `sec-fetch-*`
35//! headers and method rotation identical to Chromium.
36//!
37//! ## Getting Started
38//!
39//! ```rust
40//! use http_quik::Client;
41//!
42//! #[tokio::main]
43//! async fn main() -> Result<(), http_quik::Error> {
44//! // Auto-detects host OS and uses the matching Chrome 134 profile.
45//! let client = Client::new();
46//!
47//! // Or target a specific platform explicitly:
48//! // use http_quik::{Platform, profile::chrome_134};
49//! // let client = Client::builder()
50//! // .profile(chrome_134::profile(Platform::LinuxX64))
51//! // .build()?;
52//!
53//! let response = client.get("https://example.com").await?;
54//! println!("Status: {}", response.status());
55//!
56//! Ok(())
57//! }
58//! ```
59//!
60//! ## Safety & FFI
61//!
62//! This crate uses `boring` and `boring-sys` for low-level TLS control. All
63//! `unsafe` blocks are localized to the `tls` and `client::connector` modules
64//! and carry `// SAFETY:` annotations documenting the invariants they rely on.
65//!
66//! ## Changelog
67//!
68//! See [CHANGELOG.md](https://github.com/polymit/quik/blob/main/CHANGELOG.md)
69//! for versioned release notes.
70
71/// High-level client, connection pooling, and request execution.
72pub mod client;
73
74/// Crate-wide error types.
75pub mod error;
76
77/// Low-level HTTP/2 frame builder configuration.
78///
79/// Provides internal utilities for overriding the default H2 handshake
80/// to replicate Chromium's SETTINGS order, WINDOW_UPDATE values, and
81/// pseudo-header sequencing.
82pub(crate) mod http2;
83
84/// Chrome transport identity profiles.
85///
86/// Contains the data-only configuration schemas and pre-built profile
87/// constructors for each supported Chrome version and platform.
88pub mod profile;
89
90/// TLS connector construction and BoringSSL FFI bindings.
91///
92/// Handles bit-perfect replication of Chrome's TLS handshake, including
93/// post-quantum key shares (X25519MLKEM768), ALPS injection, and
94/// extension permutation.
95pub(crate) mod tls;
96
97pub use crate::client::{connect, Client, ClientBuilder, Response};
98pub use crate::error::{Error, Result};
99pub use crate::profile::chrome_134::AKAMAI_FINGERPRINT;
100pub use crate::profile::chrome_134::JA3_HASH;
101pub use crate::profile::{ChromeProfile, Platform};