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

137 lines (127 loc) 4.17 kB
interface optionsInterface { exclude?: string[]; include?: string[]; permissions_to_check?: PermissionName[]; timeout?: number; logging?: boolean; api_key?: string; cache_api_call?: boolean; performance?: boolean; stabilize?: string[]; } /** * * @param key @deprecated this function will be removed * @param value */ declare function setOption<K extends keyof optionsInterface>(key: K, value: optionsInterface[K]): void; /** * This file is used to create the includeComponent function as well as the interfaces each of the * fingerprint components must implement. * */ interface componentInterface { [key: string]: string | string[] | number | boolean | componentInterface; } interface componentFunctionInterface { (options?: optionsInterface): Promise<componentInterface | null>; } /** * includeComponent is the function each custom component function needs to call in order for the component to be included * in the fingerprint. * @param {string} name - the name identifier of the component * @param {componentFunctionInterface} creationFunction - the function that implements the component * @returns nothing */ declare const includeComponent: (name: string, creationFunction: componentFunctionInterface, options?: optionsInterface) => void; /** * This file is here to support legacy implementations. * Eventually, these functions will be removed to keep the library small. */ /** * * @deprecated */ declare function getFingerprintData(): Promise<componentInterface>; /** * * @param includeData boolean * @deprecated this function is going to be removed. use getThumbmark or Thumbmark class instead. */ declare function getFingerprint(includeData?: false): Promise<string>; declare function getFingerprint(includeData: true): Promise<{ hash: string; data: componentInterface; }>; /** * * @deprecated use Thumbmark or getThumbmark instead with options */ declare function getFingerprintPerformance(): Promise<{ elapsed: Record<string, number>; }>; /** * ThumbmarkJS: Main fingerprinting and API logic * * This module handles component collection, API calls, uniqueness scoring, and data filtering * for the ThumbmarkJS browser fingerprinting library. * * Exports: * - getThumbmark * - getThumbmarkDataFromPromiseMap * - resolveClientComponents * - filterThumbmarkData * * Internal helpers and types are also defined here. */ /** * Final thumbmark response structure */ interface thumbmarkResponse { components: componentInterface; info: { [key: string]: any; }; version: string; thumbmark: string; /** * Only present if options.performance is true. */ elapsed?: any; } /** * 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) */ declare function getThumbmark(options?: optionsInterface): Promise<thumbmarkResponse>; /** * Returns the current package version */ declare function getVersion(): string; /** * A client for generating thumbmarks with a persistent configuration. */ declare class Thumbmark { private options; /** * Creates a new Thumbmarker client instance. * @param options - Default configuration options for this instance. */ constructor(options?: optionsInterface); /** * Generates a thumbmark using the instance's configuration. * @param overrideOptions - Options to override for this specific call. * @returns The thumbmark result. */ get(overrideOptions?: optionsInterface): Promise<any>; getVersion(): string; /** * Register a custom component to be included in the fingerprint. * @param key - The component name * @param fn - The component function */ includeComponent(key: string, fn: (options?: optionsInterface) => Promise<componentInterface | null>): void; } export { Thumbmark, getFingerprint, getFingerprintData, getFingerprintPerformance, getThumbmark, getVersion, includeComponent, setOption };