https://github.com/actionhero/browser_fingerprint
A node.js module to help identify browser sessions
https://github.com/actionhero/browser_fingerprint
Last synced: 8 months ago
JSON representation
A node.js module to help identify browser sessions
- Host: GitHub
- URL: https://github.com/actionhero/browser_fingerprint
- Owner: actionhero
- License: apache-2.0
- Created: 2012-10-27T05:40:28.000Z (over 13 years ago)
- Default Branch: main
- Last Pushed: 2025-09-01T15:52:43.000Z (9 months ago)
- Last Synced: 2025-09-01T17:41:32.107Z (9 months ago)
- Language: TypeScript
- Size: 1.59 MB
- Stars: 59
- Watchers: 3
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Browser Fingerprint
[](https://github.com/actionhero/browser_fingerprint/actions/workflows/test.yml)
[](https://nodei.co/npm/browser_fingerprint/)
**Note: This package requires node v8, as it makes uses of native classes.**
This module attempts to uniquely identify browsers by examining their header and connection information. This information can be used as a "poor-man's" session identifier in your node projects. This module can optionally set a cookie to 'lock' in a consistent fingerprint.
Resuming sessions require that either the cookie be returned to the server, or a x-header `x-__browserFingerprint` in the default case, be sent on subsequent requests
```javascript
const http = require("http");
const port = 8080;
const { BrowserFingerprint } = require("browser_fingerprint");
// these are the default options
const options = {
cookieKey: "__browser_fingerprint",
toSetCookie: true,
onlyStaticElements: true,
settings: {
path: "/",
expires: 3600000,
httpOnly: null,
},
};
const fingerPrinter = new BrowserFingerprint(options);
http
.createServer((req, res) => {
let { fingerprint, elementsHash, headersHash } = fingerPrinter.fingerprint(
req
);
headersHash["Content-Type"] = "text/plain"; // append any other headers you want
res.writeHead(200, headersHash);
let resp = `Your Browser Fingerprint: ${fingerprint} \r\n\r\n`;
for (let i in elementsHash) {
resp += `Element ${i}: ${elementsHash[i]}\r\n`;
}
res.end(resp);
console.log(
"request from " +
req.connection.remoteAddress +
", fingerprint -> " +
fingerprint
);
})
.listen(port);
console.log(`server running at http://127.0.0.1:${port}`);
```