Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Release 1.2.10 (#841)

nyblnetfa9eb4d32220
diff --git a/.github/actions/validate-kernel/action.yml b/.github/actions/validate-kernel/action.yml
index a3f91ddb..01574f28 100644
--- a/.github/actions/validate-kernel/action.yml
+++ b/.github/actions/validate-kernel/action.yml
@@ -494,6 +494,15 @@ runs:
shell: bento-step {0}
run: node --no-warnings scripts/test-sync-session.ts
+ - name: the blob cache holds ciphertext only
+ # Live-session media is cached in IndexedDB, which every page on the
+ # same origin can read (on file://, every local file). The cache must
+ # hold the relay's ciphertext, never the decrypted bytes: every write
+ # path, a hit, a tampered entry, the version-1 purge, the shipped v1
+ # opener against an upgraded database, and a blocked upgrade.
+ shell: bento-step {0}
+ run: node --no-warnings scripts/test-blobcache.ts
+
- name: Room snapshot carries no capability fields
# Every snapshot path (relay upload, fork broadcast, re-snap, flush-time
# fork snap) builds from one helper that strips the never-synced fields.
diff --git a/.github/workflows/ci-slides.yml b/.github/workflows/ci-slides.yml
index bca3a171..a4136b41 100644
--- a/.github/workflows/ci-slides.yml
+++ b/.github/workflows/ci-slides.yml
@@ -28,6 +28,34 @@ defaults:
shell: bash scripts/ci/bento-step {0}
jobs:
+ # Its own job: ten spellings across every surface is several minutes, and it
+ # runs in parallel with the main browser job rather than against its timeout.
+ slides-egress-browser:
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 24
+ - name: Install browser test runtime
+ # Pinned outside app packages: browser automation is not shipped in documents.
+ run: |
+ npm install --prefix "$RUNNER_TEMP/bento-browser" --no-package-lock --ignore-scripts [email protected]
+ "$RUNNER_TEMP/bento-browser/node_modules/.bin/playwright" install --with-deps chromium
+ echo "PLAYWRIGHT_MODULE=$RUNNER_TEMP/bento-browser/node_modules/playwright/index.mjs" >> "$GITHUB_ENV"
+ - name: Build the packaged document
+ run: |
+ npm ci --prefix slides
+ npm run build:single --prefix slides
+ - name: No document string makes slides fetch anything in Chromium
+ # Every string field of every element kind, the slide and the theme, in
+ # ten url() spellings (escaped ones included), plus a morph into payload
+ # paint, the preview's lower tiers and a peer's presence colour: on every
+ # surface (canvas, panels, present, speaker, print, the saved file with
+ # JS off) the payload origin is never requested; a raw url() is.
+ run: node scripts/test-slides-css-egress-browser.mjs
+
slides-font-browser:
runs-on: ubuntu-latest
timeout-minutes: 15
@@ -82,6 +110,12 @@ jobs:
# a deck sealed by identity; the password menu stays keyed to the
# password; the unsealed control shows the scan sees a leak.
run: node scripts/test-slides-sealed-guards-browser.mjs
+ - name: A sealed deck's title stays out of window titles in Chromium
+ # At the gate, after unlock, after an edit, and in the speaker window;
+ # adding a password neutralises the tab before the save, and removing
+ # it brings the title back (an unencrypted deck is the control); a deck
+ # sealed by identity, on the build:sealtest shell above, too.
+ run: node scripts/test-slides-sealed-title-browser.mjs
- name: Exercise the packaged documents in Chromium
# Real UI and serialization, offline; delayed mock writes expose save races.
run: |
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 066721ac..5ade0dde 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,31 @@ pre-1.0.
## [Unreleased]
+## [1.2.10] — 2026-10-24
+
+- **Code can type itself out.** Give a code block the new Typewriter effect
+ (Presenting panel) and, in the show, its code appears character by character
+ behind a moving cursor. Morphing from one code slide to the next keeps the
+ lines that stay and types only the new ones. A long snippet types faster, so
+ no block takes more than six seconds, and reduced motion (M) shows it all at
+ once. Thanks to tikurahul.
+- **Saving a large deck is faster.** Saving no longer rebuilds the file's
+ thumbnail preview from scratch when a slide's images are too big for it, and
+ does its bookkeeping after the file is written rather than before. On a deck
+ with large images, a save took about a third of the time in our tests.
+ Thanks to tikurahul.
+- **A new document saves where it was created.** A document made with New in
+ the Bento app on iPhone, iPad or Android, or in installed Bento, saved its
+ first changes into a second file and left the one you created empty. Its
+ first save now writes to that file.
+- **Clicking a slide no longer makes the slide list jump.** In a long deck,
+ clicking a thumbnail could scroll the list so a different slide ended up
+ under the pointer. The list now only scrolls when it needs to bring the
+ current slide into view.
+- **Security: update this file. This release closes issues found in our own
+ review.** What they were is described here once people have had time to
+ update.
+
## [1.2.9] — 2026-10-17
- **Password-protected decks open again.** Since 1.2.0, a deck saved with a
diff --git a/kernel/src/sync/blobs.ts b/kernel/src/sync/blobs.ts
index dd7fd642..e30a5f4a 100644
--- a/kernel/src/sync/blobs.ts
+++ b/kernel/src/sync/blobs.ts
@@ -171,8 +171,20 @@ export async function decodeBlob(rawRoomKey: Uint8Array, blob: Uint8Array): Prom
// A blob a peer sent is worth keeping: the same asset is referenced by every
// slide that uses it, and re-fetching on each render would be absurd. Keyed by
// the blob key, which is already content-addressed.
+//
+// The cache holds the ENCRYPTED blob (the encodeBlob layout), never plaintext.
+// IndexedDB is per-origin, and on file:// every local page shares one origin, so
+// anything written here is readable by any other local HTML file. Ciphertext is
+// useless without the room key, which lives only in the document; a hit is
+// decrypted and address-checked exactly like a fetch.
+//
+// Version 2 is the ciphertext store. Upgrading from 1 DROPS the old store,
+// which held plaintext. It also shuts the old code out: a runtime that still
+// opens version 1 gets a VersionError against this database and runs with no
+// cache at all, so it cannot write plaintext here again.
const DB = 'bento-blobcache'
+const DB_VERSION = 2
const STORE = 'blobs'
let dbP: Promise<IDBDatabase | null> | null = null
@@ -181,13 +193,27 @@ function db(): Promise<IDBDatabase | null> {
dbP = new Promise((resolve) => {
if (typeof indexedDB === 'undefined') return resolve(null)
let req: IDBOpenDBRequest
- try { req = indexedDB.open(DB, 1) } catch { return resolve(null) }
- req.onupgradeneeded = () => {
+ try { req = indexedDB.open(DB, DB_VERSION) } catch { return resolve(null) }
+ req.onupgradeneeded = (ev) => {
const d = req.result
+ // a version-1 store holds plaintext: drop it, never migrate it
+ if (ev.oldVersion < 2 && d.objectStoreNames.contains(STORE)) d.deleteObjectStore(STORE)
if (!d.objectStoreNames.contains(STORE)) d.createObjectStore(STORE)
}
- req.onsuccess = () => resolve(req.result)
- req.onerror = () => resolve(null)
+ // Another tab of an older runtime may still hold a version-1 connection; the
+ // upgrade then waits until that tab closes, and older code never closes on
+ // versionchange. Don't wait with it — run uncached now. The request stays
+ // pending, so the purge above still happens once that tab goes away.
+ let settled = false
+ const done = (d: IDBDatabase | null) => { if (!settled) { settled = true; resolve(d) } else d?.close() }
+ req.onblocked = () => done(null)
+ req.onsuccess = () => {
+ const d = req.result
+ // and never be the old connection that blocks a later upgrade ourselves
+ d.onversionchange = () => d.close()
+ done(d)
+ }
+ req.onerror = () => done(null)
})
return dbP
}
@@ -204,6 +230,8 @@ export async function cacheGet(key: string): Promise<Uint8Array | null> {
})
}
+/** Store ENCRYPTED bytes (encodeBlob's output) under their address. Never pass
+ * plaintext: this store is readable by every page on the same origin. */
export async function cachePut(key: string, bytes: Uint8Array): Promise<void> {
const d = await db()
if (!d) return
@@ -243,7 +271,9 @@ export async function putBlob(e: BlobEndpoint, rawRoomKey: Uint8Array, bytes: Ui
try {
const head = await netFetch(url(e, key), { method: 'HEAD' })
if (head.status === 200) {
- void cachePut(key, bytes)
+ // The cache holds ciphertext only. Encrypting here costs one AES pass and
+ // saves this tab a refetch; it runs off the return path.
+ void encodeBlob(rawRoomKey, bytes).then((enc) => cachePut(key, enc), () => {})
return { ok: true, key, deduped: true }
}
if (head.status === 501) return { ok: false, reason: 'unsupported' }
@@ -260,7 +290,7 @@ export async function putBlob(e: BlobEndpoint, rawRoomKey: Uint8Array, bytes: Ui
// until it expires — the caller must not retry in a loop.
if (res.status === 507) return { ok: false, reason: 'room-full' }
if (!res.ok) return { ok: false, reason: 'network' }
- void cachePut(key, bytes)
+ void cachePut(key, body) // the encrypted bytes we just uploaded, never `bytes`
return { ok: true, key, deduped: false }
} catch {
return { ok: false, reason: 'network' }
@@ -269,8 +299,9 @@ export async function putBlob(e: BlobEndpoint, rawRoomKey: Uint8Array, bytes: Ui
/** Does `plain` actually hash to the address we asked for? One SHA-256 plus
* one HMAC over bytes we have just decrypted anyway — negligible beside the
- * AES-GCM pass that produced them, and it runs once per fetch, not per use
- * (the cache is keyed by the same address). */
+ * AES-GCM pass that produced them. It runs on every fetch and on every cache
+ * hit (a hit is ciphertext, decrypted first), not on every use: callers keep
+ * the decrypted bytes for the session. */
async function addressMatches(rawRoomKey: Uint8Array, key: string, plain: Uint8Array): Promise<boolean> {
return (await blobKey(rawRoomKey, plain)) === key
}
@@ -282,15 +313,19 @@ async function addressMatches(rawRoomKey: Uint8Array, key: string, plain: Uint8A
export async function getBlob(e: BlobEndpoint, rawRoomKey: Uint8Array, key: string): Promise<Uint8Array | null> {
const hit = await cacheGet(key)
try {
- // The hit is checked as well, so a cache written before this verification
- // existed (or edited under us in IndexedDB) heals: falling through re-fetches
- // and cachePut, keyed by the address, overwrites the bad entry.
+ // A hit is ciphertext: decrypt it and check its address exactly as a fetch
+ // would. Anything that fails — a wrong key, a tampered or truncated entry,
+ // a wrong-address swap — falls through to the refetch, and cachePut, keyed
+ // by the address, overwrites the bad entry, so the cache heals.
// INSIDE the try like the post-fetch check below: addressMatches can throw
// (measured — crypto.subtle.importKey('raw', new Uint8Array(0), HMAC) rejects
// with DataError on an empty room key), and the contract above promises null,
// not a rejection. session.resolveBlobs has try/finally and no catch, so a
// throw here escapes as an unhandled rejection.
- if (hit && await addressMatches(rawRoomKey, key, hit)) return hit
+ if (hit) {
+ const fromCache = await decodeBlob(rawRoomKey, hit)
+ if (fromCache && await addressMatches(rawRoomKey, key, fromCache)) return fromCache
+ }
const res = await netFetch(url(e, key))
if (!res.ok) return null
const enc = new Uint8Array(await res.arrayBuffer())
@@ -303,7 +338,7 @@ export async function getBlob(e: BlobEndpoint, rawRoomKey: Uint8Array, key: stri
// cachePut writes the swap to disk permanently. The address is the only
// binding between reference and content, so verify it before both.
if (!await addressMatches(rawRoomKey, key, plain)) return null
- void cachePut(key, plain)
+ void cachePut(key, enc) // the ciphertext as fetched — never the decrypted bytes
return plain
} catch {
return null
diff --git a/schema/slides-1.2.10.json b/schema/slides-1.2.10.json
new file mode 100644
index 00000000..d769aa6b
--- /dev/null
+++ b/schema/slides-1.2.10.json
@@ -0,0 +1,2388 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://bento.page/schema/slides.json",
+ "title": "bento/slides document",
+ "description": "The #bento-doc JSON of a Bento Slides file, generated from the app's validation tables. Guide: https://bento.page/agents.md",
+ "x-bento-version": "1.2.10",
+ "$ref": "#/$defs/doc",
+ "$defs": {
+ "prop-fx": {
+ "type": "object",
+ "properties": {
+ "ambient": {
+ "type": "string",
+ "enum": [
+ "kenburns"
+ ]
+ },
+ "countUp": {
+ "type": "boolean"
+ },
+ "enter": {
+ "type": "string",
+ "enum": [
+ "fade-up",
+ "fade",
+ "fade-down",
+ "slide-left",
+ "slide-right",
+ "slide-up",
+ "slide-down"
+ ]
+ },
+ "enterDur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 600
+ },
+ "ken": {
+ "type": "object",
+ "properties": {
+ "dir": {
+ "type": "string",
+ "enum": [
+ "drift",
+ "out",
+ "in"
+ ]
+ },
+ "duration": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 3600
+ },
+ "scale": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 100
+ }
+ },
+ "additionalProperties": false
+ },
+ "loop": {
+ "type": "object",
+ "properties": {
+ "delay": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 3600
+ },
+ "distance": {
+ "type": "number",
+ "minimum": -100000,
+ "maximum": 100000
+ },
+ "duration": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 3600
+ },
+ "ease": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "path": {
+ "type": "string",
+ "maxLength": 65536,
+ "description": "SVG path data"
+ },
+ "speeds": {
+ "type": "array",
+ "maxItems": 2000,
+ "items": {
+ "type": "number",
+ "minimum": 0.001,
+ "maximum": 1000
+ }
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "dash-march",
+ "motion-path"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type"
+ ]
+ },
+ "order": {
+ "type": "number",
+ "minimum": -10000,
+ "maximum": 10000
+ },
+ "step": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 10000
+ },
+ "typeWriter": {
+ "type": "boolean"
+ }
+ },
+ "additionalProperties": false
+ },
+ "prop-shadow": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 10000
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "x": {
+ "type": "number",
+ "minimum": -10000,
+ "maximum": 10000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -10000,
+ "maximum": 10000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "blur",
+ "color"
+ ]
+ },
+ {
+ "type": "array",
+ "maxItems": 16,
+ "items": {
+ "type": "object",
+ "properties": {
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 10000
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "x": {
+ "type": "number",
+ "minimum": -10000,
+ "maximum": 10000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -10000,
+ "maximum": 10000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "blur",
+ "color"
+ ]
+ }
+ }
+ ]
+ },
+ "prop-colorGradient": {
+ "type": "object",
+ "properties": {
+ "angle": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "stops": {
+ "type": "array",
+ "maxItems": 64,
+ "items": {
+ "type": "object",
+ "properties": {
+ "at": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "at",
+ "color"
+ ]
+ }
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "stops"
+ ]
+ },
+ "prop-themeRefs": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ },
+ "maxProperties": 64,
+ "description": "property path → palette token"
+ },
+ "prop-textStroke": {
+ "type": "object",
+ "properties": {
+ "width": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "fill": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "width",
+ "color"
+ ]
+ },
+ "prop-link": {
+ "type": "string",
+ "maxLength": 4000,
+ "description": "slide id or http(s) URL"
+ },
+ "text": {
+ "type": "object",
+ "properties": {
+ "align": {
+ "type": "string",
+ "enum": [
+ "left",
+ "center",
+ "right"
+ ]
+ },
+ "backdropFilter": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "blend": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "colorGradient": {
+ "$ref": "#/$defs/prop-colorGradient"
+ },
+ "fontFamily": {
+ "type": "string",
+ "maxLength": 300
+ },
+ "fontSize": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 4000
+ },
+ "fontWeight": {
+ "type": "number",
+ "minimum": 1,
+ "maximum": 1000
+ },
+ "fx": {
+ "$ref": "#/$defs/prop-fx"
+ },
+ "group": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "groupId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "h": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "html": {
+ "type": "string",
+ "maxLength": 65536
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "letterSpacing": {
+ "type": "number",
+ "minimum": -1000,
+ "maximum": 1000
+ },
+ "lineHeight": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 100
+ },
+ "link": {
+ "$ref": "#/$defs/prop-link"
+ },
+ "morphId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "opacity": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "placeholder": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "role": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "rotation": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "shadow": {
+ "$ref": "#/$defs/prop-shadow"
+ },
+ "showOnHover": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "textStroke": {
+ "$ref": "#/$defs/prop-textStroke"
+ },
+ "themeRefs": {
+ "$ref": "#/$defs/prop-themeRefs"
+ },
+ "type": {
+ "const": "text"
+ },
+ "valign": {
+ "type": "string",
+ "enum": [
+ "top",
+ "middle",
+ "bottom"
+ ]
+ },
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "id",
+ "html"
+ ],
+ "description": "text element; x/y/w/h in slide px (1280×720 default); a stable id pairs morphs"
+ },
+ "prop-fillGradient": {
+ "type": "object",
+ "properties": {
+ "angle": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "stops": {
+ "type": "array",
+ "maxItems": 64,
+ "items": {
+ "type": "object",
+ "properties": {
+ "at": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "at",
+ "color"
+ ]
+ }
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "stops"
+ ]
+ },
+ "prop-from": {
+ "type": "object",
+ "properties": {
+ "el": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "side": {
+ "type": "string",
+ "enum": [
+ "auto",
+ "top",
+ "right",
+ "bottom",
+ "left"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "el"
+ ]
+ },
+ "prop-to": {
+ "type": "object",
+ "properties": {
+ "el": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "side": {
+ "type": "string",
+ "enum": [
+ "auto",
+ "top",
+ "right",
+ "bottom",
+ "left"
+ ]
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "el"
+ ]
+ },
+ "shape": {
+ "type": "object",
+ "properties": {
+ "backdropFilter": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "blend": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "d": {
+ "type": "string",
+ "maxLength": 65536,
+ "description": "SVG path data"
+ },
+ "fill": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour or url(#local-id)"
+ },
+ "fillGradient": {
+ "$ref": "#/$defs/prop-fillGradient"
+ },
+ "from": {
+ "$ref": "#/$defs/prop-from"
+ },
+ "fx": {
+ "$ref": "#/$defs/prop-fx"
+ },
+ "group": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "groupId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "h": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "heads": {
+ "type": "number",
+ "minimum": 2,
+ "maximum": 2
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "lineEnd": {
+ "type": "string",
+ "enum": [
+ "none",
+ "arrow",
+ "dot",
+ "bar",
+ "arrow-open",
+ "triangle",
+ "triangle-open",
+ "diamond",
+ "diamond-open",
+ "square",
+ "circle-open"
+ ]
+ },
+ "lineStart": {
+ "type": "string",
+ "enum": [
+ "none",
+ "arrow",
+ "dot",
+ "bar",
+ "arrow-open",
+ "triangle",
+ "triangle-open",
+ "diamond",
+ "diamond-open",
+ "square",
+ "circle-open"
+ ]
+ },
+ "link": {
+ "$ref": "#/$defs/prop-link"
+ },
+ "morphId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "opacity": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "pathBox": {
+ "type": "array",
+ "minItems": 4,
+ "maxItems": 4,
+ "items": {
+ "type": "number"
+ }
+ },
+ "radius": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 100000
+ },
+ "role": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "rotation": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "shadow": {
+ "$ref": "#/$defs/prop-shadow"
+ },
+ "shape": {
+ "type": "string",
+ "enum": [
+ "rect",
+ "ellipse",
+ "triangle",
+ "arrow",
+ "line",
+ "path"
+ ]
+ },
+ "showOnHover": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "stroke": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour or url(#local-id)"
+ },
+ "strokeDash": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 10000
+ },
+ "strokeStyle": {
+ "type": "string",
+ "enum": [
+ "solid",
+ "dashed",
+ "dotted"
+ ]
+ },
+ "strokeWidth": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 10000
+ },
+ "themeRefs": {
+ "$ref": "#/$defs/prop-themeRefs"
+ },
+ "to": {
+ "$ref": "#/$defs/prop-to"
+ },
+ "type": {
+ "const": "shape"
+ },
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "id",
+ "shape",
+ "fill"
+ ],
+ "description": "shape element; x/y/w/h in slide px (1280×720 default); a stable id pairs morphs"
+ },
+ "prop-crop": {
+ "type": "object",
+ "properties": {
+ "scale": {
+ "type": "number",
+ "minimum": 1,
+ "maximum": 64
+ },
+ "x": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "y": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "x",
+ "y",
+ "scale"
+ ]
+ },
+ "image": {
+ "type": "object",
+ "properties": {
+ "backdropFilter": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "blend": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "crop": {
+ "$ref": "#/$defs/prop-crop"
+ },
+ "fit": {
+ "type": "string",
+ "enum": [
+ "contain",
+ "cover",
+ "fill"
+ ]
+ },
+ "fx": {
+ "$ref": "#/$defs/prop-fx"
+ },
+ "group": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "groupId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "h": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "keepAspectRatio": {
+ "type": "boolean"
+ },
+ "link": {
+ "$ref": "#/$defs/prop-link"
+ },
+ "morphId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "opacity": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "radius": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 100000
+ },
+ "role": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "rotation": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "shadow": {
+ "$ref": "#/$defs/prop-shadow"
+ },
+ "showOnHover": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "src": {
+ "type": "string",
+ "maxLength": 33554432,
+ "description": "data: URI, asset:<key> or URL"
+ },
+ "themeRefs": {
+ "$ref": "#/$defs/prop-themeRefs"
+ },
+ "type": {
+ "const": "image"
+ },
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "id",
+ "src"
+ ],
+ "description": "image element; x/y/w/h in slide px (1280×720 default); a stable id pairs morphs"
+ },
+ "svg": {
+ "type": "object",
+ "properties": {
+ "asset": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "backdropFilter": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "blend": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "css": {
+ "type": "string",
+ "maxLength": 131072
+ },
+ "fx": {
+ "$ref": "#/$defs/prop-fx"
+ },
+ "group": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "groupId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "h": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "link": {
+ "$ref": "#/$defs/prop-link"
+ },
+ "markup": {
+ "type": "string",
+ "maxLength": 4194304
+ },
+ "morphId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "opacity": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "role": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "rotation": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "shadow": {
+ "$ref": "#/$defs/prop-shadow"
+ },
+ "showOnHover": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "themeRefs": {
+ "$ref": "#/$defs/prop-themeRefs"
+ },
+ "type": {
+ "const": "svg"
+ },
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "id"
+ ],
+ "description": "svg element; x/y/w/h in slide px (1280×720 default); a stable id pairs morphs"
+ },
+ "prop-source": {
+ "type": "object",
+ "properties": {
+ "tableId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "tableId"
+ ]
+ },
+ "prop-option": {
+ "type": "object",
+ "description": "ECharts-shaped option, plain JSON"
+ },
+ "chart": {
+ "type": "object",
+ "properties": {
+ "backdropFilter": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "blend": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "fx": {
+ "$ref": "#/$defs/prop-fx"
+ },
+ "group": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "groupId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "h": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "link": {
+ "$ref": "#/$defs/prop-link"
+ },
+ "morphId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "opacity": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "option": {
+ "$ref": "#/$defs/prop-option"
+ },
+ "preset": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "role": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "rotation": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "shadow": {
+ "$ref": "#/$defs/prop-shadow"
+ },
+ "showOnHover": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "source": {
+ "$ref": "#/$defs/prop-source"
+ },
+ "themeRefs": {
+ "$ref": "#/$defs/prop-themeRefs"
+ },
+ "type": {
+ "const": "chart"
+ },
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "id",
+ "option"
+ ],
+ "description": "chart element; x/y/w/h in slide px (1280×720 default); a stable id pairs morphs"
+ },
+ "prop-style": {
+ "type": "object",
+ "properties": {
+ "borderColor": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "borderWidth": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "cellPadX": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "cellPadY": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "fontFamily": {
+ "type": "string",
+ "maxLength": 300
+ },
+ "fontSize": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 4000
+ },
+ "headerBg": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "headerColor": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "radius": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 100000
+ },
+ "zebra": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ }
+ },
+ "additionalProperties": false
+ },
+ "prop-rows": {
+ "type": "array",
+ "maxItems": 2000,
+ "items": {
+ "type": "object",
+ "properties": {
+ "cells": {
+ "type": "array",
+ "maxItems": 200,
+ "items": {
+ "type": "object",
+ "properties": {
+ "align": {
+ "type": "string",
+ "enum": [
+ "left",
+ "center",
+ "right"
+ ]
+ },
+ "bg": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "bold": {
+ "type": "boolean"
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "html": {
+ "type": "string",
+ "maxLength": 65536
+ }
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "cells"
+ ]
+ }
+ },
+ "prop-columns": {
+ "type": "array",
+ "maxItems": 200,
+ "items": {
+ "type": "object",
+ "properties": {
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "w"
+ ]
+ }
+ },
+ "table": {
+ "type": "object",
+ "properties": {
+ "backdropFilter": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "blend": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "columns": {
+ "$ref": "#/$defs/prop-columns"
+ },
+ "fx": {
+ "$ref": "#/$defs/prop-fx"
+ },
+ "group": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "groupId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "h": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "header": {
+ "type": "boolean"
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "link": {
+ "$ref": "#/$defs/prop-link"
+ },
+ "morphId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "opacity": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "role": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "rotation": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "rows": {
+ "$ref": "#/$defs/prop-rows"
+ },
+ "shadow": {
+ "$ref": "#/$defs/prop-shadow"
+ },
+ "showOnHover": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "style": {
+ "$ref": "#/$defs/prop-style"
+ },
+ "themeRefs": {
+ "$ref": "#/$defs/prop-themeRefs"
+ },
+ "type": {
+ "const": "table"
+ },
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "id",
+ "columns",
+ "rows"
+ ],
+ "description": "table element; x/y/w/h in slide px (1280×720 default); a stable id pairs morphs"
+ },
+ "media": {
+ "type": "object",
+ "properties": {
+ "autoplay": {
+ "type": "boolean"
+ },
+ "backdropFilter": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "blend": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "controls": {
+ "type": "boolean"
+ },
+ "fit": {
+ "type": "string",
+ "enum": [
+ "contain",
+ "cover",
+ "fill"
+ ]
+ },
+ "fx": {
+ "$ref": "#/$defs/prop-fx"
+ },
+ "group": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "groupId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "h": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "kind": {
+ "type": "string",
+ "enum": [
+ "video",
+ "audio"
+ ]
+ },
+ "link": {
+ "$ref": "#/$defs/prop-link"
+ },
+ "loop": {
+ "type": "boolean"
+ },
+ "morphId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "muted": {
+ "type": "boolean"
+ },
+ "opacity": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "poster": {
+ "type": "string",
+ "maxLength": 33554432,
+ "description": "data: URI, asset:<key> or URL"
+ },
+ "radius": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 100000
+ },
+ "role": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "rotation": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "shadow": {
+ "$ref": "#/$defs/prop-shadow"
+ },
+ "showOnHover": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "src": {
+ "type": "string",
+ "maxLength": 33554432,
+ "description": "data: URI, asset:<key> or URL"
+ },
+ "themeRefs": {
+ "$ref": "#/$defs/prop-themeRefs"
+ },
+ "type": {
+ "const": "media"
+ },
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "id",
+ "kind",
+ "src"
+ ],
+ "description": "media element; x/y/w/h in slide px (1280×720 default); a stable id pairs morphs"
+ },
+ "prop-doc": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 200
+ },
+ {
+ "type": "object"
+ }
+ ]
+ },
+ "embed": {
+ "type": "object",
+ "properties": {
+ "app": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "backdropFilter": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "blend": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "doc": {
+ "$ref": "#/$defs/prop-doc"
+ },
+ "fx": {
+ "$ref": "#/$defs/prop-fx"
+ },
+ "group": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "groupId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "h": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "link": {
+ "$ref": "#/$defs/prop-link"
+ },
+ "live": {
+ "type": "boolean"
+ },
+ "morphId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "opacity": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "role": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "rotation": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "shadow": {
+ "$ref": "#/$defs/prop-shadow"
+ },
+ "showOnHover": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "themeRefs": {
+ "$ref": "#/$defs/prop-themeRefs"
+ },
+ "type": {
+ "const": "embed"
+ },
+ "url": {
+ "type": "string",
+ "maxLength": 4000,
+ "pattern": "^https?://"
+ },
+ "view": {
+ "type": "string",
+ "maxLength": 4194304
+ },
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "id"
+ ],
+ "description": "embed element; x/y/w/h in slide px (1280×720 default); a stable id pairs morphs"
+ },
+ "code": {
+ "type": "object",
+ "properties": {
+ "align": {
+ "type": "string",
+ "enum": [
+ "left",
+ "center",
+ "right"
+ ]
+ },
+ "backdropFilter": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "blend": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "blur": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "content": {
+ "type": "string",
+ "maxLength": 65536
+ },
+ "fontFamily": {
+ "type": "string",
+ "maxLength": 300
+ },
+ "fontSize": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 4000
+ },
+ "fx": {
+ "$ref": "#/$defs/prop-fx"
+ },
+ "grammarAssetId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "grammarName": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "group": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "groupId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "h": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "lineHeight": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 100
+ },
+ "link": {
+ "$ref": "#/$defs/prop-link"
+ },
+ "morphId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "opacity": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "role": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "rotation": {
+ "type": "number",
+ "minimum": -3600,
+ "maximum": 3600
+ },
+ "shadow": {
+ "$ref": "#/$defs/prop-shadow"
+ },
+ "showOnHover": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "themeAssetId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "themeName": {
+ "type": "string",
+ "maxLength": 64,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "themeRefs": {
+ "$ref": "#/$defs/prop-themeRefs"
+ },
+ "type": {
+ "const": "code"
+ },
+ "valign": {
+ "type": "string",
+ "enum": [
+ "top",
+ "middle",
+ "bottom"
+ ]
+ },
+ "w": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type",
+ "id"
+ ],
+ "description": "code element; x/y/w/h in slide px (1280×720 default); a stable id pairs morphs"
+ },
+ "element": {
+ "oneOf": [
+ {
+ "$ref": "#/$defs/text"
+ },
+ {
+ "$ref": "#/$defs/shape"
+ },
+ {
+ "$ref": "#/$defs/image"
+ },
+ {
+ "$ref": "#/$defs/svg"
+ },
+ {
+ "$ref": "#/$defs/chart"
+ },
+ {
+ "$ref": "#/$defs/table"
+ },
+ {
+ "$ref": "#/$defs/media"
+ },
+ {
+ "$ref": "#/$defs/embed"
+ },
+ {
+ "$ref": "#/$defs/code"
+ }
+ ]
+ },
+ "slide": {
+ "type": "object",
+ "properties": {
+ "background": {
+ "type": "string",
+ "maxLength": 200,
+ "description": "CSS colour; no url()"
+ },
+ "comments": {
+ "type": "array",
+ "maxItems": 500,
+ "items": {
+ "type": "object",
+ "properties": {
+ "at": {
+ "type": "string",
+ "maxLength": 200
+ },
+ "author": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "elementId": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "replies": {
+ "type": "array",
+ "maxItems": 500,
+ "items": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "author": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "text": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "at": {
+ "type": "string",
+ "maxLength": 200
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "resolved": {
+ "type": "boolean"
+ },
+ "text": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "x": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ },
+ "y": {
+ "type": "number",
+ "minimum": -1000000,
+ "maximum": 1000000
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "elements": {
+ "type": "array",
+ "maxItems": 5000,
+ "items": {
+ "$ref": "#/$defs/element"
+ }
+ },
+ "hidden": {
+ "type": "boolean"
+ },
+ "hover": {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "enum": [
+ "focus-group",
+ "reveal"
+ ]
+ },
+ "dim": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1
+ },
+ "default": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "type"
+ ]
+ },
+ "id": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "name": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "notes": {
+ "type": "string",
+ "maxLength": 65536
+ },
+ "stateOf": {
+ "type": "string",
+ "maxLength": 200,
+ "pattern": "^[^\"'<>{};]*$"
+ },
+ "themeRefs": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ },
+ "maxProperties": 64,
+ "description": "property path → palette token"
+ },
+ "transition": {
+ "type": "string",
+ "enum": [
+ "none",
+ "fade",
+ "slide",
+ "zoom",
+ "morph"
+ ]
+ },
+ "unnumbered": {
+ "type": "boolean"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "id"
+ ],
+ "description": "stateOf = hidden variant reached by a link; transition morph pairs same-id elements"
+ },
+ "tableStyle": {
+ "type": "object",
+ "properties": {
+ "borderColor": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "borderWidth": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "cellPadX": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "cellPadY": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 1000
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "fontFamily": {
+ "type": "string",
+ "maxLength": 300
+ },
+ "fontSize": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 4000
+ },
+ "headerBg": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "headerColor": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ },
+ "radius": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 100000
+ },
+ "zebra": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "CSS colour; no url()"
+ }
+ },
+ "additionalProperties": false
+ },
+ "theme": {
+ "type": "object",
+ "properties": {
+ "accent": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "accent colour"
+ },
+ "background": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "slide background"
+ },
+ "chartPalette": {
+ "type": "array",
+ "maxItems": 64,
+ "items": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "series colour"
+ }
+ },
+ "codePalette": {
+ "type": "object",
+ "properties": {
+ "a": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "token colour"
+ },
+ "c": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "token colour"
+ },
+ "d": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "token colour"
+ },
+ "f": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "token colour"
+ },
+ "k": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "token colour"
+ },
+ "n": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "token colour"
+ },
+ "p": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "token colour"
+ },
+ "s": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "token colour"
+ }
+ },
+ "additionalProperties": false
+ },
+ "color": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "body text colour"
+ },
+ "fontFamily": {
+ "type": "string",
+ "maxLength": 300,
+ "description": "CSS font-family stack for body text"
+ },
+ "headingFamily": {
+ "type": "string",
+ "maxLength": 300,
+ "description": "display face for headings; absent = fontFamily"
+ },
+ "palette": {
+ "type": "object",
+ "properties": {
+ "accent2": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "brand slot accent2"
+ },
+ "accent3": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "brand slot accent3"
+ },
+ "accent4": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "brand slot accent4"
+ },
+ "accent5": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "brand slot accent5"
+ },
+ "accent6": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "brand slot accent6"
+ },
+ "bg2": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "brand slot bg2"
+ },
+ "folHlink": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "brand slot folHlink"
+ },
+ "hlink": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "brand slot hlink"
+ },
+ "tx2": {
+ "type": "string",
+ "maxLength": 64,
+ "description": "brand slot tx2"
+ }
+ },
+ "additionalProperties": false
+ },
+ "table": {
+ "$ref": "#/$defs/tableStyle"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "background",
+ "color",
+ "accent",
+ "fontFamily"
+ ]
+ },
+ "doc": {
+ "type": "object",
+ "properties": {
+ "assets": {
+ "type": "object",
+ "maxProperties": 2000,
+ "additionalProperties": {
+ "type": "string",
+ "maxLength": 33554432
+ },
+ "description": "key → data: URI or svg, used as asset:<key>"
+ },
+ "blobs": {
+ "type": "object",
+ "description": "runtime-written"
+ },
+ "collab": {
+ "type": "object",
+ "description": "runtime-written credentials; never author"
+ },
+ "docId": {
+ "type": "string",
+ "maxLength": 200,
+ "description": "runtime-minted uuid; omit"
+ },
+ "fonts": {
+ "type": "array",
+ "maxItems": 2000,
+ "items": {
+ "type": "object",
+ "properties": {
+ "asset": {
+ "type": "string",
+ "maxLength": 200,
+ "description": "asset:<key> or builtin:<name>"
+ },
+ "family": {
+ "type": "string",
+ "maxLength": 300
+ },
+ "style": {
+ "type": "string",
+ "maxLength": 64
+ },
+ "weight": {
+ "type": "string",
+ "maxLength": 64
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "family",
+ "asset"
+ ]
+ }
+ },
+ "format": {
+ "const": "bento/slides"
+ },
+ "layouts": {
+ "type": "array",
+ "maxItems": 500,
+ "items": {
+ "$ref": "#/$defs/slide"
+ },
+ "description": "slide templates"
+ },
+ "meta": {
+ "type": "object",
+ "properties": {
+ "author": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "company": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "event": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "keywords": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "subject": {
+ "type": "string",
+ "maxLength": 4000
+ }
+ },
+ "additionalProperties": false
+ },
+ "modified": {
+ "type": "string",
+ "maxLength": 200,
+ "description": "runtime-written"
+ },
+ "present": {
+ "type": "object",
+ "properties": {
+ "controls": {
+ "type": "boolean"
+ },
+ "morphSeconds": {
+ "type": "number",
+ "minimum": 0,
+ "maximum": 60
+ },
+ "numberHidden": {
+ "type": "boolean"
+ },
+ "progress": {
+ "type": "boolean"
+ },
+ "slideNumber": {
+ "type": "boolean"
+ },
+ "typeWriterSeconds": {
+ "type": "number",
+ "minimum": 0.08,
+ "maximum": 1,
+ "description": "typewriter: seconds per character (absent = 0.08)"
+ }
+ },
+ "additionalProperties": false
+ },
+ "readonly": {
+ "type": "boolean",
+ "description": "presentation package"
+ },
+ "size": {
+ "type": "object",
+ "properties": {
+ "height": {
+ "type": "number",
+ "minimum": 1,
+ "maximum": 100000
+ },
+ "width": {
+ "type": "number",
+ "minimum": 1,
+ "maximum": 100000
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "width",
+ "height"
+ ]
+ },
+ "slides": {
+ "type": "array",
+ "minItems": 1,
+ "maxItems": 500,
+ "items": {
+ "$ref": "#/$defs/slide"
+ }
+ },
+ "template": {
+ "type": "boolean"
+ },
+ "theme": {
+ "$ref": "#/$defs/theme"
+ },
+ "title": {
+ "type": "string",
+ "maxLength": 4000
+ },
+ "version": {
+ "type": "integer",
+ "minimum": 1,
+ "description": "format version; this shell writes 1"
+ },
+ "$schema": {
+ "type": "string"
+ },
+ "compact": {
+ "const": true,
+ "description": "input only: omitted fields take editor defaults (AGENTS.md)"
+ }
+ },
+ "additionalProperties": false,
+ "required": [
+ "format",
+ "slides"
+ ]
+ }
+ }
+}
diff --git a/schema/slides.json b/schema/slides.json
index 8bca17e7..d769aa6b 100644
--- a/schema/slides.json
+++ b/schema/slides.json
@@ -3,7 +3,7 @@
"$id": "https://bento.page/schema/slides.json",
"title": "bento/slides document",
"description": "The #bento-doc JSON of a Bento Slides file, generated from the app's validation tables. Guide: https://bento.page/agents.md",
- "x-bento-version": "1.2.9",
+ "x-bento-version": "1.2.10",
"$ref": "#/$defs/doc",
"$defs": {
"prop-fx": {
diff --git a/scripts/test-blobcache.ts b/scripts/test-blobcache.ts
new file mode 100644
index 00000000..59f8ea3f
--- /dev/null
+++ b/scripts/test-blobcache.ts
@@ -0,0 +1,301 @@
+#!/usr/bin/env node
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// Blob cache rig: the IndexedDB cache holds ciphertext, never plaintext.
+//
+// node scripts/test-blobcache.ts (Node ≥ 23.6; fake-indexeddb from an app workspace)
+//
+// WHAT THIS PROVES. Live-session media (images, video an author drops into a
+// shared deck) travels through the relay encrypted, and kernel/src/sync/blobs.ts
+// keeps a local copy in IndexedDB (`bento-blobcache`) so a slide that reuses an
+// asset does not refetch it. IndexedDB is per ORIGIN, and on file:// every local
+// page shares one origin — so whatever is written there is readable by any other
+// HTML file opened from disk. The cache must therefore hold only what the relay
+// holds: the encodeBlob ciphertext, useless without the room key in the document.
+//
+// It pins, against the real module and a real (fake-indexeddb) database:
+// - every write path (fetch, upload, dedup) stores ciphertext that decodes to
+// the asset, and no stored value contains the plaintext;
+// - a cache hit still returns the plaintext, with no network;
+// - a tampered entry falls through to a refetch, which heals the entry;
+// - an existing version-1 store (which held plaintext) is purged on upgrade;
+// - the SHIPPED version-1 opener, run verbatim against an upgraded database,
+// gets no cache at all, so an older runtime can no longer write plaintext;
+// - an older tab holding a version-1 connection cannot make getBlob hang.
+
+import { createRequire } from 'node:module'
+import { pathToFileURL } from 'node:url'
+
+let failures = 0
+let checks = 0
+function ok(cond: boolean, msg: string) {
+ checks++
+ if (!cond) { failures++; console.log(` FAIL ${msg}`) }
+ else console.log(` ok ${msg}`)
+}
+
+// fake-indexeddb lives in each app workspace (scripts/ has no package.json).
+type FakeIdb = { indexedDB: IDBFactory; IDBFactory: new () => IDBFactory }
+let fake: FakeIdb | undefined
+for (const app of ['slides', 'type', 'spaces', 'dash']) {
+ try {
+ const req = createRequire(new URL(`../${app}/package.json`, import.meta.url))
+ fake = await import(pathToFileURL(req.resolve('fake-indexeddb')).href) as FakeIdb
+ break
+ } catch { /* try the next workspace */ }
+}
+if (!fake?.IDBFactory) {
+ console.log('FAIL fake-indexeddb is not installed in any app workspace (run npm ci in slides/)')
+ process.exit(1)
+}
+const G = globalThis as unknown as { indexedDB: IDBFactory; fetch: typeof fetch }
+
+/** A fresh, empty browser profile. */
+const freshProfile = () => { G.indexedDB = new fake!.IDBFactory() }
+/** A fresh copy of the module (its db() memo starts empty), like a new tab. */
+let gen = 0
+const loadBlobs = async () =>
+ await import(`../kernel/src/sync/blobs.ts?tab=${++gen}`) as typeof import('../kernel/src/sync/blobs.ts')
+
+const DB = 'bento-blobcache'
+const STORE = 'blobs'
+const settle = (ms = 30) => new Promise((r) => setTimeout(r, ms))
+
+/** Raw read of everything in the store, bypassing the module (an attacker's view). */
+async function rawAll(): Promise<Map<string, Uint8Array> | null> {
+ return new Promise((resolve) => {
+ const req = G.indexedDB.open(DB)
+ req.onerror = () => resolve(null)
+ req.onsuccess = () => {
+ const d = req.result
+ if (!d.objectStoreNames.contains(STORE)) { d.close(); return resolve(new Map()) }
+ const out = new Map<string, Uint8Array>()
+ const tx = d.transaction(STORE, 'readonly')
+ const cur = tx.objectStore(STORE).openCursor()
+ cur.onsuccess = () => {
+ const c = cur.result
+ if (c) { out.set(String(c.key), new Uint8Array(c.value as ArrayBuffer)); c.continue() }
+ }
+ tx.oncomplete = () => { d.close(); resolve(out) }
+ }
+ })
+}
+
+/** Raw overwrite of one entry (tampering, or a pre-existing value). */
+async function rawPut(key: string, bytes: Uint8Array): Promise<void> {
+ return new Promise((resolve) => {
+ const req = G.indexedDB.open(DB)
+ req.onsuccess = () => {
+ const d = req.result
+ const tx = d.transaction(STORE, 'readwrite')
+ tx.objectStore(STORE).put(bytes.slice().buffer, key)
+ tx.oncomplete = () => { d.close(); resolve() }
+ }
+ })
+}
+
+// ---------------------------------------------------------------------------
+// The SHIPPED version-1 cache code, verbatim from kernel/src/sync/blobs.ts as
+// released through 1.2.9 (only `dbP` is per-instance so each call is a new tab).
+// Shipped shells are frozen, so this is exactly what an older runtime runs.
+function shippedV1() {
+ let dbP: Promise<IDBDatabase | null> | null = null
+ function db(): Promise<IDBDatabase | null> {
+ if (dbP) return dbP
+ dbP = new Promise((resolve) => {
+ if (typeof indexedDB === 'undefined') return resolve(null)
+ let req: IDBOpenDBRequest
+ try { req = indexedDB.open(DB, 1) } catch { return resolve(null) }
+ req.onupgradeneeded = () => {
+ const d = req.result
+ if (!d.objectStoreNames.contains(STORE)) d.createObjectStore(STORE)
+ }
+ req.onsuccess = () => resolve(req.result)
+ req.onerror = () => resolve(null)
+ })
+ return dbP
+ }
+ async function cacheGet(key: string): Promise<Uint8Array | null> {
+ const d = await db()
+ if (!d) return null
+ return new Promise((resolve) => {
+ try {
+ const r = d.transaction(STORE, 'readonly').objectStore(STORE).get(key)
+ r.onsuccess = () => resolve(r.result ? new Uint8Array(r.result as ArrayBuffer) : null)
+ r.onerror = () => resolve(null)
+ } catch { resolve(null) }
+ })
+ }
+ async function cachePut(key: string, bytes: Uint8Array): Promise<void> {
+ const d = await db()
+ if (!d) return
+ try {
+ d.transaction(STORE, 'readwrite').objectStore(STORE).put(bytes.slice().buffer, key)
+ } catch { /* cache is best effort */ }
+ }
+ return { db, cacheGet, cachePut }
+}
+// ---------------------------------------------------------------------------
+
+// A recognisable plaintext: if any stored value contains this, plaintext leaked.
+const MARKER = new TextEncoder().encode('BENTO-PLAINTEXT-MARKER-')
+const asset = new Uint8Array(4096)
+for (let i = 0; i < asset.length; i++) asset[i] = MARKER[i % MARKER.length]
+const containsMarker = (v: Uint8Array) => {
+ outer: for (let i = 0; i + MARKER.length <= v.length; i++) {
+ for (let j = 0; j < MARKER.length; j++) if (v[i + j] !== MARKER[j]) continue outer
+ return true
+ }
+ return false
+}
+const same = (a: Uint8Array | null, b: Uint8Array) =>
+ !!a && a.length === b.length && a.every((x, i) => x === b[i])
+
+const roomKey = crypto.getRandomValues(new Uint8Array(32))
+const endpoint = { base: 'https://relay.invalid', room: 'w-test', tok: 'tok' }
+
+/** A relay: answers GET with `served`, HEAD with `headStatus`, PUT with 200. Counts calls. */
+let served: Uint8Array | null = null
+let headStatus = 404
+let calls = { get: 0, head: 0, put: 0 }
+G.fetch = (async (_u: unknown, init?: RequestInit) => {
+ const m = init?.method ?? 'GET'
+ if (m === 'HEAD') { calls.head++; return new Response(null, { status: headStatus }) }
+ if (m === 'PUT') { calls.put++; return new Response(null, { status: 200 }) }
+ calls.get++
+ return served ? new Response(served as unknown as BodyInit) : new Response('missing', { status: 404 })
+}) as typeof fetch
+const resetCalls = () => { calls = { get: 0, head: 0, put: 0 } }
+
+// --- 1. fetch path: what lands in the cache ----------------------------------
+console.log('\nfetch path caches ciphertext')
+{
+ freshProfile()
+ const b = await loadBlobs()
+ const key = await b.blobKey(roomKey, asset)
+ served = await b.encodeBlob(roomKey, asset)
+ resetCalls()
+ const got = await b.getBlob(endpoint, roomKey, key)
+ await settle()
+ ok(same(got, asset), 'getBlob returns the asset')
+ const all = await rawAll()
+ const v = all?.get(key)
+ ok(!!v, 'the fetched blob was cached')
+ ok(!!v && !containsMarker(v), 'the cached value does NOT contain the plaintext')
+ ok(!!v && same(await b.decodeBlob(roomKey, v), asset), 'the cached value decodes to the asset with the room key')
+ ok(![...(all?.values() ?? [])].some(containsMarker), 'no value anywhere in the store contains the plaintext')
+
+ // --- 2. a hit returns plaintext, with no network
+ served = null
+ resetCalls()
+ const hit = await b.getBlob(endpoint, roomKey, key)
+ ok(same(hit, asset), 'a cache hit returns the plaintext')
+ ok(calls.get === 0, `and touches no network (GETs: ${calls.get})`)
+
+ // --- 3. a tampered entry falls through to a refetch, which heals it
+ const bad = v!.slice(); bad[bad.length - 1] ^= 0xff
+ await rawPut(key, bad)
+ served = await b.encodeBlob(roomKey, asset)
+ resetCalls()
+ const healed = await b.getBlob(endpoint, roomKey, key)
+ await settle()
+ ok(same(healed, asset), 'a tampered entry still yields the asset (via refetch)')
+ ok(calls.get === 1, `the tampered entry was not trusted — refetched (GETs: ${calls.get})`)
+ const after = (await rawAll())?.get(key)
+ ok(!!after && same(await b.decodeBlob(roomKey, after), asset) && !containsMarker(after),
+ 'the refetch overwrote the entry with valid ciphertext')
+
+ // a wrong-key entry (decodes to nothing) is likewise not trusted
+ await rawPut(key, await b.encodeBlob(crypto.getRandomValues(new Uint8Array(32)), asset))
+ resetCalls()
+ ok(same(await b.getBlob(endpoint, roomKey, key), asset) && calls.get === 1,
+ 'an entry sealed under another key is refetched, not trusted')
+}
+
+// --- 4. upload + dedup paths --------------------------------------------------
+console.log('\nupload and dedup paths cache ciphertext')
+{
+ freshProfile()
+ const b = await loadBlobs()
+ headStatus = 404
+ const up = await b.putBlob(endpoint, roomKey, asset)
+ await settle()
+ ok(up.ok && !up.deduped, 'putBlob uploads')
+ const k = up.ok ? up.key : ''
+ let v = (await rawAll())?.get(k)
+ ok(!!v && !containsMarker(v), 'upload path: the cached value does NOT contain the plaintext')
+ ok(!!v && same(await b.decodeBlob(roomKey, v), asset), 'upload path: it decodes to the asset')
+
+ freshProfile()
+ const b2 = await loadBlobs()
+ headStatus = 200
+ resetCalls()
+ const dd = await b2.putBlob(endpoint, roomKey, asset)
+ await settle(60)
+ ok(dd.ok && dd.deduped && calls.put === 0, 'putBlob dedups on HEAD 200 (no PUT)')
+ v = (await rawAll())?.get(dd.ok ? dd.key : '')
+ ok(!!v && !containsMarker(v), 'dedup path: the cached value does NOT contain the plaintext')
+ ok(!!v && same(await b2.decodeBlob(roomKey, v), asset), 'dedup path: it decodes to the asset')
+ headStatus = 404
+}
+
+// --- 5. a version-1 plaintext store is purged on upgrade ----------------------
+console.log('\nupgrade purges the version-1 plaintext store')
+{
+ freshProfile()
+ const old = shippedV1()
+ const b = await loadBlobs()
+ const key = await b.blobKey(roomKey, asset)
+ await old.cachePut(key, asset) // what a 1.2.9 tab wrote: PLAINTEXT
+ await settle()
+ ok(!!(await old.cacheGet(key)) && containsMarker((await old.cacheGet(key))!),
+ 'precondition: the shipped v1 code stored plaintext')
+ ;(await old.db())?.close() // that tab is closed
+ await b.cacheGet('anything') // a new runtime opens the cache once
+ await settle()
+ const all = await rawAll()
+ ok(!!all && ![...all.values()].some(containsMarker), 'after the new runtime opens it, no plaintext remains')
+ ok(!!all && !all.has(key), 'the plaintext entry itself is gone (store dropped, not migrated)')
+}
+
+// --- 6. the shipped v1 opener, against an upgraded database, gets no cache ----
+console.log('\nan older runtime gets no cache once a new one has run')
+{
+ freshProfile()
+ const b = await loadBlobs()
+ await b.cacheGet('init') // new runtime creates version 2
+ await settle()
+ const old = shippedV1() // then an older tab opens the same origin
+ ok((await old.db()) === null, 'the shipped v1 open resolves null against a version-2 database (VersionError)')
+ const key = await b.blobKey(roomKey, asset)
+ await old.cachePut(key, asset) // it tries to cache plaintext
+ await settle()
+ ok((await old.cacheGet(key)) === null, 'its cacheGet finds nothing')
+ const all = await rawAll()
+ ok(!!all && ![...all.values()].some(containsMarker), 'its cachePut wrote no plaintext')
+}
+
+// --- 7. an older tab still holding v1 cannot make getBlob hang ---------------
+console.log('\nan open version-1 connection does not hang the new runtime')
+{
+ freshProfile()
+ const old = shippedV1()
+ const held = await old.db() // an older tab, open, never closing
+ ok(!!held, 'precondition: the older tab holds an open v1 connection')
+ const b = await loadBlobs()
+ const key = await b.blobKey(roomKey, asset)
+ served = await b.encodeBlob(roomKey, asset)
+ resetCalls()
+ const t = setTimeout(() => { console.log(' FAIL getBlob hung behind a blocked upgrade'); process.exit(1) }, 3000)
+ const got = await b.getBlob(endpoint, roomKey, key)
+ clearTimeout(t)
+ ok(same(got, asset), 'getBlob still returns the asset (runs uncached while blocked)')
+ ok(calls.get === 1, 'it fetched from the relay rather than waiting')
+ held!.close() // the older tab closes
+ await settle(60)
+ const all = await rawAll()
+ ok(!!all && ![...all.values()].some(containsMarker), 'and once it closes, the pending upgrade still leaves no plaintext')
+}
+
+console.log(`\n${checks - failures}/${checks} checks passed`)
+process.exit(failures ? 1 : 0)
diff --git a/scripts/test-blobs.ts b/scripts/test-blobs.ts
index afecba3d..362cd3fb 100644
--- a/scripts/test-blobs.ts
+++ b/scripts/test-blobs.ts
@@ -22,10 +22,10 @@
// HMAC(roomKey, sha256(plaintext)), so recomputing it over what arrived proves
// the bytes are the bytes that were asked for. This rig pins that check.
//
-// The IndexedDB half of the same check (a cache hit is re-verified, so an entry
-// poisoned by a build that predates this is re-fetched rather than trusted) is
-// the same three lines against the same helper, and is not reachable from node
-// — there is no indexedDB here, so cacheGet always misses.
+// The IndexedDB half of the same check (a cache hit is decrypted and
+// re-verified, so a poisoned or tampered entry is re-fetched rather than
+// trusted) runs against fake-indexeddb in scripts/test-blobcache.ts. This rig
+// has no indexedDB, so cacheGet always misses here.
import { blobKey, encodeBlob, getBlob, type BlobEndpoint } from '../slides/src/sync/blobs.ts'
diff --git a/scripts/test-slides-css-egress-browser.mjs b/scripts/test-slides-css-egress-browser.mjs
new file mode 100644
index 00000000..e29aac35
--- /dev/null
+++ b/scripts/test-slides-css-egress-browser.mjs
@@ -0,0 +1,328 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// No string a document carries makes slides fetch anything, on any surface.
+//
+// npm run build:single --prefix slides && node scripts/test-slides-css-egress-browser.mjs
+//
+// WHAT THIS PROVES, in the packaged document (bento/connect gate-1 invariant 6).
+// A colour is the commonest thing a deck writes into CSS, and a colour that is
+// really `url(https://…)` is a fetch: a read receipt with the reader's address
+// on it, from a file that is meant to work offline. Slides gates document
+// colours at the render SINKS (render.ts cssColor / svgPaint / paintSafeShape /
+// fetchFreeOption), so every way a document arrives (file, Replace from JSON,
+// paste, a collaborator's op) meets the same gate. Here:
+// 1. a deck is generated from the format's own schema: EVERY string field of
+// every element kind, the slide and the theme carries a payload, in ten
+// spellings (a bare url(), `red url()`, a declaration break, two that
+// close a function: `red),url()` for a gradient, `red) url() blur(0` for a
+// drop-shadow filter, a protocol-relative `url(//…)`, which has no colon
+// for a colour's character allowlist to catch, and four CSS-escaped
+// spellings of the name, `u\rl(`, `\75rl(`, `\75 rl(`, `\000075rl(`, which
+// a sink that resolves escapes reads as url(), plus svg <style>,
+// svg paint attributes and chart option colours. The decks are SERVED over
+// https, as bento.page serves them, so a protocol-relative url() reaches
+// the network as it would there;
+// 2. it is opened and walked on every surface: boot, both slides on the
+// canvas, every element's panel, the speaker window, present mode, print,
+// serialize, and the saved file opened with JavaScript OFF (a thumbnailer);
+// 3. a second deck morphs a shape into payload paint (present's morph writes
+// fill/stroke/stop-color straight into attributes), and two more force the
+// saved preview down to its tinted-box and title-card tiers, which paint
+// with theme colours;
+// 4. a collaborator's presence colour, sent as a real presence frame;
+// and every request the page makes to the payload origin is logged: there must
+// be none. A raw url() written by the rig on the same page IS logged — the
+// positive control that makes the zeros a boundary.
+// Mutations: drop the gate at any one FETCHING sink — the palette swatches,
+// shape paint, present's morph, chart options (snapshot and live), the preview
+// title card's accent bar, a peer's name tag, top-bar chip or Share row, or
+// cssColor's function check — and its rows go red. Four more sinks are gated
+// for hygiene but write properties that cannot fetch today (present's
+// --bento-accent feeds outline/border-color, a peer's selection outline is a
+// border-color, the preview's tinted boxes are a gradient, the title card's
+// text is a color), so dropping those alone stays green, by design.
+import { readFileSync, writeFileSync, mkdtempSync, readdirSync, existsSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright')
+
+let checks = 0
+let failures = 0
+function ok(cond, msg) {
+ checks++
+ if (!cond) { failures++; console.log(` FAIL ${msg}`) } else console.log(` ok ${msg}`)
+}
+const root = new URL('..', import.meta.url).pathname
+const schemaFile = readdirSync(join(root, 'schema')).filter((f) => /^slides-[\d.]+\.json$/.test(f))
+ .sort((a, b) => a.localeCompare(b, undefined, { numeric: true })).pop()
+const D = JSON.parse(readFileSync(join(root, 'schema', schemaFile), 'utf8')).$defs
+const shell = readFileSync(join(root, 'slides/dist-single/Bento_Slides.bento.html'), 'utf8')
+const dir = mkdtempSync(join(tmpdir(), 'bento-egress-'))
+const O = 'http://h.t' // routed: every request to it is logged, none leaves the machine
+
+const ALL_SPELLINGS = {
+ 'bare url()': (u) => `url(${u})`,
+ 'colour then url()': (u) => `red url(${u})`,
+ 'declaration break': (u) => `red;background:url(${u})`,
+ 'closes a gradient': (u) => `red),url(${u})`,
+ 'closes a drop-shadow': (u) => `red) url(${u}) blur(0`,
+ // no scheme, so no colon: the one url() a colour's character allowlist does
+ // not stop on its own — only the function check does
+ 'protocol-relative url()': (u) => `url(${u.replace(/^https?:/, '')})`,
+ // CSS escapes inside the function name: a sink whose CSS parser resolves them
+ // (an svg paint attribute does) reads each of these as url(
+ 'escaped u\\rl(': (u) => `u\\rl(${u})`,
+ 'escaped \\75rl(': (u) => `\\75rl(${u})`,
+ 'escaped \\75 rl(': (u) => `\\75 rl(${u})`,
+ 'escaped \\000075rl(': (u) => `\\000075rl(${u})`,
+}
+// EGRESS_SPELLINGS narrows the run (comma-separated names) for mutation sweeps;
+// CI runs them all
+const only = process.env.EGRESS_SPELLINGS?.split(',').map((s) => s.trim())
+const SPELLINGS = Object.fromEntries(Object.entries(ALL_SPELLINGS).filter(([k]) => !only || only.includes(k)))
+const SKIP = new Set(['id', 'type', 'docId', 'format', 'collab', 'blobs', 'assets', 'stateOf', 'readonly', 'template', 'html', 'markup', 'code', 'option', 'rows', 'columns', 'comments', 'notes'])
+const KINDS = ['text', 'shape', 'image', 'svg', 'chart', 'table', 'media', 'embed', 'code']
+const PNG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=='
+const theme0 = { background: '#ffffff', color: '#1E2A3A', accent: '#f7a600', fontFamily: 'system-ui' }
+
+// builds payloads with unique tags, remembering which field each came from
+function payloads(spell) {
+ const tags = new Map()
+ let n = 0
+ const tag = (path) => { const t = (n++).toString(36); tags.set(t, path); return t }
+ const pay = (path) => spell(`${O}/${tag(path)}`)
+ const raw = (path) => `${O}/${tag(path)}`
+ const resolve = (s) => (s && s.$ref ? D[s.$ref.split('/').pop()] : s)
+ function fill(s, path, depth = 0) {
+ s = resolve(s)
+ if (!s || depth > 6) return undefined
+ if (s.enum) return s.enum[0]
+ if (s.oneOf || s.anyOf) return fill((s.oneOf || s.anyOf)[0], path, depth + 1)
+ const t = Array.isArray(s.type) ? s.type[0] : s.type
+ if (t === 'string') return pay(path)
+ if (t === 'number' || t === 'integer') return Math.min(s.maximum ?? 50, Math.max(s.minimum ?? 0, 40))
+ if (t === 'boolean') return true
+ if (t === 'array') { const v = fill(s.items, path + '[]', depth + 1); return v === undefined ? [] : [v] }
+ if (t === 'object' || s.properties) {
+ const o = {}
+ for (const [k, v] of Object.entries(s.properties || {})) {
+ if (SKIP.has(k)) continue
+ const x = fill(v, `${path}.${k}`, depth + 1)
+ if (x !== undefined) o[k] = x
+ }
+ return o
+ }
+ return undefined
+ }
+ return { tags, pay, raw, fill }
+}
+const geo = (i) => ({ x: 60 + (i % 4) * 290, y: 60 + Math.floor(i / 4) * 200, w: 260, h: 160, rotation: 0, opacity: 1 })
+const DECK = 'https://deck.test/'
+const write = (name, doc) => {
+ const open = '<script type="application/bento+json" id="bento-doc">', close = '</' + 'script>'
+ const at = shell.indexOf(open) + open.length
+ const file = join(dir, name)
+ writeFileSync(file, shell.slice(0, at) + JSON.stringify(doc).replace(/</g, '\\u003c') + shell.slice(shell.indexOf(close, at)))
+ return DECK + name
+}
+
+// the every-field deck
+function fieldsDeck(P) {
+ const element = (kind, i) => {
+ const e = { ...P.fill(D[kind], kind), ...geo(i), id: `e-${kind}`, type: kind }
+ if (kind === 'text') e.html = `<p style="background:url(${P.raw('text.html style')})">x</p>`
+ if (kind === 'shape') e.shape = 'rect'
+ if (kind === 'image') e.src = PNG
+ if (kind === 'svg') e.markup = `<svg viewBox="0 0 10 10"><style>rect{fill:url(${P.raw('svg <style>')})}</style><rect width="10" height="10" style="fill:url(${P.raw('svg style=""')})" fill="url(${P.raw('svg fill=""')})" stroke="url(${P.raw('svg stroke=""')})"/></svg>`
+ if (kind === 'chart') e.option = { color: [P.pay('chart option.color[0]')], backgroundColor: P.pay('chart backgroundColor'), textStyle: { color: P.pay('chart textStyle.color') }, legend: { show: true, textStyle: { color: P.pay('chart legend.textStyle.color') } }, xAxis: { type: 'category', data: ['a', 'b'], axisLabel: { color: P.pay('chart axisLabel.color') }, axisLine: { lineStyle: { color: P.pay('chart axisLine.color') } } }, yAxis: { type: 'value', splitLine: { lineStyle: { color: P.pay('chart splitLine.color') } } }, series: [{ name: 's', type: 'bar', data: [1, 2], itemStyle: { color: P.pay('chart series.itemStyle.color') }, label: { show: true, color: P.pay('chart series.label.color') } }, { name: 'l', type: 'line', data: [2, 1], lineStyle: { color: P.pay('chart series.lineStyle.color') }, itemStyle: { color: P.pay('chart line itemStyle.color') } }] }
+ if (kind === 'table') { e.columns = [{ w: 1 }, { w: 1 }]; e.header = true; e.rows = [{ cells: [{ html: 'a', color: P.pay('table cell.color'), bg: P.pay('table cell.bg') }, { html: 'b' }] }, { cells: [{ html: '1' }, { html: '2' }] }] }
+ if (kind === 'media') { e.kind = 'video'; e.src = 'x.mp4'; delete e.poster }
+ if (kind === 'embed') { e.app = 'web'; e.url = 'https://example.com/'; e.live = false }
+ if (kind === 'code') { e.code = 'let a = 1'; e.lang = 'js' }
+ return e
+ }
+ const slide = { ...P.fill(D.slide, 'slide'), id: 's1', transition: 'none', notes: '', elements: KINDS.map(element) }
+ delete slide.stateOf; delete slide.comments
+ return {
+ format: 'bento/slides', version: 1, docId: 'egress-fields', title: 'egress',
+ size: { width: 1280, height: 720 }, theme: { ...P.fill(D.theme, 'theme'), fontFamily: 'system-ui' },
+ slides: [slide, { id: 's2', background: P.pay('slide2.background'), transition: 'fade', notes: '', elements: [] }],
+ }
+}
+// a shape that morphs into payload paint (slide 2 is the morph target)
+function morphDeck(P) {
+ const shape = (fill, stroke, stops) => ({ id: 'm1', type: 'shape', shape: 'rect', ...geo(0), fill, stroke, strokeWidth: 4, ...(stops ? { fillGradient: { angle: 90, stops } } : {}) })
+ const line = (fill) => ({ id: 'm2', type: 'shape', shape: 'line', x: 400, y: 400, w: 300, h: 4, rotation: 0, opacity: 1, fill, strokeWidth: 4 })
+ return {
+ format: 'bento/slides', version: 1, docId: 'egress-morph', title: 'morph', size: { width: 1280, height: 720 }, theme: theme0,
+ slides: [
+ { id: 's1', background: '#ffffff', transition: 'none', notes: '', elements: [shape('#123456', '#000000', [{ at: 0, color: '#ff0000' }, { at: 1, color: '#0000ff' }]), line('#222222')] },
+ { id: 's2', background: '#ffffff', transition: 'morph', notes: '', elements: [shape(P.pay('morph target fill'), P.pay('morph target stroke')), line(P.pay('morph line colour'))] },
+ { id: 's3', background: '#ffffff', transition: 'morph', notes: '', elements: [shape('#00ff00', '#000000', [{ at: 0, color: P.pay('morph gradient stop') }, { at: 1, color: '#000000' }])] },
+ ],
+ }
+}
+// first pages that only fit the preview's lower tiers, painted with theme colours
+function tierDeck(P, which) {
+ const big = 'data:image/png;base64,' + 'A'.repeat(90 * 1024)
+ const els = which === 'tinted'
+ ? [{ id: 'big', type: 'image', ...geo(0), src: big }]
+ : Array.from({ length: 40 }, (_, i) => ({ id: 't' + i, type: 'text', ...geo(i % 8), html: '<p>' + 'words '.repeat(400) + '</p>' }))
+ return {
+ format: 'bento/slides', version: 1, docId: 'egress-' + which, title: 'tier ' + which, size: { width: 1280, height: 720 },
+ theme: { ...theme0, accent: P.pay(`theme.accent (preview ${which})`), color: P.pay(`theme.color (preview ${which})`) },
+ slides: [{ id: 's1', background: '#ffffff', transition: 'none', notes: '', elements: els }],
+ }
+}
+
+const browser = await chromium.launch({ executablePath: process.env.CHROME_PATH, headless: true })
+async function context(log, js = true) {
+ const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 }, javaScriptEnabled: js })
+ if (js) await ctx.addInitScript(() => { try { localStorage.setItem('bento-slideshow-started', '1') } catch {} })
+ await ctx.route(/^https?:\/\/h\.t\//, (r) => { log(new URL(r.request().url()).pathname.slice(1)); r.fulfill({ status: 200, contentType: 'image/png', body: Buffer.alloc(0) }) })
+ await ctx.route(/^https?:\/\/(?!h\.t\/)/, (r) => r.abort())
+ // decks are SERVED, as bento.page serves them: a protocol-relative url() then
+ // resolves to the network, where on a file:// page it would not
+ await ctx.route(/^https:\/\/deck\.test\//, (r) => {
+ const f = join(dir, new URL(r.request().url()).pathname.slice(1))
+ return existsSync(f) ? r.fulfill({ status: 200, contentType: 'text/html', body: readFileSync(f) }) : r.fulfill({ status: 404, body: '' })
+ })
+ return ctx
+}
+const control = async (p) => {
+ await p.evaluate((o) => { const d = document.createElement('div'); d.style.cssText = `width:20px;height:20px;background-image:url(${o}/CONTROL)`; document.body.appendChild(d); d.getBoundingClientRect() }, O)
+ await p.waitForTimeout(400)
+}
+const booted = (p) => p.waitForFunction(() => window.bento?.doc && document.querySelector('.ed-topbar'), null, { timeout: 15000 })
+const menu = async (p, label) => {
+ await p.locator('.ed-present-pill .ed-pill-caret').click()
+ await p.locator('.ed-present-pill .ed-menu').getByText(label, { exact: true }).click()
+}
+// open a saved file the way a thumbnailer does: no script, the preview paints
+async function thumbnail(saved, log) {
+ const ctx = await context(log, false)
+ const name = `saved-${Math.random().toString(36).slice(2)}.html`
+ writeFileSync(join(dir, name), saved)
+ const p = await ctx.newPage(); await p.goto(DECK + name); await p.waitForTimeout(700)
+ await ctx.close()
+}
+const report = (label, hits, tags) => {
+ const leaked = [...hits].filter((t) => t !== 'CONTROL').map((t) => `${tags.get(t) ?? '?'}`)
+ ok(hits.has('CONTROL'), `${label}: positive control — a raw url() on this page IS fetched`)
+ ok(leaked.length === 0, `${label}: no document string fetched anything${leaked.length ? ' — ' + [...new Set(leaked)].join(', ') : ''}`)
+}
+
+try {
+ for (const [name, spell] of Object.entries(SPELLINGS)) {
+ console.log(`\n${name}\n`)
+ // --- every field, every surface ------------------------------------------
+ {
+ const P = payloads(spell)
+ const hits = new Set()
+ const ctx = await context((t) => hits.add(t))
+ const p = await ctx.newPage()
+ const errors = []
+ p.on('pageerror', (e) => errors.push(e.message))
+ p.on('dialog', (d) => d.dismiss())
+ await p.goto(write('fields.bento.html', fieldsDeck(P)))
+ await booted(p)
+ await p.waitForTimeout(600)
+ await control(p)
+ for (const i of [1, 0]) { await p.evaluate((i) => document.querySelectorAll('.ed-sidebar .ed-thumb')[i]?.click(), i); await p.waitForTimeout(300) }
+ for (const k of KINDS) {
+ const box = await p.evaluate((k) => { const e = document.querySelector(`.ed-stage-scale [data-el-id="e-${k}"]`); if (!e) return null; const r = e.getBoundingClientRect(); return { x: r.x + 8, y: r.y + 8 } }, k)
+ if (!box) continue
+ await p.mouse.click(box.x, box.y); await p.waitForTimeout(200)
+ await p.evaluate(() => { for (const h of document.querySelectorAll('.ed-sec-toggle.closed')) h.click() }); await p.waitForTimeout(100)
+ }
+ await p.mouse.click(5, 880)
+ const pop = ctx.waitForEvent('page', { timeout: 5000 }).catch(() => null)
+ await menu(p, 'Open speaker view')
+ const sw = await pop
+ await p.waitForTimeout(500)
+ await menu(p, 'Present in this tab')
+ await p.waitForTimeout(1200)
+ await p.keyboard.press('ArrowRight'); await p.waitForTimeout(1200)
+ await p.keyboard.press('Escape'); await p.waitForTimeout(500)
+ await p.emulateMedia({ media: 'print' }); await p.evaluate(() => window.dispatchEvent(new Event('beforeprint'))); await p.waitForTimeout(600); await p.emulateMedia({ media: 'screen' })
+ const saved = await p.evaluate(() => window.bento.serialize())
+ ok(!!sw, 'the speaker window opened')
+ ok(errors.length === 0, `no page error${errors.length ? ' — ' + errors[0].slice(0, 100) : ''}`)
+ await ctx.close()
+ await thumbnail(saved, (t) => hits.add(t))
+ report(`every field (${P.tags.size} payloads), every surface`, hits, P.tags)
+ }
+ // --- a shape morphing into payload paint -------------------------------------
+ {
+ const P = payloads(spell)
+ const hits = new Set()
+ const ctx = await context((t) => hits.add(t))
+ const p = await ctx.newPage()
+ p.on('dialog', (d) => d.dismiss())
+ await p.goto(write('morph.bento.html', morphDeck(P)))
+ await booted(p); await p.waitForTimeout(400)
+ await control(p)
+ await p.evaluate(() => document.querySelectorAll('.ed-sidebar .ed-thumb')[0]?.click())
+ await menu(p, 'Present in this tab')
+ await p.waitForTimeout(800)
+ for (let i = 0; i < 2; i++) { await p.keyboard.press('ArrowRight'); await p.waitForTimeout(1600) }
+ await p.keyboard.press('Escape'); await p.waitForTimeout(300)
+ await ctx.close()
+ report('present morph into payload paint', hits, P.tags)
+ }
+ // --- the preview's lower tiers --------------------------------------------------
+ for (const which of ['tinted', 'title']) {
+ const P = payloads(spell)
+ const hits = new Set()
+ const ctx = await context((t) => hits.add(t))
+ const p = await ctx.newPage()
+ await p.goto(write(`tier-${which}.bento.html`, tierDeck(P, which)))
+ await booted(p); await p.waitForTimeout(400)
+ await control(p)
+ const saved = await p.evaluate(() => window.bento.serialize())
+ const tier = /linear-gradient\(135deg/.test(saved) ? 'tinted boxes' : /data-bento-preview/.test(saved) ? 'written' : 'none'
+ await ctx.close()
+ await thumbnail(saved, (t) => hits.add(t))
+ report(`saved preview, ${which === 'tinted' ? 'tinted-box' : 'title-card'} tier (${tier})`, hits, P.tags)
+ }
+ }
+
+ // --- 4. a collaborator's presence colour, sent as a real presence frame -----------
+ // Each peer computes its own colour and sends it in its presence frame; the
+ // receiver keeps it as sent, so it is peer-controlled input. The frame goes
+ // over the same-machine channel (bento-sync-<docId>), on this slide and
+ // selecting an element, so all four places a peer's colour is painted render:
+ // the selection outline and name tag on the canvas, the top-bar chip, and the
+ // row in the Share panel.
+ console.log('\na collaborator\'s presence colour\n')
+ for (const [name, spell] of Object.entries(SPELLINGS)) {
+ const P = payloads(spell)
+ const hits = new Set()
+ const ctx = await context((t) => hits.add(t))
+ const p = await ctx.newPage()
+ const doc = { format: 'bento/slides', version: 1, docId: 'egress-peer', title: 'peer', size: { width: 1280, height: 720 }, theme: theme0,
+ slides: [{ id: 's1', background: '#ffffff', transition: 'none', notes: '', elements: [{ id: 'e1', type: 'shape', shape: 'rect', ...geo(0), fill: '#88aaff' }] }] }
+ await p.goto(write('peer.bento.html', doc))
+ await booted(p); await p.waitForTimeout(500)
+ await control(p)
+ const color = P.pay(`peer.color (${name})`)
+ const send = () => p.evaluate(({ docId, color }) => {
+ const ch = new BroadcastChannel('bento-sync-' + docId)
+ ch.postMessage({ pv: 2, t: 'p', a: 'zzpeer-actor-rig', p: { name: 'Rig Peer', color, slide: 's1', sel: ['e1'] } })
+ ch.close()
+ }, { docId: doc.docId, color })
+ await send(); await p.waitForTimeout(700)
+ await send()
+ const seen = await p.waitForFunction(() => (window.bento.sync.peers() || []).some((x) => x.name === 'Rig Peer'), null, { timeout: 4000 }).then(() => true, () => false)
+ ok(seen, `${name}: the presence frame arrived — the peer is in the session`)
+ await p.locator('.ed-btn-share').click().catch(() => {}) // the Share panel's people rows
+ await p.waitForTimeout(700)
+ await send(); await p.waitForTimeout(500)
+ await ctx.close()
+ report(`${name}: a peer's presence colour, all four places it is painted`, hits, P.tags)
+ }
+} finally {
+ await browser.close()
+}
+console.log(`\n${checks - failures}/${checks} checks passed`)
+if (failures) process.exit(1)
diff --git a/scripts/test-slides-sealed-title-browser.mjs b/scripts/test-slides-sealed-title-browser.mjs
new file mode 100644
index 00000000..6f37c60d
--- /dev/null
+++ b/scripts/test-slides-sealed-title-browser.mjs
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// A password-protected deck's title never appears in a window title.
+//
+// npm run build:single --prefix slides && node scripts/test-slides-sealed-title-browser.mjs
+//
+// WHAT THIS PROVES, in the packaged document. Browsers keep tab titles in their
+// history, so a title shown in a tab outlives the session. While a deck's body
+// is sealed (a password), every window title slides sets is neutral: the file
+// name when it is known, else the app. Checked on a deck whose title is a
+// marker string, encrypted through the real UI and saved:
+// 1. at the password gate, after unlocking, and after an edit that re-runs
+// the editor's title sync, document.title does not contain the marker;
+// 2. the speaker-view popup's title does not contain it;
+// 3. control first, on an unencrypted deck: the marker IS in the tab and the
+// speaker title (so the checks above can fail); then adding a password
+// makes both neutral at once — before any save — and removing it brings
+// the marker back.
+// 4. a deck sealed by IDENTITY (no password; the build:sealtest shell via
+// scripts/lib/sealed-boot.mjs): its tab and speaker window stay neutral
+// after a rename, and the same shell unsealed shows the title (control).
+// Mutations: make the sealed check answer false and 1–4 go red; gate it on the
+// password alone (isEncryptionActive) and 4 goes red.
+import { readFileSync, writeFileSync, mkdtempSync, existsSync } from 'node:fs'
+import { openSealed, sealtestShell } from './lib/sealed-boot.mjs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright')
+
+let checks = 0
+let failures = 0
+function ok(cond, msg) {
+ checks++
+ if (!cond) { failures++; console.log(` FAIL ${msg}`) } else console.log(` ok ${msg}`)
+}
+const PASS = 'correct horse 42'
+const MARK = 'Zanzibar Merger Plan'
+const shell = readFileSync(new URL('../slides/dist-single/Bento_Slides.bento.html', import.meta.url))
+const dir = mkdtempSync(join(tmpdir(), 'bento-sealed-title-'))
+
+const browser = await chromium.launch({ executablePath: process.env.CHROME_PATH, headless: true })
+async function open(file) {
+ const ctx = await browser.newContext({ viewport: { width: 1280, height: 860 }, acceptDownloads: true })
+ await ctx.route(/^https?:/, (r) => r.abort())
+ await ctx.addInitScript(() => { delete window.showSaveFilePicker; try { localStorage.setItem('bento-slideshow-started', '1') } catch {} })
+ const p = await ctx.newPage()
+ const errors = []
+ p.on('pageerror', (e) => errors.push(e.message))
+ p.on('dialog', (d) => d.accept())
+ await p.goto('file://' + file)
+ return { ctx, p, errors }
+}
+const editorUp = (p) => p.waitForFunction(() => window.bento?.doc && document.querySelector('.ed-topbar .ed-logo'), null, { timeout: 10000 })
+async function setDeckTitle(p, title) {
+ const input = p.locator('.ed-topbar .ed-title')
+ await input.fill(title)
+ await input.press('Enter')
+ await p.waitForFunction((t) => window.bento.doc.title === t, title)
+}
+async function openSpeaker(p) {
+ const popup = p.context().waitForEvent('page')
+ await p.locator('.ed-present-pill .ed-pill-caret').click()
+ await p.locator('.ed-present-pill .ed-menu').getByText('Open speaker view', { exact: true }).click()
+ const w = await popup
+ await w.waitForLoadState()
+ return w
+}
+const encryptDialog = async (p) => {
+ await p.locator('.ed-split-caret').click()
+ await p.locator('.ed-save-menu').getByText('Encrypt with password…', { exact: true }).click()
+ await p.locator('dialog.ed-pwdialog .pw1').fill(PASS)
+ await p.locator('dialog.ed-pwdialog .pw2').fill(PASS)
+}
+
+try {
+ // --- 3. control, then adding and removing a password ------------------------
+ console.log('an unencrypted deck, then a password added and removed\n')
+ const plain = join(dir, 'plain.bento.html')
+ writeFileSync(plain, shell)
+ const a = await open(plain)
+ await editorUp(a.p)
+ await setDeckTitle(a.p, MARK)
+ const sp = await openSpeaker(a.p)
+ ok((await a.p.title()).includes(MARK), `control: the unencrypted deck's tab shows its title ("${await a.p.title()}")`)
+ ok((await sp.title()).includes(MARK), `control: so does the speaker window ("${await sp.title()}")`)
+
+ // the password is set when the dialog confirms; the save it starts is a
+ // download here, and the title must already be neutral before it lands
+ await encryptDialog(a.p)
+ // "at once" means BEFORE the save the dialog starts, which re-syncs the title
+ // itself: record the tab title the moment the "Encrypted" toast appears. The
+ // toast is inserted before save() is called, and this observer's callback is
+ // queued ahead of the save's own continuation.
+ await a.p.evaluate(() => {
+ window.__titleAtToast = null
+ const mo = new MutationObserver(() => {
+ // textContent, not innerText: the toast is appended hidden and only shown
+ // a timer later, and innerText skips hidden text
+ if (window.__titleAtToast === null && /Encrypted — remember/.test(document.querySelector('.ed-toast')?.textContent || '')) { window.__titleAtToast = document.title; mo.disconnect() }
+ })
+ mo.observe(document.body, { childList: true, subtree: true, characterData: true })
+ })
+ const dl = a.p.waitForEvent('download', { timeout: 15000 })
+ await a.p.locator('dialog.ed-pwdialog button').last().click()
+ // wait for the RECORDING, not the title: the title can turn neutral before
+ // the toast (two IndexedDB clears sit between them), and reading early saw null
+ await a.p.waitForFunction(() => window.__titleAtToast !== null, null, { timeout: 8000 }).catch(() => {})
+ const atToast = await a.p.evaluate(() => window.__titleAtToast)
+ ok(atToast !== null && !atToast.includes(MARK), `adding a password makes the tab neutral at once, before the save ("${atToast}")`)
+ ok(!(await a.p.title()).includes(MARK), `…and it stays neutral after the save ("${await a.p.title()}")`)
+ ok(!(await sp.title()).includes(MARK), `…and the open speaker window ("${await sp.title()}")`)
+ const enc = join(dir, 'enc.bento.html')
+ await (await dl).saveAs(enc)
+ ok(/bento\/enc/.test(readFileSync(enc, 'utf8')), 'the saved file is encrypted')
+
+ await a.p.locator('.ed-split-caret').click()
+ await a.p.locator('.ed-save-menu').getByText('Remove password', { exact: true }).click()
+ await a.p.waitForFunction((m) => document.title.includes(m), MARK, { timeout: 3000 }).catch(() => {})
+ ok((await a.p.title()).includes(MARK), `removing the password brings the title back ("${await a.p.title()}")`)
+ ok((await sp.title()).includes(MARK), `…to the speaker window too ("${await sp.title()}")`)
+ ok(a.errors.length === 0, `no page error${a.errors.length ? ' — ' + a.errors[0] : ''}`)
+ await a.ctx.close()
+
+ // --- 1–2. opening the encrypted deck ------------------------------------------
+ console.log('\nopening the encrypted deck\n')
+ const b = await open(enc)
+ await b.p.waitForSelector('.ed-pwcard input[type=password]')
+ ok(!(await b.p.title()).includes(MARK), `at the password gate: "${await b.p.title()}"`)
+ const input = b.p.locator('.ed-pwcard input[type=password]').first()
+ await input.fill(PASS)
+ await input.press('Enter')
+ await editorUp(b.p)
+ ok(await b.p.evaluate((m) => window.bento.doc.title === m, MARK), 'the unlocked deck carries the marker title (the check below is real)')
+ ok(!(await b.p.title()).includes(MARK), `after unlocking: "${await b.p.title()}"`)
+ // an edit that re-runs the title sync: rename the deck
+ await setDeckTitle(b.p, `${MARK} v2`)
+ ok(!(await b.p.title()).includes(MARK), `after an edit that re-syncs the title: "${await b.p.title()}"`)
+ const sp2 = await openSpeaker(b.p)
+ ok(!(await sp2.title()).includes(MARK), `the speaker window: "${await sp2.title()}"`)
+ ok(b.errors.length === 0, `no page error${b.errors.length ? ' — ' + b.errors[0] : ''}`)
+ await b.ctx.close()
+
+ // --- sealed by identity, no password (the build:sealtest shell) ----------------
+ if (existsSync(sealtestShell('slides'))) {
+ console.log('\nsealed by identity (no password)\n')
+ const s = await openSealed(browser, 'slides')
+ await s.page.evaluate(() => { try { localStorage.setItem('bento-slideshow-started', '1') } catch {} })
+ await setDeckTitle(s.page, MARK)
+ ok(!(await s.page.title()).includes(MARK), `after renaming a sealed deck: "${await s.page.title()}"`)
+ const sp3 = await openSpeaker(s.page)
+ ok(!(await sp3.title()).includes(MARK), `its speaker window: "${await sp3.title()}"`)
+ await s.context.close()
+ const c = await openSealed(browser, 'slides', { sealed: false })
+ await setDeckTitle(c.page, MARK)
+ ok((await c.page.title()).includes(MARK), `control, the same shell unsealed: the title shows ("${await c.page.title()}")`)
+ await c.context.close()
+ } else console.log('\n skip sealed by identity (run npm run build:sealtest --prefix slides)')
+} finally {
+ await browser.close()
+}
+console.log(`\n${checks - failures}/${checks} checks passed`)
+if (failures) process.exit(1)
diff --git a/scripts/test-sync-session.ts b/scripts/test-sync-session.ts
index 1913a595..31056339 100644
--- a/scripts/test-sync-session.ts
+++ b/scripts/test-sync-session.ts
@@ -533,11 +533,13 @@ H('a read-only live viewer still materialises a relay-offloaded image (not via c
}
(globalThis as unknown as { indexedDB: unknown }).indexedDB = idbMod?.indexedDB;
}
- const { blobKey, cachePut, bytesToDataUri } = await import('../kernel/src/sync/blobs.ts');
+ const { blobKey, cachePut, encodeBlob, bytesToDataUri } = await import('../kernel/src/sync/blobs.ts');
const rawKey = new Uint8Array(32).fill(7);
const bytes = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10, 1, 2, 3, 4]);
const key = await blobKey(rawKey, bytes);
- await cachePut(key, bytes); await settle(30); // prime the cache (let the IDB write commit) a same-machine peer would have written
+ // prime the cache as a same-machine peer would have written it — the cache
+ // holds CIPHERTEXT (scripts/test-blobcache.ts) — and let the IDB write commit
+ await cachePut(key, await encodeBlob(rawKey, bytes)); await settle(30);
const doc = newDoc();
doc.docId = `ro-${Math.random().toString(36).slice(2, 10)}`;
(doc as unknown as { blobs: Record<string, { key: string; mime: string }> }).blobs = { hero: { key, mime: 'image/png' } };
diff --git a/slides/package.json b/slides/package.json
index e51c5d70..be64813d 100644
--- a/slides/package.json
+++ b/slides/package.json
@@ -1,7 +1,7 @@
{
"name": "bento-slides",
"private": true,
- "version": "1.2.9",
+ "version": "1.2.10",
"license": "MIT",
"type": "module",
"scripts": {
diff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.ts
index b2266cf1..aba1b833 100644
--- a/slides/src/editor/canvas.ts
+++ b/slides/src/editor/canvas.ts
@@ -10,7 +10,7 @@ import type { Store } from '../store'
import { t } from '../i18n'
import { defaultShape, internAsset, readableInk, uid, type ShapeElement, type SlideElement, type TableElement, type TextElement } from '../model'
import { estimatedFrames, fencedElements, splitFences, toggleCodeOnSelection, type FencePart, type PartFrame } from './codefence'
-import { renderSlide, sanitizeHtml } from '../render'
+import { cssColor, renderSlide, sanitizeHtml } from '../render'
import { autoformatAtCaret, clearAutoformat, markdownToHtml, stripMarkerEscapes, undoAutoformat } from './markdown'
import { inList, shiftList, shiftListHtml, undoIndent } from './listindent'
import { bulletsToLists } from './bullets'
@@ -943,14 +943,14 @@ export class SlideCanvas {
box.style.top = `${el.y}px`
box.style.width = `${el.w}px`
box.style.height = `${el.h}px`
- box.style.borderColor = peer.color
+ box.style.borderColor = cssColor(peer.color, '#888') // a peer's colour: gated
box.style.borderWidth = `${2 * inv}px`
if (el.rotation) box.style.transform = `rotate(${el.rotation}deg)`
if (peer.editing === id) box.classList.add('ed-remote-editing')
if (!tagged) {
const tag = document.createElement('div')
tag.className = 'ed-remote-tag'
- tag.style.background = peer.color
+ tag.style.background = cssColor(peer.color, '#888')
tag.textContent = peer.editing === id ? `✏️ ${peer.name}` : peer.name
tag.style.transform = `scale(${inv})`
tag.style.transformOrigin = 'bottom left'
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index 2d30dd6d..5efad280 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -15,7 +15,7 @@ import { THEME_CHOICES, setTheme, themeChoice } from '../../../kernel/src/theme.
import type { InPlaceOutcome } from '../update'
import { APP_VERSION, applyUpdate, applyUpdateInPlace, autoCheckEnabled, canUpdateInPlace, checkForUpdates, compareVersions, offlineEnabled, sandboxed, setAutoCheck, setOffline } from '../update'
import { CHART_PRESETS } from '../charts'
-import { renderSlide, renderThumbnail } from '../render'
+import { cssColor, renderSlide, renderThumbnail } from '../render'
import { openExportImagesDialog } from './exportimages'
import { paletteSignature, resolveThemeRefs } from '../palette'
import { SlideCanvas } from './canvas'
@@ -32,7 +32,8 @@ import { noteSavedFromWeb } from './returngate'
import { addVersion, clearRecovery, clearVersions, docContentKey, getRecovery, listVersions, onRecoveryOff, pruneOld, putRecovery, recoveryLooksOlder, type Snapshot } from '../autosave'
import { insertElements, insertSlides, parseClip, serializeElements, serializeSlides } from './clipboard'
import { estimatedFrames, fencedElements, splitFences } from './codefence'
-import { openSpeakerWindow, speakerIdleBody } from '../screens'
+import { openSpeakerWindow, speakerIdleBody, speakerWindow } from '../screens'
+import { neutralWindowTitle, speakerWindowTitle, titleSealed } from '../wintitle'
import { routeAllConnectors } from '../connectors'
import { ICONS } from '../icons'
import { t, setLocale, locale, localeChoices, LOCALE_CHOICES, applyDirection, isRtl } from '../i18n'
@@ -280,7 +281,7 @@ export class Editor {
for (const peer of peers.slice(0, MAX)) {
const chip = document.createElement('button')
chip.className = 'ed-avatar'
- chip.style.background = peer.color
+ chip.style.background = cssColor(peer.color, '#888') // a peer's colour: gated
chip.textContent = (peer.name || '?').trim().charAt(0).toUpperCase() || '?'
const idx = this.store.doc.slides.findIndex((s) => s.id === peer.slide)
chip.title =
@@ -983,6 +984,7 @@ export class Editor {
t('Stop encrypting this file — the next save writes it as plain, readable JSON again.'),
() => {
setEncryptionPassword(null)
+ this.syncWindowTitle() // the deck title may return to the tab
this.toast(t('Password removed — the next save writes an unencrypted file'))
void this.save(false)
})
@@ -1274,6 +1276,7 @@ export class Editor {
const pass = await this.promptPassword()
if (pass === null) return
setEncryptionPassword(pass)
+ this.syncWindowTitle() // the deck title leaves the tab now, not at the next save
// Purge any plaintext snapshots already written to IndexedDB before encryption
// was enabled — otherwise up to MAX_VERSIONS version snapshots + a recovery copy
// (full plaintext JSON, incl. collab keys) would linger ~30 days, defeating the
@@ -1466,7 +1469,7 @@ export class Editor {
row.className = 'ed-share-peer'
const dot = document.createElement('span')
dot.className = 'dot'
- dot.style.background = peer.color
+ dot.style.background = cssColor(peer.color, '#888')
const who = document.createElement('span')
who.className = 'who'
who.textContent = peer.editing ? `${peer.name} ✏️` : peer.name
@@ -2390,7 +2393,7 @@ export class Editor {
* can be placed on a second screen before presenting — present mode adopts it. */
openSpeakerView() {
const w = openSpeakerWindow(
- `${this.store.doc.title} — ${t('Speaker view')}`,
+ speakerWindowTitle(this.store.doc.title),
speakerIdleBody(this.store.doc.title, t('Notes, controls and slide thumbnails appear here when you start presenting. Drag this window to your second display.')),
)
if (!w) this.toast(t('Couldn’t open the speaker view — allow pop-ups for this site.'))
@@ -2836,9 +2839,16 @@ export class Editor {
const named = file && fileBase(file) !== this.store.doc.title
// Two segments, never three: a tab is narrow, and once a file name is
// shown the app name is the least informative thing competing for it.
- document.title = named
- ? `${this.store.doc.title} — ${file}`
- : `${this.store.doc.title} — ${appConfig().appName}`
+ // While the body is sealed the deck title stays out of the tab: browsers
+ // keep tab titles in their history (wintitle.ts). The open speaker window
+ // follows, so adding or removing a password retitles both at once.
+ document.title = titleSealed()
+ ? neutralWindowTitle(file ?? null)
+ : named
+ ? `${this.store.doc.title} — ${file}`
+ : `${this.store.doc.title} — ${appConfig().appName}`
+ const sw = speakerWindow()
+ if (sw) sw.document.title = speakerWindowTitle(this.store.doc.title)
if (!this.fileChip) return
// out of the bar only until there IS a file; after that the chip keeps its
// slot and goes quiet when it would repeat the title (styles.css, #546)
diff --git a/slides/src/editor/panels.ts b/slides/src/editor/panels.ts
index 9d4eb28e..59267cd7 100644
--- a/slides/src/editor/panels.ts
+++ b/slides/src/editor/panels.ts
@@ -8,7 +8,7 @@ import type { Store } from '../store'
import { MEDIA_EMBED_BUDGET, applyChartPalette, defaultChart, internAsset, morphKey, paginates, isWebUrl, tableStyleFor, uid, type ChartElement, type ImageElement, type LineEnding, type MediaElement, type ShapeElement, type Slide, type SlideElement, type TableElement, type TextElement, type TransitionKind, type CodeElement, type BentoDoc, type EmbedElement } from '../model'
import { CROP_MAX_SCALE, normalizeCrop } from '../crop'
import { LANGS } from '../../../kernel/src/tokenize.ts'
-import { resolveAsset } from '../render'
+import { cssColor, resolveAsset } from '../render'
import { measureElement } from '../measure'
import { PALETTE_SLOTS, paletteOf, refAt, setColor, slotIsSet } from '../palette'
import { isMacOS } from '../screens'
@@ -2497,7 +2497,7 @@ export class PropsPanel {
const b = document.createElement('button')
b.type = 'button'
b.className = 'ed-swatch'
- b.style.background = base
+ b.style.background = cssColor(base, 'transparent') // a document colour: gated
b.title = slot
if (current && current.split(' ')[0] === slot) b.classList.add('is-on')
b.addEventListener('click', () => {
diff --git a/slides/src/main.ts b/slides/src/main.ts
index c6dc3b97..cfd23de6 100644
--- a/slides/src/main.ts
+++ b/slides/src/main.ts
@@ -5,7 +5,8 @@
import './styles.css'
import { anim } from './anim'
-import { configureApp, appConfig } from '../../kernel/src/app.ts'
+import { configureApp } from '../../kernel/src/app.ts'
+import { deckWindowTitle } from './wintitle'
import { startTheme } from '../../kernel/src/theme.ts'
import { startNetGuard } from '../../kernel/src/net.ts'
import {
@@ -179,7 +180,7 @@ function bootWith(doc: BentoDoc, docIsFresh = false) {
* the editor. (docs/DECISIONS.md, the broadcast entry.)
*/
function audienceMode(doc: BentoDoc) {
- document.title = `${doc.title} — ${appConfig().appName}`
+ document.title = deckWindowTitle(doc.title)
if (doc.fonts?.length) injectFonts(doc)
document.getElementById('bento-splash')?.remove()
@@ -238,7 +239,7 @@ function audienceMode(doc: BentoDoc) {
* never expose the editor. Leaving the presentation lands on a minimal card.
*/
function playerMode(doc: BentoDoc) {
- document.title = `${doc.title} — ${appConfig().appName}`
+ document.title = deckWindowTitle(doc.title)
if (doc.fonts?.length) injectFonts(doc)
document.getElementById('bento-splash')?.remove()
const card = document.createElement('div')
@@ -265,7 +266,7 @@ function playerMode(doc: BentoDoc) {
function editorMode(doc: BentoDoc, docIsFresh = false) {
-document.title = `${doc.title} — ${appConfig().appName}`
+document.title = deckWindowTitle(doc.title)
// Embedded fonts: register @font-face rules from the asset table so text
// elements can use bundled families in the editor, presenter and thumbnails.
diff --git a/slides/src/present.ts b/slides/src/present.ts
index c31ea268..42b12d9a 100644
--- a/slides/src/present.ts
+++ b/slides/src/present.ts
@@ -10,9 +10,10 @@ import { anim, resetXform } from './anim'
import { chartSnapshotSvg, mountChart } from './charts'
import type { BentoDoc, GradientFill, ShapeElement, Slide, SlideElement } from './model'
import { morphKey, paginates, inLinearFlow, isWebUrl } from './model'
-import { applyElementFrame, gradientLineCoords, renderSlide } from './render'
+import { applyElementFrame, cssColor, fetchFreeOption, gradientLineCoords, paintSafeShape, renderSlide } from './render'
import { cropImgStyle, isIdentityCrop, lerpCrop } from './crop'
import { paintSpeaker, setSpeakerWindow, speakerIdleBody, speakerWindow } from './screens'
+import { speakerWindowTitle } from './wintitle'
import { ICONS } from './icons'
import { t } from './i18n'
import { lsGet, lsSet } from '../../kernel/src/storage.ts'
@@ -89,7 +90,8 @@ export function startPresentation(
const overlay = document.createElement('div')
overlay.className = 'bento-present-overlay'
- overlay.style.setProperty('--bento-accent', doc.theme.accent)
+ // a document colour, so it is gated like every other (render.ts cssColor)
+ overlay.style.setProperty('--bento-accent', cssColor(doc.theme.accent, '#f7a600'))
// Reveal ignores key events originating from form fields. If focus is still
// on an editor input (title, notes…) when the show starts, arrows go dead.
;(document.activeElement as HTMLElement | null)?.blur?.()
@@ -993,7 +995,7 @@ export function startPresentation(
setSpeakerWindow(speaker)
;(window as unknown as Record<string, unknown>).__bentoSpeaker = speaker // diagnostics
const d = speaker.document
- d.title = `${doc.title} — ${t('Speaker view')}`
+ d.title = speakerWindowTitle(doc.title)
if (!d.head.querySelector('style')) { // already styled when adopting an editor window
for (const st of document.querySelectorAll('style')) d.head.appendChild(d.importNode(st, true))
}
@@ -1212,7 +1214,7 @@ export function startPresentation(
if (speakerAdopted) {
// editor-owned window — leave it open, reset to the idle placeholder so
// it's ready for the next run instead of freezing on the last slide
- paintSpeaker(speaker, `${doc.title} — ${t('Speaker view')}`,
+ paintSpeaker(speaker, speakerWindowTitle(doc.title),
speakerIdleBody(doc.title, t('Presentation ended. Start it again to bring these notes back to life.')))
} else {
speaker.close()
@@ -1581,10 +1583,12 @@ function mountLiveCharts(slide: Slide, section: HTMLElement, fromSlide?: Slide)
if (!node) continue
// a matching chart on the other side of a morph: animate its data over
const fromEl = fromSlide?.elements.find((e) => e.id === el.id && e.type === 'chart')
- const dispose = mountChart(el, node, fromEl && fromEl.type === 'chart' ? fromEl.option : undefined)
+ // the engine writes option colours into svg paint: hand it a fetch-free copy
+ const live = { ...el, option: fetchFreeOption(el.option) }
+ const dispose = mountChart(live, node, fromEl && fromEl.type === 'chart' ? fetchFreeOption(fromEl.option) : undefined)
handles.push(() => {
dispose()
- node.innerHTML = chartSnapshotSvg(el)
+ node.innerHTML = chartSnapshotSvg(live)
const csvg = node.querySelector('svg')
if (csvg) {
csvg.setAttribute('preserveAspectRatio', 'none')
@@ -2455,6 +2459,9 @@ function sampleGradient(stops: GradientFill['stops'], t: number): string {
* temporary gradient that collapses to the flat color and is then removed.
*/
function morphShapeFill(target: SVGElement, a: ShapeElement, b: ShapeElement) {
+ // the model's paint goes into fill/stroke/stop-color attributes: gated first
+ a = paintSafeShape(a)
+ b = paintSafeShape(b)
if (a.fill === b.fill && JSON.stringify(a.fillGradient) === JSON.stringify(b.fillGradient)) return
// line shapes paint with stroke (fill is the line color in the model)
if (b.shape === 'line' && target.tagName === 'line') {
diff --git a/slides/src/preview.ts b/slides/src/preview.ts
index 3633f2d0..277a4aff 100644
--- a/slides/src/preview.ts
+++ b/slides/src/preview.ts
@@ -33,7 +33,7 @@
// the content scaled non-uniformly. It is not usable for the one renderer this
// feature exists to serve.
-import { renderSlide, resolveAsset } from './render'
+import { cssColor, renderSlide, resolveAsset } from './render'
import { PREVIEW_BUDGET, type BentoDoc, type Slide, inLinearFlow } from './model'
/** Elements that must never reach a static preview (active or external). */
@@ -137,7 +137,7 @@ function staticize(root: HTMLElement, doc: BentoDoc, keepImages: boolean) {
const tint = document.createElement('div')
tint.setAttribute('style',
`width:100%;height:100%;border-radius:${img.style.borderRadius || '0'};` +
- `background:linear-gradient(135deg,${doc.theme.accent}2E,${doc.theme.accent}12)`)
+ `background:linear-gradient(135deg,${cssColor(doc.theme.accent, '#f7a600')}2E,${cssColor(doc.theme.accent, '#f7a600')}12)`)
img.replaceWith(tint)
}
}
@@ -189,11 +189,11 @@ function titleCard(doc: BentoDoc): HTMLElement {
const rule = document.createElement('div')
rule.setAttribute('style',
- `width:${Math.round(w * 0.07)}px;height:${Math.round(h * 0.011)}px;background:${doc.theme.accent};margin-bottom:${Math.round(h * 0.05)}px`)
+ `width:${Math.round(w * 0.07)}px;height:${Math.round(h * 0.011)}px;background:${cssColor(doc.theme.accent, '#f7a600')};margin-bottom:${Math.round(h * 0.05)}px`)
const title = document.createElement('div')
title.setAttribute('style',
- `font-size:${Math.round(h * 0.1)}px;font-weight:800;line-height:1.1;color:${doc.theme.color};overflow-wrap:break-word`)
+ `font-size:${Math.round(h * 0.1)}px;font-weight:800;line-height:1.1;color:${cssColor(doc.theme.color, '#1E2A3A')};overflow-wrap:break-word`)
title.textContent = doc.title
page.append(rule, title)
diff --git a/slides/src/render.ts b/slides/src/render.ts
index ec64b9bb..bdb03f51 100644
--- a/slides/src/render.ts
+++ b/slides/src/render.ts
@@ -945,10 +945,62 @@ export function cssColor(v: unknown, fallback: string): string {
const s = v.trim()
if (!s || s.length > 48) return fallback
if (!/^[#a-zA-Z0-9(),.%\s/-]+$/.test(s)) return fallback
- if (/url\s*\(|expression|@|\\/i.test(s)) return fallback
+ if (/expression|@|\\/i.test(s) || CSS_NOT_A_COLOUR.test(s)) return fallback
return s
}
+/**
+ * Functions a colour never needs and a fetch or an indirection does: url() and
+ * the image functions load, var()/env()/attr() pull a value the gate never saw,
+ * paint()/element() reach outside the value. A colour written with any of them
+ * is not a colour, so it never reaches a sink.
+ */
+const CSS_NOT_A_COLOUR = /\b(url|image-set|-webkit-image-set|image|cross-fade|element|paint|env|attr|var)\s*\(/i
+
+/**
+ * An svg paint (`fill`, `stroke`, `stop-color`) from the document. The only
+ * url() a paint may carry is a LOCAL paint server, `url(#id)` (gradients and
+ * patterns are drawn that way); anything else goes through cssColor, so an
+ * external paint server, which the browser fetches, never reaches the
+ * attribute.
+ */
+export function svgPaint(v: unknown, fallback: string): string {
+ if (typeof v !== 'string') return fallback
+ const s = v.trim()
+ if (/^url\(\s*#[-\w.:]+\s*\)$/.test(s) || s === 'none') return s
+ return cssColor(s, fallback)
+}
+
+/**
+ * A shape's paint, gated: what the shape sinks (render, and present's morph,
+ * which tweens fill/stroke/stop-color straight into attributes) receive
+ * instead of the model's own strings. A copy; the model is untouched.
+ */
+export function paintSafeShape<T extends { fill?: unknown; stroke?: unknown; fillGradient?: { stops?: Array<{ color?: unknown }> } }>(el: T): T {
+ const out = { ...el }
+ if ('fill' in el) out.fill = svgPaint(el.fill, 'transparent')
+ if ('stroke' in el) out.stroke = svgPaint(el.stroke, 'transparent')
+ if (el.fillGradient?.stops) {
+ out.fillGradient = { ...el.fillGradient, stops: el.fillGradient.stops.map((s) => ({ ...s, color: cssColor(s.color, 'transparent') })) }
+ }
+ return out
+}
+
+/**
+ * A chart option for the engine, with every string that could load something
+ * removed (the engine writes option colours into svg fill/stroke attributes).
+ * A copy; labels, names and template formatters pass unchanged unless they
+ * carry a fetching function, which no legitimate one does.
+ */
+export function fetchFreeOption<T>(v: T): T {
+ // judged as the svg attribute's CSS parser will read it: escapes decoded, so
+ // `u\rl(` and `\75 rl(` are the url( they spell
+ if (typeof v === 'string') return (CSS_NOT_A_COLOUR.test(cssDecodeIdentEscapes(v)) ? '' : v) as T
+ if (Array.isArray(v)) return v.map(fetchFreeOption) as T
+ if (v && typeof v === 'object') return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, fetchFreeOption(x)])) as T
+ return v
+}
+
/** A model number as a CSS length: finite and in range, or the fallback. */
export function cssNum(v: unknown, fallback: number, max = 4096): number {
const n = Number(v)
@@ -1110,7 +1162,7 @@ export function renderElement(el: SlideElement, doc: BentoDoc, opts: RenderOpts
break
}
case 'shape':
- node.appendChild(shapeSvg(el))
+ node.appendChild(shapeSvg(paintSafeShape(el)))
break
case 'table':
node.dataset.table = '1'
@@ -1213,7 +1265,7 @@ export function renderElement(el: SlideElement, doc: BentoDoc, opts: RenderOpts
// instance (mountLiveCharts) for tooltips/zoom. Kept as innerHTML so
// print and thumbnails need no chart runtime at render time.
node.dataset.chart = '1'
- node.innerHTML = chartSnapshotSvg(el)
+ node.innerHTML = chartSnapshotSvg({ ...el, option: fetchFreeOption(el.option) })
const csvg = node.querySelector('svg')
if (csvg) {
csvg.setAttribute('preserveAspectRatio', 'none')
diff --git a/slides/src/wintitle.ts b/slides/src/wintitle.ts
new file mode 100644
index 00000000..1f0c8b43
--- /dev/null
+++ b/slides/src/wintitle.ts
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+/**
+ * Window titles. Every title slides gives a window — the editor's tab, the
+ * player's and audience's, the speaker-view popup's — is built here, so one
+ * rule covers them all: while the file's body is sealed (a password or the
+ * identity seal — kernel isBodySealed()),
+ * a window title never carries the deck's title. Browsers keep tab titles in
+ * their history on disk, in plaintext, so a title shown in a tab outlives the
+ * session and sits beside a file whose whole point is that its content is not
+ * readable without the password. A sealed deck's tab is named by its FILE
+ * (already in the address bar and in history, through its URL), else by the
+ * app. This reverses #742's choice to show the real title after unlocking.
+ */
+import { appConfig } from '../../kernel/src/app.ts'
+import { currentFileName, isBodySealed, openedFileName } from './save'
+import { t } from './i18n'
+
+/** Is the deck's body sealed, so its title must stay out of every window title? */
+export const titleSealed = (): boolean => isBodySealed()
+
+/** The neutral name: the file when it is known, else the app. The editor
+ * passes the file it knows (a dropped file is named by itself, not the URL). */
+export function neutralWindowTitle(file: string | null = currentFileName() ?? openedFileName()): string {
+ const app = appConfig().appName
+ return file ? `${file} — ${app}` : app
+}
+const neutral = () => neutralWindowTitle()
+
+/** A boot or player window: "<deck title> — <app>", or the neutral name while sealed. */
+export function deckWindowTitle(docTitle: string): string {
+ return titleSealed() ? neutral() : `${docTitle} — ${appConfig().appName}`
+}
+
+/** The speaker-view popup: "<deck title> — Speaker view", or no deck title while sealed. */
+export function speakerWindowTitle(docTitle: string): string {
+ return titleSealed() ? `${t('Speaker view')} — ${appConfig().appName}` : `${docTitle} — ${t('Speaker view')}`
+}