feat(waiter): native app runs each venue's own UI bundle (self-hosted updater)
@capgo/capacitor-updater (MPL-2.0) in manual mode: autoUpdate off, stats/update/channel URLs empty (nothing contacts Capgo), appReadyTimeout 15s (auto rollback), resetWhenUpdate (APK update → built-in bundle, venue bundle re-fetched), autoDeletePrevious off (we keep one per venue). src/native/bundles.js syncVenueBundle(): - manifest fetched over the pinned TLS link; zip downloaded natively over the LAN HTTP port with the MANDATORY sha256 check - a tampered zip never runs - applied at once only when nobody is mid-service (after pairing / venue switch, or no one logged in); otherwise staged with next() → applied at the next background/restart; never a mid-service reload - APK too old for the bundle (min_shell_build) → skipped + update banner linking to the venue's /downloads/xenia-waiter.apk - a rolled-back version is blocklisted (attempt tracking + grace window) - without it the app re-applied the still-advertised broken bundle in a loop - server without bundles (404) → built-in UI; bundles no venue needs deleted BundleSync: notifyAppReady on start; sync at start, on resume, every 30 min. saveVenue merges fields (bundleVersion); switchVenue flags immediate apply. E2E (emulator vs two isolated venue stacks): fresh pairing applies the venue bundle and it stays healthy; logged-in update staged, applied after background, session kept; tampered zip refused; shell-too-old banner; broken bundle rolled back automatically and not retried (80s + resume); two venues each run their own bundle, round trips served from cache with 0 downloads, stale bundles cleaned; no *.capgo.app traffic. Step 5/7-era rediscovery + cold-start suites and web modes still pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
const VENUES_KEY = 'xenia.venues'
|
||||
export const APPLY_BUNDLE_NOW_KEY = 'xenia.applyBundleNow'
|
||||
|
||||
function normalizeBaseUrl(url) {
|
||||
const trimmed = String(url || '').trim().replace(/\/+$/, '')
|
||||
@@ -122,17 +123,21 @@ export function deliveryMode() {
|
||||
// ── Writing (used by pairing / venue switcher in the native app) ─────────────
|
||||
|
||||
/**
|
||||
* Add or update a paired venue without switching to it.
|
||||
* Add or update a paired venue without switching to it. Fields not passed are
|
||||
* kept (e.g. `bundleVersion`, remembered by src/native/bundles.js).
|
||||
* `spki` = the server's TLS public-key pin (native app, plan step 7).
|
||||
*/
|
||||
export function saveVenue({ siteId, name, baseUrl, spki }) {
|
||||
export function saveVenue({ siteId, name, baseUrl, spki, bundleVersion }) {
|
||||
if (!siteId) throw new Error('saveVenue: siteId is required')
|
||||
const state = readState()
|
||||
const prev = state.venues[siteId] || {}
|
||||
state.venues[siteId] = {
|
||||
...prev,
|
||||
siteId,
|
||||
name: name || siteId,
|
||||
baseUrl: normalizeBaseUrl(baseUrl),
|
||||
name: name || prev.name || siteId,
|
||||
baseUrl: normalizeBaseUrl(baseUrl || prev.baseUrl),
|
||||
...(spki ? { spki } : {}),
|
||||
...(bundleVersion ? { bundleVersion } : {}),
|
||||
}
|
||||
writeState(state)
|
||||
return state.venues[siteId]
|
||||
@@ -144,6 +149,13 @@ export function switchVenue(siteId) {
|
||||
if (!state.venues[siteId]) throw new Error(`switchVenue: unknown venue ${siteId}`)
|
||||
state.active = siteId
|
||||
writeState(state)
|
||||
// Nobody is mid-service right after a switch: the venue's own UI bundle may be
|
||||
// applied immediately on the next start (src/native/bundles.js)
|
||||
try {
|
||||
sessionStorage.setItem(APPLY_BUNDLE_NOW_KEY, '1')
|
||||
} catch {
|
||||
// storage unavailable — the bundle is then applied at the next background/restart
|
||||
}
|
||||
window.location.replace('/')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user