Repository navigation
feat(account): add a PC to the account with one approval on a device already in it - #3088
Conversation
…, behind a barrier The first link starts an enrollment barrier on the PC: no account add applies until that member's POST /api/account/enroll. An enrollment now carries removes and adds; the PC applies every remove first (in signing order), then the adds in rounds, retrying waiting removes between rounds. An add is refused removal_pending while a waiting remove names its key, an enrollment held it, or the waiting queue is full or unreadable. The status lists the signed adds behind the rows and every blocked key; ?fresh=1 pulls the mailbox first. The client's enrollPc sends its removes through enroll, which lifts the barrier.
…removals every reachable PC holds Before enrolling a PC it brought into the account, the client reads every other PC of the account it is linked on (status ?fresh=1: blocked keys, signed removals and signed adds). It then sends one enrollment: its own and kept removes, its own adds and the adds those PCs list, minus any key a PC keeps out or a verified removal names, and those keys as held. Nothing is signed for collected records. If no other PC answers, nothing is sent until the next connection. Each PC that answered introduces the new PC to the devices let in; introductions now persist for 30 days and merge by PC.
- a remove waiting on its signer is kept before the next record of its batch, so an add for its key right behind it is held back (records and mailbox) - only the member whose link started the barrier ends it, with the last part of its enrollment, once every remove was decided; a refused link never lifts it - status ?fresh=1 says fresh only after a whole, error-free mailbox read; the client counts only such PCs as checked - more held keys than one enrollment carries latch every add off (held_full) - the overflow latch is written before any waiting remove is dropped; a full queue of waiting adds no longer holds every add back, and a relayed remove makes room by dropping a waiting add - the approver hands its add to the PC that let the device in, which keeps it
# Conflicts: # server/index.ts
- settle and a mailbox pull retry the waiting records one at a time, so a waiting remove never leaves the add gate's sight - status says blocked_all when the PC holds every add back; the client then sends no add and holds every one on the new PC - a remove a full queue could not keep still holds back an add for its key in the same batch - an earlier part with an undecided remove keeps the new PC's wait - the barrier names the device whose link succeeded - account-enrolling.json and account-held.json are read apart, and neither is written over while one cannot be read - older PCs: a peer without fresh counts only for its removals (no add is sent); a new PC that refuses removes in enroll gets them through records
…one existing device - Settings > Account on a PC in no account: Add this PC to my account lists it in the account's directory and opens a pairing window only that PC approves (POST /api/relay/link?local_only=1); remote members never see or decide it - on a signed-in device, a PC new in the directory shows as a card; adding it asks for the six digits the new PC shows, typed (one wrong entry ends it) - the phone app's front page puts signing in first; QR and pairing code go under Other ways
… attempts they were meant for - the typed-digits marker for a PC joined from its card survives the page load that opens it (tab session storage), so the plain tap comparison never stands in for it - whether a comparison is the PC's own to decide is fixed when the phone asks, so a window closing before its digits show cannot hand it to a member - the add-me screen stops reopening the window once the PC is in the account, and lists the PC anew when its directory entry is older than the card
|
Caution Review failedThe pull request is closed. Summary
Merge Risk:
|
|
Browser QA at e9b0475: |
…p that card up while the PC waits - a PC's plain row joins as before (digits shown on this device); only the card for a PC that just asked to be added asks for the number it shows, with a hint to tap the row instead when no number is there - each reopening of the add-me window lists the PC anew before the card's ten minutes run out, so the card stays while the screen waits - the waiting screen names the phone app, where the card is
Review round (omo + Codex Terra xhigh on e9b0475) and how each finding was resolvedFixed in c703948:
Not changed (LOW, for follow-up):
|
- a fresh status is fresh only for the account and relay identity it was read for - a relayed remove the full queue cannot take holds its key out of every add - enroll takes only true or false for last and held_full - the first link that succeeds keeps the barrier - while any PC from before enrollments answers, no add is enrolled - opening the account's other PCs before an enrollment is bounded like their answer
…a PC that cannot, and let a new first member take over - ?fresh=1 waits for a pull that starts after the request, so a remove posted a moment before it is counted; a PC with no account service is fresh - a PC whose mailbox read failed counts like an older PC: its removals go, no add does, and the new PC's wait ends instead of holding every add for good - a barrier confirmed by a first member revoked before it enrolled the PC is taken over by the next first link
…hold every add when a PC could not vouch - only OVIS_ACCOUNT_SERVICE_URL=off counts as having no mailbox; an unusable address is never fresh - when a PC the client read could not vouch for what it keeps out (mailbox read failed, or older), the enrollment sends held_full, so adds that waited on the new PC stay out after its barrier ends
…hose signer a waiting remove names, and keep a row's add through a merge
…block a signer only on a waiting remove, and replace a kept add for another key - a PC that could not read its mailbox this time (or is older) only keeps the enrollment's adds home; only lost removal evidence latches every add off - an add waits on its signer only while a remove for that signer waits here, not for a key an enrollment held that is back on this PC - a row's kept add for an older key is replaced by its approver's current one
… on a new PC from before enrollments - with no other PC to read while the directory lists some (or the directory cannot be read), the client sends the removes but no add - a new PC whose status has no enrolling is from before enrollments: it gets the removes through records and no add, whatever the batch holds
… a removal is signed while it runs
…em on the next connection
… and introduce what an unfinished attempt let in
…s its own enrollment, removals first
…p the wait while a PC could not read its mailbox - a member's remote approval and a link onto a key this PC holds back (removed elsewhere, or a remove for it waits here) are refused; a pairing approved on the PC itself still lets it in - an enrollment while a PC answered not fresh sends its removes and no add, and is not the last part: the new PC keeps its wait until a later connection reads that PC whole
…account-one-tap-ui
…movals are in (#3087) Part of #2956 (the add half) ## What A PC that a client brings into the account now gets the account's devices in one go, instead of every device asking that PC again. This is the "approve a new PC once" half of linking by account; the screens come in a follow-up PR. **Server (PC)** - **Enrollment barrier.** The link that gives a PC its first member writes `account-enrolling.json` first. Until that member's `POST /api/account/enroll` succeeds, no account `add` applies there, from `/api/account/records` or the mailbox (`refused`, `enrolling`; mailbox adds wait in `account-pending.json` and are tried again after the enrollment). A refused link leaves the barrier; the first link that succeeds keeps it. No timeout: a client that never enrolls leaves the adds held. - **Ordered enrollment.** `/api/account/enroll` now takes removes and adds (at most 512) plus `held` keys (at most 4096). The PC keeps `held` on disk (`account-held.json`), applies every remove first in signing order, then the adds in rounds (an add whose signer another add lets in applies in the next round), retrying waiting removes after each round, then lifts the barrier. - **Add gates on every path.** An add is refused `removal_pending` while a waiting remove names its key (whatever its signer), an enrollment held it, or the waiting queue is full or cannot be read. Past 1000 waiting records adds are dropped first; if a remove has to go, every add is refused from then on. An unreadable `account-pending.json` is no longer an empty queue. - **Status.** `GET /api/account/status` adds `adds` (the signed add behind each row, kept as received, including the approver's own add for a row its remote approval made), `blocked` (every tombstone key, signed or not, every key a waiting remove names, every held key) and `enrolling`. `?fresh=1` pulls the mailbox first (a pull that starts after the request; requests that come while one runs share the next). - **Introductions** persist in `account-introductions.json` for 30 days and merge by PC. **Client** - `enrollPc` first reads every other PC of the account it is linked on (`?fresh=1`, 8 s each). It then sends one enrollment: its own and kept removes, its own adds and the adds those PCs list, minus every key a PC keeps out or a verified removal names (any signer: fail closed), and those keys as `held`. It signs nothing for collected records. If no other PC answers, it sends nothing and tries on the next connection. - Each PC that answered then introduces the new PC to the devices let in, so they sign in there; an introduction a PC could not take stays in the plan and is sent again on the next connection. Design and two rounds of Codex (Terra, xhigh) adversarial design review are summarised in the first PR comment. Known, documented limit: a removal held only by PCs the client cannot reach, and hidden by the account service, is missed; the device then comes back on the new PC, announced. ## Tests `server/account/account.contract.test.ts` (real servers): - the first link holds every account add (direct and mailbox) until the member enrolls, across a restart, then lets the waiting ones in; - an enrollment applies removes before adds whatever the order sent, and adds in rounds; - a remove waiting for its signer keeps that key's adds out on every path, and once an enrollment lets the signer in the key is removed; - held keys stay out of every later path, while a device already there keeps its row; - the status lists signed adds (incl. an approver's own) and every blocked key; - an unreadable pending file, or removes pushed out of a full queue, hold every add back; - introductions merge by PC, outlast a restart and expire. `src/lib/account/join.test.ts`: - the #2947 Mac repro, "does not let back on the new PC a device another member removed": with adds enabled and no other PC read, it fails (Y admits the Mac); with the client reading X first it passes, and a copy of the Mac's add arriving later is refused `removal_pending`; - devices another PC lists come into the new PC and are introduced to it there, and sign in; - with no other PC answering nothing is sent and the PC stays in its barrier. Failing-first: each new server test fails with its part reverted (the `held` gate, the barrier start on link, the remove-first ordering, keeping the approver's add, the overflow latch). Review fixes already in (Codex Terra xhigh on the branch before opening): a remove waiting on its signer is kept before the next record of its batch; only the linking member ends the barrier, with the last part of its enrollment and every remove decided; `?fresh=1` reports `fresh` only after a whole, error-free mailbox read and the client counts only such PCs; `held_full` latches every add off; the overflow latch is written before any waiting remove is dropped; a full queue of waiting adds no longer holds every add back; the approver hands its add to the PC that let the device in. ## Validation - `bun test server/account src/lib/account src/lib/relay server/state-merge server/relay/pair-sas.contract.test.ts`: 399 pass, 0 fail (head 0c6807d, main merged) - `bun run check fast` at 0c6807d: pass (workflow syntax, generated types and themes, typecheck, build, unit tests) - Not run: `bun run check full`, browser regressions (no UI in this PR; the stacked UI PR #3088 ran the relay shell browser QA)
# Conflicts: # docs/account.md # src/lib/i18n.ja.ts # src/lib/i18n.ko.ts # src/lib/i18n.zh.ts
|
Local merge gate (owner-approved): based on main after #3087, |
…ce (#3148) ## What Settings → Devices and PCs is regrouped so connecting anything is one list and one button. - **Account** on top (sign in with GitHub, Add this PC to my account, Sign out of GitHub). - **My devices**: one **Connect a device** row with a **Connect** button, then one list: this PC (a **This PC** pill and its relay ID, read again when the relay starts or its identity is reset), the other PCs this app shows (PC pill, state; removing a PC stays in the sidebar's PC menu, which moves the selection off it first and leaves herdr-managed PCs to herdr), signed in the account's other PCs, then the paired phones and browsers (a Phone / Tablet / Browser pill when the label is still the one the app gave it, none for a renamed device; last seen, Rename, Revoke), **Revoke every device**, and **Sign out of this PC** (named apart from Sign out of GitHub). On a touch phone on this PC's own address with the relay online, its own row carries **Use the relay**. - **Connect a device** dialog: - Signed in, this PC in that account and the relay online: the new device signs in with GitHub and is approved once on a device already in the account (the existing account approval prompt, number picked out of three, #3087/#3088; per docs/account.md it never shows on the PC's own windows). **Connect with a code (no sign-in)** shows the code view. - Otherwise: the relay's QR code and the code to type side by side, only **Refresh** and **Copy**; signed out where the account is offered, one line says signing in skips the code. While the relay is not online: its state, the switch for the owner (with the gate condition), a failed start's reason and Try again; read-only devices get the owner-only line. - **Enter a code from another device** (the typed-code form, with the ID match step). - **Other ways to connect**: Same Wi-Fi (six-digit code, QR, Refresh, Copy), Tailscale, Portal (where offered), Add a PC over SSH. - **More settings**: This device (Keep screen on, Install), Ovis relay (switch, Reset relay identity), Show in sidebar, Access, the PCs' bridge updates and load line. - This PC's ID left the dialog: it is at the top of My devices, and the typed-code confirmation (here and in the hosted app) says to compare it there. - Old links `?settings=devices§ion=phone|remote|portal` land on My devices; the palette's Remote PCs entry is My devices; Connect a device's row carries the old rows' words for search. The same Wi-Fi code stays a row under Other ways: connecting directly on the same network with the relay code needs a new pairing step (find the PC's LAN address and prove it is the same PC), so it is left for a follow-up rather than added here. Design precedent: WhatsApp's Linked devices (one list, one Link a device) and Tailscale's admin Add device (one button, the ways inside). DESIGN.md is updated. ## Notes for review - Opening Connect a device now makes a live code at once (the relay's code to type, which starts a six-digit code, or the six-digit code when the relay is off), as the owner asked for the code to be on screen beside the QR code. It is never kept for the next opening (a looked-up code is spent even when its person cancels at the ID comparison), so opening the dialog more than ten times in ten minutes reaches the PC's pairing limit, and its error shows in the dialog. The code and the QR code carry the one pending pairing and are renewed together when it runs out. - The relay's code to type is minted as the dialog opens, then the offer is asked for: asked together, the six-digit code the offer starts ended the code being minted (`This code was replaced`, a 500), found by the updated relay-panel regression. - Connect a device sits above Settings even where Settings is raised over a file preview, and the account approval prompt sits above Connect a device. - The demo answers `/api/account/status` with `?demo_account=member` and carries the Host's relay ID while its device routes are on, for the captures. ## Validation - `bun run check fast`: green. - Browser regressions in the CI runner image (herdr-ci-runner:local, as the runner user): settings-pages-demo, security-summary-demo, hide-pc-demo, pc-load-demo, sidebar-declutter-demo, install-state-demo, lan-exposure-notice, portal, file-viewer, device-security-demo and ui-regression (which runs the relay panel and wake-lock checks) all passed before the merge of main; after it, settings-pages-demo, install-state-demo, device-security-demo and ui-regression passed again. file-viewer-regression and ui-regression each failed once on an unrelated timing (a "Needs input" droplet over the file viewer's menu; a sidebar agent badge 27 s in) and passed on the lane's own retry. - Not run: relay-shell-browser-qa and machines-browser-qa (they need a real herdr and relay outside the lane; their edits here are a selector and comments). - Codex (Terra, xhigh) on the first commit: CLEAR, five MEDIUM/LOW findings, all fixed in the second commit. - Screenshots (1280 and 390, light and dark, signed out and signed in, dialog states): in the lane's report (demo build).
Follows #3087 (merged).
What
Adding a PC to the account takes one approval on a device already in it, instead of every device
pairing with the new PC. The design follows WhatsApp's linked devices and Tailscale's Tailnet Lock:
an existing device approves once, and the server only carries messages.
Add this PC to my account lists the PC in the account's directory and opens a pairing window
with
POST /api/relay/linkand the headerx-ovis-local-only: 1. What comes in under that window is decided on this PConly: it is never listed to account members (
remote-pairings) nor approvable by one, and thatis fixed when the phone asks, so a window closing before the digits show changes nothing. The
screen keeps the window open while it waits and stops once the PC is in the account. An entry
older than the card's ten minutes is listed anew, which rings the account's devices again.
to your account? Adding it from the card asks for the six digits the new PC shows, typed (not a tap, as
a directory name is anyone's); one wrong entry ends the comparison. The person then approves on
the PC, and feat(account): enroll a new PC with the account's devices once its removals are in #3087's enrollment brings in the account's other devices and introduces the PC to them.
Other ways. Without an account service the page is unchanged.
Docs:
docs/account.md"Adding a PC".Review
Codex (Terra, xhigh) on this branch before opening; fixed here:
comparison stood in for it. Kept in the tab's session storage (only ever makes a comparison
stricter).
remotely approvable. Fixed at request time in the session.
still waited. Both fixed.
is listed (the push ring and reopening the app do).
Tests
server/relay/pair-sas.contract.test.ts: a local-only window's requests are never listed ordecided remotely, and stay so when the window closes between request and reveal (fails with the
session capture reverted).
src/components/RelayShell.test.tsx: sign-in before Other ways beside saved PCs; the new-PC cardfor a fresh directory entry only; the typed comparison shows no digits and a wrong entry ends it.
Visual QA
Rendered the four new states (front page signed out with a saved PC, new-PC card, typed digits,
wrong number) at 390 and 1280 wide, light and dark, in Chromium: no overflow, card and fold sit on
the existing spacing tokens.
Validation
bun test server/account src/lib/account src/lib/relay src/components server/relay/pair-sas.contract.test.ts server/relay-pc.contract.test.ts src/lib/i18n.test.ts: pass (head 840526a, main merged)bun run check fastat 840526a: pass (workflow syntax, generated types and themes, typecheck, build, unit tests)scripts/relay-shell-browser-qa.ts: fails at its file-viewer step (.workspace-group .pane-selectclick times out, line 496), and fails the same way on origin/main 554332a, so the break is on main, not here; its earlier steps (front page, pairing) pass