guise 0.1.2

Canonical browser fingerprint bundles, human-behavior timing, and TLS profile re-exports for the Santh fleet
Documentation
//! BiDi browser stealth application for Firefox + rustenium.
//!
//! Anti-detection JS is injected via BiDi `add_preload_script` + an immediate
//! `evaluate`. Firefox prefs (viewport, user-agent, etc.) are set at launch
//! time via `user.js`; this module ties the two layers together at launch.
//!
//! Responsibilities are split by layer:
//! - [`inject`] — the JS-runtime overrides (`apply_stealth`, `apply_stealth_profile`).
//! - [`userjs`] — the launch-time Firefox pref builder (`build_user_js`).
//! - [`reynard`] — engine-level spoof config for the patched Camoufox/reynard binary.
//!
//! The `launch_*` orchestration below composes them: build the pref file, launch
//! Firefox, then apply the JS + fingerprint layers so the BiDi path has the same
//! anti-detection coverage as the legacy CDP path.

use runtime_foxdriver::browser::{FoxBrowserConfig, Page};

mod inject;
mod reynard;
mod userjs;

pub use inject::{apply_default_stealth_profile, apply_stealth, apply_stealth_profile};
pub use reynard::{
    align_ua_to_engine, identity_seed, launch_reynard, launch_reynard_with_config, reynard_config,
    reynard_config_env, reynard_engine_major, REYNARD_CONFIG_ENV,
};
pub use userjs::{automation_prefs, build_user_js};

/// Launch Firefox with the given profile applied at both the pref layer
/// (`user.js`) and the JS runtime layer (`evaluate` + `preload`).
///
/// Also applies the default fingerprint evasion (canvas noise, audio noise,
/// font noise, WebGL shaping) so the BiDi path matches the CDP path's
/// anti-detection coverage.
pub async fn launch_profiled_firefox(
    mut config: FoxBrowserConfig,
    profile: &crate::StealthProfile,
) -> anyhow::Result<Page> {
    let overrides = crate::profile_to_overrides(profile);
    let user_js = build_user_js(&overrides);

    // Merge caller-supplied user.js with our profile prefs.
    config.user_js_content = Some(match config.user_js_content {
        Some(existing) => format!("{}\n{}", existing, user_js),
        None => user_js,
    });

    let page = runtime_foxdriver::browser::launch_firefox(config).await?;
    apply_stealth_profile(&page, profile).await?;

    // Apply fingerprint evasion (canvas, audio, fonts, WebGL, performance)
    // so the BiDi path has the same surface coverage as the CDP path.
    let fp_config = crate::fingerprint::FingerprintConfig::default();
    let _ = crate::fingerprint::apply_fingerprint(&page, &fp_config).await;

    Ok(page)
}

/// Launch Firefox with the default stealth profile.
pub async fn launch_default_profiled_firefox(
    config: FoxBrowserConfig,
) -> anyhow::Result<Page> {
    launch_profiled_firefox(config, &crate::StealthProfile::FirefoxLinux).await
}