UNPKG

fingerprint-oss

Version:

A comprehensive JavaScript library for device fingerprinting and system information collection. Provides robust, deterministic fingerprinting for web applications with privacy-conscious design.

66 lines (65 loc) 2.67 kB
/*! * Copyright (c) 2025 Akshat Kotpalliwar (alias IntegerAlex on GitHub) * This software is licensed under the GNU Lesser General Public License (LGPL) v3 or later. * * You are free to use, modify, and redistribute this software, but modifications must also be licensed under the LGPL. * This project is distributed without any warranty; see the LGPL for more details. * * For a full copy of the LGPL and ethical contribution guidelines, please refer to the `COPYRIGHT.md` and `NOTICE.md` files. */ /** * Generates a SHA-256 hash from sorted system info for identification. * @param systemInfo Object containing system-specific data. * @returns A SHA-256 hash string. */ import { SystemInfo } from './types'; /** * Generates a deterministic SHA-256 hash string that uniquely identifies a system based on normalized and sorted system information. * * Extracts key properties from the provided system information, applies default placeholders for missing data, normalizes and sorts the data, and serializes it consistently before hashing. This ensures the resulting fingerprint is stable and unique for the given system characteristics. * * @param systemInfo - The system information object containing browser, hardware, and environment details to be fingerprinted. * @returns A SHA-256 hash string representing the normalized system fingerprint. */ export declare function generateId(systemInfo: SystemInfo): Promise<string>; export interface HashGeneratorConfig { debugMode?: boolean; enableValidation?: boolean; } export interface HashDebugInfo { processingTime?: number; normalizedInput?: any; hashInput?: string; originalInput?: any; appliedFallbacks?: Record<string, string>; validationErrors?: string[]; serializationResult?: { normalized: any; stats?: Record<string, any>; }; } export interface HashGenerationResult { hash: string; debugInfo?: HashDebugInfo; } export interface InputComparisonResult { identical: boolean; normalizedInput1?: any; normalizedInput2?: any; hashInput1?: string; hashInput2?: string; differences?: Array<{ property: string; left: any; right: any; affectsHash: boolean; }>; } /** * Enhanced generator with optional debug output used across tests */ export declare function generateIdWithDebug(systemInfo: SystemInfo, config?: HashGeneratorConfig): Promise<HashGenerationResult>; /** * Compare two inputs post-normalization for debugging and analysis */ export declare function compareInputs(left: SystemInfo, right: SystemInfo, _config?: HashGeneratorConfig): Promise<InputComparisonResult>;