Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
guestbook: v2 owner-moderated room
nyblnet829702803afd
diff --git a/scripts/build-guestbook.mjs b/scripts/build-guestbook.mjsindex f5ea4ec5..1f3b8479 100644--- a/scripts/build-guestbook.mjs+++ b/scripts/build-guestbook.mjs@@ -34,7 +34,34 @@ const font = (n) => fontSrc.match(new RegExp(`export const ${n}\\s*=\\s*'(data:[const b64u = (bytes) => Buffer.from(bytes).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')const rnd = (n) => { const b = new Uint8Array(n); crypto.getRandomValues(b); return b }-const collab = { room: `${host}/d/r${b64u(rnd(12))}`, key: b64u(rnd(32)), on: true }++// v2 room (fine-grained): the room commits to an OWNER key (moderation — the+// owner can remove a vandal's device key from the People panel), and the PUBLIC+// deck carries an owner-signed INVITE so anyone who opens it can write. The+// owner's private key never enters the public file — it lands in a separate+// gitignored owner deck next to the admin token. Rolls are MANUAL now+// (daemon ROLL_HOURS=0): a re-mint would invalidate the held owner file.+const EC = { name: 'ECDSA', namedCurve: 'P-256' }+const SIG = { name: 'ECDSA', hash: 'SHA-256' }+const keypair = async () => {+ const kp = await crypto.subtle.generateKey(EC, true, ['sign', 'verify'])+ return {+ pub: b64u(new Uint8Array(await crypto.subtle.exportKey('raw', kp.publicKey))),+ priv: b64u(new Uint8Array(await crypto.subtle.exportKey('pkcs8', kp.privateKey))),+ key: kp.privateKey,+ }+}+const ownerKp = await keypair()+const inviteKp = await keypair()+const inviteSig = b64u(new Uint8Array(await crypto.subtle.sign(+ SIG, ownerKp.key, new TextEncoder().encode(`inv.${inviteKp.pub}.writer.0`))))+const commit = b64u(new Uint8Array(await crypto.subtle.digest('SHA-256', Buffer.from(ownerKp.pub, 'base64url'))))+const readKey = b64u(rnd(32))+const collab = {+ room: `${host}/d/w${commit}`, key: readKey, on: true, v: 2, owner: ownerKp.pub,+ invite: { pub: inviteKp.pub, priv: inviteKp.priv, role: 'writer', sig: inviteSig },+}+const ownerCollab = { room: collab.room, key: readKey, on: true, v: 2, owner: ownerKp.pub, ownerPriv: ownerKp.priv }let epoch = 1if (existsSync(out)) {@@ -56,7 +83,16 @@ const doc = buildGuestbookDoc({const spliced = spliceDoc(shell, doc)mkdirSync(dirname(out), { recursive: true })writeFileSync(out, spliced)++// the OWNER deck: same document, owner credentials — open THIS file to+// moderate (People panel → Remove). Keep it with the admin token; never public.+const ownerOut = join(dirname(out), 'guestbook-owner.bento.html')+writeFileSync(ownerOut, spliceDoc(shell, { ...doc, collab: ownerCollab }))+writeFileSync(join(dirname(out), 'guestbook-owner-keys.json'),+ JSON.stringify({ epoch, room: collab.room, key: readKey, owner: ownerKp.pub, ownerPriv: ownerKp.priv, invitePub: inviteKp.pub }, null, 2))+console.log(`guestbook epoch ${epoch} → ${out} (${Math.round(spliced.length / 1024)} KB)`)-console.log(`room: ${collab.room}`)+console.log(`owner deck → ${ownerOut}`)+console.log(`room: ${collab.room} (v2, owner-moderated)`)console.log('note: the Cloudflare daemon (server/guestbook-daemon) is authoritative once seeded —')console.log(' seed it via PUT /guestbook-admin/seed after building locally')diff --git a/server/guestbook-daemon/wrangler.toml b/server/guestbook-daemon/wrangler.tomlindex 9a607e48..6fd3c3c7 100644--- a/server/guestbook-daemon/wrangler.toml+++ b/server/guestbook-daemon/wrangler.toml@@ -29,7 +29,7 @@ SYNC_HOST = "wss://sync.bento.page"# 24 = daily roll (the archivist cron fires daily at 01:00 UTC, so sub-24 is a# no-op). Daily during launch to cap spam exposure on the unmoderated wall;# relax to 168 (weekly) once traffic settles.-ROLL_HOURS = "24"+ROLL_HOURS = "0"# secrets (set with `npx wrangler secret put ADMIN_KEY`):# ADMIN_KEY — bearer for /guestbook-admin/*