Skip to main content
Experimental Crate: codec

seleniumbase-rs-codec (library seleniumbase_rs_codec, in crates/codec of the seleniumbase-rs-stealth repository) holds the wire formats of the stealth layer. It is pure: no sockets, no clock, no files, and #![forbid(unsafe_code)]. Every parser bounds its input and returns an error for hostile or truncated bytes instead of panicking. The measured browser table is embedded from src/measured/*.json; today it holds one entry, Chrome 155.0.8059.40 on macOS. The guide that explains these formats is Wire formats.

Depend on it#

The crate is not on crates.io. Cargo finds it inside the repository by its package name:

Cargo.toml

Write seleniumbase-rs by its plain git URL, as above (no branch, tag or rev): the codec takes the core the same way, so Cargo resolves both to one commit and types such as OsType and ClientHints match. Its other dependencies are ring, serde, serde_json and thiserror; there is no BoringSSL here.

Features#

test-fixturesfeature#

Turns on the ClientHello byte builders of the tests (client_hello::fixtures, hidden from the documentation), for the tests of the crates built on this one. Test support only: no release build turns it on. The crate has no default features.

Default: "off"

Module map#

ModuleWhat it holdsPage
emulationThe measured browser tables, embedded from JSON, and their lookups.Emulation
client_helloThe TLS ClientHello parser, ext_id constants and GREASE helpers.ClientHello
ja3, ja3::peetprintJA3 and the peetprint, parsed, rendered and hashed.JA3 and peetprint
ja4JA4, JA4_o, JA4_r and JA4_ro.JA4
akamaiAkamai HTTP/2 fingerprint strings.Akamai
h2_frames, h2_frames::hpack, h2_frames::huffmanHTTP/2 frame reading, the client preface, HPACK and Huffman decoding.HTTP/2 frames
tls_specThe TLS profile a client must send, and the custom JA3, JA4 and peetprint overlays.TlsSpec
h2_specThe HTTP/2 profile: SETTINGS, window, PRIORITY, pseudo-header order.H2Spec
header_specHeader names, order and values per request shape.HeaderSpec
idsIANA names of TLS and HTTP/2 ids, and what BoringSSL can emit.Registries

Re-exports at the root#

The main types are re-exported, so seleniumbase_rs_codec::Ja4 is seleniumbase_rs_codec::ja4::Ja4. Two enums are both called SpecError in their modules, and three lookups of emulation have short names, so they are renamed:

Root nameItem
Akamai, AkamaiErrorakamai::Akamai, akamai::AkamaiError
ClientHello, ClientHelloErrorclient_hello::ClientHello, client_hello::ClientHelloError
Emulation, EmulationErroremulation::Emulation, emulation::EmulationError
measured_emulationsemulation::measured
emulation_for_kindemulation::for_kind
get_emulationemulation::get
H2Spec, H2SpecErrorh2_spec::H2Spec, h2_spec::SpecError
HeaderIdentity, HeaderSpec, HeaderSpecError, RequestShapethe header_spec items of the same name
Ja3, Ja3Error, Peetprint, PeetprintErrorja3::Ja3, ja3::Ja3Error, ja3::peetprint::Peetprint, ja3::peetprint::PeetprintError
Ja4, Ja4Error, Ja4Rawthe ja4 items of the same name
KnownGap, TlsSpec, TlsSpecErrortls_spec::KnownGap, tls_spec::TlsSpec, tls_spec::SpecError

emulation::SpecError is a type alias of EmulationError.

BrowserKind#

enum

A browser whose wire behaviour the measured tables describe. It is defined at the crate root and has no serde of its own: the measured JSON spells it Chrome, and the identity file of the scrape crate spells it chrome.

BrowserKindenum#

The enum is #[non_exhaustive]: match it with a wildcard arm. Every variant has a measured entry; a unit test of the crate fails when one is added without a measurement.

Sub-pages#