Scrum4Me/actions
Madhura68 625221f9ee feat(ST-1005): add pairing server actions + mobile confirmation page
actions/pairing.ts (Server Actions, volgt docs/patterns/server-action.md):
- getPairingForApproval(pairingId, mobileSecret): auth + Zod + lookup + status
  + expiry + verifyToken-check; retourneert UA/IP/username voor de
  bevestigingspagina. Demo MAG aanroepen (read-only).
- approvePairing: zelfde checks PLUS demo-blokkade (session.isDemo). Update
  status pending→approved, zet user_id + approved_at, bumpt expires_at +5min.
  Postgres-trigger emit pg_notify automatisch — desktop-SSE pikt het op.
- cancelPairing: status pending→cancelled. Demo mag annuleren.
- Tagged-union return-type uit loadPendingPairing voor schone discriminatie.

app/(app)/m/pair/page.tsx (Server Component, achter (app)/layout-guard):
- Geen searchParams uitlezen — page leest URL niet. Alleen statische uitleg +
  PairConfirmation client-island.

app/(app)/m/pair/pair-confirmation.tsx (Client Component):
- useEffect parseert window.location.hash voor #id=…&s=… (server ziet de
  fragment nooit)
- Roept getPairingForApproval om UA/IP/username op te halen
- Toont kaart "Inloggen als <username> op dit apparaat?" met UA + IP +
  expliciete waarschuwing tegen phishing-QR; Bevestig/Annuleer-knoppen
- Na approve: window.history.replaceState wist de hash zodat back/forward de
  secret niet meer onthult; transitioneert naar success-state
- queueMicrotask voor synchrone setState om React-Compiler "cascading renders"
  warning te vermijden

Tests __tests__/actions/pairing.test.ts (11 cases):
- getPairingForApproval: ok + 5 fail-paths (geen sessie, approved, verlopen,
  verkeerd secret, ongeldige cuid)
- approvePairing: happy + demo-block + verkeerd secret (geen DB-write)
- cancelPairing: happy + demo mag annuleren

Quality gates: lint 0 errors, tsc clean, vitest 132/132.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 22:50:42 +02:00
..
active-product.ts feat(M9): active product backlog — persistent active PB, NavBar splits, sprint card styling (#10) 2026-04-27 20:25:13 +02:00
api-tokens.ts feat: ST-401-ST-410 M4 REST API, tokenbeleer en activiteitenlog 2026-04-24 11:56:29 +02:00
auth.ts feat: ST-601-ST-612 M6 polish, beveiliging en launch-ready 2026-04-24 12:36:23 +02:00
pairing.ts feat(ST-1005): add pairing server actions + mobile confirmation page 2026-04-27 22:50:42 +02:00
pbis.ts Todo description, entity codes, REST API extensions and Claude Code hardening (ST-509/511/512/513) (#2) 2026-04-26 23:40:54 +02:00
products.ts feat(M9): active product backlog — persistent active PB, NavBar splits, sprint card styling (#10) 2026-04-27 20:25:13 +02:00
profile.ts feat(ST-507): persist email in updateProfileAction with Zod validation 2026-04-26 19:37:49 +02:00
sprints.ts Fix scoped access checks 2026-04-25 14:36:55 +02:00
stories.ts Todo description, entity codes, REST API extensions and Claude Code hardening (ST-509/511/512/513) (#2) 2026-04-26 23:40:54 +02:00
tasks.ts feat(M8): Realtime Solo Paneel via Postgres LISTEN/NOTIFY (ST-801..ST-806) (#8) 2026-04-27 13:59:32 +02:00
todos.ts feat(ST-509): persist Todo description in create and update actions 2026-04-26 19:59:53 +02:00