Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fingerprint-generator

Package Overview
Dependencies
Maintainers
10
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fingerprint-generator

NodeJs package for generating realistic browser fingerprints.

  • 2.0.0-beta.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25K
decreased by-21.79%
Maintainers
10
Weekly downloads
 
Created
Source

Fingerprint generator

NodeJs package for generating realistic browser fingerprints and matching headers.

Works best with the Fingerprint injector.

Installation

Run the npm install fingerprint-generator command. No further setup is needed afterwards.

Usage

To use the generator, you need to create an instance of the FingerprintGenerator class which is exported from this package. Constructor of this class accepts a HeaderGeneratorOptions object, which can be used to globally specify what kind of fingerprint and headers you are looking for:

const FingerprintGenerator = require('fingerprint-generator');
let fingerprintGenerator = new FingerprintGenerator({
        browsers: [
            {name: "firefox", minVersion: 80},
            {name: "chrome", minVersion: 87},
            "safari"
        ],
        devices: [
            "desktop"
        ],
        operatingSystems: [
            "windows"
        ]
});

You can then get the fingerprint and headers using the getFingerprint method, either with no argument, or with another HeaderGeneratorOptions object, this time specifying the options only for this call (overwriting the global options when in conflict) and using the global options specified beforehands for the unspecified options:

let { fingerprint, headers } = fingerprintGenerator.getFingerprint({
        operatingSystems: [
            "linux"
        ],
        locales: ["en-US", "en"]
});

This method always generates a random realistic fingerprint and a matching set of headers, excluding the request dependant headers, which need to be filled in afterwards. Since the generation is randomized, multiple calls to this method with the same parameters can generate multiple different outputs.

Result example

Fingerprint that might be generated for the usage example above:

{
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0",
  "cookiesEnabled": true,
  "timezone": "Europe/Prague",
  "timezoneOffset": -60,
  "audioCodecs": {
    "ogg": "probably",
    "mp3": "maybe",
    "wav": "probably",
    "m4a": "maybe",
    "aac": "maybe"
  },
  "videoCodecs": {
    "ogg": "probably", 
    "h264": "probably", 
    "webm": "probably"
  },
  "videoCard": [
    "Intel Open Source Technology Center",
    "Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)"
  ],
  "productSub": "20100101",
  "hardwareConcurrency": 8,
  "multimediaDevices": { 
    "speakers": 0, 
    "micros": 0, 
    "webcams": 0
  },
  "platform": "Linux x86_64",
  "pluginsSupport": true,
  "screenResolution": [ 1920, 1080 ],
  "availableScreenResolution": [ 1920, 1080 ],
  "colorDepth": 24,
  "touchSupport": { 
    "maxTouchPoints": 0, 
    "touchEvent": false, 
    "touchStart": false
  },
  "languages": [ "en-US", "en" ]
}

And the matching headers:

{
  "user-agent": "Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Firefox/90.0",
  "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
  "accept-language": "en-US,en;q=0.9",
  "accept-encoding": "gzip, deflate, br",
  "upgrade-insecure-requests": "1",
  "te": "trailers"
}

API Reference

All public classes, methods and their parameters can be inspected in this API reference.

FingerprintGenerator

Fingerprint generator - randomly generates realistic browser fingerprints


new FingerprintGenerator(options)
ParamTypeDescription
optionsHeaderGeneratorOptionsdefault header generation options used unless overridden

fingerprintGenerator.getFingerprint(options, requestDependentHeaders)

Generates a fingerprint and a matching set of ordered headers using a combination of the default options specified in the constructor and their possible overrides provided here.

ParamTypeDescription
optionsHeaderGeneratorOptionsspecifies options that should be overridden for this one call
requestDependentHeadersObjectspecifies known values of headers dependent on the particular request

BrowserSpecification

ParamTypeDescription
namestringOne of chrome, firefox and safari.
minVersionnumberMinimal version of browser used.
maxVersionnumberMaximal version of browser used.
httpVersionstringHttp version to be used to generate headers (the headers differ depending on the version). Either 1 or 2. If none specified the httpVersion specified in HeaderGeneratorOptions is used.

HeaderGeneratorOptions

ParamTypeDescription
browsersArray.<(BrowserSpecification|string)>List of BrowserSpecifications to generate the headers for, or one of chrome, firefox and safari.
operatingSystemsArray.<string>List of operating systems to generate the headers for. The options are windows, macos, linux, android and ios.
devicesArray.<string>List of devices to generate the headers for. Options are desktop and mobile.
localesArray.<string>List of at most 10 languages to include in the Accept-Language request header in the language format accepted by that header, for example en, en-US or de.
httpVersionstringHttp version to be used to generate headers (the headers differ depending on the version). Can be either 1 or 2. Default value is 2.

FAQs

Package last updated on 28 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc