Skip to content

feat: account/info for reading your own account - #42

Merged
leviFrosty merged 1 commit into
mainfrom
feat/account-info
Oct 15, 2026
Merged

leviFrosty merged 1 commit into
mainfrom
feat/account-info

Conversation

@leviFrosty

Copy link
Copy Markdown
Owner

Adds POST /accounts/v1/account/info so the app's developer Tools screen can show what D1 holds for the device's own account. This makes it possible to debug accounts in prod without the admin token.

What it returns

accountId, accountPub, status, createdAt, inboxIds, and statusChanges (each with status and createdAt).

Why it's safe

  • Self-signed: it uses the same {p, s} envelope as account/register, under the ww-account/v1 context with op account/info. Only the holder of the account key can read the account, and a register signature can't be replayed as an info request (there's a test for this).
  • Read-only: it never creates an account. An unregistered key gets 404 unknown_account.
  • No moderation details: status changes leave out their reason, which stays visible only through /admin/accounts/lookup.
  • Rate limited: it counts against the Buddies read edge tier (600/min per caller). Nothing logs the body, the key, or the id.

Changes

  • contracts.ts: adds the account/info op. parseAccountRegister becomes parseAccountKeyPayload, since both ops share the payload.
  • route.ts: envelope, signature and timestamp checks move into a shared verifiedKeyPayload.
  • store.ts: adds findAccountInfo.
  • openapi.ts: documents the new route, sharing the signed-body schema and the signature errors with register.
  • New unit tests and src/e2e/accounts.e2e.test.ts. AGENTS.md documents the route.

Verification

  • pnpm test: 735 passed. tsc --noEmit: clean.
  • verify-ww-api: up, doctor ok. pnpm test:e2e: 42 passed, 3 skipped (HERE/paid paths with no credentials). All 4 new accounts e2e cases ran, including the admin-suspension case. Then down.
  • /openapi.json on the local worker lists /accounts/v1/account/info.

Deploy

No migration and no new binding. After merging, pnpm run deploy:dev lets the app PR be tested against dev.

@leviFrosty

Copy link
Copy Markdown
Owner Author

App side: leviFrosty/witness-work#770 (Tools → Server account).

@leviFrosty
leviFrosty merged commit de54b83 into main Oct 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant