fp.d.ts
10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/**
* FingerprintJS v3.0.3 - Copyright (c) FingerprintJS, Inc, 2020 (https://fingerprintjs.com)
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*
* This software contains code from open-source projects:
* MurmurHash3 by Karan Lyons (https://github.com/karanlyons/murmurHash3.js)
*/
declare function x64hash128(key: string, seed?: number): string;
declare function getAudioFingerprint(): Promise<number>;
declare function getFonts(): string[];
interface PluginMimeTypeData {
type: string;
suffixes: string;
}
interface PluginData {
name: string;
description: string;
mimeTypes: PluginMimeTypeData[];
}
declare function getPlugins(): PluginData[] | undefined;
interface CanvasFingerprint {
winding: boolean;
data: string;
}
declare function getCanvasFingerprint(): CanvasFingerprint;
interface TouchSupport {
maxTouchPoints: number;
/** The success or failure of creating a TouchEvent */
touchEvent: boolean;
/** The availability of the "ontouchstart" property */
touchStart: boolean;
}
/**
* This is a crude and primitive touch screen detection. It's not possible to currently reliably detect the availability
* of a touch screen with a JS, without actually subscribing to a touch event.
*
* @see http://www.stucox.com/blog/you-cant-detect-a-touchscreen/
* @see https://github.com/Modernizr/Modernizr/issues/548
*/
declare function getTouchSupport(): TouchSupport;
declare function getOsCpu(): string | undefined;
declare function getLanguages(): string[][];
declare function getColorDepth(): number;
declare function getDeviceMemory(): number | undefined;
declare function getScreenResolution(): [number, number];
declare function getAvailableScreenResolution(): [number, number] | undefined;
declare function getHardwareConcurrency(): number;
declare function getTimezoneOffset(): number;
declare function getTimezone(): string | undefined;
declare function getSessionStorage(): boolean;
declare function getLocalStorage(): boolean;
declare function getIndexedDB(): boolean | undefined;
declare function getOpenDatabase(): boolean;
declare function getCpuClass(): string | undefined;
declare function getPlatform(): string;
declare function getPluginsSupport(): boolean;
declare function getProductSub(): string;
declare function getEmptyEvalLength(): number;
declare function getErrorFF(): boolean;
declare function getVendor(): string;
declare function getChrome(): boolean;
/**
* navigator.cookieEnabled cannot detect custom or nuanced cookie blocking configurations. For example, when blocking
* cookies via the Advanced Privacy Settings in IE9, it always returns true. And there have been issues in the past with
* site-specific exceptions. Don't rely on it.
*
* @see https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cookies.js Taken from here
*/
declare function areCookiesEnabled(): boolean;
/**
* The list of entropy sources used to make visitor identifiers.
*
* This value isn't restricted by Semantic Versioning, i.e. it may be changed without bumping minor or major version of
* this package.
*/
declare const sources: {
osCpu: typeof getOsCpu;
languages: typeof getLanguages;
colorDepth: typeof getColorDepth;
deviceMemory: typeof getDeviceMemory;
screenResolution: typeof getScreenResolution;
availableScreenResolution: typeof getAvailableScreenResolution;
hardwareConcurrency: typeof getHardwareConcurrency;
timezoneOffset: typeof getTimezoneOffset;
timezone: typeof getTimezone;
sessionStorage: typeof getSessionStorage;
localStorage: typeof getLocalStorage;
indexedDB: typeof getIndexedDB;
openDatabase: typeof getOpenDatabase;
cpuClass: typeof getCpuClass;
platform: typeof getPlatform;
plugins: typeof getPlugins;
canvas: typeof getCanvasFingerprint;
touchSupport: typeof getTouchSupport;
fonts: typeof getFonts;
audio: typeof getAudioFingerprint;
pluginsSupport: typeof getPluginsSupport;
productSub: typeof getProductSub;
emptyEvalLength: typeof getEmptyEvalLength;
errorFF: typeof getErrorFF;
vendor: typeof getVendor;
chrome: typeof getChrome;
cookiesEnabled: typeof areCookiesEnabled;
};
/**
* A functions that returns data with entropy to identify visitor.
* Source must handle expected errors by itself and turn them into entropy.
* The return value must be compatible with `JSON.stringify` or be undefined.
*/
declare type Source<TOptions, TValue> = (options: TOptions) => Promise<TValue> | TValue;
/**
* Generic dictionary of unknown sources
*/
declare type UnknownSources<TOptions> = Record<string, Source<TOptions, unknown>>;
/**
* Converts an entropy source type to the source return value type
*/
declare type SourceValue<TSource extends Source<any, any>> = TSource extends Source<any, infer T> ? T : never;
/**
* Result of getting entropy data from a source
*/
declare type Component<T> = ({
value: T;
error?: undefined;
} | {
value?: undefined;
error: Error | {
message: unknown;
};
}) & {
duration: number;
};
/**
* Generic dictionary of unknown components
*/
declare type UnknownComponents = Record<string, Component<unknown>>;
/**
* Converts an entropy source list type to a corresponding component list type.
*
* Warning for package users:
* This type is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
*/
declare type SourcesToComponents<TSources extends UnknownSources<any>> = {
[K in keyof TSources]: Component<SourceValue<TSources[K]>>;
};
/**
* List of components from the built-in entropy sources.
*
* Warning! This type is out of Semantic Versioning, i.e. may have incompatible changes within a major version. If you
* want to avoid breaking changes, use `UnknownComponents` instead that is more generic but guarantees backward
* compatibility within a major version. This is because browsers change constantly and therefore entropy sources have
* to change too.
*/
declare type BuiltinComponents = SourcesToComponents<typeof sources>;
/**
* Gets a components list from the given list of entropy sources.
*
* Warning for package users:
* This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
*/
declare function getComponents<TSourceOptions, TSources extends UnknownSources<TSourceOptions>, TExclude extends string>(sources: TSources, sourceOptions: TSourceOptions, excludeSources: readonly TExclude[]): Promise<Omit<SourcesToComponents<TSources>, TExclude>>;
/**
* Options for Fingerprint class loading
*/
interface LoadOptions {
/**
* When browser doesn't support `requestIdleCallback` a `setTimeout` will be used. This number is only for Safari and
* old Edge, because Chrome/Blink based browsers support `requestIdleCallback`. The value is in milliseconds.
* @default 50
*/
delayFallback?: number;
}
/**
* Options for getting visitor identifier
*/
interface GetOptions {
/**
* Whether to print debug messages to the console.
* Required to ease investigations of problems.
*/
debug?: boolean;
}
/**
* Result of getting a visitor identifier
*/
interface GetResult {
/**
* The visitor identifier
*/
visitorId: string;
/**
* List of components that has formed the visitor identifier.
*
* Warning! The type of this property is specific but out of Semantic Versioning, i.e. may have incompatible changes
* within a major version. If you want to avoid breaking changes, treat the property as having type
* `UnknownComponents` that is more generic but guarantees backward compatibility within a major version.
*/
components: BuiltinComponents;
}
/**
* Agent object that can get visitor identifier
*/
interface Agent {
/**
* Gets the visitor identifier
*/
get(options?: Readonly<GetOptions>): Promise<GetResult>;
}
declare function componentsToDebugString(components: UnknownComponents): string;
declare function hashComponents(components: UnknownComponents): string;
/**
* Builds an instance of Agent and waits a delay required for a proper operation.
*/
declare function load({ delayFallback }?: Readonly<LoadOptions>): Promise<Agent>;
/**
* Checks whether the browser is based on Trident (the Internet Explorer engine) without using user-agent.
*
* Warning for package users:
* This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
*/
declare function isTrident(): boolean;
/**
* Checks whether the browser is based on EdgeHTML (the pre-Chromium Edge engine) without using user-agent.
*
* Warning for package users:
* This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
*/
declare function isEdgeHTML(): boolean;
/**
* Checks whether the browser is based on Chromium without using user-agent.
*
* Warning for package users:
* This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
*/
declare function isChromium(): boolean;
/**
* Checks whether the browser is based on mobile or desktop Safari without using user-agent.
* All iOS browsers use WebKit (the Safari engine).
*
* Warning for package users:
* This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
*/
declare function isWebKit(): boolean;
/**
* Checks whether the WebKit browser is a desktop Safari.
*
* Warning for package users:
* This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
*/
declare function isDesktopSafari(): boolean;
/**
* Checks whether the browser is based on Gecko (Firefox engine) without using user-agent.
*
* Warning for package users:
* This function is out of Semantic Versioning, i.e. can change unexpectedly. Usage is at your own risk.
*/
declare function isGecko(): boolean;
declare const _default: {
load: typeof load;
hashComponents: typeof hashComponents;
componentsToDebugString: typeof componentsToDebugString;
};
/** Not documented, out of Semantic Versioning, usage is at your own risk */
declare const murmurX64Hash128: typeof x64hash128;
export default _default;
export { Agent, BuiltinComponents, Component, GetOptions, GetResult, LoadOptions, SourcesToComponents, UnknownComponents, componentsToDebugString, getComponents, hashComponents, isChromium, isDesktopSafari, isEdgeHTML, isGecko, isTrident, isWebKit, load, murmurX64Hash128 };