logicsrc/apps/pwa
Anthony Ettinger 6ff3089088
feat(recovery): assisted recovery, no old email: one-time code + passkey or CoinPay (CLI 0.18.0) (#305)
Email recovery needs the recovery code from the enrollment email. People who
delete their mail lose it, and with it the only way back in.

`logicsrc vault recovery enable --assisted` (opt-in) replaces that code with a
fresh sign-in: recovery asks for the one-time code emailed at that moment and a
confirmation in the browser with a passkey of the account or its connected
CoinPay identity (bound by subject, never by email, never creating an account,
no session made).

- Server: U is kept sealed under VAULT_ESCROW_KEY in vault_recovery_assisted
  (migration 015) only for accounts that ask. A step-up
  (vault_recovery_stepups) is single use, lives ten minutes, names no account
  and is approved only by a proof belonging to the account being recovered.
  The second proof is checked before the one-time code, so a missing
  confirmation never spends it. A claim without a confirmed step-up never
  returns U. disable and a plain re-enroll delete the stored U.
- CLI: `passwd --email` and `vault recover --email` print the link, wait for
  the confirmation, then ask for the one-time code. The re-arm keeps the mode.
- This mode is custodial: the server holds everything that opens the vault.
  docs/opencreds/security.md says so; accounts that do not opt in keep the
  split-key scheme unchanged.

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-02 22:17:56 -08:00
..
public feat(recovery): assisted recovery, no old email: one-time code + passkey or CoinPay (CLI 0.18.0) (#305) 2026-12-02 22:17:56 -08:00
src feat(recovery): assisted recovery, no old email: one-time code + passkey or CoinPay (CLI 0.18.0) (#305) 2026-12-02 22:17:56 -08:00
test feat(recovery): assisted recovery, no old email: one-time code + passkey or CoinPay (CLI 0.18.0) (#305) 2026-12-02 22:17:56 -08:00
.env.example feat(pwa): logicsrc credentials app — real auth + Turso, redesigned; retire commandboard-api credshare 2026-07-13 14:29:29 +00:00
.gitignore feat(pwa): logicsrc credentials app — real auth + Turso, redesigned; retire commandboard-api credshare 2026-07-13 14:29:29 +00:00
package.json App grants: one secret sealed to an external app (key hub phase 1) (#286) 2026-11-11 05:16:37 -08:00
Procfile feat(pwa): logicsrc credentials app — real auth + Turso, redesigned; retire commandboard-api credshare 2026-07-13 14:29:29 +00:00
railway.json feat(pwa): logicsrc credentials app — real auth + Turso, redesigned; retire commandboard-api credshare 2026-07-13 14:29:29 +00:00
README.md Machine API keys: headless teams pull for deploy boxes and CI (#230) 2026-10-05 23:08:32 -07:00

@logicsrc/pwa — LogicSRC credentials

Express app on Postgres for team credential sharing: auth (email/password, passkeys, CoinPay OAuth, sessions, lsk_ CLI API keys) + end-to-end-encrypted team vaults. Zero-knowledge — the server only stores ciphertext, per-member sealed vault keys, and identity public keys. Decryption happens in the logicsrc CLI.

cp .env.example .env      # set SESSION_SECRET; DATABASE_URL=postgres://… for prod (else a local libSQL file db)
npm install
npm start                 # migrates on boot, serves on :8080

Database

Production runs on Postgres: DATABASE_URL must be a postgres:// URL and the app refuses to start on anything else there (a leftover libsql:// value is called out by name). The client is @profullstack/libsql-pg, which keeps the @libsql/client surface the code was written against and rewrites the remaining SQLite idioms per statement. Development and the tests use libSQL itself (file:./data/local.db by default, :memory: in tests).

Migrations run at boot and live in two dialect copies with the same file names: src/migrations/ (SQLite) and src/migrations-pg/ (Postgres, generated with npx libsql-pg convert-schema and reviewed). npm run migrate applies the copy matching DATABASE_URL. To move an existing Turso database:

DATABASE_URL=postgres://… npm run migrate                                   # schema
npx libsql-pg copy --from "$TURSO_DATABASE_URL" --token "$TURSO_AUTH_TOKEN" \
  --to "$DATABASE_URL" --verify                                             # rows

Set PWA_TEST_DATABASE_URL=postgres://… to run the test suite against a real Postgres (it drops and recreates the public schema of that database).

The CLI connects with LOGICSRC_API=<origin> logicsrc login (browser OAuth-PKCE loopback → an lsk_ key). See docs/credential-sharing.md in the repo root.

Deploy boxes and CI use a machine key instead (logicsrc keys create, or Settings ▸ API keys): one team, optional vault list, read-only by default, optional expiry, and its own identity public key on the api_keys row. Vault keys reach it through credshare_key_grants. Routes: GET|POST /api/keys, DELETE /api/keys/:id (session or a person's key only) and GET|POST /api/credshare/vaults/:id/key-grants, DELETE /api/credshare/vaults/:id/key-grants/:keyId. Migration 005_machine_keys.sql; tests in test/machine-keys.test.mjs.