Skillfarm / website · skillfarm.ai / migrations / 0019_biolock.sql
| 1 | -- BioLock sign-in: each device's own fingerprint or face reader. No passwords and no outside sign-in providers. |
| 2 | -- oauth_accounts is kept as it is, so data keyed to older accounts (such as verified repo owners) stays linked. |
| 3 | |
| 4 | CREATE TABLE biolock_credentials ( |
| 5 | id TEXT PRIMARY KEY, -- credential id (base64url) |
| 6 | user_id TEXT NOT NULL REFERENCES users(id), |
| 7 | alg INTEGER NOT NULL, |
| 8 | public_jwk TEXT NOT NULL, -- public key as JSON; the private key never leaves the device |
| 9 | counter INTEGER NOT NULL DEFAULT 0, |
| 10 | name TEXT NOT NULL DEFAULT '', |
| 11 | created_at INTEGER NOT NULL, |
| 12 | last_used_at INTEGER |
| 13 | ); |
| 14 | CREATE INDEX biolock_credentials_user ON biolock_credentials (user_id); |
| 15 | |
| 16 | -- Single-use challenges, five minutes each. |
| 17 | CREATE TABLE biolock_challenges ( |
| 18 | id TEXT PRIMARY KEY, |
| 19 | challenge TEXT NOT NULL, |
| 20 | kind TEXT NOT NULL, -- signin | new | add | link |
| 21 | user_id TEXT, -- for new: the id the account will get; for add and link: the account |
| 22 | link_hash TEXT, |
| 23 | expires_at INTEGER NOT NULL |
| 24 | ); |
| 25 | |
| 26 | -- One-time links that add BioLock on another device. Only a SHA-256 hash of the link code is stored. |
| 27 | CREATE TABLE biolock_links ( |
| 28 | token_hash TEXT PRIMARY KEY, |
| 29 | user_id TEXT NOT NULL REFERENCES users(id), |
| 30 | expires_at INTEGER NOT NULL, |
| 31 | created_at INTEGER NOT NULL |
| 32 | ); |