fingerprintjs

Форк
0
123 строки · 4.7 Кб
1
import { loadSources, SourcesToComponents } from '../utils/entropy_source'
2
import getAudioFingerprint from './audio'
3
import getFonts from './fonts'
4
import getPlugins from './plugins'
5
import getCanvasFingerprint from './canvas'
6
import getTouchSupport from './touch_support'
7
import getOsCpu from './os_cpu'
8
import getLanguages from './languages'
9
import getColorDepth from './color_depth'
10
import getDeviceMemory from './device_memory'
11
import getScreenResolution from './screen_resolution'
12
import getScreenFrame from './screen_frame'
13
import getHardwareConcurrency from './hardware_concurrency'
14
import getTimezone from './timezone'
15
import getSessionStorage from './session_storage'
16
import getLocalStorage from './local_storage'
17
import getIndexedDB from './indexed_db'
18
import getOpenDatabase from './open_database'
19
import getCpuClass from './cpu_class'
20
import getPlatform from './platform'
21
import getVendor from './vendor'
22
import getVendorFlavors from './vendor_flavors'
23
import areCookiesEnabled from './cookies_enabled'
24
import getDomBlockers from './dom_blockers'
25
import getColorGamut from './color_gamut'
26
import areColorsInverted from './inverted_colors'
27
import areColorsForced from './forced_colors'
28
import getMonochromeDepth from './monochrome'
29
import getContrastPreference from './contrast'
30
import isMotionReduced from './reduced_motion'
31
import isTransparencyReduced from './reduced_transparency'
32
import isHDR from './hdr'
33
import getMathFingerprint from './math'
34
import getFontPreferences from './font_preferences'
35
import isPdfViewerEnabled from './pdf_viewer_enabled'
36
import getArchitecture from './architecture'
37
import getApplePayState from './apple_pay'
38
import getPrivateClickMeasurement from './private_click_measurement'
39
import { getWebGlBasics, getWebGlExtensions } from './webgl'
40

41
/**
42
 * The list of entropy sources used to make visitor identifiers.
43
 *
44
 * This value isn't restricted by Semantic Versioning, i.e. it may be changed without bumping minor or major version of
45
 * this package.
46
 *
47
 * Note: Rollup and Webpack are smart enough to remove unused properties of this object during tree-shaking, so there is
48
 * no need to export the sources individually.
49
 */
50
export const sources = {
51
  // READ FIRST:
52
  // See https://github.com/fingerprintjs/fingerprintjs/blob/master/contributing.md#how-to-make-an-entropy-source
53
  // to learn how entropy source works and how to make your own.
54

55
  // The sources run in this exact order.
56
  // The asynchronous sources are at the start to run in parallel with other sources.
57
  fonts: getFonts,
58
  domBlockers: getDomBlockers,
59
  fontPreferences: getFontPreferences,
60
  audio: getAudioFingerprint,
61
  screenFrame: getScreenFrame,
62
  canvas: getCanvasFingerprint,
63

64
  osCpu: getOsCpu,
65
  languages: getLanguages,
66
  colorDepth: getColorDepth,
67
  deviceMemory: getDeviceMemory,
68
  screenResolution: getScreenResolution,
69
  hardwareConcurrency: getHardwareConcurrency,
70
  timezone: getTimezone,
71
  sessionStorage: getSessionStorage,
72
  localStorage: getLocalStorage,
73
  indexedDB: getIndexedDB,
74
  openDatabase: getOpenDatabase,
75
  cpuClass: getCpuClass,
76
  platform: getPlatform,
77
  plugins: getPlugins,
78
  touchSupport: getTouchSupport,
79
  vendor: getVendor,
80
  vendorFlavors: getVendorFlavors,
81
  cookiesEnabled: areCookiesEnabled,
82
  colorGamut: getColorGamut,
83
  invertedColors: areColorsInverted,
84
  forcedColors: areColorsForced,
85
  monochrome: getMonochromeDepth,
86
  contrast: getContrastPreference,
87
  reducedMotion: isMotionReduced,
88
  reducedTransparency: isTransparencyReduced,
89
  hdr: isHDR,
90
  math: getMathFingerprint,
91
  pdfViewerEnabled: isPdfViewerEnabled,
92
  architecture: getArchitecture,
93
  applePay: getApplePayState,
94
  privateClickMeasurement: getPrivateClickMeasurement,
95

96
  // Some sources can affect other sources (e.g. WebGL can affect canvas), so it's important to run these sources
97
  // after other sources.
98
  webGlBasics: getWebGlBasics,
99
  webGlExtensions: getWebGlExtensions,
100
}
101

102
/**
103
 * List of components from the built-in entropy sources.
104
 *
105
 * Warning! This type is out of Semantic Versioning, i.e. may have incompatible changes within a major version. If you
106
 * want to avoid breaking changes, use `UnknownComponents` instead that is more generic but guarantees backward
107
 * compatibility within a major version. This is because browsers change constantly and therefore entropy sources have
108
 * to change too.
109
 */
110
export type BuiltinComponents = SourcesToComponents<typeof sources>
111

112
export interface BuiltinSourceOptions {
113
  debug?: boolean
114
  cache: Record<string, unknown>
115
}
116

117
/**
118
 * Loads the built-in entropy sources.
119
 * Returns a function that collects the entropy components to make the visitor identifier.
120
 */
121
export default function loadBuiltinSources(options: BuiltinSourceOptions): () => Promise<BuiltinComponents> {
122
  return loadSources(sources, options, [])
123
}
124

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.