{"id":16813,"library":"express-fingerprint","title":"Express Server-Side Fingerprinting Middleware","description":"express-fingerprint is an Express middleware designed for passive, server-side client fingerprinting. It allows developers to identify incoming requests based on characteristics observable in HTTP request contents without executing any client-side code. The current stable version is `1.2.2`. The library processes information such as the User-Agent string, HTTP Accept headers, and GeoIP data (if available) to generate a unique hash and a detailed component breakdown for each request, accessible via `req.fingerprint`. Releases are infrequent but have recently addressed critical import issues and added TypeScript support. A key differentiator is its strict adherence to server-side data collection, prioritizing privacy by avoiding client-side scripts, and offering extensibility through custom parameter functions to gather additional request-specific data.","status":"active","version":"1.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/yusukeshibata/express-fingerprint","tags":["javascript","express","fingerprint","server-side","device","identification","node"],"install":[{"cmd":"npm install express-fingerprint","lang":"bash","label":"npm"},{"cmd":"yarn add express-fingerprint","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-fingerprint","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, required for middleware functionality.","package":"express","optional":false}],"imports":[{"note":"Since v1.2.0, the package primarily uses a default export. Use named imports only for static properties like `Fingerprint.useragent`.","wrong":"import { Fingerprint } from 'express-fingerprint'","symbol":"Fingerprint","correct":"import Fingerprint from 'express-fingerprint'"},{"note":"CommonJS usage requires importing the default export directly. Fixes for this specific `require` pattern were included in v1.2.2.","wrong":"const { Fingerprint } = require('express-fingerprint')","symbol":"Fingerprint","correct":"const Fingerprint = require('express-fingerprint')"},{"note":"Static properties like `useragent`, `acceptHeaders`, and `geoip` are accessed directly on the default `Fingerprint` export, not as named imports.","symbol":"Fingerprint.useragent","correct":"import Fingerprint from 'express-fingerprint'; // Then use Fingerprint.useragent"}],"quickstart":{"code":"import express from 'express';\nimport Fingerprint from 'express-fingerprint';\n\nconst app = express();\n\napp.use(Fingerprint({\n    parameters: [\n        // Default parameters\n        Fingerprint.useragent,\n        Fingerprint.acceptHeaders,\n        Fingerprint.geoip,\n\n        // Custom additional parameters\n        function(next) {\n            // Example: Add a custom header value\n            const customHeader = this.req.headers['x-custom-id'] || 'N/A';\n            next(null, {\n                'customHeaderId': customHeader\n            });\n        },\n        function(next) {\n            // Example: Asynchronously fetch and add data\n            setTimeout(() => {\n                next(null, {\n                    'customAsyncParam': 'asyncValue'\n                });\n            }, 50);\n        }\n    ]\n}));\n\napp.get('/', (req, res) => {\n    // The fingerprint object is available on req.fingerprint\n    console.log('Request Fingerprint:', req.fingerprint);\n    res.json({\n        message: 'Fingerprint collected!',\n        fingerprint: req.fingerprint\n    });\n});\n\napp.listen(3000, () => {\n    console.log('Server listening on http://localhost:3000');\n});","lang":"typescript","description":"This quickstart demonstrates how to initialize `express-fingerprint` as middleware, including default and custom parameters, and how to access the generated fingerprint object on the `req` object for every incoming request."},"warnings":[{"fix":"Ensure you are using version `1.2.2` or later. If upgrading, verify your `require` statements are consistent with a default export (`const Fingerprint = require('express-fingerprint')`).","message":"The `require('express-fingerprint')` statement was not working correctly in some versions prior to `1.2.2`, leading to import errors for CommonJS users.","severity":"breaking","affected_versions":"<1.2.2"},{"fix":"Always invoke `next(null, dataObject)` with `dataObject` containing the properties you wish to add to the fingerprint component. Ensure `dataObject` is a plain object.","message":"Custom fingerprint parameters are asynchronous and require a specific callback pattern (`next(null, { key: 'value' })`). Incorrect use can prevent data from being added or halt the middleware chain.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For ESM, use `import Fingerprint from 'express-fingerprint'`. For CommonJS, use `const Fingerprint = require('express-fingerprint')`. Static properties like `Fingerprint.useragent` are accessed directly on the default export.","message":"The library primarily uses a default export. Attempting to destructure it as a named import in ESM (`import { Fingerprint } from 'express-fingerprint'`) or CommonJS (`const { Fingerprint } = require('express-fingerprint')`) will result in `undefined` or a `TypeError`.","severity":"gotcha","affected_versions":">=1.2.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Adjust your import statement to correctly get the default export: `import Fingerprint from 'express-fingerprint'` (ESM) or `const Fingerprint = require('express-fingerprint')` (CommonJS).","cause":"Attempting to use `Fingerprint` as a constructor or function after incorrectly importing it as a named export from a default-exported module.","error":"TypeError: Fingerprint is not a function"},{"fix":"Run `npm install express-fingerprint` to ensure the package is installed. If the error persists, clear your `node_modules` and `package-lock.json` and reinstall dependencies.","cause":"The package is either not installed, or the Node.js runtime cannot locate it due to incorrect path resolution or corrupted `node_modules`.","error":"Error: Cannot find module 'express-fingerprint'"},{"fix":"Ensure `app.use(Fingerprint(...))` is called *before* any routes or other middleware that attempt to access `req.fingerprint`. Verify there are no errors in the middleware's initialization.","cause":"The `express-fingerprint` middleware has not been correctly applied to the Express app, or `req.fingerprint` is being accessed before the middleware has had a chance to execute.","error":"TypeError: Cannot read properties of undefined (reading 'fingerprint')"}],"ecosystem":"npm","meta_description":null}