Latest: Fix test regex after rename by Moontrace, 39 min ago
| 📁 demo | |
| 📁 src | |
| 📁 test | |
| 📄 .gitignore | 13 B |
| 📄 LICENSE | 1.2 KB |
| 📄 package.json | 199 B |
| 📄 README.md | 3.6 KB |
BioLock
BioLock: sign in with your own fingerprint or face. That is the only way: no passwords, no security keys, no QR codes, no phone-to-computer sign-in. A Moontrace project, public domain (Unlicense).
Live: https://biolock.dev · Demo: https://biolock.dev/demo/
How it works
- Enroll a device. On a device you are signed in to, make a one-time "Add a device" link
(10 minutes, single use). Open it on the new device and touch your fingerprint. - A key sealed inside. The device makes its own key, locked behind its reader. The website keeps
only the public key. - Touch to sign in. The website allows only this device's own built-in reader, so the browser goes
straight to the fingerprint or face. Nothing else is offered. - Lose one, remove it from any other enrolled device.
The server refuses anything that is not a built-in reader: USB, NFC and Bluetooth keys, and QR phone-to-computer sign-in.
Under the hood: browsers let a website reach the device's reader through one open standard, W3C Web Authentication. We use only its built-in reader part and switch the rest off. No new cryptography: Ed25519, P-256 and RSA signatures only.
Files
src/server.js: enroll and sign-in options, every check, add-a-device links. Runs anywhere with
Web Crypto (Cloudflare Workers, Deno, Bun, Node 20+, browsers). No dependencies.src/client.js:hasBuiltInReader(),enrollThisDevice(),signIn(),removedOnServer(),enrolledOnThisDevice().demo/: the working demo at biolock.dev/demo.test/server.test.js: software devices (P-256 and Ed25519) enroll and sign in; the checks refuse a
wrong site, a reused challenge, a missing biometric, a bad signature, a cloned key, security keys and QR.
Add it to a site in five steps
// server
import { registrationOptions, verifyRegistration, signInOptions, verifySignIn,
makeDeviceInvite, readDeviceInvite } from './server.js';
// 1. On a signed-in device: make a one-time link and send it to yourself.
const token = await makeDeviceInvite({ secret: env.INVITE_SECRET, accountId });
// https://example.com/add-device#<token> (store the nonce once used, refuse it again)
// 2. On the new device: read the link, send enroll options (keep options.challenge).
const { accountId } = await readDeviceInvite({ secret: env.INVITE_SECRET, token });
const options = registrationOptions({ rpId: 'example.com', rpName: 'Example', userId, userName });
// 3. Check it and store the record for the account.
const record = await verifyRegistration({ credential, expectedChallenge, expectedOrigin: 'https://example.com', rpId: 'example.com' });
// 4. Sign in: the browser sends the IDs it enrolled (client enrolledOnThisDevice()).
const opts = signInOptions({ rpId: 'example.com', deviceCredentialIds });
// 5. Check it and save the new counter.
const { counter } = await verifySignIn({ credential, stored: record, expectedChallenge, expectedOrigin: 'https://example.com', rpId: 'example.com' });
// browser
import { hasBuiltInReader, enrollThisDevice, signIn, enrolledOnThisDevice } from './client.js';
const enrolled = await enrollThisDevice(optionsFromServer); // touch fingerprint
const login = await signIn(signInOptionsFromServer); // straight to fingerprint
Honest limits
- A device with no fingerprint or face reader cannot sign in, by design.
- The browser draws the final prompt. Some older browsers may still show extra choices; the server
refuses anything that is not the built-in reader. - Keep at least two enrolled devices. There is no password fallback.
Test
node --test test/*.test.js
Public domain. See LICENSE.