hermes-agent/apps/desktop/electron
Ben 9d07927a23 desktop: OAuth-aware remote gateway connection
The desktop remote-gateway settings now auto-detect whether a gateway
authenticates with OAuth or a static session token and present the
matching UI + connection mechanism.

Detection: an unauthenticated GET {base}/api/status reads auth_required
(true => OAuth, false => session token); /api/auth/providers supplies the
provider label. The settings UI debounce-probes the entered URL and shows
either a 'Sign in with <provider>' button or the session-token box.

OAuth connection mechanism:
- REST is authed by the HttpOnly session cookie held in a persistent
  Electron session partition (persist:hermes-remote-oauth); main-process
  REST routes through electron net bound to that partition so the cookie
  attaches automatically.
- Login opens a BrowserWindow on {base}/login in that partition and
  resolves once the hermes_session_at cookie lands.
- WebSocket upgrades use a single-use ?ticket= minted at
  POST /api/auth/ws-ticket (the gateway rejects ?token= in gated mode);
  getGatewayWsUrl() re-mints before every (re)connect since tickets are
  single-use and short-lived.
- Missing cookie / 401 surfaces needsOauthLogin to prompt re-sign-in
  (Nous Portal contract v1 issues no refresh token).

Local and token modes are unchanged.

Pure helpers (URL normalize, ws-url token/ticket builders, auth-mode
classify/resolve, cookie detector) are extracted to a standalone
connection-config.cjs (no electron import) and unit-tested with
node --test (26 tests), matching the backend-probes.cjs pattern.
2026-06-04 01:11:34 -07:00
..
backend-probes.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
backend-probes.test.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
bootstrap-platform.cjs fix(desktop): don't treat WSLg as a remote display 2026-06-03 00:42:05 -05:00
bootstrap-platform.test.cjs fix(desktop): don't treat WSLg as a remote display 2026-06-03 00:42:05 -05:00
bootstrap-runner.cjs fix(installer): stop mislabeling stdout-style progress as stderr 2026-06-03 10:38:34 -05:00
bootstrap-runner.test.cjs feat(desktop): cancellable first-launch install 2026-06-02 08:50:45 -05:00
connection-config.cjs desktop: OAuth-aware remote gateway connection 2026-06-04 01:11:34 -07:00
connection-config.test.cjs desktop: OAuth-aware remote gateway connection 2026-06-04 01:11:34 -07:00
entitlements.mac.inherit.plist fix(desktop): inherit microphone entitlement for macOS helpers 2026-06-03 07:32:00 +07:00
entitlements.mac.plist Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
hardening.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
hardening.test.cjs Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
main.cjs desktop: OAuth-aware remote gateway connection 2026-06-04 01:11:34 -07:00
preload.cjs desktop: OAuth-aware remote gateway connection 2026-06-04 01:11:34 -07:00