@thumbmarkjs/thumbmarkjs 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +3 -2
  2. package/dist/thumbmark.cjs.js +1 -1
  3. package/dist/thumbmark.cjs.js.map +1 -1
  4. package/dist/thumbmark.esm.d.ts +3 -10
  5. package/dist/thumbmark.esm.js +1 -1
  6. package/dist/thumbmark.esm.js.map +1 -1
  7. package/dist/thumbmark.umd.js +1 -1
  8. package/dist/thumbmark.umd.js.map +1 -1
  9. package/package.json +1 -1
  10. package/src/components/mathml/index.ts +149 -0
  11. package/src/components/webrtc/index.ts +126 -0
  12. package/src/factory.ts +12 -0
  13. package/src/functions/api.ts +130 -0
  14. package/src/functions/filterComponents.ts +0 -1
  15. package/src/functions/index.ts +39 -140
  16. package/src/options.ts +3 -1
  17. package/src/utils/log.ts +2 -1
  18. package/dist/types/components/audio/index.d.ts +0 -2
  19. package/dist/types/components/canvas/index.d.ts +0 -3
  20. package/dist/types/components/fonts/index.d.ts +0 -4
  21. package/dist/types/components/hardware/index.d.ts +0 -2
  22. package/dist/types/components/locales/index.d.ts +0 -2
  23. package/dist/types/components/math/index.d.ts +0 -2
  24. package/dist/types/components/permissions/index.d.ts +0 -3
  25. package/dist/types/components/plugins/index.d.ts +0 -2
  26. package/dist/types/components/screen/index.d.ts +0 -2
  27. package/dist/types/components/system/browser.d.ts +0 -7
  28. package/dist/types/components/system/index.d.ts +0 -2
  29. package/dist/types/components/webgl/index.d.ts +0 -2
  30. package/dist/types/factory.d.ts +0 -51
  31. package/dist/types/functions/filterComponents.d.ts +0 -10
  32. package/dist/types/functions/index.d.ts +0 -89
  33. package/dist/types/functions/legacy_functions.d.ts +0 -27
  34. package/dist/types/index.d.ts +0 -8
  35. package/dist/types/options.d.ts +0 -43
  36. package/dist/types/thumbmark.d.ts +0 -26
  37. package/dist/types/utils/commonPixels.d.ts +0 -1
  38. package/dist/types/utils/ephemeralIFrame.d.ts +0 -4
  39. package/dist/types/utils/getMostFrequent.d.ts +0 -5
  40. package/dist/types/utils/hash.d.ts +0 -5
  41. package/dist/types/utils/imageDataToDataURL.d.ts +0 -1
  42. package/dist/types/utils/log.d.ts +0 -8
  43. package/dist/types/utils/raceAll.d.ts +0 -9
  44. package/dist/types/utils/sort.d.ts +0 -8
  45. package/dist/types/utils/version.d.ts +0 -4
  46. package/dist/types/utils/visitorId.d.ts +0 -11
package/src/options.ts CHANGED
@@ -8,6 +8,7 @@ export interface optionsInterface {
8
8
  cache_api_call?: boolean,
9
9
  performance?: boolean,
10
10
  stabilize?: string[],
11
+ experimental?: boolean,
11
12
  }
12
13
 
13
14
  export const API_ENDPOINT = 'https://api.thumbmarkjs.com';
@@ -19,7 +20,8 @@ export const defaultOptions: optionsInterface = {
19
20
  logging: true,
20
21
  timeout: 5000,
21
22
  cache_api_call: true,
22
- performance: false
23
+ performance: false,
24
+ experimental: false,
23
25
  };
24
26
 
25
27
  export let options = {...defaultOptions};
package/src/utils/log.ts CHANGED
@@ -10,11 +10,12 @@ import { API_ENDPOINT } from '../options';
10
10
  * You can disable this by setting options.logging to false.
11
11
  * @internal
12
12
  */
13
- export async function logThumbmarkData(thisHash: string, thumbmarkData: componentInterface, options: optionsInterface): Promise<void> {
13
+ export async function logThumbmarkData(thisHash: string, thumbmarkData: componentInterface, options: optionsInterface, experimentalData: componentInterface = {}): Promise<void> {
14
14
  const url = `${API_ENDPOINT}/log`;
15
15
  const payload = {
16
16
  thumbmark: thisHash,
17
17
  components: thumbmarkData,
18
+ experimental: experimentalData,
18
19
  version: getVersion(),
19
20
  options,
20
21
  path: window?.location?.pathname,
@@ -1,2 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- export default function getAudio(): Promise<componentInterface | null>;
@@ -1,3 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- export default function getCanvas(): Promise<componentInterface | null>;
3
- export declare function generateCanvasFingerprint(): Promise<componentInterface>;
@@ -1,4 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- import { optionsInterface } from '../../options';
3
- export default function getFonts(options?: optionsInterface): Promise<componentInterface | null>;
4
- export declare function getFontMetrics(): Promise<componentInterface>;
@@ -1,2 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- export default function getHardware(): Promise<componentInterface>;
@@ -1,2 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- export default function getLocales(): Promise<componentInterface>;
@@ -1,2 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- export default function getMath(): Promise<componentInterface>;
@@ -1,3 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- import { optionsInterface } from '../../options';
3
- export default function getPermissions(options?: optionsInterface): Promise<componentInterface>;
@@ -1,2 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- export default function getPlugins(): Promise<componentInterface | null>;
@@ -1,2 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- export default function getScreen(): Promise<componentInterface>;
@@ -1,7 +0,0 @@
1
- interface BrowserResult {
2
- name: string;
3
- version: string;
4
- }
5
- export declare function getBrowser(): BrowserResult;
6
- export declare function isMobileUserAgent(): boolean;
7
- export {};
@@ -1,2 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- export default function getSystem(): Promise<componentInterface>;
@@ -1,2 +0,0 @@
1
- import { componentInterface } from '../../factory';
2
- export default function getWebGL(): Promise<componentInterface>;
@@ -1,51 +0,0 @@
1
- /**
2
- * This file is used to create the includeComponent function as well as the interfaces each of the
3
- * fingerprint components must implement.
4
- *
5
- */
6
- import { optionsInterface } from './options';
7
- import getAudio from "./components/audio";
8
- import getCanvas from "./components/canvas";
9
- import getFonts from "./components/fonts";
10
- import getHardware from "./components/hardware";
11
- import getLocales from "./components/locales";
12
- import getMath from "./components/math";
13
- import getPermissions from "./components/permissions";
14
- import getPlugins from "./components/plugins";
15
- import getScreen from "./components/screen";
16
- import getSystem from "./components/system";
17
- import getWebGL from "./components/webgl";
18
- /**
19
- * @description key->function map of built-in components. Do not call the function here.
20
- */
21
- export declare const tm_component_promises: {
22
- audio: typeof getAudio;
23
- canvas: typeof getCanvas;
24
- fonts: typeof getFonts;
25
- hardware: typeof getHardware;
26
- locales: typeof getLocales;
27
- math: typeof getMath;
28
- permissions: typeof getPermissions;
29
- plugins: typeof getPlugins;
30
- screen: typeof getScreen;
31
- system: typeof getSystem;
32
- webgl: typeof getWebGL;
33
- };
34
- export interface componentInterface {
35
- [key: string]: string | string[] | number | boolean | componentInterface;
36
- }
37
- export interface componentFunctionInterface {
38
- (options?: optionsInterface): Promise<componentInterface | null>;
39
- }
40
- export declare const customComponents: {
41
- [name: string]: componentFunctionInterface | null;
42
- };
43
- export declare const timeoutInstance: componentInterface;
44
- /**
45
- * includeComponent is the function each custom component function needs to call in order for the component to be included
46
- * in the fingerprint.
47
- * @param {string} name - the name identifier of the component
48
- * @param {componentFunctionInterface} creationFunction - the function that implements the component
49
- * @returns nothing
50
- */
51
- export declare const includeComponent: (name: string, creationFunction: componentFunctionInterface, options?: optionsInterface) => void;
@@ -1,10 +0,0 @@
1
- import { componentInterface } from "../factory";
2
- import { optionsInterface } from "../options";
3
- /**
4
- * Filters a componentInterface object based on include/exclude and stabilization options.
5
- *
6
- * @param obj - The object to filter
7
- * @param options - Filtering options
8
- * @returns Filtered object
9
- */
10
- export declare function filterThumbmarkData(obj: componentInterface, options?: optionsInterface): componentInterface;
@@ -1,89 +0,0 @@
1
- /**
2
- * ThumbmarkJS: Main fingerprinting and API logic
3
- *
4
- * This module handles component collection, API calls, uniqueness scoring, and data filtering
5
- * for the ThumbmarkJS browser fingerprinting library.
6
- *
7
- * Exports:
8
- * - getThumbmark
9
- * - getThumbmarkDataFromPromiseMap
10
- * - resolveClientComponents
11
- * - filterThumbmarkData
12
- *
13
- * Internal helpers and types are also defined here.
14
- */
15
- import { optionsInterface } from "../options";
16
- import { componentInterface, includeComponent as globalIncludeComponent } from "../factory";
17
- /**
18
- * Info returned from the API (IP, classification, uniqueness, etc)
19
- */
20
- interface infoInterface {
21
- ip_address?: {
22
- ip_address: string;
23
- ip_identifier: string;
24
- autonomous_system_number: number;
25
- ip_version: 'v6' | 'v4';
26
- };
27
- classification?: {
28
- tor: boolean;
29
- vpn: boolean;
30
- bot: boolean;
31
- datacenter: boolean;
32
- danger_level: number;
33
- };
34
- uniqueness?: {
35
- score: number | string;
36
- };
37
- timed_out?: boolean;
38
- }
39
- /**
40
- * API response structure
41
- */
42
- interface apiResponse {
43
- info?: infoInterface;
44
- version?: string;
45
- components?: componentInterface;
46
- visitorId?: string;
47
- }
48
- /**
49
- * Final thumbmark response structure
50
- */
51
- interface thumbmarkResponse {
52
- components: componentInterface;
53
- info: {
54
- [key: string]: any;
55
- };
56
- version: string;
57
- thumbmark: string;
58
- visitorId?: string;
59
- /**
60
- * Only present if options.performance is true.
61
- */
62
- elapsed?: any;
63
- }
64
- /**
65
- * Calls the Thumbmark API with the given components, using caching and deduplication.
66
- * Returns a promise for the API response or null on error.
67
- */
68
- export declare const getApiPromise: (options: optionsInterface, components: componentInterface) => Promise<apiResponse | null>;
69
- /**
70
- * Main entry point: collects all components, optionally calls API, and returns thumbmark data.
71
- *
72
- * @param options - Options for fingerprinting and API
73
- * @returns thumbmarkResponse (elapsed is present only if options.performance is true)
74
- */
75
- export declare function getThumbmark(options?: optionsInterface): Promise<thumbmarkResponse>;
76
- /**
77
- * Resolves and times all filtered component promises from a component function map.
78
- *
79
- * @param comps - Map of component functions
80
- * @param options - Options for filtering and timing
81
- * @returns Object with elapsed times and filtered resolved components
82
- */
83
- export declare function resolveClientComponents(comps: {
84
- [key: string]: (options?: optionsInterface) => Promise<componentInterface | null>;
85
- }, options?: optionsInterface): Promise<{
86
- elapsed: Record<string, number>;
87
- resolvedComponents: componentInterface;
88
- }>;
89
- export { globalIncludeComponent as includeComponent };
@@ -1,27 +0,0 @@
1
- /**
2
- * This file is here to support legacy implementations.
3
- * Eventually, these functions will be removed to keep the library small.
4
- */
5
- import { componentInterface } from '../factory';
6
- /**
7
- *
8
- * @deprecated
9
- */
10
- export declare function getFingerprintData(): Promise<componentInterface>;
11
- /**
12
- *
13
- * @param includeData boolean
14
- * @deprecated this function is going to be removed. use getThumbmark or Thumbmark class instead.
15
- */
16
- export declare function getFingerprint(includeData?: false): Promise<string>;
17
- export declare function getFingerprint(includeData: true): Promise<{
18
- hash: string;
19
- data: componentInterface;
20
- }>;
21
- /**
22
- *
23
- * @deprecated use Thumbmark or getThumbmark instead with options
24
- */
25
- export declare function getFingerprintPerformance(): Promise<{
26
- elapsed: Record<string, number>;
27
- }>;
@@ -1,8 +0,0 @@
1
- import { getFingerprint, getFingerprintData, getFingerprintPerformance } from './functions/legacy_functions';
2
- import { getThumbmark } from './functions';
3
- import { getVersion } from './utils/version';
4
- import { setOption, optionsInterface, stabilizationExclusionRules } from './options';
5
- import { includeComponent } from './factory';
6
- import { Thumbmark } from './thumbmark';
7
- import { filterThumbmarkData } from './functions/filterComponents';
8
- export { Thumbmark, getThumbmark, getVersion, filterThumbmarkData, optionsInterface, stabilizationExclusionRules, setOption, getFingerprint, getFingerprintData, getFingerprintPerformance, includeComponent };
@@ -1,43 +0,0 @@
1
- export interface optionsInterface {
2
- exclude?: string[];
3
- include?: string[];
4
- permissions_to_check?: PermissionName[];
5
- timeout?: number;
6
- logging?: boolean;
7
- api_key?: string;
8
- cache_api_call?: boolean;
9
- performance?: boolean;
10
- stabilize?: string[];
11
- }
12
- export declare const API_ENDPOINT = "https://api.thumbmarkjs.com";
13
- export declare const defaultOptions: optionsInterface;
14
- export declare let options: {
15
- exclude?: string[] | undefined;
16
- include?: string[] | undefined;
17
- permissions_to_check?: PermissionName[] | undefined;
18
- timeout?: number | undefined;
19
- logging?: boolean | undefined;
20
- api_key?: string | undefined;
21
- cache_api_call?: boolean | undefined;
22
- performance?: boolean | undefined;
23
- stabilize?: string[] | undefined;
24
- };
25
- /**
26
- *
27
- * @param key @deprecated this function will be removed
28
- * @param value
29
- */
30
- export declare function setOption<K extends keyof optionsInterface>(key: K, value: optionsInterface[K]): void;
31
- export declare const stabilizationExclusionRules: {
32
- private: {
33
- exclude: string[];
34
- browsers: string[];
35
- }[];
36
- iframe: {
37
- exclude: string[];
38
- browsers: string[];
39
- }[];
40
- vpn: {
41
- exclude: string[];
42
- }[];
43
- };
@@ -1,26 +0,0 @@
1
- import { optionsInterface } from "./options";
2
- import { componentInterface } from "./factory";
3
- /**
4
- * A client for generating thumbmarks with a persistent configuration.
5
- */
6
- export declare class Thumbmark {
7
- private options;
8
- /**
9
- * Creates a new Thumbmarker client instance.
10
- * @param options - Default configuration options for this instance.
11
- */
12
- constructor(options?: optionsInterface);
13
- /**
14
- * Generates a thumbmark using the instance's configuration.
15
- * @param overrideOptions - Options to override for this specific call.
16
- * @returns The thumbmark result.
17
- */
18
- get(overrideOptions?: optionsInterface): Promise<any>;
19
- getVersion(): string;
20
- /**
21
- * Register a custom component to be included in the fingerprint.
22
- * @param key - The component name
23
- * @param fn - The component function
24
- */
25
- includeComponent(key: string, fn: (options?: optionsInterface) => Promise<componentInterface | null>): void;
26
- }
@@ -1 +0,0 @@
1
- export declare function getCommonPixels(images: ImageData[], width: number, height: number): ImageData;
@@ -1,4 +0,0 @@
1
- export declare function ephemeralIFrame(callback: ({ iframe }: {
2
- iframe: Document;
3
- }) => void): Promise<any>;
4
- export declare function wait<T = void>(durationMs: number, resolveWith?: T): Promise<T>;
@@ -1,5 +0,0 @@
1
- export declare function mostFrequentValuesInArrayOfDictionaries(arr: {
2
- [key: string]: any;
3
- }[], keys: string[]): {
4
- [key: string]: any;
5
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * This code is taken from https://github.com/LinusU/murmur-128/blob/master/index.js
3
- * But instead of dependencies to encode-utf8 and fmix, I've implemented them here.
4
- */
5
- export declare function hash(key: ArrayBuffer | string, seed?: number): string;
@@ -1 +0,0 @@
1
- export declare function imageDataToDataURL(imageData: ImageData): string;
@@ -1,8 +0,0 @@
1
- import { componentInterface } from '../factory';
2
- import { optionsInterface } from '../options';
3
- /**
4
- * Logs thumbmark data to remote logging endpoint (only once per session)
5
- * You can disable this by setting options.logging to false.
6
- * @internal
7
- */
8
- export declare function logThumbmarkData(thisHash: string, thumbmarkData: componentInterface, options: optionsInterface): Promise<void>;
@@ -1,9 +0,0 @@
1
- type DelayedPromise<T> = Promise<T>;
2
- export declare function delay<T>(t: number, val: T): DelayedPromise<T>;
3
- export interface RaceResult<T> {
4
- value: T;
5
- elapsed?: number;
6
- }
7
- export declare function raceAllPerformance<T>(promises: Promise<T>[], timeoutTime: number, timeoutVal: T): Promise<RaceResult<T>[]>;
8
- export declare function raceAll<T>(promises: Promise<T>[], timeoutTime: number, timeoutVal: T): Promise<(T | undefined)[]>;
9
- export {};
@@ -1,8 +0,0 @@
1
- import { componentInterface } from '../factory';
2
- /**
3
- * Recursively sorts the keys of a component object alphabetically.
4
- * This ensures a consistent order for hashing.
5
- * @param obj The component object to sort.
6
- * @returns A new object with sorted keys.
7
- */
8
- export declare function sortComponentKeys(obj: componentInterface): componentInterface;
@@ -1,4 +0,0 @@
1
- /**
2
- * Returns the current package version
3
- */
4
- export declare function getVersion(): string;
@@ -1,11 +0,0 @@
1
- /**
2
- * Visitor ID storage utilities - localStorage only, server generates IDs
3
- */
4
- /**
5
- * Gets visitor ID from localStorage, returns null if unavailable
6
- */
7
- export declare function getVisitorId(): string | null;
8
- /**
9
- * Sets visitor ID in localStorage
10
- */
11
- export declare function setVisitorId(visitorId: string): void;