amiunique
TypeScript icon, indicating that this package has built-in type declarations

0.0.15 • Public • Published

Am I Unique

AmIUnique is an npm package designed to generate a comprehensive browser fingerprint using various techniques. This package collects information about the user's browser and device to create a unique identifier, which can be used for analytics, fraud detection, or personalization.

What is Browser Fingerprinting?

Browser fingerprinting is a technique used to collect information about a user's device and browser configuration. By combining multiple pieces of information, such as installed fonts, screen resolution, and browser plugins, it is possible to create a unique identifier for a browser without using cookies or other tracking mechanisms.

Accuracy

The accuracy of browser fingerprinting depends on the amount and uniqueness of the collected data. Studies have shown that combining multiple attributes can achieve a high level of uniqueness, potentially identifying individual browsers with high accuracy. However, factors like browser updates, user configuration changes, and privacy measures can affect fingerprint stability.

Features

  • Comprehensive Data Collection: Gathers a wide range of attributes, including:

    • User agent and platform information
    • Screen resolution and color depth
    • Installed plugins and fonts
    • Canvas and WebGL fingerprints
    • Audio fingerprinting
    • Touch support and hardware concurrency
    • Media devices enumeration
    • Network information
    • Battery level (if available)
    • CPU information
    • Installed languages
    • Do Not Track setting
    • Local and session storage availability
    • IndexedDB support
    • Add behavior and open database support
    • Ad blocker detection
    • Browser lies detection
  • User Behavior Tracking: Monitors user interactions such as mouse movements, clicks, and keyboard events.

  • Navigation Tracking: Tracks page visits, transitions, and time spent on pages.

  • Request Sequence Tracking: Monitors and analyzes sequences of network requests.

  • Asynchronous Operations: Utilizes asynchronous functions for non-blocking data collection.

  • Modular Design: Easily extensible with additional fingerprinting techniques.

Installation

Install AmIUnique using npm:

npm install amiunique

Usage

To utilize the full capabilities of AmIUnique, you can import the following functions and types:

  • Fingerprint Generation:
    • amiunique(): Generates a unique fingerprint of the user's browser.
  • User Behavior Tracking:
    • trackUserBehavior(): Tracks user interactions such as mouse movements, clicks, and keyboard events.
    • UserBehaviorTracker: Type definition for the user behavior tracker.
  • Navigation Tracking:
    • trackNavigation(): Monitors navigation events like page visits and transitions.
    • NavigationTracker: Type definition for the navigation tracker.
  • Request Sequence Tracking:
    • RequestSequenceTracker: Utility class for tracking sequences of network requests.
  • Types:
    • Attributes: Type definition for the fingerprint attributes.

Generating a Browser Fingerprint

Use the amiunique function to generate a unique fingerprint:

import { amiunique, Attributes } from 'amiunique';

(async () => {
  const fingerprint: Attributes | null = await amiunique();
  console.log('Generated fingerprint:', fingerprint);
})();

The amiunique function returns a Promise that resolves to an Attributes object containing various browser attributes and behavior patterns.

Tracking User Behavior

Use the trackUserBehavior function to monitor user interactions:

import { trackUserBehavior, UserBehaviorTracker } from 'amiunique';

const tracker: UserBehaviorTracker = trackUserBehavior();

// Start tracking user behavior
tracker.start();

// Retrieve user behavior data
const behaviorPattern = tracker.getBehaviorPattern();
console.log('User behavior pattern:', behaviorPattern);

// Stop the tracker when done
tracker.stop();

The UserBehaviorTracker captures mouse movements, clicks, and keyboard events.

Tracking Navigation Events

Use the trackNavigation function to track navigation events:

import { trackNavigation, NavigationTracker } from 'amiunique';

const navigationTracker: NavigationTracker = trackNavigation();

// Start tracking navigation events
navigationTracker.start();

// Retrieve navigation events data
const navigationEvents = navigationTracker.getNavigationEvents();
console.log('Navigation events:', navigationEvents);

// Stop the tracker when done
navigationTracker.stop();

Tracking Request Sequences

Use the trackRequestSequence to monitor and analyze sequences of network requests:

import { trackRequestSequence } from 'amiunique';

const requestTracker = trackRequestSequence();

// Start tracking request sequences
requestTracker.start();

// Perform network requests or operations

// Retrieve the recorded request sequences
const sequences = requestTracker.getSequences();
console.log('Request sequences:', sequences);

// Stop the tracker when done
requestTracker.stop();

Types

Attributes

The Attributes type represents the structure of the fingerprint data returned by amiunique(). Here's an updated version based on the current implementation:

interface Attributes {
  user_agent: string;
  language: string;
  color_depth: number;
  device_memory: number | 'not available';
  hardware_concurrency: number | 'not available';
  screen_resolution: string;
  available_screen_resolution: string;
  timezone_offset: number;
  timezone: string;
  session_storage: boolean;
  local_storage: boolean;
  indexed_db: boolean;
  add_behavior: boolean;
  open_database: boolean;
  cpu_class: string;
  platform: string;
  plugins: string[] | 'not available';
  canvas: string;
  webgl: WebGLFingerprint | 'not available';
  webgl_vendor: string | 'not available';
  ad_block: boolean;
  has_lied_languages: boolean;
  has_lied_resolution: boolean;
  has_lied_os: boolean;
  has_lied_browser: boolean;
  touch_support: TouchSupport;
  fonts: string[] | 'not available';
  audio: string;
  enumerateDevices: string[] | 'not available';
  available_resolution_height: number;
  available_resolution_width: number;
  battery_level: number | null;
  charging: boolean | null;
  chargingTime: number | null;
  dischargingTime: number | null;
  doNotTrack: string | null;
  installed_fonts: string[];
  installed_languages: string[];
  cpu_architecture: string | null;
  cpu_cores: number | null;
  navigator_cpu_concurrency: number | null;
  devicePixelRatio: number;
  productSub: string;
  emit_non_tri_dimpacts: boolean;
  event_listener: boolean;
  window_external: string;
  window_status: string;
  math_tan: string;
  date_get_time_zone_off_set: string;
  regexp_error_to_string: string;
  error_generator: string;
  // ... other attributes ...
}

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contributing

We welcome contributions to AmIUnique! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

Package Sidebar

Install

npm i amiunique

Weekly Downloads

5

Version

0.0.15

License

MIT

Unpacked Size

90.8 kB

Total Files

20

Last publish

Collaborators

  • charlkruger