Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
home: no recents snapshot while a sealed document is open (Android), with a page seal signal (#787)
nyblnet14b648e33c69
diff --git a/docs/DECISIONS.md b/docs/DECISIONS.mdindex bcae36dd..05055aa3 100644--- a/docs/DECISIONS.md+++ b/docs/DECISIONS.md@@ -11366,6 +11366,27 @@ test-spaces-chrome reads the pill's values from slides' stylesheet and holdsthe computed pill to them at 1440 and 390. It presses each new home withtrusted input, and its before/after command walk maps each moved command toits new home rather than dropping it.++## 2026-10-18 — Android: no recents snapshot while a sealed document is open++While the open document is password-protected or identity-sealed, the Android+editor turns off its app-switcher snapshot (`setRecentsScreenshotEnabled(false)`,+API 33+), so the recents card is blank. The decision comes from the bytes the+host opened or last wrote (`DocumentIndex.isEncrypted`), so it switches on at+the save that encrypts the file and back off at the save that removes the+password. The page can also say so first, over the bridge (`seal` capability,+`seal.state {sealed}`, fire-and-forget), the moment a password is set and+before any save lands. It can only ADD blanking: recents stays blank while+the file OR the page says sealed. It comes back only when the file was+written unsealed AND the page says unsealed (security). Below API 33 the only tool is `FLAG_SECURE`, which also blocks+screenshots, so it is not set by default there; it can come later as an+opt-in setting. Measured on the emulator (API 36), with recents opened from+Home so the stored snapshot is what shows: a sealed document's card is blank;+the same file on a build without this change shows its screen; an unsealed+document's card still shows its content. With the page signal (sent here+through the same postMessage channel the kernel will use): an unsealed file+whose page says sealed is blank; a sealed file whose page says unsealed is+still blank; an unsealed file whose page says unsealed again shows content.## 2026-10-18 — bento/connect on Android: the recovery code and key blobs (Recovery.kt)The Android port of `kernel/src/recovery.ts` (K2b). It reproduces every byte ofdiff --git a/home/android/app/src/main/java/page/bento/home/EditorActivity.kt b/home/android/app/src/main/java/page/bento/home/EditorActivity.ktindex 9cf433d4..1f665af3 100644--- a/home/android/app/src/main/java/page/bento/home/EditorActivity.kt+++ b/home/android/app/src/main/java/page/bento/home/EditorActivity.kt@@ -205,6 +205,7 @@ class EditorActivity : Activity() {fatal(getString(R.string.err_open))} else {bytes = data+ applySealedPrivacy(data)Recents.touch(this, uri, docName)chooseOrigin(facts!!) { origin ->if (isFinishing || isDestroyed) return@chooseOrigin@@ -408,6 +409,9 @@ class EditorActivity : Activity() {override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {openDocumentVended = falseexportTargets.clear()+ // a new page says nothing yet; only the file speaks until it does+ pageSealed = false+ applySealedPrivacy()}}@@ -466,7 +470,7 @@ class EditorActivity : Activity() {// Capabilities first, then the shared bridge, in one injected script:// bridge.js advertises the per-document store to the page ONLY when// the host declares it here, so a host without one never offers it.- val src = "window.__bentoHostCaps = ['store'];\n" ++ val src = "window.__bentoHostCaps = ['store', 'seal'];\n" +assets.open("bridge.js").use { it.readBytes().toString(Charsets.UTF_8) }WebViewCompat.addDocumentStartJavaScript(web, src, rules)}@@ -612,6 +616,12 @@ class EditorActivity : Activity() {}val id = m.optInt("id", -1)when (m.optString("op")) {+ "seal.state" -> {+ // Fire-and-forget. The page can only ADD blanking (security):+ // see applySealedPrivacy.+ pageSealed = m.optBoolean("sealed", false)+ applySealedPrivacy()+ }"begin" -> {if (!openDocumentVended && canWriteInPlace) {openDocumentVended = true@@ -728,6 +738,36 @@ class EditorActivity : Activity() {*/private fun targetsOpenDocument(name: String?) = openDocumentVended && name == docName+ /**+ * Neutral recents while a sealed document is open (threat model §30.6): an+ * encrypted or identity-sealed file gets no app-switcher snapshot, since the+ * snapshot is a picture of the unlocked content. Decided from the bytes this+ * host opened or just wrote, OR from the page's own "sealed" signal (bridge+ * 'seal'), which arrives the moment a password is set — before any save. API 33+; below that the only tool is FLAG_SECURE, which+ * also blocks screenshots, so it is an opt-in there and not set here.+ */+ private fun applySealedPrivacy(data: ByteArray) {+ val head = String(data, 0, minOf(data.size, DocumentIndex.HEAD_CHARS), Charsets.UTF_8)+ fileSealed = DocumentIndex.isEncrypted(head)+ applySealedPrivacy()+ }++ /** The file the host opened or last wrote is sealed. */+ private var fileSealed = false+ /** The page says the document is sealed (a password set, not yet saved). */+ private var pageSealed = false++ /**+ * Blank while EITHER says sealed. The page's signal can only add: a page+ * claiming "unsealed" never re-enables the snapshot of a file the host+ * knows is sealed. It comes back only once both say unsealed — the file+ * was written unsealed AND the page reports so.+ */+ private fun applySealedPrivacy() {+ if (Build.VERSION.SDK_INT < 33) return+ setRecentsScreenshotEnabled(!(fileSealed || pageSealed))+ }+private fun writeInPlace(id: Int, text: String) {val uri = docUri ?: return reply(id, false, "no document")val data = text.toByteArray()@@ -741,6 +781,7 @@ class EditorActivity : Activity() {runOnUiThread {if (err == null) {bytes = data+ applySealedPrivacy(data)OriginIndex.record(this, f!!.uri,DocumentOrigin.Claim(originHost.substringBefore('.'), f.docId, f.contentSha256))}diff --git a/home/bridge.js b/home/bridge.jsindex 04c48ed2..619522fb 100644--- a/home/bridge.js+++ b/home/bridge.js@@ -235,13 +235,34 @@;(() => {const caps = Array.isArray(window.__bentoHostCaps) ? window.__bentoHostCaps.slice() : []try { delete window.__bentoHostCaps } catch (_) {}- if (window !== window.top || caps.indexOf('store') < 0) return+ if (window !== window.top) return+ // Only what this file can relay; a host naming something else adds nothing.+ const offered = ['store', 'seal'].filter((c) => caps.indexOf(c) >= 0)+ if (!offered.length) returnconst prev = window.__bentoHost && Array.isArray(window.__bentoHost.ops) ? window.__bentoHost.ops : []- const ops = Object.freeze(Array.from(new Set(prev.concat(['store']))))+ const ops = Object.freeze(Array.from(new Set(prev.concat(offered))))Object.defineProperty(window, '__bentoHost', {value: Object.freeze({ ops }), writable: false, enumerable: true, configurable: false,})+ const CH = '__bento_tray__'++ // 'seal': the page tells the host whether the open document is sealed+ // (password or identity), whenever that changes, so the host can keep the+ // document out of its own surfaces (the app-switcher snapshot) before the+ // sealed file is even saved. Fire-and-forget: {sealed: boolean}, nothing+ // comes back. The host may only ADD protection on this signal; it never+ // lifts protection for a file it knows is sealed because a page said so.+ if (offered.indexOf('seal') >= 0) {+ window.addEventListener('message', (ev) => {+ const d = ev.data+ if (ev.source !== window || !d || d[CH] !== true || d.dir !== 'req' || d.op !== 'seal.state') return+ const p = d.payload || {}+ if (typeof p.sealed !== 'boolean') return+ call('seal.state', { sealed: p.sealed }).catch(() => {})+ })+ }+ if (offered.indexOf('store') < 0) return// THE NATIVE CONTRACT, identical on every host. Requests arrive through the// ordinary call() channel as {id, op, name} (plus b64 for store.set). The@@ -256,7 +277,6 @@// | 'unavailable' (the host could not do it)// The partition is the document's identity as the HOST derived it; nothing// in a request names it. scripts/test-home-docstore.mjs holds a host to this.- const CH = '__bento_tray__'const KNOWN = { 'store.get': 1, 'store.set': 1, 'store.list': 1, 'store.delete': 1 }// Both transports carry strings, so bytes travel as base64 — and are turned// back into a Uint8Array HERE, in the page's own realm, because the kernel