Skip to content

feat(account): account key, sign-in and My PCs in the relay shell - #2846

Closed
devswha wants to merge 10 commits into
feat/account-pcfrom
feat/account-client
Closed

devswha wants to merge 10 commits into
feat/account-pcfrom
feat/account-client

Conversation

@devswha

@devswha devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Stacked on #2843 (account records on the PC), itself on #2840 and #2834.

What

The client side of signing in to link devices (docs/account.md), first part: the account key, the sign-in and the account's PCs on the hosted shell's front page.

  • Account key (src/lib/account/store.ts): one ECDSA P-256 key per client, made by WebCrypto as non-extractable, in its own IndexedDB database ovis-account (with the sign-in and a sign-in in progress). ovis-relay v2, which public/sw.js shares, is not touched; a test checks that the worker opens only ovis-relay at the shell's version and never ovis-account.
  • Sign-in (src/lib/account/signin.ts, service.ts): GitHub or Sign in with Apple through the account service, OAuth authorization code with PKCE (S256). The web return is https://app.ovis.sh/ with #code=…&state=… in the fragment, so the code never reaches the host's request logs, and it leaves the address bar before anything else runs. A return this client did not start, one opened twice, or one older than ten minutes is refused. Access tokens refresh before they run out (refresh tokens rotate); a refused refresh signs the client out and leaves every PC pairing as it was. No token is logged.
  • My PCs (src/lib/account/myPcs.ts, src/components/AccountPcs.tsx): the account's directory, which the client does not trust, merged with the PCs this device is paired with. States in words under each name: paired, this device is not approved on it yet, offline (last seen), needs an update. Only a paired PC is a link; the directory's label never renames a PC this device already knows, and no key ever comes from the directory.
  • Off unless configured: a page offers sign-in only when it names an account service in <meta name="ovis-account-service"> (https, or http on loopback). The shell build does not add it yet, so app.ovis.sh is unchanged by this PR; the same meta lets a self-hosted install point at its own service.
  • lastSeen moves from DevicesPanel to src/lib/lastSeen.ts so both lists say it the same way (its four strings move from the devices dictionary part to the base).

Not in this PR (next PRs of the same work): joining through a PC with remote approval and number matching, moving existing QR pairings into the account, the account's device list with remove and sign-out, native sign-in on iOS, Android and the desktop app, docs and the privacy page.

Depends on

The sign-in endpoints, the fragment return for https://app.ovis.sh/ and the hosted shell's connect-src for https://account.ovis.sh come from the contract below this PR (docs/account.md "Signing in"); the tests sign in through the in-repo fake's own /v1/signin and /v1/token.

Design

DESIGN.md "Relay shell" gains the account part. GitHub and Apple are two equal neutral buttons (App Review 4.8 asks for Sign in with Apple wherever another provider is offered). PC states are words, not badges, as the shell's list already rules. Precedent: Tailscale's machine list (every machine of the account with its state in words) and Signal's linked devices (trust stays on devices already linked, not on the sign-in).

Validation

  • bun run check fast at fcc5939: ok (workflow syntax, generated types, themes, typecheck, build, unit 10995 pass / 0 fail).
  • bun test src/lib/account src/components/RelayShell.test.tsx src/lib/relay src/lib/i18n.test.ts: pass.
  • Manual, on the built shell (bun run build:shell) behind HTTPS with the meta pointing at the in-repo fake behind a small CORS wrapper: Continue with GitHub → the fake's sign-in → back on / with a clean address → My PCs lists the account's three PCs (all "not approved yet" for a fresh device). Screenshots at 390 and 1280 px, dark and light, signed out and signed in.
  • Skipped: native apps (no native change here); the real account service (not deployed).

The hosted shell's front page can sign in to the account service (GitHub or
Sign in with Apple, OAuth code + PKCE, the code returned in the fragment) and
list the account's PCs merged with the PCs this device is paired with.

- src/lib/account/store.ts: one non-extractable P-256 account key per client in
  its own IndexedDB database, ovis-account; ovis-relay and the service worker
  are untouched.
- src/lib/account/service.ts: directory calls with refresh and sign-out; a
  page offers sign-in only when it names an account service in
  <meta name="ovis-account-service">, so no build shows dead buttons.
- src/lib/account/myPcs.ts: directory rows are never trusted for keys; only a
  paired PC opens.
- lastSeen moves to src/lib/lastSeen.ts, shared by Devices and My PCs.
@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

…-in, no service text in errors

From the adversarial review of the first account PR:
- Refreshes run one at a time between tabs (Web Locks) and store their answer
  only over the session they started from, so a rotated refresh token is never
  used twice and a refresh in flight cannot bring a session back after sign-out.
- Sign-out refreshes an expired access token first, so the service really ends
  the sign-in's tokens; a revocation the service did not confirm throws.
- Errors keep the service's error code only, never its message, which could
  echo a token.
- A paired PC with no name is never named from the directory.
- Waiting sign-ins are kept by state and taken in one transaction: a forged
  return cancels nothing, and two tabs can sign in at once.
- The sign-in's return leaves the address bar at boot, before the shell's chunk
  loads.
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review findings and how they were resolved (613a935)

Reviews at fcc5939: omo reviewer CLEAR; Codex (gpt-6.1-terra, xhigh, adversarial) found five MEDIUM and two LOW issues, each reproduced against the in-repo fake account service. All seven are fixed in 613a935, each with a test:

# Severity Finding Resolution
1 MEDIUM Two tabs refreshing at once reuse the rotating refresh token and the service ends the whole sign-in Refreshes run one at a time between tabs (Web Locks); a tab that waited uses the tokens another tab just got
2 MEDIUM Sign-out with an expired access token got a 401 and left the refresh family alive Sign-out refreshes first, then revokes; a revocation the service did not confirm throws; the local session goes either way
3 MEDIUM A refresh in flight could store its answer after sign-out and bring the session back A refresh stores its answer only over the session it started from (compare-and-set in one transaction)
4 MEDIUM A paired PC with no name took the directory's label A paired PC is named only from its own pairing, else its id
5 MEDIUM The service's error message (which could echo a token) went into errors and logs Errors keep the service's error code only, with fixed wording
6 LOW A forged return cancelled the sign-in waiting in this tab; two tabs could not sign in at once Waiting sign-ins are kept by state and taken in one transaction
7 LOW The sign-in's return stayed in the address until the shell's chunk loaded Boot takes it off the address with the pairing offer, before anything loads

Not reproduced by the reviewer: a forged or replayed return producing a session, a directory-only row becoming openable, or a directory key being used.

Validation at 613a935: bun run check fast ok (unit 11001 pass / 0 fail, typecheck, build).

…aw it

The sign-in is a centred card with one short title and line, GitHub and Apple as
two alike buttons in the theme's strongest ink (black in light, white in dark,
as Sign in with Apple asks), the QR route behind a link and one line on what the
account sees. My PCs says each state in a word after a dot; the digit comparison
is centred with one line under the numbers.
…nt-client

# Conflicts:
#	src/lib/i18n/relay.ja.ts
#	src/lib/i18n/relay.ko.ts
#	src/lib/i18n/relay.zh.ts
@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

New commits

  • 654c533 a shorter sign-in, closer to the sign-in pages people know (Linear, Vercel, Tailscale, Warp): a centred card with one short title and line, Continue with GitHub and Continue with Apple as two alike buttons in the theme's strongest ink (black in light, white in dark, which is also what Sign in with Apple's button rules ask for), the QR route behind a small link, and one line on what the account sees. My PCs says each state in a word after a dot (Ready, Needs approval, Offline · 3 h ago, Update Ovis on it). The digit comparison is centred with one line under the numbers. No new colours: only theme tokens.
  • 6771646 merge of the contract branch below (no conflict but dictionary entries on both sides).
  • 6d1d93d PUT /v1/pcs now sends the PC's relay key and relay, as the directory takes them.

Validation at the new head: bun run check fast ok (unit 11412 pass / 0 fail, typecheck, build).

@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: 38fb9e4
Status: ✅  Deploy successful!
Preview URL: https://3f0c7722.ovis.pages.dev
Branch Preview URL: https://feat-account-client.ovis.pages.dev

View logs

@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