logicsrc/apps/pwa/src/migrations
Anthony Ettinger 41ad9f0987
vault: opt-in paid email recovery for the personal vault ($5 lifetime) (#298)
* vault: opt-in paid email recovery for the personal vault ($5 lifetime)

A second way back into a logicsrc personal vault when the master password and
the offline recovery key are both gone, without the server holding anything
that alone (even with the DB and server env) opens the vault.

Client (packages/opencreds): random escrow key E encrypts the user key K
(AES-256-GCM, AAD "<ns>:vault:email-escrow:v1|<createdAt>"); E is split into
S (random, to the server) and U = E XOR S (emailed once as a checksummed
Crockford recovery code, never stored). `recover --email` checks the code's
check group first, asks the server for a one-time code, claims S, recombines
E, proves K against an item, sets a new password, issues a new offline
recovery key and re-enrolls with fresh shares (warns loudly if that fails).
New `recovery status|buy|enable|disable` commands; the CLI client lives in
packages/cli/src/vault-sync.ts.

Server (apps/pwa): /api/opencreds/recovery/{checkout,enroll,start,claim} +
status/disable. S is sealed under VAULT_ESCROW_KEY (versioned for rotation,
AAD binds the user). Enrollment is pending until the email with U is sent,
else rolled back. One-time codes: 8 digits, HMAC at rest, 15 min, 5 tries,
single use, 3 starts/hour; claims are audited and announced by email.
Purchase via CoinPay checkout (purpose vault_recovery); /api/coinpay/webhook
now verifies once and dispatches by purpose, auto_rotation unchanged.
Settings card with status and a Buy button. Migration 014 in both dialects.

Docs: security.md and crypto.md "Email recovery (opt-in, paid)" sections with
the honest trade-off; cli.md command reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* vault email recovery: state that the mailbox alone is enough

The account password resets by email, so mailbox control = sign-in + one-time
code + the enrollment code U. Say so in security.md and stop the one-time-code
email from implying the vault stays safe if someone else reads the mailbox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* vault email recovery: leave .env.example as on master

Touching it made the credential gate re-scan the existing SESSION_SECRET
placeholder (false positive). VAULT_ESCROW_KEY / _VERSION / VAULT_RECOVERY_PRICE_USD
are documented in docs/opencreds/security.md and crypto.md; prod values live in
vault app-logicsrc-com--prod.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 07:49:06 -08:00
..
001_auth.sql feat(pwa): logicsrc credentials app — real auth + Turso, redesigned; retire commandboard-api credshare 2026-07-13 14:29:29 +00:00
002_credshare.sql feat(pwa): logicsrc credentials app — real auth + Turso, redesigned; retire commandboard-api credshare 2026-07-13 14:29:29 +00:00
003_cli_device_codes.sql fix(cli): point logicsrc login at the real app + add device-code login 2026-07-28 18:07:49 +00:00
004_opencreds_sync.sql vault: autosync the personal vault to the logicsrc account (#226) 2026-10-04 03:45:25 -07:00
005_machine_keys.sql Machine API keys: headless teams pull for deploy boxes and CI (#230) 2026-10-05 23:08:32 -07:00
006_user_profiles.sql feat(pwa): signup profile fields via @profullstack/profile (#256) 2026-10-26 04:24:44 -07:00
007_hardening.sql security: harden credentials app after the 2026-10-27 dev2 incident (CLI 0.10.0) 2026-10-28 16:04:22 +00:00
007_password_resets.sql feat(auth): add password reset and recovery flow 2026-10-29 13:21:27 +00:00
008_keyring.sql feat(keyring): end-to-end encrypted keyring for SSH keys and key pairs, optional cloud sync (CLI 0.12.0) 2026-10-28 18:45:46 +00:00
008_recovery_tokens.sql feat(auth): add password reset and recovery flow 2026-10-29 13:21:27 +00:00
009_keyring_shares.sql feat(keyring): revocable share link for SSH public keys (#267) 2026-10-29 01:57:47 +00:00
010_rotation_runs.sql fix(pwa): migration 010 boot failure on Postgres: no inline SQL comments (#271) 2026-10-29 04:41:42 +00:00
011_rotation_policy.sql feat(rotation): 90-day policy, due runs wait for owner approval (CLI 0.16.0) (#270) 2026-10-29 04:36:26 +00:00
012_auto_rotation_billing.sql feat(rotation): buy automatic rotation, $29 per team per 30 days (CoinPay) (#272) 2026-10-29 05:12:01 +00:00
013_app_grants.sql App grants: one secret sealed to an external app (key hub phase 1) (#286) 2026-11-11 05:16:37 -08:00
014_vault_email_recovery.sql vault: opt-in paid email recovery for the personal vault ($5 lifetime) (#298) 2026-11-30 07:49:06 -08:00