Fingerprint

Struct Fingerprint 

Source
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: String

Full user-agent string.

§screen_resolution: (u32, u32)

Physical screen resolution (width, height) in pixels.

§timezone: String

IANA timezone identifier, e.g. "America/New_York".

§language: String

BCP 47 primary language tag, e.g. "en-US".

§platform: String

Navigator platform string, e.g. "MacIntel" or "Win32".

§hardware_concurrency: u32

Logical CPU core count reported to JavaScript.

§device_memory: u32

Device memory in GiB reported to JavaScript.

§webgl_vendor: Option<String>

WebGL GL_VENDOR string.

§webgl_renderer: Option<String>

WebGL GL_RENDERER string.

§canvas_noise: bool

Whether 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

Source

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);
Source

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());
Source

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());
Source

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());
Source

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

Source§

fn clone(&self) -> Fingerprint

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Fingerprint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Fingerprint

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Fingerprint

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Fingerprint

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,