OpenVision icon indicating copy to clipboard operation
OpenVision copied to clipboard

Store API keys in the Keychain instead of settings.json

Open raphaelbarreiros opened this issue 2 months ago • 1 comments

Follow-up from the #63 review.

API keys and tokens are saved in plain text in Documents/settings.json, together with the other settings. There are 8 of them:

  • openClawAuthToken
  • geminiAPIKey
  • openAIAPIKey
  • grokAPIKey
  • hermesAPIKey
  • tavilyAPIKey
  • telemetryToken
  • telemetryPassword

The subscription sign-ins (ChatGPT, SuperGrok, Hermes web UI) already keep their tokens in the Keychain. The Hermes API key matters most, because it gives access to a terminal on the user's server, but the same reasoning applies to every key.

Proposal:

  • Keep the fields in AppSettings in memory, so views and services don't change. SettingsManager saves them to the Keychain (after first unlock, this device only, like the OAuth tokens) and writes them blank to settings.json.
  • Migration: when settings.json from an older build still has a key, it is moved to the Keychain on launch, and the file is rewritten without it.
  • Never lose a key:
    • If the Keychain can't be read (for example, a launch before the phone's first unlock), the key is never overwritten or deleted.
    • If a Keychain write fails, the key stays in the file.

Live check: Hermes API-key mode

Also from the #63 review: the response shape of /v1/capabilities, which "Test Connection" reads in API-key mode, hasn't been checked against a live server yet. I'll post the result here.

raphaelbarreiros avatar Oct 03 '26 06:10 raphaelbarreiros

Live check result: on the user's own Hermes server, with the API server enabled, Test Connection in API-key mode succeeded ("Connected"). /v1/capabilities returns the shape HermesService.parseCapabilities expects, so no change is needed there.

A UX gap showed up during setup: an address typed without https:// or http:// (e.g. myhost.ts.net) is rejected with "Enter the server address, e.g. https://hermes.example.com." That's correct, but easy to trip on. I can open a small PR that adds the scheme automatically:

  • https:// for host names
  • http:// for loopback, LAN and Tailscale IPs

This would apply to both Hermes address fields.

raphaelbarreiros avatar Oct 03 '26 08:10 raphaelbarreiros