New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

get-browser-fingerprint

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-browser-fingerprint - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

.nvmrc

8

package.json
{
"name": "get-browser-fingerprint",
"version": "1.0.2",
"version": "1.1.0",
"author": "Damiano Barbati <damiano.barbati@gmail.com> (http://github.com/damianobarbati)",

@@ -10,8 +10,8 @@ "repository": "https://github.com/damianobarbati/get-browser-fingerprint",

"scripts": {
"test": "node --experimental-modules src/index.spec.js || echo 'test failed'"
"test": "node src/index.spec.js || echo 'test failed'"
},
"devDependencies": {
"eslint": "^6.6.0",
"puppeteer": "^2.0.0"
"eslint": "^7.8.1",
"puppeteer": "^5.2.1"
}
}
# get-browser-fingerprint
This package exports a single function computing a browser fingerprint once executed.
No dependency.
Zero dependencies package exporting a single function which computes a browser fingerprint.
## Usage
```
Get browser fingerprint:
```javascript
import getBrowserFingerprint from 'get-browser-fingerprint';
const fingerprint = getBrowserFingerprint();
console.log(fingerprint);
//
```
```
Get a "stable" browser fingerprint across os/browser updates taking into account only hardware:
```javascript
import getBrowserFingerprint from 'get-browser-fingerprint';
const fingerprint = getBrowserFingerprint(true);
console.log(fingerprint);
```

@@ -1,2 +0,2 @@

export default () => {
export default hardwareOnly => {
const { userAgent, language, languages, platform, hardwareConcurrency, deviceMemory } = window.navigator;

@@ -8,3 +8,2 @@ const plugins = Object.entries(window.navigator.plugins).map(([, plugin]) => plugin.name);

const touchSupport = 'ontouchstart' in window;
const canvas = (() => {

@@ -32,18 +31,29 @@ try {

const data = JSON.stringify({
userAgent,
language,
languages,
platform,
hardwareConcurrency,
deviceMemory,
plugins,
colorDepth,
availWidth,
availHeight,
timezoneOffset,
timezone,
touchSupport,
canvas,
});
const data = hardwareOnly ?
JSON.stringify({
platform,
hardwareConcurrency,
deviceMemory,
colorDepth,
availWidth,
availHeight,
touchSupport,
canvas,
}) :
JSON.stringify({
userAgent,
language,
languages,
platform,
hardwareConcurrency,
deviceMemory,
plugins,
colorDepth,
availWidth,
availHeight,
timezoneOffset,
timezone,
touchSupport,
canvas,
});

@@ -113,2 +123,2 @@ const murmurhash3_32_gc = key => {

return result;
};
};

@@ -6,9 +6,21 @@ import { strict as assert } from 'assert';

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const result = await page.evaluate(getBrowserFingerprint);
await browser.close();
await (async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const result = await page.evaluate(getBrowserFingerprint);
await browser.close();
assert.deepStrictEqual(Number.isInteger(result), true, 'fingerprint is not an integer');
assert.deepStrictEqual(String(result).length > 7, true, 'fingerprint is not long enough');
})().then(console.log).catch(console.error).finally(process.exit);
assert.deepStrictEqual(Number.isInteger(result), true, 'fingerprint is not an integer');
assert.deepStrictEqual(String(result).length > 7, true, 'fingerprint is not long enough');
})();
await (async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const result = await page.evaluate(getBrowserFingerprint, true);
await browser.close();
assert.deepStrictEqual(Number.isInteger(result), true, 'fingerprint is not an integer');
assert.deepStrictEqual(String(result).length > 7, true, 'fingerprint is not long enough');
})();
})().then(console.log).catch(console.error).finally(process.exit);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc