npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ahmedelsharkawycs/browser-fingerprinting

v1.0.6

Published

A powerful, privacy-focused browser fingerprinting library that generates unique identifiers based on browser and device characteristics. Perfect for fraud prevention, analytics, and user identification without cookies.

Readme

Browser Fingerprinting Library

npm version TypeScript MIT License

A powerful, privacy-focused browser fingerprinting library that generates unique identifiers based on browser and device characteristics. Perfect for fraud prevention, analytics, and user identification without cookies.

Features

  • Comprehensive Data Collection: Gathers 15+ unique browser and device attributes
  • Privacy-Focused: No external dependencies or data transmission
  • High Performance: Optimized async operations with minimal impact
  • Canvas Fingerprinting: Advanced canvas-based fingerprinting technique
  • Cross-Browser Support: Works on all modern browsers
  • Device Detection: Mobile, tablet, and desktop identification
  • TypeScript Support: Full type safety and IntelliSense
  • Flexible Output: Base64, SHA-256 hash, or raw data formats

Table of Contents

Installation

npm install @ahmedelsharkawycs/browser-fingerprinting
yarn add @ahmedelsharkawycs/browser-fingerprinting
pnpm add @ahmedelsharkawycs/browser-fingerprinting

Quick Start

JavaScript (ES6+)

import {
  getBrowserFingerprint,
  normalizeFingerprint,
  getFingerprintBase64,
  getFingerprintHashAsync
} from "@ahmedelsharkawycs/browser-fingerprinting"

// Get complete browser fingerprint
const fingerprint = getBrowserFingerprint()
console.log("Full fingerprint:", fingerprint)

// Get normalized fingerprint for ID generation
const normalized = normalizeFingerprint(fingerprint)
console.log("Normalized:", normalized)

// Generate Base64 ID
const base64Id = getFingerprintBase64(normalized)
console.log("Base64 ID:", base64Id)

// Generate SHA-256 hash ID
const hashId = await getFingerprintHashAsync(normalized)
console.log("Hash ID:", hashId)

TypeScript

import {
  getBrowserFingerprint,
  normalizeFingerprint,
  getFingerprintBase64,
  getFingerprintHashAsync,
  type BrowserFingerprint,
  type NormalizedBrowserFingerprint
} from "@ahmedelsharkawycs/browser-fingerprinting"

async function generateFingerprint(): Promise<string> {
  // Get complete fingerprint with full type safety
  const fingerprint: BrowserFingerprint = getBrowserFingerprint()

  // Normalize for consistent ID generation
  const normalized: NormalizedBrowserFingerprint = normalizeFingerprint(fingerprint)

  // Generate a unique hash-based ID
  const uniqueId: string = await getFingerprintHashAsync(normalized)

  return uniqueId
}

API Reference

Core Functions

getBrowserFingerprint(): BrowserFingerprint

Collects comprehensive browser and device information.

Returns: Complete fingerprint object with all available data points.

normalizeFingerprint(fingerprint: BrowserFingerprint): NormalizedBrowserFingerprint

Normalizes fingerprint data for consistent ID generation across sessions.

Parameters:

  • fingerprint: The complete browser fingerprint

Returns: Normalized fingerprint with stable attributes only.

getFingerprintBase64(fingerprint: NormalizedBrowserFingerprint): string

Generates a Base64-encoded unique identifier.

Parameters:

  • fingerprint: Normalized fingerprint data
  • isNormalized: Whether the input is already normalized (default: true)

Returns: URL-safe Base64 encoded ID.

getFingerprintHashAsync(fingerprint: NormalizedBrowserFingerprint): Promise

Generates a SHA-256 hash-based unique identifier.

Parameters:

  • fingerprint: Normalized fingerprint data
  • isNormalized: Whether the input is already normalized (default: true)

Returns: Hexadecimal SHA-256 hash string.

Data Collected

Browser Information

  • User Agent: Browser and OS identification
  • Platform: Operating system details
  • Vendor: Browser vendor information
  • Language: Primary and available languages
  • Plugins: Installed browser plugins
  • MIME Types: Supported media types

Hardware & Performance

  • Screen Resolution: Display dimensions and pixel density
  • Hardware Concurrency: CPU core count
  • Device Memory: Available RAM (if supported)
  • Touch Support: Touch capabilities and max touch points
  • Performance Metrics: Timing benchmarks

Graphics & Media

  • Canvas Fingerprint: Rendered canvas signature
  • WebGL Information: Graphics card vendor and renderer
  • Font Detection: Available system fonts

Network & Storage

  • Network Information: Connection type and speed
  • Storage Support: Local/session storage and IndexedDB
  • Local IP Addresses: WebRTC-based IP detection
  • Timezone: User's timezone setting

Browser Quirks Detection

  • Browser Type: Chrome, Firefox, Safari, Edge, etc.
  • Device Type: Mobile, tablet, or desktop
  • Operating System: Windows, macOS, Linux, etc.

Advanced Usage

Custom Fingerprint Processing

import { getBrowserFingerprint, normalizeFingerprint, getFingerprintHashAsync } from "@ahmedelsharkawycs/browser-fingerprinting"

async function createCustomFingerprint() {
  const fingerprint = getBrowserFingerprint()

  // Custom processing for specific use cases
  const customData = {
    id: await getFingerprintHashAsync(normalizeFingerprint(fingerprint)),
    deviceType: fingerprint.quirks.mobile ? "mobile" : fingerprint.quirks.tablet ? "tablet" : "desktop",
    browserFamily: fingerprint.quirks.chrome ? "Chrome" : fingerprint.quirks.firefox ? "Firefox" : fingerprint.quirks.safari ? "Safari" : "Other",
    screenSignature: `${fingerprint.screen.width}x${fingerprint.screen.height}@${fingerprint.screen.devicePixelRatio}x`,
    hasWebGL: fingerprint.webgl.vendor !== "unknown",
    timestamp: fingerprint.currentTimestamp
  }

  return customData
}

Fingerprint Comparison

async function compareFingerprints() {
  const fp1 = getBrowserFingerprint()
  const fp2 = getBrowserFingerprint() // Later session

  const id1 = await getFingerprintHashAsync(normalizeFingerprint(fp1))
  const id2 = await getFingerprintHashAsync(normalizeFingerprint(fp2))

  return id1 === id2 // Same user/device
}

Use Cases

Fraud Prevention

async function detectSuspiciousActivity(userFingerprint: string) {
  const currentFingerprint = await getFingerprintHashAsync(normalizeFingerprint(getBrowserFingerprint()))

  return userFingerprint !== currentFingerprint
}

Analytics & Tracking

async function trackUniqueVisitors() {
  const fingerprint = getBrowserFingerprint()
  const visitorId = getFingerprintBase64(normalizeFingerprint(fingerprint))

  // Send to analytics without personal data
  analytics.track("page_view", { visitor_id: visitorId })
}

Session Management

async function validateSession(storedFingerprintId: string) {
  const currentId = await getFingerprintHashAsync(normalizeFingerprint(getBrowserFingerprint()))

  if (currentId !== storedFingerprintId) {
    // Potential session hijacking
    return false
  }
  return true
}

Browser Support

| Browser | Version | Notes | | ------- | ------- | -------------- | | Chrome | 60+ | Full support | | Firefox | 55+ | Full support | | Safari | 12+ | Limited WebRTC | | Edge | 79+ | Full support | | Opera | 47+ | Full support |

Note: Some features may have limited availability on older browsers or privacy-focused configurations.

Privacy & Ethics

This library is designed for legitimate use cases such as:

  • Fraud prevention and security
  • Analytics and user experience improvement
  • A/B testing and personalization
  • Bot detection and spam prevention

Ethical Guidelines

  • Always inform users about data collection
  • Provide opt-out mechanisms where required
  • Comply with privacy regulations (GDPR, CCPA, etc.)
  • Don't use for malicious tracking or profiling
  • Respect user privacy settings and preferences

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

git clone https://github.com/AhmedElsharkawyCS/browser-fingerprinting
cd browser-fingerprinting
npm install
npm run build

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support & Contact


Made with ❤️ by Ahmed Sharkawy

⭐ Star this repo if you find it useful!