Skip to content

A robust device UUID generator with enhanced fingerprinting parameters.

License

Notifications You must be signed in to change notification settings

auralogiclabs/client-uuid-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

@auralogiclabs/client-uuid-gen

npm version License: MIT minzipped size TypeScript

A robust, browser-based device UUID generator that creates unique fingerprints using multiple browser attributes including Canvas, WebGL, AudioContext, and LocalStorage estimates.

Key Benefits

Feature Description
πŸ›‘οΈ Privacy-First Generates a hash, never stores raw PII. Cookies are NOT used.
πŸ•΅οΈβ€β™‚οΈ Incognito-Proof Stable Mode (default) ensures the same Device ID is generated in Normal and Incognito windows.
πŸš€ High Entropy Combines 8+ hardware/software signals (Canvas, WebGL, Audio, Storage, etc.) for high uniqueness.
πŸ“¦ Universal Works everywhere: Browser (ESM/IIFE), Node.js, and Bundlers (Webpack/Vite).
πŸ’Ž TypeScript Written in TypeScript with full type definitions included.

Browser Support

Browser Version Status
Chrome 60+ βœ… Supported
Firefox 60+ βœ… Supported
Safari 12+ βœ… Supported
Edge 79+ βœ… Supported
iOS / Android Modern βœ… Supported

Installation

npm install @auralogiclabs/client-uuid-gen

Usage

Basic Usage (ES Modules / TypeScript)

import { getFingerprint } from '@auralogiclabs/client-uuid-gen';

async function identifyDevice() {
  try {
    // Default: MD5 hash, Stable Mode enabled
    const deviceId = await getFingerprint();
    console.log('Device UUID (Stable):', deviceId);

    // Option: SHA-256 hash (64 chars)
    const deviceIdStrong = await getFingerprint({ algo: 'sha256' });
    console.log('Device UUID (SHA-256):', deviceIdStrong);
  } catch (error) {
    console.error('Failed to generate fingerprint:', error);
  }
}

Stable Fingerprinting (Incognito Mode)

Browsers often intentionally alter fingerprinting data in Incognito/Private windows to prevent tracking (e.g., hiding real screen height, adding noise to audio signals).

This library handles this automatically.

Configuration: enableStableFingerprinting

  • true (Default): Treats Normal and Incognito windows as the SAME user.
    • How? It neutralizes unstable components (e.g., ignores screen height, skips audio fingerprinting) to ensure the hash remains consistent.
  • false: Treats Normal and Incognito windows as DIFFERENT users.
    • How? It uses all available data, which means the noise injected by the browser will cause the hash to change.
// Treat Incognito as a unique/different user (Strict Mode)
const strictId = await getFingerprint({
  enableStableFingerprinting: false,
});

// Treat Incognito as the same user (Stable Mode - Default)
const stableId = await getFingerprint({
  enableStableFingerprinting: true,
});

Advanced Usage (Class Access)

You can access the EnhancedDeviceFingerprint class directly to inspect individual components.

import { EnhancedDeviceFingerprint } from '@auralogiclabs/client-uuid-gen';

async function fullAnalysis() {
  const fingerprinter = new EnhancedDeviceFingerprint();

  // 1. Generate the hash
  const uuid = await fingerprinter.get();
  console.log('UUID:', uuid);

  // 2. Access internal components (populated after get/generateFingerprint)
  console.log('Detailed Components:', fingerprinter.components);
  /* Output example:
  {
    basic: { userAgent: "...", screenResolution: "1920x(Authored)", ... },
    canvas: "data:image/png;base64,...",
    webgl: "...",
    audio: "audio-omitted-for-stability",
    storage: "..."
  }
  */
}

Browser Usage (Script Tag)

For direct use in the browser without a bundler, use the global build.

<!-- Load crypto-js dependency (standard hashing support) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>

<!-- Load the library -->
<script src="https://unpkg.com/@auralogiclabs/client-uuid-gen/dist/index.global.js"></script>

<script>
  const { getFingerprint } = window.ClientUUIDGen;

  getFingerprint().then((uuid) => {
    console.log('Generated UUID:', uuid);
  });
</script>

How It Works

This library generates a "fingerprint" by collecting stable characteristics of the user's browser environment:

  1. Basic Info: User Agent, OS, Browser, Device Type, Language, Screen Resolution, Timezone.
  2. Canvas Fingerprinting: Renders a hidden canvas with specific text and colors. Differences in graphics hardware produce unique data URLs.
  3. WebGL Fingerprinting: Queries WebGL vendor and renderer information.
  4. Audio Fingerprinting: Uses an OfflineAudioContext to render a specific oscillator tone. Differences in audio hardware/drivers produce unique signal processing results.
  5. Storage Fingerprinting: Estimates available storage quota to bucket users (e.g., "fast device with lots of space" vs "budget device").

All these components are combined into a JSON string and hashed to produce a short, unique identifier.

Privacy Note

Fingerprinting allows identification without cookies. Ensure you comply with GDPR, CCPA, and other privacy regulations.

  • Inform users that device characteristics are being used for identification/fraud prevention.
  • Obtain necessary consents if required in your jurisdiction.

Development

Prerequisites

  • Node.js 18+

Setup

git clone https://github.com/auralogiclabs/client-uuid-gen.git
cd client-uuid-gen
npm install

Build

Generates dist/ folder with CJS, ESM, and IIFE formats.

npm run build

Test

Runs unit tests using Vitest.

npm test

Lint & Format

npm run lint
npm run format

Running Example

To run the example page locally:

Important: Run the server from the project root, not inside the examples/ folder. This ensures the browser can correct access the dist/ folder.

# 1. Build the library first
npm run build

# 2. Serve from project root
npx serve .

# 3. Visit http://localhost:3000/examples/
Example Output
Example Interface

License

MIT Β© Auralogic Labs

About

A robust device UUID generator with enhanced fingerprinting parameters.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published