A device fingerprint is a similarity score, not an ID
Most device fingerprinting ends in one string. Hash everything the browser exposes, call the result a device ID, and look it up later. The trouble is that phones are built in batches. Two units of the same model, on the same OS version, with the same language and time zone, give the same string. The ID says one device. There are two people.
I published a small npm library that starts from that problem: r-detect (External website). It doesn't return an ID. It compares two readings and returns a score from 0 to 100, with a list of where every point came from.
How often devices are twins
The default weights come from a field deployment of 1,217 browsers over one week, 91% of them on Android. In that data, 34% of browsers had at least one other browser that was identical on every part the library reads (scoring notes (External website)).
One in three is too many to ignore. If a matching fingerprint blocks a signup or flags an account, a third of your users can be mistaken for a stranger who bought the same phone.
So the first design rule is a ceiling. Device evidence alone can't reach the top band, however much of it agrees.
Ten parts, each with its own weight
collect() reads what a page can see without a permission prompt and hashes it into ten parts: the pixels of a fixed WebGL scene, WebGL limits, physical screen size, device model, OS version, GPU model, dark mode, time zone and locale format, installed fonts, and a few audio and display values (signal reference (External website)). Each part is one SHA-256 digest. A part the browser doesn't expose is left out.
The parts are not worth the same. Each weight is a log-likelihood ratio: how often the part stays equal on the same device, against how often two different devices share it by chance. Two different browsers shared a model in under 1% of pairs, so it carries 19 points. They shared the font result in 66% of pairs, so fonts carries 2. The ten weights add up to 72.
That total is the ceiling. The strong band starts at 80.
What gets a pair past 72
Two things can add points on top of the device parts. The same network adds 20. A battery level within 2 points of charge, read at most 15 minutes apart, adds 8.
import { compare } from 'r-detect/score';
const alone = compare(a.parts, b.parts);
// all ten parts equal: score 72, band 'similar'
const sameNet = compare(a.parts, b.parts, { context: { sameNetwork: true } });
// all ten parts equal, same network: score 92, band 'strong'The band names are chosen to be read literally. similar means the two readings can't be told apart, which could be one device or two units of one model. strong means the parts agree and something outside the device backs them up.
Every result also carries reasons, a list of { code, points } lines that always sums to the score. A pair that agrees on everything except the GPU image, on the same network, scores 74, and the list shows a mismatch.gpuPixels line worth minus 10 next to the matches. When someone asks why an account was flagged, there's an answer to read, not a hash to shrug at.
A mismatch on a stable part subtracts points but never vetoes the pair. In the field data the GPU image, the screen and the model never differed for the same browser across 481 pairs. I still wouldn't make them a veto. A driver update or a second monitor would turn into a certain miss.
The network is weak evidence too
Sharing a network means little in an office or behind a mobile carrier's gateway. bestMatch() counts how many candidates sit on the current reading's network. Above three, it stops counting the network for all of them and reports that it did.
The network itself is never stored as an address. sealReading() reduces the client address to its IPv4 /24 or IPv6 /48 and keeps only a keyed digest of that. That digest is still personal data. With the key, every IPv4 /24 can be tried quickly.
Seal before you store
The digests a browser sends are plain SHA-256 of values with few possible outcomes. Anyone who sees a reading can recover most of them by hashing the possibilities: the dark-mode setting, the OS version, the screen size. The same device also produces the same digests on every site that uses the library (privacy notes (External website)).
So the server entry re-hashes every part with HMAC-SHA256 under your own key, and you store only the sealed form. Sealing doesn't make the data anonymous. Equal devices still give equal sealed digests, and the key protects nothing if it leaks with the data. Discard the unsealed reading and keep request bodies out of your logs.
import { parseReading, sealReading, bestMatch } from 'r-detect/server';
const reading = parseReading(body); // null when the input is invalid
const sealed = await sealReading(reading, { key, ip: clientAddress, keyId: 'k1' });
const { best } = bestMatch(sealed, earlierSealedReadings);
// best.result: { score, band, coverage, reasons, ... }The library makes no network request and writes no storage. It has no runtime dependencies. Sending the reading and keeping it are your code.
What it can't do
This is browser fingerprinting, and it should be called that. In some jurisdictions it needs disclosure and may need consent. Working out what applies, and telling users, is the job of whoever deploys it. This is not legal advice.
A reading comes from the client, so it can be forged, copied or replayed. The battery level is client-supplied as well. Where clients may be hostile, I'd set weights.battery to 0. A match should never be a login factor, a reason to skip a verification step, or the only ground for something you can't undo.
The evidence is narrow. The weights were measured on a mostly Android population and may not suit a desktop or iOS audience. Stability was measured up to 29 hours, nothing longer. model is absent on iOS and Firefox. The package's collector produced the same digests as the field collector on desktop browser builds, but no phone has run this package yet. All of this is written in the README, with a method for learning weights from your own labelled pairs.
npm install r-detectThe package is on npm (External website) as ESM with types, and the server entry needs Node 20 or later.
If you already store a fingerprint ID, there's one number worth knowing: how many of your users share theirs with someone else. If you've never counted, the ID is answering a question it can't answer.