(async () => { const box = document.getElementById("seal26"); if (!box) return; const say = (html) => { box.innerHTML = html; }; if (!window.RCSeal) { say('
storage\'s sealing scripts did not load, or not the ones this page pins
'); return; } const call = async (op, body) => { const j = await zoo.call("/api/26/storage", { op, body }); if (j.error) throw new Error(j.error); return j; }; const seal = RCSeal.app({ app: "zoo", user: box.dataset.user, call: (body) => call("keyring", body) }); window.zooSeal = seal; const hex = (u) => [...u].map((x) => x.toString(16).padStart(2, "0")).join(" "); const when = (t) => new Date(t * 1000).toLocaleString(undefined, { hour: "2-digit", minute: "2-digit", month: "short", day: "numeric" }); // The postcard as storage and the bucket hold it, and, on a device that can, opened. async function postcard() { const u = (await call("urls", {})).files[0]; if (!u || !u.url) return null; const bytes = new Uint8Array(await (await fetch(u.url)).arrayBuffer()); let opened = null, why = ""; if (seal.status === "ready") { try { const d = await RCCrypt.decrypt((id) => seal.keyFor(id), new Blob([bytes])); opened = { words: await d.blob.text(), meta: d.meta }; } catch (e) { why = e.message; } } return { u, bytes, opened, why }; } function held(p) { const head = hex(p.bytes.slice(0, 48)); return 'What storage and the bucket hold (' + p.bytes.length + ' bytes, as B2 serves them)
' + '' + zoo.esc(head) + ' …' + '
It starts RCE1: an envelope. Your words are not in it. What the server knows: ' + p.u.size + ' bytes, saved ' + zoo.esc(when(p.u.updated)) + ', a random file name. Not the words, not that they are words.
' + zoo.esc(e.message) + '
'); return; } const st = seal.status; if (st === "unsupported") { say('This browser cannot seal (no WebCrypto or IndexedDB here).
'); return; } if (st === "nostorage" || st === "none") { say('The zoo seals a postcard with a key of its own, kept under yours: only your devices and your recovery key open it.
' + '' + '
' + (st === "nostorage" ? "Storage opens in a small window: you make your key and write down a recovery key, once." : "Storage opens in a small window and hands the zoo your key's public half.") + '
'); document.getElementById("seal-setup").onclick = async (ev) => { ev.target.disabled = true; document.getElementById("seal-out").textContent = "in storage's window…"; try { await seal.setup(); render("The zoo now seals with its own key, kept under yours."); } catch (e) { ev.target.disabled = false; document.getElementById("seal-out").textContent = e.message; } }; return; } const p = await postcard().catch(() => null); if (st === "locked") { say('locked This browser cannot open your sealed postcard.' + (seal.why ? ' ' + zoo.esc(seal.why) + '' : '') + ' Card 27 lets it in.
' + (p ? held(p) : '')); return; } let html = (flash ? '' + zoo.esc(flash) + '
' : '') + ''; if (p) { html += 'Opened on this device
' + (p.opened ? '' + zoo.esc(p.opened.words) + '
sealed ' + zoo.esc(new Date(p.opened.meta.mtime).toLocaleString()) + '
' : 'does not open: ' + zoo.esc(p.why) + '
') + '