When a desktop app calls a hosted model, ask who owns the billable credential before deciding where the request should originate. A user’s own credential and an operator’s shared credential belong to different trust boundaries. Moving both into a helper process on the user’s machine does not solve the same problem.
Case 1: the operator pays for every call
Keep the provider credential in a service controlled by the operator. The client authenticates the user to that service. The service checks whether the specific request is allowed, applies per-user limits, and calls the provider. The distributable application should never need the operator’s key. A native application installed on a device outside the operator’s control cannot reliably keep one shared static secret confidential from the device owner. RFC 8252 discusses the corresponding public-client limitation for native OAuth applications. RFC 8252, section 8.5
Case 2: the user supplies their own key
Use the operating system’s credential store where supported. A per-user helper can keep the value out of the frontend bundle, preferences, browser scripts, routine logs, and crash reports. Restrict its interface to the operations the UI actually needs and authenticate local callers using the platform’s supported mechanisms. Loopback binding alone grants no identity. A helper on a compromised device cannot promise that no other local software or device administrator can obtain or misuse the key.
Test the boundaries independently
- Package a build using a synthetic marker instead of any real credential. Check the distributable, source maps, sample configuration, crash fixtures and debug output for that marker.
- With a stub upstream, verify an unauthorized caller causes no forwarded request. Count calls at the stub independently of the local response status.
- End an authorized session and start another. The old session should lose authority according to the documented policy; the new session should use its own authorization state.
- Disconnect the network. Local editing or search should have its documented offline behavior. Hosted inference should report its network dependency without silently rerouting sensitive input.
- Inspect the settings screen and verify it names the provider and explains which selected content leaves the device. Credential storage and prompt confidentiality are separate decisions.
Choose a local helper for a concrete purpose such as isolating a user-owned credential from renderer code. Choose a server-side credential boundary when the operator must retain exclusive custody of a shared provider key.
This article was created with AI assistance.
Top comments (0)