Repository navigation
fix(account): a PC reads its mailbox when a device of its account it does not know yet signs in - #3537
Conversation
…does not know yet signs in A member who approves a new device on one PC leaves a signed add in the mailbox of the account's other PCs, but a PC read its mailbox only at start and every five minutes, so the device's sign-in there ended in auth_failed until the next pull. A sign-in naming a device the PC has no row for now makes a PC in an account read its mailbox first: it joins a pull under way or starts one, at most once a minute on a count of its own (apart from the one account joins use), and waits at most five seconds. The sign-in is then checked as before, so a device still unknown gets the same auth_failed, and records are verified and applied as in any other pull. A PC in no account, and a sign-in for a device the PC already knows, call nothing. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…refused sign-in takes the same way Review follow-ups to the pull a refused sign-in asks for. A pull that could not read the mailbox (the account service was down or did not answer) spent the one-a-minute count, so a device whose add was waiting stayed out for the whole minute. Such a pull found nothing out: the next may now start 10 seconds after it began, also when it failed after the sign-in stopped waiting for it. Whether the pull ran depended on the claimed id having a row here, so the refusal's delay told an unauthenticated peer which ids a PC knows. The sign-in is now checked first, and any failed one on a PC in an account, an unknown id or a signature that does not hold, asks for the same pull and is checked once more; a sign-in that holds calls nothing. The docs and the changelog entry no longer say "at once": a device that asks before its add is in the mailbox may wait up to a minute. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The refused sign-in's pull is decided in one line ahead of the sign-in's own check, which stays as it was, so the open change to that check (#3516) merges without a conflict. A sign-in that holds on a PC in an account is verified there and again by the check. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
Merged with these checks red, none of them required: ssh;
|
What
When a member approves a new device on one PC, the approver leaves a signed
addin the mailbox of the account's other PCs, and the new device learns those PCs right away. But a PC read its mailbox only at start and every five minutes, so the device's sign-in there ended inauth_failed("{name} has not added this device yet … Try again in a moment.") for up to five minutes.Now a PC in an account reads its mailbox when a sign-in fails, applies what it finds as in any other pull, and checks the sign-in once more. A device whose add is waiting is let in on its first sign-in. A sign-in that still fails gets the same
auth_failedas before, with no new field or code.Limits a user can meet: such sign-ins start at most one pull a minute. A device that signs in before its add reached the mailbox, or just after another failed sign-in spent that pull, is still told to try again and gets in up to a minute later (before: up to five).
How
server/account/mailbox.ts:pullForRefusedSignIn(waitMs, now). Returns at once on a PC in no account, joins a pull under way, otherwise starts one on a count of its own (SIGN_IN_PULL_MS, 60 s, apart from theadmitted()count joins use) and waits at mostSIGN_IN_WAIT_MS(5 s). A pull that ended with an error gives the minute back: the next may startSIGN_IN_PULL_RETRY_MS(10 s) after it began, also when it failed after the sign-in stopped waiting.server/relay/session.ts: before the AUTH check, on a PC in an account, the sign-in is verified; if it does not hold, the setup deadline is extended (asaccountJoindoes), the pull is awaited, and the normal check runs. A sign-in that holds calls nothing. PAIR and PAIR_REQUEST are untouched, as arerecords.ts, the join path and the client.docs/account.mdand achangelog.d/fragment.Differences from the plan's brief:
accountDeviceId: the frame decoder already accepts only 16 hex characters fordevice_id(shared/relay-mux.ts), which is that shape, so nothing was added.Release: this changes
server/, so the release must considerREMOTE_BUNDLE_VERSION(not bumped here).Review
An independent reviewer read the first commit (verdict: fix, then ship).
docs/account.md.origin/main(0.5.2) is merged in. feat(relay): a PC names a new device to the relay when its pass allows no new sessions #3516 was not waited for, since this run opens the PR; instead its head (ad89f36) was merged into this branch in a throwaway worktree: the merge is clean, and thereserver/account/account.contract.test.ts(95 pass), everyserver/relay/*.test.tsfile (run one by one, all pass,new-session.contract.test.tsincluded) andbun run typecheckpass. Whichever of the two merges second should rerun those files on the result.Validation
Ran:
bun run check faston this branch withorigin/mainmerged in: every line ok.bun test server/account/account.contract.test.ts: 95 pass (5 new or changed tests: the added device signs in on its first try; one pull a minute and the sameauth_failedwith and without it; a member's own sign-in reads nothing and a bad signature for a known id takes the unknown id's way; a PC in no account never calls the service; a tombstoned key stays out after the pull; the wait is bounded and joins a pull under way; a failed pull gives the minute back, also when it fails late).server/relay/*.test.tsfile andbun run typecheckon a local trial merge with feat(relay): a PC names a new device to the relay when its pass allows no new sessions #3516's head.Not run:
bun run check full, the integration suite as a whole and the browser regressions (no rendered component changes).shared/account-service-fake.ts,mkdtempSyncstate dirs andport: 0.Needs a real review: this changes relay sign-in (authentication). An unauthenticated peer that knows a PC's
server_idcan now make that PC call the account service, at most once a minute (once every 10 s while the service fails).🤖 Generated with Claude Code