get-browser-fingerprint 3.0.0 → 3.1.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.
package/package.json CHANGED
@@ -1,19 +1,24 @@
1
1
  {
2
2
  "name": "get-browser-fingerprint",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "author": "Damiano Barbati <damiano.barbati@gmail.com> (https://github.com/damianobarbati)",
5
5
  "repository": "https://github.com/damianobarbati/get-browser-fingerprint",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
+ "files": [
9
+ "README.md",
10
+ "package.json",
11
+ "src/index.js"
12
+ ],
8
13
  "type": "module",
9
14
  "scripts": {
10
15
  "eslint": "eslint --ignore-path .gitignore --fix",
11
16
  "test": "vitest run"
12
17
  },
13
18
  "devDependencies": {
14
- "eslint-config-xs": "^1.6.2",
19
+ "eslint-config-xs": "^2.6.1",
15
20
  "http-server": "^14.1.1",
16
- "puppeteer": "^19.8.0",
17
- "vitest": "^0.29.7"
21
+ "puppeteer": "^21.4.1",
22
+ "vitest": "^0.34.6"
18
23
  }
19
24
  }
package/src/index.js CHANGED
@@ -1,5 +1,16 @@
1
1
  const getBrowserFingerprint = ({ hardwareOnly = false, enableWebgl = false, debug = false } = {}) => {
2
- const { cookieEnabled, deviceMemory, doNotTrack, hardwareConcurrency, language, languages, maxTouchPoints, platform, userAgent, vendor } = window.navigator;
2
+ const {
3
+ cookieEnabled,
4
+ deviceMemory,
5
+ doNotTrack,
6
+ hardwareConcurrency,
7
+ language,
8
+ languages,
9
+ maxTouchPoints,
10
+ platform,
11
+ userAgent,
12
+ vendor,
13
+ } = window.navigator;
3
14
 
4
15
  const { width, height, colorDepth, pixelDepth } = window.screen;
5
16
  const timezoneOffset = new Date().getTimezoneOffset();
@@ -97,7 +108,8 @@ export const getWebglID = (debug) => {
97
108
 
98
109
  const f =
99
110
  'attribute vec2 attrVertex;varying vec2 varyinTexCoordinate;uniform vec2 uniformOffset;void main(){varyinTexCoordinate=attrVertex+uniformOffset;gl_Position=vec4(attrVertex,0,1);}';
100
- const g = 'precision mediump float;varying vec2 varyinTexCoordinate;void main() {gl_FragColor=vec4(varyinTexCoordinate,0,1);}';
111
+ const g =
112
+ 'precision mediump float;varying vec2 varyinTexCoordinate;void main() {gl_FragColor=vec4(varyinTexCoordinate,0,1);}';
101
113
  const h = ctx.createBuffer();
102
114
 
103
115
  ctx.bindBuffer(ctx.ARRAY_BUFFER, h);
@@ -151,10 +163,10 @@ export const getWebglInfo = () => {
151
163
  const ctx = document.createElement('canvas').getContext('webgl');
152
164
 
153
165
  const result = {
154
- VERSION: ctx.getParameter(ctx.VERSION),
155
- SHADING_LANGUAGE_VERSION: ctx.getParameter(ctx.SHADING_LANGUAGE_VERSION),
156
- VENDOR: ctx.getParameter(ctx.VENDOR),
157
- SUPORTED_EXTENSIONS: ctx.getSupportedExtensions(),
166
+ VERSION: String(ctx.getParameter(ctx.VERSION)),
167
+ SHADING_LANGUAGE_VERSION: String(ctx.getParameter(ctx.SHADING_LANGUAGE_VERSION)),
168
+ VENDOR: String(ctx.getParameter(ctx.VENDOR)),
169
+ SUPORTED_EXTENSIONS: String(ctx.getSupportedExtensions()),
158
170
  };
159
171
 
160
172
  return result;
@@ -172,7 +184,11 @@ export const murmurhash3_32_gc = (key) => {
172
184
  let h1, h1b, k1;
173
185
 
174
186
  for (let i = 0; i < bytes; i++) {
175
- k1 = (key.charCodeAt(i) & 0xff) | ((key.charCodeAt(++i) & 0xff) << 8) | ((key.charCodeAt(++i) & 0xff) << 16) | ((key.charCodeAt(++i) & 0xff) << 24);
187
+ k1 =
188
+ (key.charCodeAt(i) & 0xff) |
189
+ ((key.charCodeAt(++i) & 0xff) << 8) |
190
+ ((key.charCodeAt(++i) & 0xff) << 16) |
191
+ ((key.charCodeAt(++i) & 0xff) << 24);
176
192
  ++i;
177
193
 
178
194
  k1 = ((k1 & 0xffff) * c1 + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
@@ -220,6 +236,8 @@ export const murmurhash3_32_gc = (key) => {
220
236
  return h1 >>> 0;
221
237
  };
222
238
 
223
- window.getBrowserFingerprint = getBrowserFingerprint;
239
+ if (typeof window !== 'undefined') {
240
+ window.getBrowserFingerprint = getBrowserFingerprint;
241
+ }
224
242
 
225
243
  export default getBrowserFingerprint;
package/.eslintrc DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "extends": [
3
- "eslint-config-xs/react"
4
- ]
5
- }
@@ -1,24 +0,0 @@
1
- name: commit
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- test:
10
- runs-on: ubuntu-22.04
11
- timeout-minutes: 3
12
- steps:
13
- - name: checkout
14
- uses: actions/checkout@v2
15
-
16
- - name: setup node
17
- uses: actions/setup-node@v2
18
- with:
19
- node-version-file: '.nvmrc'
20
-
21
- - name: test
22
- run: |
23
- yarn install
24
- yarn test
@@ -1,28 +0,0 @@
1
- name: tag
2
-
3
- on:
4
- push:
5
- tags:
6
- - v*
7
-
8
- jobs:
9
- release:
10
- runs-on: ubuntu-22.04
11
- timeout-minutes: 3
12
- steps:
13
- - name: checkout
14
- uses: actions/checkout@v2
15
-
16
- - name: setup node
17
- uses: actions/setup-node@v2
18
- with:
19
- node-version-file: '.nvmrc'
20
- registry-url: https://registry.npmjs.org/
21
-
22
- - name: release
23
- env:
24
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
25
- run: |
26
- yarn install
27
- yarn test
28
- npm publish
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- v16.16
package/src/index.html DELETED
@@ -1,47 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>get-browser-fingerprint demo</title>
5
- </head>
6
- <body>
7
- <h1>get-browser-fingerprint</h1>
8
-
9
- <h2 id="default"></h2>
10
- <h2 id="hardwareOnly"></h2>
11
- <h2 id="enableWebgl"></h2>
12
-
13
- <script type="module">
14
- import getFingerprint from './index.js';
15
-
16
- args_default: {
17
- const t0 = performance.now();
18
- const fingerprint = getFingerprint({ debug: true });
19
- const t1 = performance.now();
20
-
21
- const result = `Fingerprint: ${fingerprint} (computed in ${(t1 - t0).toFixed(0)} ms)`;
22
- console.log(result);
23
- document.getElementById('default').innerText = result;
24
- }
25
-
26
- args_hardwareOnly: {
27
- const t0 = performance.now();
28
- const fingerprint = getFingerprint({ hardwareOnly: true, debug: true });
29
- const t1 = performance.now();
30
-
31
- const result = `Fingerprint with hardwareOnly=true: ${fingerprint} (computed in ${(t1 - t0).toFixed(0)} ms)`;
32
- console.log(result);
33
- document.getElementById('hardwareOnly').innerText = result;
34
- }
35
-
36
- args_enableWebgl: {
37
- const t0 = performance.now();
38
- const fingerprint = getFingerprint({ enableWebgl: true, debug: true });
39
- const t1 = performance.now();
40
-
41
- const result = `Fingerprint with enableWebgl=true: ${fingerprint} (computed in ${(t1 - t0).toFixed(0)} ms)`;
42
- console.log(result);
43
- document.getElementById('enableWebgl').innerText = result;
44
- }
45
- </script>
46
- </body>
47
- </html>
package/src/index.spec.js DELETED
@@ -1,53 +0,0 @@
1
- import { describe, it, beforeAll, afterAll, expect } from 'vitest';
2
- import puppeteer from 'puppeteer';
3
-
4
- describe('getBrowserFingerprint', () => {
5
- let browser, page;
6
-
7
- beforeAll(async () => {
8
- browser = await puppeteer.launch({
9
- // headless: false,
10
- // devtools: true,
11
- });
12
- page = await browser.newPage();
13
-
14
- await page.addScriptTag({
15
- type: 'module',
16
- path: './src/index.js',
17
- });
18
- });
19
-
20
- afterAll(async () => {
21
- await browser.close();
22
- });
23
-
24
- it('works without args', async () => {
25
- const result = await page.evaluate(() => {
26
- const result = window.getBrowserFingerprint();
27
- return result;
28
- });
29
-
30
- expect(typeof result).toBe('number');
31
- expect(String(result).length).toBeGreaterThanOrEqual(7);
32
- });
33
-
34
- it('works without hardwareOnly=true', async () => {
35
- const result = await page.evaluate(() => {
36
- const result = window.getBrowserFingerprint();
37
- return result;
38
- });
39
-
40
- expect(typeof result).toBe('number');
41
- expect(String(result).length).toBeGreaterThanOrEqual(7);
42
- });
43
-
44
- it('works with enableWebgl=true', async () => {
45
- const result = await page.evaluate(() => {
46
- const result = window.getBrowserFingerprint({ enableWebgl: true });
47
- return result;
48
- });
49
-
50
- expect(typeof result).toBe('number');
51
- expect(String(result).length).toBeGreaterThanOrEqual(7);
52
- });
53
- });