# 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://moontrace.ai/biolock/ ยท Demo: https://moontrace.ai/biolock/demo/ ## How it works 1. **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. 2. **A key sealed inside.** The device makes its own key, locked behind its reader. The website keeps only the public key. 3. **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. 4. **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 on moontrace.ai. - `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 ```js // 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# (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' }); ``` ```js // 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 ```sh node --test test/*.test.js ``` Public domain. See LICENSE.