feat(mosaic): gateway token recovery via BetterAuth cookie #411
Reference in New Issue
Block a user
Delete Branch "feat/gateway-token-recovery"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Mission: cli-unification-20260404. Tasks: CU-03-03, CU-03-04, CU-03-05, CU-03-06, CU-03-07. Design doc: PR 401.
Commands added:
mosaic gateway login - Thin wrapper with gateway URL defaulting from meta.json, falling back to localhost:14242. Email and password prompted if not supplied as flags.
mosaic gateway config rotate-token - Requires a stored valid BetterAuth session. Calls POST /api/admin/tokens with the session cookie and writes the returned plaintext to meta.json.
mosaic gateway config recover-token - Stranded-operator entry point. If no valid session exists, prompts for email and password inline, signs in, saves the session, then mints and persists a new admin token.
Installer fix - bootstrapFirstUser in install.ts now offers inline token recovery when admin user exists but no token is on file. In TTY mode it prompts; non-interactive prints the recover-token hint.
New files: login.ts, token-ops.ts, login.spec.ts (5 tests), rotate-token.spec.ts (10 tests), recover-token.spec.ts (7 tests).
All gates green: 100 tests pass, typecheck clean, lint clean, format clean.