Repository navigation
Commit 949b714
w3(dashboard): QR-proof sign-in demo page + tests
The desktop side of the W3 QR-proof wrapper demo (ADR-0009). The page
mounts at /demo/qr-proof-login under the existing RequireAuth + AppShell
chain so it's only reachable from inside the developer console, where
the console JWT already gates access.
State machine in useReducer with five phases: idle → creating → pending
(QR shown) → awaiting_proof (paste-fallback for the proof QR) → success
(auto-redirects to /overview) or expired/error (Start over). The SSE
stream and the submit response are both treated as canonical paths to
'success' — whichever lands first wins; the reducer is idempotent.
api.pairing extends the dashboard's existing fetch client with the four
endpoints + a tiny pub/sub wrapper around EventSource (returns a stream
with .on(type, cb) and .close(); withCredentials: true so the
zeroauth_pair_bind cookie ships on the SSE GET). Discriminated union
PairingStreamEvent on .type mirrors the four SSE event names the
backend emits.
VITE_PAIRING_MOCK=1 swaps in a client-side mock store keyed on session
id. Mock-mode shows "Trigger mock claim" / "Trigger mock expire"
buttons inside the cards so the W3 demo deck reviewer can walk the
state machine without a live backend.
QR rendering: api.qrserver.com via <img> (no new JS dep — kept the
bundle 10.65 kB / 3.61 kB gzip for the lazy chunk). The raw QR payload
is always exposed as a paste-fallback so a CSP/network block can't
lock the operator out of the demo.
AppShell nav gains a "Demos" entry pointing at the new route. Five
vitest cases cover render-after-create, SSE expired transition, SSE
bound transition, EventSource cleanup on unmount, and the Start-over
flow.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2f6d55d commit 949b714
6 files changed
Lines changed: 1191 additions & 0 deletions
File tree
- dashboard/src
- components/layout
- lib
- routes/demo
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
20 | 40 | | |
21 | 41 | | |
22 | 42 | | |
| |||
89 | 109 | | |
90 | 110 | | |
91 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
92 | 120 | | |
93 | 121 | | |
94 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
| |||
0 commit comments