Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
bento.page/id: privacy notice and web account-deletion page for bento/id, prepared (#762)
nyblnetbf8f51091650
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex cbce102c..42db3d8b 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -2691,6 +2691,13 @@ jobs:# that refuses the recovery copy gets the notice once, held to read;# pt and de show slides' words. Planted in bento-spaces-autosave.run: node scripts/test-spaces-recovery-browser.mjs+ - name: bento/id privacy notice and web deletion page (build rules + Chromium)+ # A publishing build refuses any page still carrying a __PLACEHOLDER__;+ # the deletion page's CSP pins its exact inline script and style and+ # lets it reach only the directory. In Chromium with the API mocked:+ # the start → code → done flow, its refusals, and that it never says+ # whether an address exists.+ run: node scripts/test-id-pages-browser.mjs- name: bento.page passkey association files never publish a placeholder# scripts/well-known.mjs fills /.well-known/apple-app-site-association# and assetlinks.json from site-src/well-known/ once the Apple team iddiff --git a/scripts/build-id-pages.mjs b/scripts/build-id-pages.mjsnew file mode 100644index 00000000..aa1e5774--- /dev/null+++ b/scripts/build-id-pages.mjs@@ -0,0 +1,86 @@+#!/usr/bin/env node+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+//+// Build bento.page/id/privacy and bento.page/id/delete — the bento/id privacy+// notice and the web account-deletion page (an app-store requirement: a person+// must be able to ask for deletion without the app).+//+// node scripts/build-id-pages.mjs --facts <facts.json> [--out site] [--api https://id.bento.page]+// node scripts/build-id-pages.mjs --preview <dir> (placeholders left visible; never into site/)+//+// facts.json supplies what only the maintainer can state — the controller, the+// contact address, the effective date, the legal basis, rights wording and+// the tombstone retention. Every one is a __PLACEHOLDER__ in the source, and a+// normal build REFUSES to write a page that still contains one: a privacy+// notice that says "__CONTROLLER__" must never be published.+//+// The deletion page gets a Content-Security-Policy built from the SHA-256 of+// its exact inline script and style, with connect-src limited to the directory+// — the same discipline as the import page (scripts/build-import-page.mjs):+// replacer functions, never replacement strings, and a read-back check.+//+// Publishing is the maintainer's, when the directory is live.++import { createHash } from 'node:crypto'+import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'+import { dirname, join } from 'node:path'+import { fileURLToPath } from 'node:url'++const root = join(dirname(fileURLToPath(import.meta.url)), '..')+export const FACT_KEYS = ['CONTROLLER', 'CONTACT_EMAIL', 'EFFECTIVE_DATE', 'LEGAL_BASIS', 'RIGHTS_JURISDICTION', 'CHILDREN', 'TOMBSTONE_RETENTION']+const PLACEHOLDER = /__[A-Z0-9_]+__/+const sha = (s) => `'sha256-${createHash('sha256').update(s, 'utf8').digest('base64')}'`+const esc = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')++export function build({ facts = {}, api = 'https://id.bento.page', preview = false } = {}) {+ if (!/^https:\/\/[a-z0-9.-]+(:\d+)?$/.test(api) && !(preview && /^http:\/\/localhost(:\d+)?$/.test(api))) {+ throw new Error(`--api must be an https origin (got ${api})`)+ }+ let privacy = readFileSync(join(root, 'site-src/id-privacy.html'), 'utf8')+ let del = readFileSync(join(root, 'site-src/id-delete.html'), 'utf8')+ for (const k of FACT_KEYS) {+ const v = facts[k]+ if (v === undefined) continue+ if (typeof v !== 'string' || !v.trim() || PLACEHOLDER.test(v)) throw new Error(`fact ${k} must be non-empty text`)+ privacy = privacy.split(`__${k}__`).join(esc(v))+ }+ del = del.replace('__ID_API__', () => api)+ // the CSP covers the exact inline script and style+ const script = /<script>([\s\S]*?)<\/script>/.exec(del)?.[1]+ const style = /<style>([\s\S]*?)<\/style>/.exec(del)?.[1]+ if (script === undefined || style === undefined) throw new Error('id-delete.html lost its inline script or style')+ const csp = [+ "default-src 'none'", `script-src ${sha(script)}`, `style-src ${sha(style)}`,+ `connect-src ${api}`, "img-src 'self' data:", "base-uri 'none'", "form-action 'none'",+ ].join('; ')+ del = del.replace('<!--ID_DELETE_CSP-->', () => `<meta http-equiv="Content-Security-Policy" content="${csp}">`)+ if (del.split('http-equiv="Content-Security-Policy"').length !== 2) throw new Error('deletion page must carry exactly one CSP')+ if (/<script>([\s\S]*?)<\/script>/.exec(del)?.[1] !== script) throw new Error('inline script does not read back as the hashed one')+ if (/\bsrc=/.test(del) || /\bsrc=/.test(privacy)) throw new Error('no external resources on these pages')+ if (!preview) {+ for (const [name, html] of [['privacy', privacy], ['delete', del]]) {+ const left = html.match(PLACEHOLDER)+ if (left) throw new Error(`${name} page still contains ${left[0]} — refusing to build it for publishing`)+ }+ }+ return { privacy, delete: del, csp }+}++function main(argv) {+ const arg = (k) => { const i = argv.indexOf(k); return i >= 0 ? argv[i + 1] : undefined }+ const previewDir = arg('--preview')+ const out = previewDir ?? arg('--out') ?? join(root, 'site')+ if (previewDir && /(^|\/)site\/?$/.test(previewDir)) throw new Error('--preview never writes into site/')+ const facts = arg('--facts') ? JSON.parse(readFileSync(arg('--facts'), 'utf8')) : {}+ const pages = build({ facts, api: arg('--api') ?? 'https://id.bento.page', preview: !!previewDir })+ for (const [name, html] of [['privacy', pages.privacy], ['delete', pages.delete]]) {+ mkdirSync(join(out, 'id', name), { recursive: true })+ writeFileSync(join(out, 'id', name, 'index.html'), html)+ }+ console.log(`bento/id pages → ${join(out, 'id')}${previewDir ? ' (PREVIEW: placeholders visible)' : ''}`)+}++if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {+ try { main(process.argv.slice(2)) } catch (e) { console.error(String(e.message || e)); process.exit(1) }+}diff --git a/scripts/test-id-pages-browser.mjs b/scripts/test-id-pages-browser.mjsnew file mode 100644index 00000000..9a7afaf2--- /dev/null+++ b/scripts/test-id-pages-browser.mjs@@ -0,0 +1,111 @@+#!/usr/bin/env node+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+// The bento/id privacy notice and web account-deletion page.+//+// node scripts/test-id-pages-browser.mjs+//+// Build rules: a publishing build refuses any page that still carries a+// __PLACEHOLDER__ (a privacy notice reading "__CONTROLLER__" must never go+// live), and the deletion page carries exactly one CSP whose hashes match its+// inline script and style, with connect-src the directory alone.+// In Chromium, with the directory API mocked: the deletion flow (start →+// code → done), its refusals, that it never says whether an address exists,+// and that the CSP really blocks every other origin.+import { build, FACT_KEYS } from './build-id-pages.mjs'++const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright')+let fails = 0, passes = 0+const ok = (c, n) => { if (c) passes++; else { fails++; console.log('FAIL ' + n) } }+const FACTS = Object.fromEntries(FACT_KEYS.map((k) => [k, `fact-${k.toLowerCase()}`]))+FACTS.CONTACT_EMAIL = '[email protected]'++// ---- build rules ----+let refused = ''+try { build({ facts: {} }) } catch (e) { refused = e.message }+ok(/__[A-Z_]+__/.test(refused), `a publishing build with no facts is refused (${refused.slice(0, 60)})`)+for (const k of FACT_KEYS) {+ const partial = { ...FACTS }; delete partial[k]+ let r = ''+ try { build({ facts: partial }) } catch (e) { r = e.message }+ ok(r.includes(`__${k}__`), `missing ${k} → refused`)+}+let bad = ''+try { build({ facts: { ...FACTS, CONTROLLER: '__X__' } }) } catch (e) { bad = e.message }+ok(/CONTROLLER/.test(bad), 'a fact that is itself a placeholder → refused')+let http = ''+try { build({ facts: FACTS, api: 'http://id.bento.page' }) } catch (e) { http = e.message }+ok(/https/.test(http), 'a non-https API → refused')+const pages = build({ facts: FACTS })+ok(!/__[A-Z0-9_]+__/.test(pages.privacy + pages.delete), 'a complete build leaves no placeholder')+ok(pages.privacy.includes('[email protected]') && pages.privacy.includes('fact-controller'), 'facts are substituted into the notice')+ok(build({ facts: { ...FACTS, CONTROLLER: '<b>x</b>' } }).privacy.includes('<b>x</b>'), 'facts are HTML-escaped')+ok(/connect-src https:\/\/id\.bento\.page;/.test(pages.csp) && /default-src 'none'/.test(pages.csp) && /form-action 'none'/.test(pages.csp), `CSP: default none, connect only to the directory, no form posts (${pages.csp.slice(0, 50)}…)`)+const prev = build({ preview: true })+ok(prev.privacy.includes('__CONTROLLER__'), 'a preview build keeps placeholders visible')+for (const must of ['What the directory stores', 'What it never stores', 'Amazon SES', '/id/delete', '13 months']) {+ ok(pages.privacy.includes(must), `notice says: ${must}`)+}++// ---- the deletion page in Chromium ----+const browser = await chromium.launch({ executablePath: process.env.CHROME_PATH, headless: true })+const page = await browser.newPage()+const seen = []+const bodies = []+const errors = []+page.on('pageerror', (e) => errors.push(String(e)))+page.on('request', (r) => seen.push(r.url()))+await page.route('https://bento.page/id/delete', (r) => r.fulfill({ contentType: 'text/html', body: pages.delete }))+await page.route('https://id.bento.page/**', async (r) => {+ const req = r.request()+ if (req.method() === 'OPTIONS') return r.fulfill({ status: 204, headers: { 'access-control-allow-origin': '*', 'access-control-allow-headers': 'content-type', 'access-control-allow-methods': 'POST' } })+ const b = JSON.parse(req.postData() || '{}')+ bodies.push({ path: new URL(req.url()).pathname, b })+ const cors = { 'access-control-allow-origin': '*' }+ if (req.url().endsWith('/v1/delete/start')) return r.fulfill({ status: 202, headers: cors, contentType: 'application/json', body: '{"ok":true}' })+ if (req.url().endsWith('/v1/delete/complete')) {+ return b.code === 'ABCDEFGH' ? r.fulfill({ status: 204, headers: cors }) : r.fulfill({ status: 400, headers: cors, contentType: 'application/json', body: '{"error":"invalid"}' })+ }+ return r.fulfill({ status: 404, headers: cors })+})+await page.route('https://evil.example/**', (r) => r.fulfill({ status: 200, body: 'reached' }))+await page.goto('https://bento.page/id/delete')++const status = () => page.textContent('#status')+await page.fill('#email', 'not-an-address')+await page.click('#send')+ok(/Enter the email/.test(await status()), 'a malformed address is refused before any request')+ok(bodies.length === 0, 'no request for a malformed address')++await page.fill('#email', '[email protected]')+await page.click('#send')+await page.waitForSelector('#step-code:not([hidden])')+ok(bodies[0]?.path === '/v1/delete/start' && JSON.stringify(bodies[0].b) === '{"email":"[email protected]"}', 'start sends exactly {email}')+ok(/If Someone@Example\.com has a bento\/id, we’ve sent it a code/.test(await page.textContent('#sent')), 'the page never says whether the address exists')++await page.fill('#code', 'abc')+await page.click('#confirm')+ok(/8 letters and numbers/.test(await status()) && bodies.length === 1, 'a malformed code is refused before any request')+await page.fill('#code', 'ABCDEFGL') // L is not in the code alphabet+await page.click('#confirm')+ok(bodies.length === 1, 'a code outside the alphabet (L) is refused before any request')+await page.fill('#code', 'zzzzzzzz')+await page.click('#confirm')+await page.waitForFunction(() => /didn’t work/.test(document.getElementById('status').textContent))+ok(bodies[1]?.b.code === 'ZZZZZZZZ', 'the code is sent uppercased')+await page.fill('#code', 'abcdefgh')+await page.click('#confirm')+await page.waitForFunction(() => /Done/.test(document.getElementById('status').textContent))+ok(/removed from the directory/.test(await status()), 'the right code → done')+ok(JSON.stringify(bodies[2]?.b) === '{"email":"[email protected]","code":"ABCDEFGH"}', 'complete sends exactly {email, code}')++const blocked = await page.evaluate(() => fetch('https://evil.example/x').then(() => 'reached', () => 'blocked'))+ok(blocked === 'blocked', 'the CSP blocks a request to any other origin')+const inline = await page.evaluate(() => { const s = document.createElement('script'); s.textContent = 'window.__ran = 1'; document.body.appendChild(s); return window.__ran === 1 })+ok(!inline, 'the CSP blocks an injected inline script')+ok(seen.every((u) => u.startsWith('https://bento.page/id/delete') || u.startsWith('https://id.bento.page/')), `the page reached only itself and the directory (${[...new Set(seen.map((u) => new URL(u).host))]})`)+ok(errors.length === 0, `no page errors (${errors})`)++await browser.close()+console.log(`${passes} passed, ${fails} failed`)+process.exit(fails)diff --git a/site-src/id-delete.html b/site-src/id-delete.htmlnew file mode 100644index 00000000..f265a470--- /dev/null+++ b/site-src/id-delete.html@@ -0,0 +1,108 @@+<!DOCTYPE html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<!--ID_DELETE_CSP-->+<title>Delete your bento/id — bento.page</title>+<meta name="description" content="Remove your email address and keys from the bento/id directory.">+<meta name="robots" content="noindex">+<link rel="canonical" href="https://bento.page/id/delete">+<style>+:root{--ink:#0D1B2E;--panel:#16273E;--text:rgba(196,206,221,.92);--dim:rgba(182,193,210,.62);--white:#F4F6F9;--peach:#FF9E8A;--line:rgba(182,193,210,.24)}+*{margin:0;padding:0;box-sizing:border-box}+body{background:var(--ink);color:var(--text);font-family:'Instrument Sans',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;line-height:1.6}+a{color:var(--peach)}+main{max-width:560px;margin:0 auto;padding:48px 16px 80px}+h1{color:var(--white);font-family:Fraunces,Georgia,serif;font-size:clamp(28px,5vw,38px);line-height:1.1;margin-bottom:12px}+p{margin:0 0 12px}+label{display:block;color:var(--white);font-weight:600;margin:16px 0 6px}+input{width:100%;font:inherit;padding:10px 12px;border-radius:10px;border:1px solid var(--line);background:var(--panel);color:var(--white)}+input:focus{outline:2px solid var(--peach);outline-offset:1px}+button{margin-top:14px;font:inherit;font-weight:700;padding:10px 22px;border-radius:999px;border:0;background:var(--peach);color:var(--ink);cursor:pointer}+button[disabled]{opacity:.5;cursor:default}+#status{margin-top:16px;min-height:1.6em}+#status[data-kind="error"]{color:#ffb4a6}+[hidden]{display:none!important}+.small{color:var(--dim);font-size:14px;margin-top:24px}+</style>+</head>+<body>+<main>+<h1>Delete your bento/id</h1>+<p>This removes your email address, keys and any recovery data from the+bento/id directory. People who look up your address will see that it was+withdrawn. Files you have on your devices, and copies other people already+have, are not affected.</p>+<p>If you still have bento/home, you can also do this there.</p>++<form id="step-email" novalidate>+ <label for="email">Email address</label>+ <input id="email" type="email" autocomplete="email" required>+ <button id="send" type="submit">Send a code</button>+</form>++<form id="step-code" novalidate hidden>+ <p id="sent"></p>+ <label for="code">Code</label>+ <input id="code" inputmode="text" autocomplete="one-time-code" autocapitalize="characters" spellcheck="false" maxlength="8" required>+ <button id="confirm" type="submit">Delete my bento/id</button>+</form>++<p id="status" role="status" aria-live="polite"></p>+<p class="small">What we store and why: <a href="/id/privacy">bento/id privacy notice</a>.</p>+</main>+<script>+(() => {+ 'use strict'+ const API = '__ID_API__'+ const $ = (id) => document.getElementById(id)+ const say = (text, kind) => { const s = $('status'); s.textContent = text; s.dataset.kind = kind || '' }+ let email = ''++ const post = async (path, body) => {+ try {+ return await fetch(API + path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })+ } catch {+ return null+ }+ }++ $('step-email').addEventListener('submit', async (e) => {+ e.preventDefault()+ email = $('email').value.trim()+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) return say('Enter the email address your bento/id uses.', 'error')+ $('send').disabled = true+ say('Sending…')+ const r = await post('/v1/delete/start', { email })+ $('send').disabled = false+ if (!r) return say('Could not reach the directory. Check your connection and try again.', 'error')+ if (r.status === 400) return say('That doesn’t look like an email address the directory accepts.', 'error')+ // 202 whatever the directory holds: the page never says whether an address exists+ $('step-email').hidden = true+ $('step-code').hidden = false+ $('sent').textContent = 'If ' + email + ' has a bento/id, we’ve sent it a code. It expires in 20 minutes.'+ say('')+ $('code').focus()+ })++ $('step-code').addEventListener('submit', async (e) => {+ e.preventDefault()+ const code = $('code').value.trim().toUpperCase()+ if (!/^[23456789ABCDEFGHJKMNPQRSTUVWXYZ]{8}$/.test(code)) return say('The code is 8 letters and numbers, as in the email.', 'error')+ $('confirm').disabled = true+ say('Deleting…')+ const r = await post('/v1/delete/complete', { email, code })+ $('confirm').disabled = false+ if (!r) return say('Could not reach the directory. Check your connection and try again.', 'error')+ if (r.status === 204) {+ $('step-code').hidden = true+ return say('Done. Your bento/id has been removed from the directory.')+ }+ if (r.status === 429) return say('Too many attempts from this network. Try again in an hour.', 'error')+ say('That code didn’t work. Check it, or start again for a new one.', 'error')+ })+})()+</script>+</body>+</html>diff --git a/site-src/id-privacy.html b/site-src/id-privacy.htmlnew file mode 100644index 00000000..247745a1--- /dev/null+++ b/site-src/id-privacy.html@@ -0,0 +1,94 @@+<!DOCTYPE html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>bento/id privacy notice — bento.page</title>+<meta name="description" content="What the bento/id directory at id.bento.page stores, what it never stores, who processes it, how long it is kept, and how to delete it.">+<link rel="canonical" href="https://bento.page/id/privacy">+<meta name="theme-color" content="#0D1B2E">+<style>+:root{--ink:#0D1B2E;--text:rgba(196,206,221,.92);--dim:rgba(182,193,210,.62);--white:#F4F6F9;--peach:#FF9E8A;--line:rgba(182,193,210,.16)}+*{margin:0;padding:0;box-sizing:border-box}+body{background:var(--ink);color:var(--text);font-family:'Instrument Sans',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;line-height:1.65}+a{color:var(--peach)}+main{max-width:720px;margin:0 auto;padding:48px 16px 80px}+h1{color:var(--white);font-family:Fraunces,Georgia,serif;font-size:clamp(30px,5vw,42px);line-height:1.1;margin-bottom:8px}+h2{color:var(--white);font-size:19px;margin:32px 0 8px}+p,li{margin:0 0 10px}+ul{padding-left:20px}+.meta{color:var(--dim);font-size:14px;margin-bottom:24px}+table{border-collapse:collapse;width:100%;font-size:15px;margin:8px 0 12px}+th,td{text-align:left;vertical-align:top;border-bottom:1px solid var(--line);padding:8px 6px}+th{color:var(--white);font-weight:600}+</style>+</head>+<body>+<main>+<h1>bento/id privacy notice</h1>+<p class="meta">Effective __EFFECTIVE_DATE__ · Controller: __CONTROLLER__ · Contact: <a href="mailto:__CONTACT_EMAIL__">__CONTACT_EMAIL__</a></p>++<p>bento/id lets people find your Bento key from your email address, so they+can share documents with you and see that a collaborator is really you. It is+run by a small directory service at <b>id.bento.page</b>. This notice covers+that service. Bento documents themselves are files you keep; we never host+them in bento/id.</p>++<h2>What the directory stores</h2>+<table>+<tr><th>What</th><th>Why</th><th>How long</th></tr>+<tr><td>Your email address</td><td>So people who already know it can look up your key. Lookups match an exact address only; there is no search and no list.</td><td>Until you delete it, or 13 months after you last confirmed it, whichever comes first</td></tr>+<tr><td>Your public account key and public key-agreement key</td><td>So others can check your signatures and encrypt to you. These are public by design; the private halves never leave your devices.</td><td>As above</td></tr>+<tr><td>A display name, if you chose to give one</td><td>Shown next to your address, marked as self-chosen and unverified</td><td>As above</td></tr>+<tr><td>Dates: when you published, confirmed or changed your key, and the history of key changes (as fingerprints)</td><td>So collaborators can tell a routine key change from a suspicious one</td><td>As above</td></tr>+<tr><td>A record that an address was deleted, holding a fingerprint of the last published statement, never the address in readable form</td><td>So people who had your key can see it was withdrawn</td><td>__TOMBSTONE_RETENTION__</td></tr>+<tr><td>Encrypted recovery data, if you set up passkey recovery (when that feature is available)</td><td>So you can add a new device with your passkey. It is encrypted with a key only your passkey can produce; we cannot open it</td><td>Until you remove that passkey or delete your account</td></tr>+</table>++<h2>What it never stores</h2>+<ul>+<li>Your documents, or anything inside them.</li>+<li>Your private keys.</li>+<li>Who you share with, or a list of your contacts.</li>+<li>Who looked up your address. Lookups are not logged against you.</li>+</ul>++<h2>Verification codes and email</h2>+<p>To publish or remove an address we email it a one-time code. The code+expires after 20 minutes and is stored only as a hash. Email is sent through+<b>Amazon Web Services (Amazon SES), in the European Union</b>, which acts as+our processor. Like any email sender, it sees the address and the time a+message is sent. Messages contain only the code and fixed wording, with no+tracking.</p>++<h2>Network information</h2>+<p>To stop abuse we limit how often one network can ask for codes or+lookups. For this we keep a one-way, daily-changing fingerprint of your IP+address, and a counter, for at most a day. We do not store IP addresses+themselves.</p>++<h2>Legal basis</h2>+<p>__LEGAL_BASIS__</p>++<h2>Your choices and rights</h2>+<ul>+<li><b>Delete:</b> from bento/home on any of your devices, or on the web at+<a href="/id/delete">bento.page/id/delete</a> with a code sent to the+address. Deletion is immediate.</li>+<li><b>See what we hold:</b> your published entry is exactly what anyone who+knows your address can look up. For anything else, write to+<a href="mailto:__CONTACT_EMAIL__">__CONTACT_EMAIL__</a>.</li>+<li><b>Correct:</b> publish a new entry from bento/home; the old one is+replaced.</li>+<li>__RIGHTS_JURISDICTION__</li>+</ul>++<h2>Children</h2>+<p>__CHILDREN__</p>++<h2>Changes</h2>+<p>If this notice changes, the new version will be posted here with a new+effective date.</p>+</main>+</body>+</html>