Repository navigation
feat(relay): show both key IDs when a relay key does not match its PC id - #2703
Conversation
A pairing link or a saved pairing whose relay key is not the one its PC's id names was refused with a sentence only. The phone now shows the PC's ID (a SHA-256 of its real key, the server_id) and the ID the other key would have, in groups of four, the groups that differ marked by weight, underline and colour and named for a screen reader. The PC shows its own ID under its pairing QR code, so a person can tell which one is the PC's. Both IDs are derived on the device from what it already holds; nothing new is sent to the relay or the PC.
Codex review: on a forged link the id shown as "This PC's ID" was the link's own server_id, which the link chooses; and when a saved key was the bad one, it was labelled as the link's. The phone now labels the ids as the one the link names or this phone paired with, and the key's as the link's or the saved pairing's. Only the PC's own screen calls an id the PC's.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 42 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
Codex (gpt-6.1-terra, xhigh) reviewed this branch in two rounds before the PR opened:
Nothing new is sent to the relay or the PC. Both ids are derived on the device. |
|
Merge note: owner approved the screen from screenshots on 2026-11-04. CodeRabbit was rate-limited and did not review this head; merged on the omo review (CLEAR receipt at 3a19040), the Codex Terra adversarial review (round 1 HIGH + MEDIUM reproduced and fixed with a failing-first test, round 2 no findings) and green required checks. |
Summary
The phone's hosted shell refuses a pairing when a relay key is not the one its PC id names. This happens with a pairing link that carries another key under a PC's id, with a saved pairing whose key does not match its id, or when a link's key and the saved key disagree on connect. Before this PR the refusal was a sentence only. Now the phone also shows two IDs a person can compare:
server_idin question. A PC'sserver_idis a SHA-256 of its real relay key (deriveServerId).Each ID is labelled by where it came from. The phone never calls either one "the PC's", because a link can name any id it likes. Only the PC's own screen does that: Settings → Phone & devices now shows the PC's ID under its pairing QR code, and the phone's screen points there.
Each ID is shown in eight groups of four characters. A group that differs from the named ID is marked by weight, an underline and colour, and is named "differs" for screen readers.
Both IDs are computed on the device from data it already holds: the link's fragment, the saved pairing, and the PC's own offer. Nothing new is sent to the relay or the PC. The refusal itself is unchanged: no pairing happens, and no saved key is touched.
Changes:
src/lib/relay/shellState.ts:keyIdOf, andkeyMismatch, which picks the first key that is not the named id's and records where it came from (linkorsaved). Theforgedandidentity-changedstates gain an optionalmismatch.src/lib/relay/device.ts:ServerIdentityChangedErrorcarries the saved key and the offered key.src/lib/relay/shell.tsx: fillsmismatchon the three refusal paths.src/components/KeyId.tsx(new),RelayShell.tsxandRelayPanel.tsx: the grouped ID, the two-ID block, and the PC's own ID under its QR code. Translations for ko, ja and zh.Design idea credit: the idea of comparing fingerprints when keys disagree came from a study of another project. No code was taken from it.
Screenshots
A pairing link whose key is not the key of the id it names, opened in the hosted shell.
Validation
bun run check fast: all green (unit 10900 pass, 0 fail), on a tree byte-identical to this head (c627660d).bun test src/components/RelayShell.test.tsx src/lib/relay/shellState.test.ts: covers both states rendering the two IDs with exactly the differing groups marked; the labels by provenance, including that no id is called the PC's and that a bad saved key is labelled the saved key's, not the link's; the invalid-key case; andkeyMismatchpicking the right key and source in either order. The provenance test fails against the first version of the screen.bun test src/lib/i18n.test.ts: every new string has ko, ja and zh.bun run build:shell) from main and from this branch, and opened a forged pairing link in Chromium at 1280×800 and 390×844, dark and light.