UNPKG

@thumbmarkjs/thumbmarkjs

Version:

![GitHub package.json dynamic](https://img.shields.io/github/package-json/version/ilkkapeltola/thumbmarkjs) ![NPM Version](https://img.shields.io/npm/v/@thumbmarkjs/thumbmarkjs) ![NPM Downloads](https://img.shields.io/npm/dm/%40thumbmarkjs%2Fthumbmarkjs

64 lines (63 loc) 2.74 kB
/** * ThumbmarkJS: Main fingerprinting and API logic * * This module handles component collection, API calls, uniqueness scoring, and data filtering * for the ThumbmarkJS browser fingerprinting library. * */ import { optionsInterface } from "../options"; import { componentInterface, componentFunctionInterface, includeComponent as globalIncludeComponent } from "../factory"; import { infoInterface } from "./api"; /** * Final thumbmark response structure */ export interface ThumbmarkError { type: 'component_timeout' | 'component_error' | 'api_timeout' | 'api_error' | 'api_unauthorized' | 'network_error' | 'fatal'; message: string; component?: string; } export interface ThumbmarkResponse { /** Hash of all components - the main fingerprint identifier */ thumbmark: string; /** All resolved fingerprint components */ components: componentInterface; /** Information from the API (IP, classification, uniqueness score) */ info: infoInterface; /** Library version */ version: string; /** Persistent visitor identifier (requires API key) */ visitorId?: string; /** Performance timing for each component (only when options.performance is true) */ elapsed?: Record<string, number>; /** Structured error array. Present only when errors occurred. */ error?: ThumbmarkError[]; /** Experimental components (only when options.experimental is true) */ experimental?: componentInterface; /** Unique identifier for this API request */ requestId?: string; /** Metadata echoed back from the API */ metadata?: string | object; } /** * Main entry point: collects all components, optionally calls API, and returns thumbmark data. * * @param options - Options for fingerprinting and API * @returns ThumbmarkResponse (elapsed is present only if options.performance is true) */ export declare function getThumbmark(options?: optionsInterface, instanceCustomComponents?: Record<string, componentFunctionInterface | null>): Promise<ThumbmarkResponse>; /** * Resolves and times all filtered component promises from a component function map. * * @param comps - Map of component functions * @param options - Options for filtering and timing * @returns Object with elapsed times, filtered resolved components, errors, and pipeline phase timings */ export declare function resolveClientComponents(comps: { [key: string]: (options?: optionsInterface) => Promise<componentInterface | null>; }, options?: optionsInterface): Promise<{ elapsed: Record<string, number>; resolvedComponents: componentInterface; errors: ThumbmarkError[]; pipelineTimings: Record<string, number>; }>; export { globalIncludeComponent as includeComponent };