feat(waiter): sign-in v2 on the phones (platform-v2 step 4.2)

- Login follows auth.waiter_login_mode / auth.waiter_require_username from the
  bootstrap: name + PIN, name + password, typed username, or a "paired screens
  only" message for tap mode. POST /api/auth/login {client: "waiter"}; a miss
  shows the translated error without a reload.
- POST /api/auth/login-by-id removed; bootstrap login carries waiter_mode and
  waiter_require_username.
- Sign-out ends the session on the server (POST /api/auth/logout), so
  single_session_waiter = refuse_new no longer strands a waiter.
- Lock on the phone: menu "Lock", automatic lock / sign-out after inactivity
  (security.auto_lock*, auto_logout*), unlock with the PIN in the same session,
  lock kept across app restarts (restore() no longer clears it).
- e2e: new waiter.mjs (22 checks) in run-all; android.mjs signs in for real and
  locks/unlocks on the emulator; TLS live check waits for the socket; the
  rediscovery helper re-attaches to a stale WebView handle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 15:25:00 +02:00
co-authored by Claude Opus 5.5
parent 9f5498332a
commit 8299184e3a
14 changed files with 664 additions and 106 deletions
+22
View File
@@ -0,0 +1,22 @@
// What a phone does after a while without a touch (plan step 4.2). Pure: unit-tested
// (tests/idle.test.mjs). Settings (venue): security.auto_lock + security.auto_lock_seconds,
// security.auto_logout + security.auto_logout_seconds — the same ones the manager follows.
/** settings: the GET /api/settings/ map. → { lockMs, logoutMs } (Infinity = never). */
export function idleLimits(settings) {
const get = (k, d) => settings?.[k]?.value ?? d
const secs = (on, k, d) => {
if (get(on, 'false') !== 'true') return Infinity
const n = parseInt(get(k, d), 10)
return Number.isFinite(n) && n > 0 ? n * 1000 : Infinity
}
return { lockMs: secs('security.auto_lock', 'security.auto_lock_seconds', '300'),
logoutMs: secs('security.auto_logout', 'security.auto_logout_seconds', '1800') }
}
/** 'logout' | 'lock' | null for this much idle time. Signing out wins over locking. */
export function idleAction(idleMs, { lockMs, logoutMs }, locked) {
if (idleMs >= logoutMs) return 'logout'
if (!locked && idleMs >= lockMs) return 'lock'
return null
}