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.
npm install express-fingerprintVerified import paths — ran on the pinned version, not inferred.
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.
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')`).Always invoke `next(null, dataObject)` with `dataObject` containing the properties you wish to add to the fingerprint component. Ensure `dataObject` is a plain object.
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.Adjust your import statement to correctly get the default export: `import Fingerprint from 'express-fingerprint'` (ESM) or `const Fingerprint = require('express-fingerprint')` (CommonJS).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.
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.