Devices: tell same-machine rows apart by origin and key fingerprint - #85
Merged
Conversation
A browser's device key lives in IndexedDB, which the browser scopes to the origin, so the same browser reaching the same daemon from 127.0.0.1, localhost and the vite dev server enrols as three devices — and their rows all read "Browser on <host>" with nothing but dates to tell them apart. Record the Origin header of the enrolment POST on the local registry row and show it on the Devices row, beside a short fingerprint of the device id. First seen wins; older rows are backfilled on their next load (the browser enrols on every load); the origin stays out of the certificate, because it is a fact about how this machine was reached rather than about the device; and a row with no origin — paired by QR, admitted on a fleet cert — renders as ordinary. Closes #71 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #71.
What
A Devices screen could list four rows all reading
Browser on karn.local, with nothing but a paired-at and a last-seen date to tell them apart. This is the trust model working as designed — the device key is scoped to the browser origin — so the fix is to surface the fact that differs, not to change enrolment:Originheader of the enrolment POST on the local registry row (crypto.Device.Origin), carries it on the wire (wire.DeviceInfo.Origin,omitempty), and the Devices row shows it as a place —127.0.0.1:7719,localhost:7719— with the scheme dropped.Decisions on the issue's open points
DeviceStore.SetOriginwrites once and refuses overwrites, so a tab that later loads from the daemon's other spelling does not rewrite where it enrolled. One value is enough because enrolment is the only moment an origin is known.Worth knowing: the vite dev server's proxy rewrites
Originto the daemon's own (web/vite.config.ts), so the vite tab records127.0.0.1:7719— same as the direct tab. Those two remain distinguishable only by fingerprint, which is part of why the fingerprint ships alongside the origin.Not in this PR
The issue's secondary suggestions — connected-right-now and a truer last-seen. Loopback sockets carry no device identity (the session cookie is the credential, and
wire.Hellonames no device), so "connected now" cannot be answered for exactly the rows this issue is about without a protocol change, and it needs its own broadcast machinery. Better as a follow-up.Tests
TestSetOriginKeepsTheFirstOrigin(store semantics),TestEnrolRecordsWhereTheBrowserCameFrom(record, wire carry, no-overwrite, backfill).go test ./...,pnpm vitest run(1465 tests, includes the Tailwind prose-scanner build guard), andpnpm run lintall pass.🤖 Generated with Claude Code