Files
CatoandClaude Opus 5.5 4fd7cf0195 fix(settings): API keys are sealed at rest and checked before they are saved (#208)
* fix(settings): API keys are sealed at rest and checked before they are saved

Readers' Groq/OpenRouter keys sat in user_settings as plaintext, and GET
/api/settings returned the whole row — keys included — to the browser.

- Keys are sealed with @bitbaum/ai-kit/seal (BYOK_SEAL_SECRET); GET returns
  only a hint (…abcd). Without the secret nothing new is stored (503).
- Legacy plaintext rows keep working and are sealed in place on first read.
- Save checks a new key with probeByokKey first; a key the provider refuses is
  never stored, and the reason is the provider's own words.
- An empty key field keeps the saved key (removing is explicit); the old PUT
  wrote key || null, which would have wiped keys once they stopped being sent.
- The key check now runs on its own after pasting, and actually passes:
  both pages read the jsonSuccess payload at the top level, so settings never
  loaded and every key — good or bad — was reported invalid.
- OpenRouter is checked on /key: its /models is public and 200s a dead key.

ai-kit ^1.18.0.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(settings): type the seal-secret lookup for plain env objects

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 12:35:30 -07:00
..