rustenium-identity 0.1.11

A versatile stealth overlay for rustenium
Documentation
# rustenium-identity

A Rust crate that transforms a raw CDP browser session into a fully-personified browser instance. Built on top of [rustenium](https://github.com/dashn9/rustenium), it consumes an identity record and applies fingerprint spoofing to make the session indistinguishable from a real user.

## Features

- **Full UA construction** for all OS/browser combinations (Windows, macOS, Linux, Android, iOS x Chrome, Safari, Edge)
- **iOS-aware**: CriOS/EdgiOS user agents, no client hints, Safari stealth block for all iOS browsers
- **CDP emulation overrides**: screen metrics, locale, timezone, touch, hardware concurrency
- **Client Hints** (Sec-CH-UA) for Chrome/Edge with platform-specific grease brands
- **JS stealth injection** via `Page.addScriptToEvaluateOnNewDocument` (runs before page JS):
  - Navigator properties (platform, hardwareConcurrency, deviceMemory, languages, webdriver)
  - WebGL parameter spoofing (vendor/renderer)
  - Battery status with randomized percentage
  - History count manipulation
  - Browser-specific overrides (Chrome plugins, Safari vendor, Edge plugins)
- **Hardware fingerprint protection** (deterministic, seeded per-identity so a persona is
  stable across sessions): sub-perceptual canvas/WebGL-readPixels pixel noise, AudioContext
  float noise, and text-metric (font) perturbation
- **Timezone resolution**: explicit value or auto-fetch from ip-api.com via proxy
- **Runtime GPU update** via `Runtime.evaluate`
- **Optional BSON** deserialization behind `bson` feature flag

## Quick Start

```rust
use rustenium_identity::{Identity, IdentitySession};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let raw = std::fs::read_to_string("identity.json")?;
    let identity = Identity::from_json(&raw)?;

    let mut session = IdentitySession::launch(identity).await?;
    session.navigate("https://example.com").await?;

    Ok(())
}
```

## Identity JSON Example

```json
{
  "id": 1,
  "device_model": "SM-S921B",
  "has_battery": true,
  "has_mouse": false,
  "has_touch": true,
  "os": "Android",
  "os_version": "14",
  "platform": {
    "bitness": null,
    "architecture": null,
    "navigator_platform": "Linux armv81",
    "version": "14.0.0"
  },
  "browser": "chrome",
  "browser_version": [124, 0, 6367, 78],
  "screen": {
    "logical_width": 412,
    "logical_height": 915,
    "original_width": 1080,
    "original_height": 2340,
    "density_pixel_ratio": 2.625
  },
  "hardware_concurrency": 8,
  "memory": 8,
  "gpu": {
    "vendor": "Qualcomm",
    "webgl_renderer": "ANGLE (Qualcomm, Adreno (TM) 750, OpenGL ES 3.2)",
    "webgl_vendor": "Google Inc. (Qualcomm)"
  },
  "language": ["en-US", "en"],
  "history_count": 4,
  "proxy": "socks5://user:pass@proxy.example.com:1080",
  "timezone": "America/New_York"
}
```

## Custom ChromeConfig

```rust
use rustenium::browsers::chrome::browser::ChromeConfig;
use rustenium_identity::{Identity, IdentityConfig, IdentitySession};

let identity = Identity::from_json(&raw)?;
let config = IdentityConfig::new(identity, ChromeConfig {
    enable_cdp: true,
    enable_bidi: false,
    ..Default::default()
});
let mut session = IdentitySession::launch(config).await?;
```

## Project Structure

```
src/
  lib.rs          - Public API (IdentityConfig, IdentitySession)
  identity.rs     - Data model (Identity, Gpu, Os, Browser, etc.)
  ua.rs           - User-agent string construction
  cdp.rs          - CDP emulation commands + client hints
  script/mod.rs   - Stealth JS builder (template substitution)
  tz.rs           - Timezone resolution
  error.rs        - Error types
js/
  property_modifier.js  - Stealthy property spoofing utility + toString cloak
  main_world.js         - Main stealth script (templated)
  hardware.js           - Hardware fingerprint protection (canvas/audio/WebGL/fonts), seeded
  browser_chrome.js     - Chrome-specific overrides
  browser_safari.js     - Safari-specific overrides
  browser_edge.js       - Edge-specific overrides
  update_gpu.js         - Runtime GPU update script
```