framework
Browser fingerprinting in Express
Add browser fingerprinting and bot, disposable email and IP checks to an Express signup form: the SDK in the page, one check call in the route, and req.ip behind a proxy.
This guide adds OpenFingerprint to a signup form served by Express. The browser runs the SDK, which posts its evidence to the API's public identify listener, and puts the identification ID it gets back in a hidden field; your route sends the identification ID, the email address and the visitor's IP to the check API with your secret key, and decides what to do with the answer. The listener sees the browser connect, and your key never reaches the browser.
1. Install the SDK and add your key
npm install @openfingerprint/sdkCreate a secret key under API keys in the dashboard and put it in the server's environment as OPENFINGERPRINT_KEY, for example in a .env file loaded with node --env-file=.env. Never send it to the browser.
2. Identify in the browser
If your front end has a bundler, import { identify, watch } from '@openfingerprint/sdk'. Without one, the package ships a standalone script that defines OpenFingerprint.identify and OpenFingerprint.watch; serve it from your own origin:
app.use('/vendor/openfingerprint', express.static('node_modules/@openfingerprint/sdk/dist'));Start watching and collecting when the page loads, and fill the hidden fields before the form is sent. Collect only once your disclosure or consent requirements are met.
<form id="signup" method="post" action="/signup">
<input type="email" name="email" required />
<input type="hidden" name="of_identification" />
<button>Sign up</button>
</form>
<script src="/vendor/openfingerprint/index.iife.js"></script>
<script>
const form = document.getElementById('signup');
OpenFingerprint.watch();
const collecting = OpenFingerprint.identify({
endpoint: 'https://events.openfingerprint.com/v1/identify'
});
let ready = false;
form.addEventListener('submit', async (event) => {
if (ready) return;
event.preventDefault();
try {
const { identificationId } = await collecting;
form.elements.of_identification.value = identificationId ?? '';
} catch {}
ready = true;
form.requestSubmit();
});
</script>If posting fails, identificationId is null and the form still submits. The server omits that ID; email and IP checks continue, and browser evidence stays unknown, not suspicious. There is no local-evidence fallback. If your site sets a Content-Security-Policy, allow https://events.openfingerprint.com in connect-src.
3. Check on the server
The route calls POST /v1/check with Node's built-in fetch. The API never reads an IP from the connection: your server passes the address it saw. Behind a load balancer or reverse proxy, set trust proxy to the number of proxies in front of the app, so req.ip is the visitor's address and not a value the browser could have sent.
import express from 'express';
const app = express();
app.set('trust proxy', 1); // one proxy in front of the app
app.use(express.urlencoded({ extended: false }));
async function check(input) {
try {
const response = await fetch('https://api.openfingerprint.com/v1/check', {
method: 'POST',
headers: {
'content-type': 'application/json',
'x-api-key': process.env.OPENFINGERPRINT_KEY
},
body: JSON.stringify(input),
signal: AbortSignal.timeout(5000)
});
return response.ok ? await response.json() : {};
} catch {
return {};
}
}
app.post('/signup', async (req, res) => {
const { email, of_identification: identificationId } = req.body;
const result = await check({ identificationId: identificationId || null, email, ip: req.ip });
if (result.disposable) {
return res.status(400).send('Please use a permanent email address.');
}
const verifyFirst = result.automation || result.spoofing || result.replayed || result.tor;
// create the account, store result.visitorId on it only when present, and ask for
// email verification before any free credits when verifyFirst is true
res.redirect('/welcome');
});A failed or slow check returns {}, so signups keep working when the API can't be reached.
4. Decide
The response is flat: a key is present only when it is known, so a missing disposable means unknown, never "clean".
disposableis strong evidence: ask for another address.automation,spoofing(the browser's report contradicts its headers or TLS handshake, as when a script poses as a browser),replayed(the same identification looked up twice) andtorare reasons to ask for more proof, such as email verification or a challenge, not to block.behaviorlists input patterns sincewatch(), such asclicks_without_movement. Keyboard users, autofill and password managers match some of them, so treat them as context for your own rules.visitorIdis a random server-issued browser grouping, not a fingerprint hash. Store it only when present and count recent accounts with the same ID. It can split repeat visits or merge indistinguishable browsers; missing IDs stay unknown.identificationIdreferences one hour-long observation and is not the value to store on accounts.
The free trial abuse guide has an example policy, and the check API reference lists every key.
Self-hosting
The SDK and the check API are MIT licensed. To run the API yourself, follow Deploy with Helm, replace the URL with your own service, drop the x-api-key header, and point endpoint at your own mandatory public identify listener. Configure identify.origins and identify.certificates, and use TCP passthrough so it sees the browser's TLS handshake. The internal check API has no authentication, so keep it on a private network. To receive visitor IDs, configure PostgreSQL, apply the visitor migrations and keep the deployment namespace stable. A single-customer install can set postgres.visitorScope; shared hosts should require backend-derived customer scopes. See visitor IDs and scopes.