Skip to Content

Browser

Browser HTTP headers and full browser fingerprints drawn from the Bayesian networks of opentele2-browser, as browserforge’s HeaderGenerator and FingerprintGenerator. A seed (a string, or an integer number or bigint as its decimal text) makes a draw reproducible and the same as opentele2.browser in Python with the same options and seed; without one it comes from the operating system’s entropy.

browser.mjs
import { generateFingerprint, generateHeaders } from 'opentele2' const headers = await generateHeaders({ browsers: [{ name: 'chrome', minVersion: 130 }], os: 'windows' }, 7) const fingerprint = await generateFingerprint({ screen: { maxWidth: 1920 } }, 'profile-1') console.log(headers['User-Agent']) console.log(fingerprint.navigator.userAgent === fingerprint.headers['User-Agent']) // true

Functions

index.d.ts
function generateHeaders(options?: BrowserHeaderOptions | null, seed?: string | number | bigint | null): Promise<Record<string, string>> function generateFingerprint(options?: BrowserFingerprintOptions | null, seed?: string | number | bigint | null): Promise<BrowserFingerprint>
FunctionDescription
generateHeaders(options, seed)One set of headers, name to value in sending order.
generateFingerprint(options, seed)One fingerprint with its matching headers, keyed as browserforge’s Fingerprint.

Both run as async tasks; the first call parses the embedded networks. Invalid options reject with ERR_INVALID_ARG_VALUE, options nothing satisfies (strict, or a screen no sample has with strict) with OT_INVALID_INPUT.

Options

index.d.ts
interface BrowserHeaderOptions { browsers?: string | BrowserSpec | Array<string | BrowserSpec> os?: string | Array<string> devices?: string | Array<string> locales?: string | Array<string> httpVersion?: 1 | 2 | '1' | '2' strict?: boolean userAgent?: string | Array<string> requestDependentHeaders?: Record<string, string> } interface BrowserSpec { name: string minVersion?: number maxVersion?: number httpVersion?: 1 | 2 | '1' | '2' } interface BrowserFingerprintOptions { screen?: ScreenConstraint strict?: boolean mockWebRtc?: boolean slim?: boolean header?: BrowserHeaderOptions } interface ScreenConstraint { minWidth?: number maxWidth?: number minHeight?: number maxHeight?: number }
OptionDescription
browsers'chrome', 'firefox', 'safari', 'edge' or a BrowserSpec with inclusive major version bounds; all four by default.
os'windows', 'macos', 'linux', 'android', 'ios'; all by default.
devices'desktop', 'mobile'; both by default.
localesAccept-Language locales, most preferred first, at most ten; 'en-US' by default.
httpVersionThe HTTP version, also that of every browser given by name; 2 by default, HTTP/1 falling back to HTTP/2 when no HTTP/1 sample fits.
strictFail instead of relaxing the options (headers) or dropping the screen constraint (fingerprint).
userAgentWhen given, the User-Agent is one of these.
requestDependentHeadersReferer, Cookie and the like: one matching a generated header (ignoring case) replaces its value in place, any other is appended.
screenInclusive bounds on the screen, in CSS pixels.
mockWebRtc, slimCarried to the output as mockWebRTC and slim for an injector.
headerThe header options the fingerprint is drawn for.

BrowserFingerprint

index.d.ts
interface BrowserFingerprint { screen: FingerprintScreen navigator: FingerprintNavigator headers: Record<string, string> videoCodecs: Record<string, string> audioCodecs: Record<string, string> pluginsData: Record<string, unknown> battery: Record<string, unknown> | null videoCard: FingerprintVideoCard | null multimediaDevices: Record<string, unknown> fonts: Array<string> mockWebRTC: boolean slim: boolean } interface FingerprintVideoCard { renderer: string; vendor: string }
TypeFields
FingerprintScreenavailTop, availLeft, pageXOffset, pageYOffset, screenX, hasHDR, width, height, availWidth, availHeight, clientWidth, clientHeight, innerWidth, innerHeight, outerWidth, outerHeight, colorDepth, pixelDepth, devicePixelRatio
FingerprintNavigatoruserAgent, userAgentData, doNotTrack, appCodeName, appName, appVersion, oscpu, webdriver, language, languages, platform, deviceMemory, hardwareConcurrency, product, productSub, vendor, vendorSub, maxTouchPoints, extraProperties
FingerprintVideoCardThe unmasked WebGL renderer and vendor

navigator.userAgent equals the headers’ User-Agent, and navigator.languages are the Accept-Language locales in order.

Last updated on