auth/bootstrap_account.ts view source
(deps: BootstrapAccountDeps, provided_token: string, input: BootstrapAccountInput): Promise<BootstrapAccountResult> Bootstrap the first account with keeper and admin privileges.
Uses an atomic bootstrap_lock UPDATE to prevent concurrent bootstrap
attempts (TOCTOU). The full flow runs in a single transaction:
1. Read and verify the bootstrap token (before transaction)
2. Hash the password (CPU-intensive, before transaction)
3. Acquire the bootstrap lock atomically (inside transaction)
4. Create account + actor
5. Grant keeper and admin permits (no expiry, granted_by = null)
6. Delete the token file (after commit, reported via token_file_deleted)
deps
database, token path, filesystem callbacks, and password hashing
provided_token
the bootstrap token from the user
stringinput
username and password
returns
Promise<BootstrapAccountResult> the created account, actor, and permits — or a bootstrap failure