feat(terminal): pairing, sign-in per mode, device app router and live states (platform-v2 3.1c)

- Pairing screen: requests a code, shows it big, polls with the secret, new code on
  expiry, keeps the device token; "removed from the venue" notice after a revoke.
- Sign-in per device mode: PIN (name + PinPad), tap your name, password (name +
  password), none (straight into the app). Names = holders of <app>.access, refreshed
  every 30 s and on reconnect. Slim bar with screen, user and Sign out; idle sign-out
  after the device's auto_sign_out_minutes; hourly token refresh (same session).
- DeviceProvider: GET /api/devices/me (retried while unreachable), session, the live
  connection with credentials in the first frame (device.updated -> reload, app moved ->
  sign out, device.revoked -> forget, session.ended -> sign out), offline banner;
  useLiveEvent for apps. Screen choice is pure (device/flow.js, unit-tested).
- Blocked screen: app turned off / not licensed / device refused, recovers by itself.
- @xenia/access AccessProvider: autoRetryMs (retry bootstrap while unreachable).
- Tests: terminal unit tests (screen choice, live actions, idle, pairing polls), new
  tests/e2e/terminal.mjs (18 checks), manager.mjs owner flow now pairs and signs in on
  the real terminal screen; run-all runs terminal.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 17:29:18 +02:00
co-authored by Claude Opus 5.5
parent 7ff3c3b48e
commit c24cb72640
22 changed files with 928 additions and 83 deletions
+10 -1
View File
@@ -20,9 +20,11 @@ import { OverrideHost } from './OverrideHost.jsx'
* for `client` (OverrideHost), unless override={false}
* Until the bootstrap for the current token has loaded it renders `loading` (a spinner by
* default); if it fails, an error screen with Retry. Nothing below ever sees a half-loaded state.
* autoRetryMs (unattended screens, e.g. the terminal): when the server can't be reached
* (offline or 5xx), retry by itself every autoRetryMs as well.
*/
export function AccessProvider({
client, token = null, i18n, deviceLanguage, override = true, loading, children,
client, token = null, i18n, deviceLanguage, override = true, loading, autoRetryMs = 0, children,
}) {
const [state, setState] = useState({ data: null, forToken: undefined, error: null })
@@ -40,6 +42,13 @@ export function AccessProvider({
useEffect(() => { load() }, [load])
const unreachable = !!state.error && (state.error.offline || state.error.status >= 500)
useEffect(() => {
if (!autoRetryMs || !unreachable) return undefined
const id = setTimeout(load, autoRetryMs)
return () => clearTimeout(id)
}, [autoRetryMs, unreachable, state.error, load])
const value = useMemo(() => {
const d = state.data
if (!d) return null
+28 -2
View File
@@ -1,7 +1,33 @@
{
"start": {
"title": "Τερματικό Xenia",
"notPaired": "Αυτή η οθόνη δεν έχει συζευχθεί ακόμη με το κατάστημα."
"title": "Τερματικό Xenia"
},
"pairing": {
"intro": "Συζεύξτε αυτή την οθόνη με το κατάστημα:",
"howTo": "Στη διαχείριση, ανοίξτε Συσκευές → Σύζευξη συσκευής και πληκτρολογήστε αυτόν τον κωδικό.",
"removed": "Αυτή η οθόνη αφαιρέθηκε από το κατάστημα. Κάντε ξανά σύζευξη για να τη χρησιμοποιήσετε."
},
"signIn": {
"title": "Ποιος συνδέεται;",
"enterPin": "Πληκτρολογήστε το PIN σας",
"password": "Κωδικός",
"submit": "Σύνδεση",
"back": "Πίσω",
"empty": "Κανείς δεν μπορεί να συνδεθεί εδώ ακόμη",
"emptyBody": "Δώστε σε κάποιον το δικαίωμα {{app}} στο Προσωπικό, στη διαχείριση."
},
"blocked": {
"off": "Η εφαρμογή {{app}} είναι απενεργοποιημένη",
"offBody": "Ένας διαχειριστής μπορεί να την ενεργοποιήσει στις Εφαρμογές. Τότε η οθόνη ξεκινά μόνη της.",
"notLicensed": "Η εφαρμογή {{app}} δεν περιλαμβάνεται στην άδεια του καταστήματος",
"notLicensedBody": "Ζητήστε να προστεθεί στην άδεια. Τότε η οθόνη ξεκινά μόνη της.",
"refused": "Αυτή η οθόνη δεν μπορεί να χρησιμοποιηθεί αυτή τη στιγμή"
},
"bar": {
"signOut": "Αποσύνδεση"
},
"offline": {
"banner": "Δεν υπάρχει σύνδεση με τον διακομιστή του καταστήματος. Νέα προσπάθεια…"
},
"apps": {
"placeholder": "Αυτή η οθόνη τρέχει: {{app}}. Οι οθόνες της ετοιμάζονται.",
+28 -2
View File
@@ -1,7 +1,33 @@
{
"start": {
"title": "Xenia terminal",
"notPaired": "This screen isn't paired with the venue yet."
"title": "Xenia terminal"
},
"pairing": {
"intro": "Pair this screen with the venue:",
"howTo": "In the manager, open Devices → Pair a device and type this code.",
"removed": "This screen was removed from the venue. Pair it again to use it."
},
"signIn": {
"title": "Who's signing in?",
"enterPin": "Enter your PIN",
"password": "Password",
"submit": "Sign in",
"back": "Back",
"empty": "Nobody can sign in here yet",
"emptyBody": "Give someone the {{app}} permission under Staff in the manager."
},
"blocked": {
"off": "{{app}} is turned off",
"offBody": "A manager can turn it on under Apps. This screen starts by itself then.",
"notLicensed": "{{app}} isn't in the venue's license",
"notLicensedBody": "Ask for it to be added to the license. This screen starts by itself then.",
"refused": "This screen can't be used right now"
},
"bar": {
"signOut": "Sign out"
},
"offline": {
"banner": "Can't reach the venue server. Trying again…"
},
"apps": {
"placeholder": "This screen runs {{app}}. Its screens are being built.",