pub struct Fingerprint {
pub user_agent: String,
pub screen_resolution: (u32, u32),
pub timezone: String,
pub language: String,
pub platform: String,
pub hardware_concurrency: u32,
pub device_memory: u32,
pub webgl_vendor: Option<String>,
pub webgl_renderer: Option<String>,
pub canvas_noise: bool,
pub fonts: Vec<String>,
}Expand description
A complete browser fingerprint used to make each session look unique.
§Example
use stygian_browser::fingerprint::Fingerprint;
let fp = Fingerprint::random();
let (w, h) = fp.screen_resolution;
assert!(w > 0 && h > 0);Fields§
§user_agent: StringFull user-agent string.
screen_resolution: (u32, u32)Physical screen resolution (width, height) in pixels.
timezone: StringIANA timezone identifier, e.g. "America/New_York".
language: StringBCP 47 primary language tag, e.g. "en-US".
platform: StringNavigator platform string, e.g. "MacIntel" or "Win32".
hardware_concurrency: u32Logical CPU core count reported to JavaScript.
device_memory: u32Device memory in GiB reported to JavaScript.
webgl_vendor: Option<String>WebGL GL_VENDOR string.
webgl_renderer: Option<String>WebGL GL_RENDERER string.
canvas_noise: boolWhether to inject imperceptible canvas pixel noise.
fonts: Vec<String>System fonts available on this device.
Populated by Fingerprint::from_device_profile. Empty when created
via Fingerprint::random or Default.
Implementations§
Source§impl Fingerprint
impl Fingerprint
Sourcepub fn random() -> Self
pub fn random() -> Self
Generate a realistic randomised fingerprint.
Values are selected from curated pools representative of real-world browser distributions. Each call uses sub-second system entropy so consecutive calls within the same second may differ.
§Example
use stygian_browser::fingerprint::Fingerprint;
let fp = Fingerprint::random();
assert!(fp.hardware_concurrency > 0);
assert!(fp.device_memory > 0);Sourcepub fn from_profile(profile: &FingerprintProfile) -> Self
pub fn from_profile(profile: &FingerprintProfile) -> Self
Clone a fingerprint from a FingerprintProfile.
§Example
use stygian_browser::fingerprint::{Fingerprint, FingerprintProfile};
let profile = FingerprintProfile::new("test".to_string());
let fp = Fingerprint::from_profile(&profile);
assert!(!fp.user_agent.is_empty());Sourcepub fn from_device_profile(device: DeviceProfile, seed: u64) -> Self
pub fn from_device_profile(device: DeviceProfile, seed: u64) -> Self
Generate a fingerprint consistent with a specific DeviceProfile.
All properties — user agent, platform, GPU, fonts — are internally consistent. A Mac profile will never carry a Windows GPU, for example.
§Example
use stygian_browser::fingerprint::{Fingerprint, DeviceProfile};
let fp = Fingerprint::from_device_profile(DeviceProfile::DesktopMac, 42);
assert_eq!(fp.platform, "MacIntel");
assert!(!fp.fonts.is_empty());Sourcepub fn validate_consistency(&self) -> Vec<String>
pub fn validate_consistency(&self) -> Vec<String>
Check that all fingerprint fields are internally consistent.
Returns a Vec<String> of human-readable inconsistency descriptions.
An empty vec means the fingerprint passes every check.
§Example
use stygian_browser::fingerprint::Fingerprint;
let fp = Fingerprint::default();
assert!(fp.validate_consistency().is_empty());Sourcepub fn injection_script(&self) -> String
pub fn injection_script(&self) -> String
Produce a JavaScript IIFE that spoofs browser fingerprint APIs.
The returned script is intended to be passed to the CDP command
Page.addScriptToEvaluateOnNewDocument so it runs before page JS.
Covers: screen dimensions, timezone, language, hardware concurrency, device memory, WebGL parameters, canvas noise, and audio fingerprint defence.
§Example
use stygian_browser::fingerprint::Fingerprint;
let fp = Fingerprint::default();
let script = fp.injection_script();
assert!(script.contains("1920"));
assert!(script.contains("screen"));Trait Implementations§
Source§impl Clone for Fingerprint
impl Clone for Fingerprint
Source§fn clone(&self) -> Fingerprint
fn clone(&self) -> Fingerprint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Fingerprint
impl Debug for Fingerprint
Source§impl Default for Fingerprint
impl Default for Fingerprint
Source§impl<'de> Deserialize<'de> for Fingerprint
impl<'de> Deserialize<'de> for Fingerprint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Fingerprint
impl RefUnwindSafe for Fingerprint
impl Send for Fingerprint
impl Sync for Fingerprint
impl Unpin for Fingerprint
impl UnsafeUnpin for Fingerprint
impl UnwindSafe for Fingerprint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more