Skip to content

feat(account): join from a pairing, approve a new device by its number, introduce it - #2851

Closed
devswha wants to merge 12 commits into
feat/account-clientfrom
feat/account-join
Closed

devswha wants to merge 12 commits into
feat/account-clientfrom
feat/account-join

Conversation

@devswha

@devswha devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Stacked on #2846 (account key, sign-in, My PCs).

What

Joining the account from a client, approving a new device from one already in it, and moving existing QR pairings into the account (docs/account.md, "Account members", "Who may admit a device", "Introductions").

  • Negotiation (shared/relay-channel.ts, shared/relay-device.ts): a client offers account in HELLO and keeps what the PC selected (server.features), so an older PC can be told apart. Signed in, a new pairing uses the account key and offers pair-intent-account, so the PC's prompt says what is being approved.
  • Linking an existing pairing (src/lib/account/join.ts, shell.tsx): once in a PC that has accounts, a pairing from before the account is linked to the account key over its own session (POST /api/account/link), with no tap. My PCs says Ready · not in the account yet for a pairing that is not linked yet, since removing the device through the account would not reach it.
  • Directory: each PC this device is in is listed with its relay key and relay (PUT /v1/pcs).
  • Joining a PC from My PCs: a listed PC this device is not paired with opens a digit comparison, only when the directory's key is the one the PC's id is derived from, so the directory cannot point this device at another PC.
  • Remote approval (AccountApprovals.tsx, AccountApprovalPrompt.tsx): an account member sees a device asking to join through the PC it is in (remote-pairings), picks the number that device shows out of three, and approves or denies. After approving it signs the add for the new device into every other PC's mailbox (POST /v1/records) and hands the PC the PCs it checked itself as the new device's introduction (POST /api/account/introduce).
  • Introduction: the new device collects it (GET /api/account/introduction), checks each PC's id against its key, and saves each to sign in with its account key and the id the add gave it there.
  • Korean: the approval title picks 을 or 를 by how the device name ends (src/lib/koreanParticle.ts).

Design

The approval sheet follows Microsoft Authenticator's number matching for the pick and Apple's "approve on another device" for what it shows: the device's name, the PC the request came through, how many PCs it joins, three large numbers split 3+3, Deny and Approve (Approve stays off until a number is picked). DESIGN.md's relay shell entry covers the sheet.

Tests

  • src/lib/account/join.test.ts, against real servers (createServer, mkdtemp state, port 0, real RelaySession and Noise) and the in-repo fake account service:
    • QR pairings move into the account one PC at a time; a PC not reached yet is reported as not covered.
    • An approved device reaches every PC: the add waits in an offline PC's mailbox, the PC collects it on reconnect, and the new device signs in there from the introduction alone.
  • src/lib/relay/channel.test.ts: the account feature offered and recorded.
  • src/lib/account/account.test.ts: a directory key that is not the PC's opens no comparison.
  • src/lib/koreanParticle.test.ts.

Validation

  • bun run check fast at 24bfdaa: ok (typecheck, build, unit tests).
  • Not covered here: the enroll snapshot for a brand-new PC and Disconnect from all PCs for another device need each member's account key on /api/devices, coming in the contract below; they land with the account devices screen.

…by its number, and introduce it

- A signed-in client offers the account feature in HELLO and pairs a new PC with
  its account key, asking to join the account so the PC's prompt says so.
- Once in a PC that has accounts, a pairing from before the account is linked to
  the account key with no tap, the PC is listed in the account's directory with
  its relay key and relay, and an introduction waiting there saves the account's
  other PCs, each signed in to with the id the add gave this device.
- My PCs opens a digit comparison with a listed PC this device is not paired
  with, only when the directory's key is the one the PC's id comes from, and says
  which pairings are not in the account yet.
- An account member sees a device asking to join through its PC, picks the
  number that device shows out of three, and on approval signs the add into every
  other PC's mailbox and leaves the PCs it checked itself as the introduction.
# Conflicts:
#	src/App.tsx
#	src/lib/account/account.test.ts
#	src/lib/account/service.ts
#	src/lib/i18n/relay.ja.ts
#	src/lib/i18n/relay.ko.ts
#	src/lib/i18n/relay.zh.ts
#	src/lib/relay/channel.ts
#	src/lib/relay/device.ts
#	src/lib/useMachineRoster.ts
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Deploying ovis with  Cloudflare Pages  Cloudflare Pages

Latest commit: 476bcf9
Status: ✅  Deploy successful!
Preview URL: https://230cec31.ovis.pages.dev
Branch Preview URL: https://feat-account-join.ovis.pages.dev

View logs

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

…oin only once the PC let it in

From the reviews of the join PR:
- An approver adds a device to the account only when the account service itself
  saw a device of this account ring at that PC with that key in the last 10
  minutes (GET /v1/admissions); a PC that shows another key is declined and the
  approver is told it could not be verified. A request for that PC only is
  answered there and never added to the account.
- The approver hands the PC the introduction first, retrying until the new
  device's row exists, and only then leaves the add in the other PCs' mailboxes.
- A device that just paired takes the account's steps over a connection of its
  own, signed in, since the PC refuses a link from the session that paired; it
  looks for its introduction for a minute.
- A device rings through the account service before it compares digits with a
  PC of the account (POST /v1/admissions).
- A PC of another account is not listed in this account's directory, a pairing
  counts as in the account only when the account lists the PC, a link swaps the
  key only for the pairing it was signed for, and an introduction is kept to 32
  PCs on the PC's own relay.
- The chat card's Deny keeps its words.
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review findings and how they were resolved (4134998)

Reviews at 24bfdaa: omo BLOCK (one HIGH, reproduced) and Codex (gpt-6.1-terra, xhigh, adversarial: one HIGH, six MEDIUM). Fixed in 4134998, with tests:

Severity Source Finding Resolution
HIGH Codex A compromised PC X could show the approver another key and have it signed into every PC The approver adds a device only when the account service itself (GET /v1/admissions, never X) saw a device of this account ring at X with that key in the last 10 minutes; otherwise the request is declined on X and the approver is told the device could not be verified. Test: X swaps the key, the approver refuses and signs nothing.
HIGH omo A device that just paired ran the account steps on the session that paired, which the PC refuses for a link and an introduction The steps take a connection of their own, signed in with the saved key, and look for the introduction for a minute. Test over a real PAIR session: refused there, linked over a signed-in connection.
MEDIUM both A request for one PC only was added to the whole account Only a pair-intent-account request is added; a PC-only one is answered on that PC, and the sheet says "Only for {pc}".
MEDIUM both The add went out before the new device confirmed The approver hands X the introduction first, retrying until the new device's row exists, and only then leaves the add in the other PCs' mailboxes.
MEDIUM both No admission was rung before joining a PC outside its pairing window My PCs rings (POST /v1/admissions with the account key) before it opens the comparison.
MEDIUM Codex A PC of another account was listed in this account's directory and shown as in the account Only a PC that belongs to this account is listed; a pairing counts as in the account only when the account lists the PC.
MEDIUM Codex A link's success answer swapped the saved key whatever the saved pairing was by then The key is swapped only for the pairing the link was signed for.
MEDIUM Codex Introductions could name any relay and any number of PCs Kept to 32 PCs on X's own relay.
LOW omo The chat card's Deny changed wording Restored.
LOW omo A link whose answer is lost leaves the old key saved Left as is: the next sign-in fails and pairing again recovers; follow-up only if it shows up in QA.

GET /v1/admissions is being added to docs/account.md and the in-repo fake by the contract PR below; until then the tests serve it from the fake's own admissions.

Validation at 4134998: bun run check fast ok (typecheck, build, unit tests).

…wait for a PC that has not added this device yet, and ring before an account comparison from any link
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Second review round (869551f)

omo at 89c20f7: BLOCK (one HIGH, four MEDIUM). Resolution:

Severity Finding Resolution
HIGH Over the default WebSocket event stream the PC never sends remote-pairings, so the approval sheet does not show Server side (server/dispatch.ts), outside this PR's scope: raised for the contract branch below, where the SSE path already sends it
MEDIUM A link whose answer is lost leaves only the old key saved, which the PC now refuses The account key is kept as pending before the link is sent; a refused sign-in tries it once before anything is forgotten. Test added.
MEDIUM An introduction named PCs where the approver was not yet linked (its add is refused there) Only PCs the approver signs in to with the account key are introduced. Test added.
MEDIUM A PC from an introduction refuses the new device until its mailbox brings the add, and the pairing was forgotten Within 15 minutes of the introduction such a refusal shows "has not added this device yet" with Try again, and keeps the pairing
MEDIUM A link without a code opened while signed in asked to join the account without ringing first It rings first (POST /v1/admissions); if that fails it asks to pair this PC only
LOW No enroll for a new PC Out of scope, follow-up #2855

Validation at 869551f: bun run check fast ok (typecheck, build, unit tests).

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Third review round (1aef6f3)

omo at aa05f2c found no HIGH. Fixed here: a pairing counts as in the account (My PCs, leave, disconnect) only once its PC confirmed it a member (a link it applied, or its account status listing the row), not because it holds the account key. Reproduced MEDIUMs left for a follow-up, per the one-extra-round rule: #2878 (an approval failing after the PC let the device in reaches only that PC; approving while signed out). LOWs noted there too.

Validation: bun run check fast ok at the new head.

# Conflicts:
#	src/components/RelayShell.tsx
#	src/lib/relay/shell.tsx
Also takes the PC's answer to HELLO after a provisional WELCOME (same nonce), as a PC that selects the account feature sends one.
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Landed as part of #2867 (the whole account stack was merged there in one squash).

@devswha devswha closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant