Identify each CLI install to HEY with its own install_id
Why
Every hey-cli install sent the constant install_id=hey-cli on login and refresh, so HEY treated every CLI sign-in, on any machine, as one already-known device and never sent a new-device alert for it. This is the CLI half of the HEY OAuth blast-radius work (Security Hardening card 10248716553, H1 #3945131); the server half binds each refresh-token lineage to the install that presents it and stops accepting the placeholder for new sign-ins.
What
- Mint a random v4 UUID per install on first use and keep it at
<config dir>/install_id(0600). It lives beside the credentials, not inside them: a device outlives a logout, and re-logging in from the same machine should not look like a new device. - Send it as
install_idon the authorization request, the code exchange, and every refresh. The refresh path reads it under the store lock it already holds, sohey tuiandhey watchpresent the same id. - The id is minted before the request goes out, never after success, so a lost response can't leave two ids racing for the same lineage.
hey auth statusshows it (Install:/install_id) for support.
Rollout
No migration step. Existing installs mint an id on their next run; their next refresh presents it and the server rebinds the existing grant to it (quietly โ the server treats the placeholder-to-real transition as the same device). An old binary left running (hey watch) keeps sending the placeholder, which the server accepts as a no-op.
Tests
- Id is a v4 UUID, minted once, shared by every store on the same directory, file mode 0600.
- Survives
Logout. - Differs between installs.
- Login sends the same id on the auth URL and the token exchange; the two-process refresh test asserts a per-install id, not the placeholder.
go test ./internal/...,go vet,golangci-lintclean.
Summary by cubic
Sends a unique per-install identifier to HEY on login and refresh so HEY can treat each CLI install as a distinct device and send new-device alerts. Previously every install sent the constant hey-cli.
- Mints a random v4 UUID per install and stores it in
<config dir>/install_idwith mode 0600. - Sends the ID on login, token exchange, and refresh; refresh reads it under the existing store lock.
- Writes the ID atomically and validates it on read, reminting a truncated or garbage file rather than sending it.
- The ID survives logout, so re-login from the same machine uses the same ID.
hey auth statussurfaces the ID in every status path, in JSON and styled output.- No migration needed: existing installs mint an ID on next run, and the server binds the grant to it.