feat(web): zero-input pairing, a real QR, and no scanner or scopes
The console side of ADR 0001: a scanned link pairs itself, the status page
draws the daemon's actual symbol, and the second entry point for pairing
(the in-page camera scanner) is gone.
- `POST /api/v1/pair/redeem` replaced the dual-purpose `/api/v1/pair`; the
redeem response is parsed strictly as `{token, device}` (the five-layer
alias fallbacks for `deviceToken`/`payload.device`/… are deleted).
- `features/status/qr.ts` no longer invents "a deterministic fake QR from a
seed" — it renders `pairCode.qr.rows` module by module (devicePixelRatio
aware, square, token colours, redraws on theme/resize), and a mint without a
matrix shows the link instead of a pattern that will not scan.
- `/pair/<CODE>` (daemon 302 or the SPA route) lands on
`/connect?code=…&auto=1`, which redeems against its own origin with the
localized device name and then navigates to `next`/`/workspaces`, dropping
the code from the URL; a rejected code falls back to the prefilled form.
- The camera scanner (`features/connect/scan-dialog.tsx`) and its i18n keys are
removed: phones scan with the system camera, desktops type the code. Paste a
`pi2://pair?…` link or `/pair/CODE` still fills the form.
- Scope tracking disappears from the store, API types, device list and pairing
metadata (`pi2-device-scopes` is no longer written or read).
- Stale default removed: link parsing falls back to the served origin's port,
then 443/80, instead of a hard-coded 4321.
- `scripts/ui-{fixtures,mock-server,shots}.mjs` follow the new contract
(mint carries `qr`/`bases`, redeem route, no scopes), so the visual harness
exercises the real flow.
Verification: web typecheck clean, 299/299 tests, `vite build` green, visual
matrix 24/24 clean, and the i18n catalog has no missing keys.
This commit is contained in:
1 parent
a57c874095
commit
3e35fb7ef3
20 files changed
+419
-946
No files matched your search
@@ -20,7 +20,6 @@ export interface DeviceEntry {
|
||||
deviceId?: string;
|
||||
name: string;
|
||||
kind: string;
|
||||
scopes: string[];
|
||||
/** `lastSeenAt` is the daemon field; `lastActiveAt` came from older builds. */
|
||||
lastActiveAt?: number | null;
|
||||
lastSeenAt?: number | null;
|
||||
@@ -52,9 +51,10 @@ export async function fetchModels(workspaceId: string, signal?: AbortSignal): Pr
|
||||
}
|
||||
|
||||
/**
|
||||
* `/api/v1/pair` is public for redemption (`{code,…}`) and *authenticated* for
|
||||
* minting: an authenticated `POST` with no `code` returns
|
||||
* `{accepted,code,url,expiresAt,nonce}` (docs/protocol.md §3.2).
|
||||
* `POST /api/v1/pair` is authenticated and mints a code:
|
||||
* `{accepted,code,url,expiresAt,nonce,qr,bases}`, where `qr` carries the opaque
|
||||
* matrix (version 1–10, EC level M, no quiet zone) and is absent when the URL
|
||||
* is too long to encode (docs/protocol.md §3.2).
|
||||
*/
|
||||
export interface PairCodeResponse {
|
||||
accepted?: boolean;
|
||||
@@ -62,6 +62,8 @@ export interface PairCodeResponse {
|
||||
url?: string;
|
||||
expiresAt?: number;
|
||||
nonce?: string;
|
||||
qr?: { version: number; ecc: string; mask: number; size: number; rows: string[] };
|
||||
bases?: { kind: string; name: string; address: string; url: string }[];
|
||||
}
|
||||
|
||||
/** Pairing codes are short-lived; 10 minutes matches `auth.pairCreate`'s default. */
|
||||
|
||||
Reference in new issue
Block a user