Skip to content

Repository files navigation

Fingerprint Lib

A production-grade, lightweight, and robust browser fingerprinting library written in TypeScript. It generates a stable, deterministic, and unique SHA-256 fingerprint for visitors.

Features

  • Stable: Resistant to window resizing, zooming, and screen resolution changes.
  • Unique: Distinguishes between similar browsers using Canvas, WebGL, Audio, and Font signals.
  • Lightweight: Zero external dependencies (uses native Web Crypto API).
  • Privacy-focused: Does not use unstable or intrusive signals like screen geometry.

Installation

npm install fingerprint-lib

Usage

import { generateFingerprint } from "fingerprint-lib";

// Async function to generate fingerprint
const result = await generateFingerprint();

console.log("Visitor ID:", result.id);
console.log("Details:", result.components);

For more detailed examples, including integration with React, Vue, and plain HTML, see USAGE_GUIDE.md.

Output Format

The generateFingerprint function returns a FingerprintResult object:

interface FingerprintResult {
  id: string;       // SHA-256 hash
  components: {     // Individual signals
    hardware: { value: ... },
    os: { value: ... },
    canvas: { value: ... },
    webgl: { value: ... },
    audio: { value: ... },
    fonts: { value: ... },
    math: { value: ... }
  };
  version: string;
  time: number;
}

Collected Signals

Signal Category Description
Hardware Concurrency, Memory, Touch Points
OS/Browser Platform, Vendor, Language, Timezone
Canvas Rendering of text, emoji, and geometry
WebGL GPU Vendor and Renderer strings
Audio Audio processing dynamics (oscillator/compressor)
Fonts Detection of installed system fonts
Math Floating-point math stability checks

Development

  1. Install dependencies:

    npm install
  2. Run development demo:

    npm run dev
  3. Build library:

    npm run build

License

MIT