Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
Guestbook: on-demand owner-deck builder for moderation
nyblnet55fa7090bf73
diff --git a/scripts/guestbook-owner-deck.mjs b/scripts/guestbook-owner-deck.mjsnew file mode 100644index 00000000..86f03ec7--- /dev/null+++ b/scripts/guestbook-owner-deck.mjs@@ -0,0 +1,55 @@+#!/usr/bin/env node+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento/Suite authors+// Build an OWNER deck for the CURRENT live guestbook epoch, on demand — open it+// to moderate (People panel → Remove). The daemon mints epochs server-side and+// stashes the owner key in KV; this fetches it (admin-gated) and splices it into+// the live public deck.+//+// LAUNCH NOTE: with the daemon auto-rolling every 15 min, an owner deck is valid+// only until the next roll — after that the room it moderates is orphaned. Just+// re-run this to get a deck for the new epoch. (At that cadence spam auto-clears+// anyway, so you rarely need this.)+//+// node scripts/guestbook-owner-deck.mjs [--base <url>] [--out <file>]+//+// Auth: Bearer key in working/guestbook-admin-key.txt (gitignored).++import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'+import { dirname, join } from 'node:path'+import { fileURLToPath } from 'node:url'+import { extractDoc, spliceDoc } from './guestbook-deck.mjs'++const root = dirname(dirname(fileURLToPath(import.meta.url)))+const args = process.argv.slice(2)+const opt = (n, fb) => { const i = args.indexOf(`--${n}`); return i >= 0 && args[i + 1] ? args[i + 1] : fb }+const base = opt('base', 'https://bento.page').replace(/\/$/, '')+const out = opt('out', join(root, 'working/guestbook-live/guestbook-owner-live.bento.html'))++const keyFile = join(root, 'working/guestbook-admin-key.txt')+if (!existsSync(keyFile)) { console.error('no admin key at working/guestbook-admin-key.txt'); process.exit(1) }+const adminKey = readFileSync(keyFile, 'utf8').trim()++// Owner creds and the public deck are two fetches; if a roll lands between them+// the rooms won't match — retry a few times.+async function attempt() {+ const credRes = await fetch(`${base}/guestbook-admin/owner`, { headers: { Authorization: `Bearer ${adminKey}` } })+ if (!credRes.ok) throw new Error(`owner creds → ${credRes.status}: ${(await credRes.text()).slice(0, 200)}`)+ const creds = await credRes.json()+ const publicHtml = await (await fetch(`${base}/guestbook.bento.html?cb=${Date.now()}`, { cache: 'no-store' })).text()+ const doc = extractDoc(publicHtml)+ if (doc.collab?.room !== creds.room) return null // rolled between the two fetches+ // owner collab: same room + read key, carrying ownerPriv; no public invite+ doc.collab = { room: creds.room, key: creds.key, on: true, v: 2, owner: creds.owner, ownerPriv: creds.ownerPriv }+ return { html: spliceDoc(publicHtml, doc), epoch: creds.epoch, room: creds.room }+}++let built = null+for (let i = 0; i < 4 && !built; i++) built = await attempt()+if (!built) { console.error('the epoch kept rolling mid-build — run it again'); process.exit(2) }++mkdirSync(dirname(out), { recursive: true })+writeFileSync(out, built.html)+console.log(`✓ owner deck for epoch ${built.epoch} → ${out}`)+console.log(` room: …${built.room.slice(-16)}`)+console.log(' open it in Chrome → People panel → Remove. Valid ONLY until the next 15-min roll.')diff --git a/server/guestbook-daemon/src/worker.js b/server/guestbook-daemon/src/worker.jsindex 303f0a41..be428443 100644--- a/server/guestbook-daemon/src/worker.js+++ b/server/guestbook-daemon/src/worker.js@@ -215,6 +215,14 @@ export default {const list = await env.STORE.list({ prefix: 'archives/' })return json({ ...m, archives: list.keys.map((k) => k.name) })}+ if (action === 'owner') {+ // The current epoch's OWNER credentials (incl. ownerPriv) — for+ // building a moderation deck on demand. Gated by ADMIN_KEY above; the+ // owner key never appears in the public deck. See scripts/guestbook-owner-deck.mjs.+ const raw = await env.STORE.get('owner/current', 'text')+ if (!raw) return json({ error: 'no owner creds stashed yet — roll once first' }, 404)+ return new Response(raw, { headers: { 'content-type': 'application/json' } })+ }if (action === 'snapshot' && req.method === 'POST') return json(await snapshot(env))if (action === 'roll' && req.method === 'POST') return json(await roll(env))if (action === 'kill' && req.method === 'POST') {@@ -246,7 +254,7 @@ export default {if (!obj) return json({ error: 'not found' }, 404)return new Response(obj, { headers: { 'content-type': 'text/html; charset=utf-8' } })}- return json({ error: 'unknown action', actions: ['status', 'POST snapshot', 'POST roll', 'POST kill', 'PUT seed', 'archives/<key>'] }, 404)+ return json({ error: 'unknown action', actions: ['status', 'owner', 'POST snapshot', 'POST roll', 'POST kill', 'PUT seed', 'archives/<key>'] }, 404)} catch (e) {return json({ error: String(e) }, 500)}