Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

loader: an app at its password gate or refusing a file counts as having run (encrypted decks, 1.2.0–1.2.8) (#736)

nyblnet98199d0ae4d5
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 15c59bae..9fb04d12 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2382,6 +2382,17 @@ jobs:
# primary in both themes, and N language rebuilds leaving one set of
# window/document listeners and bar observers.
run: node scripts/test-slides-topbar-browser.mjs
+ - name: A password-protected deck opens in Chromium
+ # One password gate and no loader failure card (1.2.0–1.2.8 showed
+ # three gates under "every loader path was refused"); wrong then right
+ # password; the same with only the blob import allowed; the ⌘S re-save
+ # and the self-update re-splice open again.
+ run: node scripts/test-slides-encrypted-open-browser.mjs
+ - name: The loader reads what the app published in Chromium
+ # Toy shells from the real postbuild: an app that is running, locked at
+ # a gate, or refused (and threw) runs ONCE and gets no loader card; only
+ # an app that published nothing does. Every path, blob only, import.meta.
+ run: node scripts/test-shell-loader-published-browser.mjs
- name: Top bar holds still in Chromium
# #546: a real auto-save "Saved" flash and a file-chip change (rename to
# the file's name, then undo) leave Undo/Redo exactly where they were,
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md
index 3f043f6e..7d59d512 100644
--- a/docs/DECISIONS.md
+++ b/docs/DECISIONS.md
@@ -10434,3 +10434,43 @@ choices are dash's and are recorded because a later change could undo them:
must never cost the copy. It stays for the next open, as ✕ already left it.
`recoveryLooksOlder` is read against the workbook AS LOADED, because dash
stamps `modified` on every edit.
+
+
+## 2026-10-17 — the loader reads what the app published: running, locked or refused
+
+The compressed shell's loader (scripts/postbuild-compress.mjs) runs the app
+through a cascade: an inline classic script, then `new Function`, then a blob
+import. After each path it decides whether the app ran by reading
+`window.bento`. It used to read `window.bento.doc` alone.
+
+An encrypted deck's app is still at its password gate when the path returns,
+so it had published nothing. Every path read as refused, the app ran once per
+path (three password cards), and the loader painted "every loader path was
+refused" over all of them. Measured in Chromium and WebKit: released slides
+1.2.0 through 1.2.8 cannot open a password-protected deck. 1.1.0 and 1.0.19 can.
+The cascade first shipped in 1.2.0, since there was no 1.1.1 release.
+
+**The contract.** An app publishes `window.bento` before it hands control back
+to the loader:
+- `{ doc, … }` while running;
+- `{ format, locked: true }` while waiting at its password gate, set
+ synchronously BEFORE the gate is shown and replaced wholesale on unlock;
+- `{ format, refused: true }` after painting its OWN refusal of a file it will
+ not open. It may throw afterwards.
+
+Any of the three means the app ran: no later path runs it again, and the loader
+paints nothing. The loader's failure card is only for an app that published
+nothing at all. The decision is made from what was published, not from whether
+the app threw, so `runNow` and the blob step check `mounted()` after a throw
+too.
+
+The apps: slides sets `locked` (this change). Spaces sets `locked` on its own
+branch. Type will set `refused` once security clears its finding in that code.
+
+Guards: `scripts/test-shell-loader-published-browser.mjs` builds toy shells with
+the real postbuild script, for each state and with every path, blob only, and an
+`import.meta` bundle. `scripts/test-slides-encrypted-open-browser.mjs` tests the
+real deck.
+
+`docs/PLATFORM.md` is where cross-app invariants live, and it is the
+maintainer's to edit. This contract belongs there once the maintainer agrees.
diff --git a/scripts/postbuild-compress.mjs b/scripts/postbuild-compress.mjs
index 3937a232..cca056c0 100644
--- a/scripts/postbuild-compress.mjs
+++ b/scripts/postbuild-compress.mjs
@@ -450,13 +450,18 @@ const loader = `
(async () => {${diag ? DIAG : ''}
var violations = 0
document.addEventListener('securitypolicyviolation', function () { violations++ })
- var fail = function (msg) {
+ // Two ways to fill the card, kept apart: fail() takes the loader's OWN fixed
+ // markup (the unsupported-browser notice), failText() takes anything built
+ // from an error, whose message the loader does not control, as plain text.
+ var card = function () {
var d = document.createElement('div')
d.style.cssText = 'position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:#0D1B2E;color:#F2F0EA;font:16px/1.6 sans-serif;text-align:center;padding:40px;z-index:99999'
- d.innerHTML = msg
document.body.appendChild(d)
var s = document.getElementById('bento-splash'); if (s) s.remove()
+ return d
}
+ var fail = function (html) { card().innerHTML = html }
+ var failText = function (text) { card().textContent = text }
if (${inflateMode === 'js' ? "typeof Uint8Array === 'undefined' || typeof TextDecoder === 'undefined'" : inflateMode === 'native' ? "typeof DecompressionStream === 'undefined'" : 'false'}) {
// The old text said "2023 or later" and then listed Chrome 80, which is
// 2020 — a reader checking their version against it learns nothing. It also
@@ -520,11 +525,24 @@ const loader = `
// report arrives in a later task and is counted, but nothing waits for
// it). Then new Function, also synchronous. Only the blob import is a
// promise, and it is the last resort.
- var mounted = function () { return !!(window.bento && window.bento.doc) }
+ // THE CONTRACT: an app publishes window.bento before it hands control back,
+ // { doc, … } running;
+ // { format, locked: true } waiting at its password gate (no doc yet);
+ // { format, refused: true } it painted its OWN refusal (a file it will
+ // not open) — it may throw afterwards.
+ // Any of the three means the app ran: no later path runs it again and the
+ // loader paints nothing. The loader's card is only for "nothing ran at all".
+ // Reading doc alone made every path of an encrypted file "fail", re-run the
+ // app (one gate per path) and end on the failure card (1.2.4–1.2.8). What
+ // the app PUBLISHED decides, not whether it threw: the check runs after a
+ // throw too.
+ var mounted = function () { return !!(window.bento && (window.bento.doc || window.bento.locked || window.bento.refused)) }
var runNow = function (name, fn) {
if (mounted()) return true
- try { fn() } catch (e) { tried.push(name + ': ' + (e && e.name) + ': ' + (e && e.message))${diag ? `; say('loader path ' + name + ' → ' + tried[tried.length - 1] + ' (t=' + Math.round(performance.now()) + ' ms since navigation)', true)` : ''}; return false }
+ var threw = false
+ try { fn() } catch (e) { threw = true; tried.push(name + ': ' + (e && e.name) + ': ' + (e && e.message))${diag ? `; say('loader path ' + name + ' → ' + tried[tried.length - 1] + ' (t=' + Math.round(performance.now()) + ' ms since navigation)', true)` : ''} }
var okp = mounted()
+ if (threw && !okp) return false
tried.push(name + (okp ? ': ok' : ': ran, no app (refused, or the app did not mount)'))${diag ? `
say('loader path ' + name + ' → ' + tried[tried.length - 1] + ' (t=' + Math.round(performance.now()) + ' ms since navigation)', true)` : ''}
if (okp) path = name
@@ -566,7 +584,8 @@ const loader = `
await import(url)
} catch (e) { why = why || ((e && e.name) + ': ' + (e && e.message)) }
document.removeEventListener('securitypolicyviolation', onv)
- var okb = !why && mounted()
+ // published counts even if the module then threw (a refusal may throw)
+ var okb = mounted()
tried.push('blob' + (okb ? ': ok' : why ? ': ' + why : ': imported, no app'))${diag ? `
say('loader path blob → ' + tried[tried.length - 1] + ' (t=' + Math.round(performance.now()) + ' ms since navigation)', true)` : ''}
if (okb) path = 'blob'
@@ -616,7 +635,7 @@ const loader = `
await import(url)`}
} catch (e) {${diag ? `
say('BOOT FAILED: ' + (e && e.name) + ': ' + (e && e.message) + (e && e.stack ? ' | ' + String(e.stack).split('\\n').slice(0, 3).join(' | ') : ''), true)` : ''}
- fail('This file could not start: ' + (e && e.message ? e.message : e))
+ failText('This file could not start: ' + (e && e.message ? e.message : e))
}
})()
`
diff --git a/scripts/test-shell-loader-published-browser.mjs b/scripts/test-shell-loader-published-browser.mjs
new file mode 100644
index 00000000..3330b4c0
--- /dev/null
+++ b/scripts/test-shell-loader-published-browser.mjs
@@ -0,0 +1,108 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// The loader decides "the app ran" from what the app PUBLISHED, never from a doc alone.
+//
+// node scripts/test-shell-loader-published-browser.mjs
+//
+// WHAT THIS PROVES, on shells built by the real scripts/postbuild-compress.mjs
+// from tiny synthetic apps, in Chromium. The contract the loader reads:
+// { doc } the app is running;
+// { locked: true } it is waiting at its password gate;
+// { refused: true } it painted its own refusal (and may throw after);
+// nothing it never ran — only then the loader's failure card.
+// For each kind of app: how many times the app ran (the loader cascade must
+// stop at the first path that ran it — re-running an app at a gate stacked
+// one password card per path, 1.2.4–1.2.8), which path it stopped at, and
+// whether the loader painted "every loader path was refused". Each is checked
+// with every path allowed, with only the blob import allowed (the inline and
+// Function paths refused, as a strict policy refuses them), and with a bundle
+// that uses `import.meta` (a SyntaxError in a classic script and in Function,
+// so only the blob import can run it — bento/type's bundle measured this way).
+import { writeFileSync, readFileSync, mkdtempSync } from 'node:fs'
+import { join, dirname } from 'node:path'
+import { tmpdir } from 'node:os'
+import { fileURLToPath } from 'node:url'
+import { execFileSync } from 'node:child_process'
+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 = join(dirname(fileURLToPath(import.meta.url)), '..')
+const dir = mkdtempSync(join(tmpdir(), 'loader-published-'))
+
+// every app counts its runs and draws one card per run, so a re-run shows
+const COUNT = `window.__runs = (window.__runs || 0) + 1; var c = document.createElement('div'); c.className = 'app-card'; document.body.appendChild(c);`
+const APPS = {
+ running: `${COUNT} window.bento = { doc: { format: 'x' } }`,
+ locked: `${COUNT} window.bento = { format: 'x', locked: true }`,
+ refused: `${COUNT} c.textContent = 'This file could not be opened'; window.bento = { format: 'x', refused: true }; throw new Error('app: unreadable file')`,
+ nothing: `${COUNT} throw new Error('app: crashed before publishing')`,
+ // the loader's failure message is plain text: an error message carrying
+ // markup reaches the card as characters, never as an element
+ markup: `${COUNT} throw new Error('app: <img data-rig-injected src="data:,"><b data-rig-injected>bold</b>')`,
+}
+// [ran, card] expected: the first three run once and paint nothing; an app
+// that publishes nothing is tried on every path and ends on the card
+const EXPECT = { running: [1, false], locked: [1, false], refused: [1, false], nothing: [null, true], markup: [null, true] }
+
+function build(name, body) {
+ const file = join(dir, `${name}.html`)
+ writeFileSync(file, `<!DOCTYPE html><html><head><meta charset="UTF-8"><title>t</title>
+<script type="module" crossorigin>${body}</script>
+<style rel="stylesheet" crossorigin>#app{color:red}</style>
+<script type="application/bento+json" id="bento-doc"></script></head>
+<body><style>#bento-splash{opacity:.5}</style><div id="bento-splash"><div>splash</div></div><div id="app"></div></body></html>`)
+ execFileSync(process.execPath, [join(root, 'scripts/postbuild-compress.mjs'), file, '--loader', 'cascade'], { cwd: join(root, 'slides'), encoding: 'utf8', env: { ...process.env, ZOPFLI: '0' } })
+ return file
+}
+const BLOB_ONLY = () => {
+ const append = Element.prototype.appendChild
+ Element.prototype.appendChild = function (n) {
+ if (n && n.id === 'bento-rt-script') throw new Error('rig: inline script refused')
+ return append.call(this, n)
+ }
+ window.Function = new Proxy(window.Function, { construct() { throw new Error('rig: Function refused') } })
+}
+
+const browser = await chromium.launch({ executablePath: process.env.CHROME_PATH, headless: true })
+try {
+ for (const [variant, opts] of [['every path allowed', {}], ['only the blob import allowed', { blobOnly: true }], ['a bundle using import.meta', { meta: true }]]) {
+ console.log(`\n${variant}\n`)
+ for (const [kind, body] of Object.entries(APPS)) {
+ const src = opts.meta ? `const here = import.meta.url; ${body}` : body
+ const file = build(`${kind}${opts.meta ? '-meta' : ''}`, src)
+ const ctx = await browser.newContext()
+ if (opts.blobOnly) await ctx.addInitScript(BLOB_ONLY)
+ const p = await ctx.newPage()
+ await p.goto('file://' + file)
+ await p.waitForFunction(() => window.bento?.loader || /every loader path/.test(document.body.innerText), null, { timeout: 8000 }).catch(() => {})
+ await p.waitForTimeout(200)
+ const r = await p.evaluate(() => ({
+ runs: window.__runs || 0, cards: document.querySelectorAll('.app-card').length,
+ card: /every loader path/.test(document.body.innerText), path: window.bento?.loader?.path ?? null,
+ injected: document.querySelectorAll('[data-rig-injected]').length,
+ literal: /<img data-rig-injected/.test(document.body.innerText),
+ }))
+ const [runs, card] = EXPECT[kind]
+ const wantPath = opts.blobOnly || opts.meta ? 'blob' : 'inline'
+ if (kind === 'markup') {
+ ok(r.card && r.injected === 0 && r.literal,
+ `${kind}: the failure message is plain text — no element made from it, the markup shown as characters (${r.injected} element(s), literal ${r.literal})`)
+ } else if (kind === 'nothing') {
+ ok(r.card && !r.path, `${kind}: the loader's failure card, and no path claimed (${r.runs} run(s))`)
+ } else {
+ ok(r.runs === runs && r.cards === 1 && r.card === card && r.path === wantPath,
+ `${kind}: ran once, one card of its own, no loader card, stopped at ${wantPath} (runs ${r.runs}, cards ${r.cards}, loader card ${r.card}, path ${r.path})`)
+ }
+ await ctx.close()
+ }
+ }
+} finally {
+ await browser.close()
+}
+console.log(`\n${checks - failures}/${checks} checks passed`)
+if (failures) process.exit(1)
diff --git a/scripts/test-slides-encrypted-open-browser.mjs b/scripts/test-slides-encrypted-open-browser.mjs
new file mode 100644
index 00000000..24bce98d
--- /dev/null
+++ b/scripts/test-slides-encrypted-open-browser.mjs
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: MIT
+// Copyright (c) 2026 The Bento authors
+// A password-protected deck opens: one gate, no failure card, and the password unlocks it.
+//
+// npm run build:single --prefix slides && node scripts/test-slides-encrypted-open-browser.mjs
+//
+// WHAT THIS PROVES, in the packaged document. The shell's loader (#495,
+// scripts/postbuild-compress.mjs) runs the app through a cascade of paths and
+// decides each one worked by reading `window.bento` the moment it returns. An
+// encrypted deck's app is then waiting at its password gate and had published
+// nothing, so every path read as refused: the app ran once per path (three
+// password cards) and the loader painted "every loader path was refused" over
+// all of them. Released slides 1.2.4–1.2.8 could not open a password-protected
+// deck (measured on 1.2.8, Chromium and WebKit). Now the app publishes
+// `{ format, locked: true }` before its gate and the loader counts `locked` as
+// mounted. Checked here, on a deck encrypted through the real UI and saved:
+// 1. opening it shows exactly ONE gate, no failure card, and window.bento is
+// the locked stub; the loader stopped at its first path;
+// 2. a wrong password keeps the one gate and says so; the right one boots the
+// editor with the deck's slides and no gate left;
+// 3. the same when only the LAST path (the blob import) can run — the
+// inline and Function paths refused, as a strict policy refuses them;
+// 4. what this version writes opens again: ⌘S re-saves encrypted, and the
+// self-update re-splice (updates.build) produces a file with one gate
+// that unlocks.
+// Mutation: drop the app's stub (or the loader's `locked`) and 1 goes red.
+import { readFileSync, writeFileSync, mkdtempSync } from 'node:fs'
+import { createHash } from 'node:crypto'
+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 shellPath = new URL('../slides/dist-single/Bento_Slides.bento.html', import.meta.url)
+const shell = readFileSync(shellPath)
+const dir = mkdtempSync(join(tmpdir(), 'bento-encrypted-'))
+
+// the inline and Function paths refused, as a policy without 'unsafe-inline'
+// and 'unsafe-eval' refuses them: only the blob import is left
+const BLOB_ONLY = () => {
+ const append = Element.prototype.appendChild
+ Element.prototype.appendChild = function (n) {
+ if (n && n.id === 'bento-rt-script') throw new Error('rig: inline script refused')
+ return append.call(this, n)
+ }
+ const F = window.Function
+ window.Function = new Proxy(F, { construct() { throw new Error('rig: Function refused') } })
+}
+
+const browser = await chromium.launch({ executablePath: process.env.CHROME_PATH, headless: true })
+async function openFile(file, { blobOnly = false } = {}) {
+ const ctx = await browser.newContext({ viewport: { width: 1280, height: 860 }, acceptDownloads: true })
+ await ctx.route(/^https?:\/\/(?!rig\.test)/, (r) => r.abort())
+ await ctx.route('https://rig.test/shell.html', (r) => r.fulfill({ body: shell, contentType: 'text/html' }))
+ await ctx.addInitScript(() => { delete window.showSaveFilePicker; try { localStorage.setItem('bento-slideshow-started', '1') } catch {} })
+ if (blobOnly) await ctx.addInitScript(BLOB_ONLY)
+ 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)
+ // the loader is done when it has recorded a path or painted its card
+ await p.waitForFunction(() => window.bento?.loader || /every loader path/.test(document.body?.innerText || ''), null, { timeout: 10000 }).catch(() => {})
+ await p.waitForTimeout(400)
+ return { ctx, p, errors }
+}
+const state = (p) => p.evaluate(() => ({
+ gates: document.querySelectorAll('.ed-pwcard').length,
+ card: /every loader path/.test(document.body.innerText),
+ locked: window.bento?.locked === true && !window.bento.doc,
+ path: window.bento?.loader?.path,
+ tried: window.bento?.loader?.tried?.length,
+}))
+async function unlock(p, pass) {
+ // .first(): the broken loader leaves several gates, and the rig must report
+ // that rather than die on it
+ const input = p.locator('.ed-pwcard input[type=password]').first()
+ await input.fill(pass)
+ await input.press('Enter')
+}
+const booted = (p) => p.waitForFunction(() => window.bento?.doc && document.querySelector('.ed-topbar .ed-logo'), null, { timeout: 10000 }).then(() => true, () => false)
+async function saveDownload(p, act) {
+ const dl = p.waitForEvent('download', { timeout: 15000 })
+ await act()
+ const d = await dl
+ const file = join(dir, `${Math.random().toString(36).slice(2)}.bento.html`)
+ await d.saveAs(file)
+ return file
+}
+
+try {
+ // --- make an encrypted deck through the UI ---------------------------------
+ const plainFile = join(dir, 'plain.bento.html')
+ writeFileSync(plainFile, shell)
+ const made = await openFile(plainFile)
+ await booted(made.p)
+ const slides = await made.p.evaluate(() => window.bento.doc.slides.length)
+ await made.p.locator('.ed-split-caret').click()
+ await made.p.locator('.ed-save-menu').getByText('Encrypt with password…', { exact: true }).click()
+ await made.p.locator('dialog.ed-pwdialog .pw1').fill(PASS)
+ await made.p.locator('dialog.ed-pwdialog .pw2').fill(PASS)
+ const encFile = await saveDownload(made.p, () => made.p.locator('dialog.ed-pwdialog button').last().click())
+ await made.ctx.close()
+ ok(/bento\/enc/.test(readFileSync(encFile, 'utf8')), `the saved deck carries an encrypted envelope (${slides} slides inside)`)
+
+ for (const [label, opts] of [['every loader path allowed', {}], ['only the blob import allowed', { blobOnly: true }]]) {
+ console.log(`\n${label}\n`)
+ const { ctx, p, errors } = await openFile(encFile, opts)
+ const s = await state(p)
+ ok(s.gates === 1 && !s.card, `one password gate, no failure card (${s.gates} gate(s)${s.card ? ', failure card shown' : ''})`)
+ ok(s.locked, 'window.bento is the locked stub, with no doc')
+ ok(s.path === (opts.blobOnly ? 'blob' : 'inline'), `the loader stopped at the ${opts.blobOnly ? 'blob' : 'first'} path (${s.path}; ${s.tried} tried)`)
+ await unlock(p, 'not the password')
+ await p.waitForTimeout(800)
+ const w = await p.evaluate(() => ({ gates: document.querySelectorAll('.ed-pwcard').length, err: document.querySelector('.ed-pwerr')?.textContent || '' }))
+ ok(w.gates === 1 && w.err.length > 0 && !(await p.evaluate(() => !!window.bento.doc)), `a wrong password keeps the one gate and says so ("${w.err}")`)
+ await unlock(p, PASS)
+ const up = await booted(p)
+ const after = await p.evaluate(() => ({ n: window.bento.doc?.slides.length, gates: document.querySelectorAll('.ed-pwcard, .ed-pwgate').length, card: /every loader path/.test(document.body.innerText) }))
+ ok(up && after.n === slides && after.gates === 0 && !after.card, `the password boots the editor (${after.n} slides, ${after.gates} gate(s) left)`)
+ // blob-only: the rig's own refusals are page errors by design; nothing else may be
+ const real = errors.filter((e) => !/^rig: /.test(e))
+ ok(real.length === 0, `no page error${real.length ? ' — ' + real[0].slice(0, 100) : ''}`)
+
+ if (!opts.blobOnly) {
+ console.log('\nwhat this version writes opens again\n')
+ const resaved = await saveDownload(p, () => p.keyboard.press(process.platform === 'darwin' ? 'Meta+s' : 'Control+s'))
+ const sha256 = createHash('sha256').update(shell).digest('hex')
+ const updated = await p.evaluate((r) => window.bento.updates.build(r), { url: 'https://rig.test/shell.html', sha256, version: '99.0.0' })
+ const updFile = join(dir, 'updated.bento.html')
+ writeFileSync(updFile, updated)
+ for (const [what, file] of [['the ⌘S re-save', resaved], ['the self-update re-splice', updFile]]) {
+ ok(/bento\/enc/.test(readFileSync(file, 'utf8')), `${what} is still encrypted`)
+ const o = await openFile(file)
+ const s2 = await state(o.p)
+ await unlock(o.p, PASS)
+ const up2 = await booted(o.p)
+ ok(s2.gates === 1 && !s2.card && up2 && await o.p.evaluate(() => window.bento.doc.slides.length) === slides,
+ `${what} opens: one gate, no card, unlocks to ${slides} slides`)
+ await o.ctx.close()
+ }
+ }
+ await ctx.close()
+ }
+} finally {
+ await browser.close()
+}
+console.log(`\n${checks - failures}/${checks} checks passed`)
+if (failures) process.exit(1)
diff --git a/slides/src/main.ts b/slides/src/main.ts
index 7d971f7c..c6dc3b97 100644
--- a/slides/src/main.ts
+++ b/slides/src/main.ts
@@ -85,6 +85,13 @@ applyDirection()
const embedded = readEmbeddedDoc()
const envelope = embedded ? parseEnvelope(embedded) : null
if (envelope) {
+ // Published BEFORE the gate, synchronously: the shell's loader decides the
+ // app mounted by reading window.bento as soon as this script returns, and an
+ // app waiting for a password has no doc yet. Without this stub every loader
+ // path read as refused, re-ran the app (one gate per path) and painted
+ // "every loader path was refused" over the gates (1.2.4–1.2.8). bootWith
+ // replaces it wholesale after unlock.
+ ;(window as any).bento = { format: 'bento/slides', locked: true }
void passwordGate()
} else {
const parsed = embedded ? parseDoc(embedded) : null