fingerprint

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() []string

Available returns a list of available preset names

Types

type ClientHints added in v1.0.1

type ClientHints struct {
	// Low-entropy hints (always sent by Chrome)
	UA         string // Sec-Ch-Ua
	UAMobile   string // Sec-Ch-Ua-Mobile
	UAPlatform string // Sec-Ch-Ua-Platform

	// High-entropy hints (only sent after Accept-CH)
	UAArch            string // Sec-Ch-Ua-Arch
	UABitness         string // Sec-Ch-Ua-Bitness
	UAFullVersionList string // Sec-Ch-Ua-Full-Version-List
	UAModel           string // Sec-Ch-Ua-Model
	UAPlatformVersion string // Sec-Ch-Ua-Platform-Version
}

ClientHints contains browser client hint headers

func GenerateClientHints added in v1.0.1

func GenerateClientHints(chromeVersion string, platform PlatformInfo, includeHighEntropy bool) ClientHints

GenerateClientHints generates client hint headers for Chrome

type FetchDest added in v1.0.1

type FetchDest string

FetchDest represents the Sec-Fetch-Dest header value

const (
	FetchDestDocument      FetchDest = "document"
	FetchDestEmbed         FetchDest = "embed"
	FetchDestFont          FetchDest = "font"
	FetchDestImage         FetchDest = "image"
	FetchDestManifest      FetchDest = "manifest"
	FetchDestMedia         FetchDest = "media"
	FetchDestObject        FetchDest = "object"
	FetchDestReport        FetchDest = "report"
	FetchDestScript        FetchDest = "script"
	FetchDestServiceWorker FetchDest = "serviceworker"
	FetchDestSharedWorker  FetchDest = "sharedworker"
	FetchDestStyle         FetchDest = "style"
	FetchDestWorker        FetchDest = "worker"
	FetchDestXHR           FetchDest = "empty" // XHR/fetch uses "empty"
)

type FetchMode added in v1.0.1

type FetchMode string

FetchMode represents the Sec-Fetch-Mode header value

const (
	// FetchModeNavigate is for document navigation (clicking links, typing URLs)
	FetchModeNavigate FetchMode = "navigate"
	// FetchModeCORS is for cross-origin requests (fetch API with CORS)
	FetchModeCORS FetchMode = "cors"
	// FetchModeNoCORS is for simple requests that don't trigger CORS
	FetchModeNoCORS FetchMode = "no-cors"
	// FetchModeSameOrigin is for same-origin requests
	FetchModeSameOrigin FetchMode = "same-origin"
	// FetchModeWebSocket is for WebSocket connections
	FetchModeWebSocket FetchMode = "websocket"
)

type FetchSite added in v1.0.1

type FetchSite string

FetchSite represents the Sec-Fetch-Site header value

const (
	FetchSiteNone       FetchSite = "none"        // Direct navigation (typing URL)
	FetchSiteSameOrigin FetchSite = "same-origin" // Same origin request
	FetchSiteSameSite   FetchSite = "same-site"   // Same site but different subdomain
	FetchSiteCrossSite  FetchSite = "cross-site"  // Different site entirely
)

type HTTP2Settings

type HTTP2Settings struct {
	HeaderTableSize      uint32
	EnablePush           bool
	MaxConcurrentStreams uint32
	InitialWindowSize    uint32
	MaxFrameSize         uint32
	MaxHeaderListSize    uint32
	// Window update and stream settings
	ConnectionWindowUpdate uint32
	StreamWeight           uint16 // Chrome uses 256
	StreamExclusive        bool
}

HTTP2Settings contains HTTP/2 connection settings

type HeaderCoherence added in v1.0.1

type HeaderCoherence struct {
	// contains filtered or unexported fields
}

HeaderCoherence provides methods for generating coherent request headers

func NewHeaderCoherence added in v1.0.1

func NewHeaderCoherence(preset *Preset) *HeaderCoherence

NewHeaderCoherence creates a new HeaderCoherence helper

func (*HeaderCoherence) ApplyToHeaders added in v1.0.1

func (h *HeaderCoherence) ApplyToHeaders(headers map[string]string, ctx RequestContext)

ApplyToHeaders applies coherent headers to the given header map

func (*HeaderCoherence) GenerateNavigationHeaders added in v1.0.1

func (h *HeaderCoherence) GenerateNavigationHeaders() map[string]string

GenerateNavigationHeaders returns complete headers for page navigation

func (*HeaderCoherence) GenerateXHRHeaders added in v1.0.1

func (h *HeaderCoherence) GenerateXHRHeaders(referrer, targetURL string) map[string]string

GenerateXHRHeaders returns complete headers for XHR/fetch requests

type PlatformInfo

type PlatformInfo struct {
	UserAgentOS        string // e.g., "(Windows NT 10.0; Win64; x64)" or "(X11; Linux x86_64)"
	Platform           string // e.g., "Windows", "Linux", "macOS"
	Arch               string // e.g., "x86", "arm"
	PlatformVersion    string // e.g., "10.0.0", "6.12.0", "14.7.0"
	FirefoxUserAgentOS string // Firefox has slightly different format
}

PlatformInfo contains platform-specific header values

func GetPlatformInfo

func GetPlatformInfo() PlatformInfo

GetPlatformInfo returns platform-specific info based on runtime OS

type Preset

type Preset struct {
	Name                 string
	ClientHelloID        tls.ClientHelloID // For TCP/TLS (HTTP/1.1, HTTP/2)
	PSKClientHelloID     tls.ClientHelloID // For TCP/TLS with PSK (session resumption)
	QUICClientHelloID    tls.ClientHelloID // For QUIC/HTTP/3 (different TLS extensions)
	QUICPSKClientHelloID tls.ClientHelloID // For QUIC/HTTP/3 with PSK (session resumption)
	UserAgent            string
	Headers              map[string]string
	HTTP2Settings        HTTP2Settings
	SupportHTTP3         bool
}

Preset represents a browser fingerprint configuration

func Chrome131

func Chrome131() *Preset

Chrome131 returns the Chrome 131 fingerprint preset

func Chrome133

func Chrome133() *Preset

Chrome133 returns the Chrome 133 fingerprint preset

func Chrome141

func Chrome141() *Preset

Chrome141 returns the Chrome 141 fingerprint preset (latest)

func Chrome143

func Chrome143() *Preset

Chrome143 returns the Chrome 143 fingerprint preset with platform-specific TLS fingerprint

func Chrome143Linux added in v1.0.1

func Chrome143Linux() *Preset

Chrome143Linux returns Chrome 143 with Linux platform and fixed TLS extension order

func Chrome143Windows

func Chrome143Windows() *Preset

Chrome143Windows returns Chrome 143 with Windows platform and fixed TLS extension order

func Chrome143macOS added in v1.0.1

func Chrome143macOS() *Preset

Chrome143macOS returns Chrome 143 with macOS platform and fixed TLS extension order

func Firefox133

func Firefox133() *Preset

Firefox133 returns the Firefox 133 fingerprint preset

func Get

func Get(name string) *Preset

Get returns a preset by name, or Chrome143 as default

func Safari18

func Safari18() *Preset

Safari18 returns the Safari 18 fingerprint preset Note: Safari is macOS-only, so no platform detection needed

type RequestContext added in v1.0.1

type RequestContext struct {
	// Mode is the fetch mode (navigate, cors, no-cors, same-origin)
	Mode FetchMode
	// Dest is the resource destination type
	Dest FetchDest
	// Site is the relationship between request origin and target
	Site FetchSite
	// IsUserTriggered indicates if the request was user-initiated (affects Sec-Fetch-User)
	IsUserTriggered bool
	// Referrer is the page that initiated the request (for Sec-Fetch-Site calculation)
	Referrer string
	// TargetURL is the URL being requested
	TargetURL string
}

RequestContext contains information about the request context for header generation

func ImageContext added in v1.0.1

func ImageContext(referrer, targetURL string) RequestContext

ImageContext returns a RequestContext for image loads

func NavigationContext() RequestContext

NavigationContext returns a RequestContext for page navigation

func ScriptContext added in v1.0.1

func ScriptContext(referrer, targetURL string) RequestContext

ScriptContext returns a RequestContext for script loads

func StyleContext added in v1.0.1

func StyleContext(referrer, targetURL string) RequestContext

StyleContext returns a RequestContext for stylesheet loads

func XHRContext added in v1.0.1

func XHRContext(referrer, targetURL string) RequestContext

XHRContext returns a RequestContext for XHR/fetch API requests

type SecFetchHeaders added in v1.0.1

type SecFetchHeaders struct {
	Site string
	Mode string
	Dest string
	User string // "?1" for user-triggered, empty otherwise
}

SecFetchHeaders generates coherent Sec-Fetch-* headers based on context

func GenerateSecFetchHeaders added in v1.0.1

func GenerateSecFetchHeaders(ctx RequestContext) SecFetchHeaders

GenerateSecFetchHeaders generates Sec-Fetch-* headers for the given context

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL