diff --git a/frame.lock b/frame.lock index 3295c3d..a66a4a5 100644 --- a/frame.lock +++ b/frame.lock @@ -2,8 +2,8 @@ "spec": "prism/frame-lock/1", "source": { "repository": "UOR-Foundation/template", - "commit": "d65a5ff543bf98fc4bbfb4a4e81789767529ab1d", - "raw": "https://raw.githubusercontent.com/UOR-Foundation/template/d65a5ff543bf98fc4bbfb4a4e81789767529ab1d/" + "commit": "892f3ad6ad2b28b0f14e65a966c63b8722f9ef2b", + "raw": "https://raw.githubusercontent.com/UOR-Foundation/template/892f3ad6ad2b28b0f14e65a966c63b8722f9ef2b/" }, "files": [ { diff --git a/frame/frame.mjs b/frame/frame.mjs index 7085b64..72eb8c4 100644 --- a/frame/frame.mjs +++ b/frame/frame.mjs @@ -765,7 +765,9 @@ class PrismFrame extends Element { // the panel waits for them rather than open empty. let ui = null; const ready = (theme) => { - if (ui) return; + // A render since this one (an attribute changed, as when Holo Search + // opens an app) drew a new panel, which its own render wires. + if (ui || !panel.isConnected) return; frame.adoptPanels(theme); panel.innerHTML = theme.THEME_PANEL; frame.themed = true; diff --git a/frame/panels.css b/frame/panels.css index d60dca9..98005af 100644 --- a/frame/panels.css +++ b/frame/panels.css @@ -462,6 +462,8 @@ .account-in { display: grid; gap: 0.382rem; } .account-id { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: 0.618rem !important; padding: 0.618rem 1rem; border: var(--border-width) solid var(--border); border-radius: var(--radius-control); background: var(--background); } .account-id code { font-family: var(--font-mono); color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.account-qr { display: block; width: min(100%, 14rem); aspect-ratio: 1; margin: 0 auto 0.618rem; background: #fff; border-radius: var(--radius-control); } +.account-qr path { fill: #000; } .account-panel .text { padding: 0; border: 0; background: none; color: var(--foreground); font-weight: 500; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 0.2em; cursor: pointer; } .account-panel .row { justify-content: flex-start; width: 100%; min-height: 2.618rem; padding: 0 1rem; border: 0; border-radius: var(--radius-control); background: none; color: var(--foreground); font-size: 1rem; text-align: start; cursor: pointer; } .account-panel .row:hover { background: var(--accent); } diff --git a/frame/panels.mjs b/frame/panels.mjs index 9836a41..8fee36e 100644 --- a/frame/panels.mjs +++ b/frame/panels.mjs @@ -420,7 +420,8 @@ export async function verifySession(session, { now = Date.now(), fresh = 60000 } const at = fresh ? now : body.at; let verdict; try { - verdict = await Prism.verifyAction(body.prism, log, envelope, { audience: app, now: at, window: fresh || 1 }); + // With the relay known, also hear removals the signing device did not present (the id's public log). + verdict = await Prism.verifyAction(body.prism, log, envelope, { audience: app, now: at, window: fresh || 1, ...(relay ? { bus: bus(Prism) } : {}) }); } catch (error) { if (error instanceof Prism.PrismIdError) deny("log", `The log does not resolve: ${error.message}`); throw error; @@ -464,9 +465,11 @@ const relayAdmitted = (origin) => { const bus = (Prism) => (relayBus ??= Prism.createRelayBus({ relay: relay && relayAdmitted(new URL(relay).origin) ? relay : null })); // Share this device's log with the id's other devices, under every boundary -// key it holds, so a device that has not taken up a rotation still hears. +// key it holds, so a device that has not taken up a rotation still hears, +// and publish its public records where apps hear removals. async function share(Prism, held) { for (const keyId of held.keyring.keys()) await Prism.publishSync(held, bus(Prism), { keyId }).catch(() => {}); + await Prism.publishLog(held, bus(Prism)).catch(() => {}); } // Take in what the other devices shared. A message that does not open or // resolve is someone else's or stale: it is skipped, never trusted. @@ -474,7 +477,7 @@ async function pull(Prism, held) { for (const keyId of [...held.keyring.keys()]) { const topic = await Prism.syncTopic(held, keyId).catch(() => null); if (!topic) continue; - for (const bytes of await bus(Prism).fetch(topic).catch(() => [])) { + for (const bytes of await bus(Prism).retained(topic).catch(() => [])) { try { held = await Prism.receiveSync(held, bytes); } catch (error) { @@ -484,6 +487,8 @@ async function pull(Prism, held) { } return held; } +// The id's log as apps see it: this device's, with what the public log holds. +const heard = (Prism, held) => Prism.heardLog(held.prism, held.log, bus(Prism)).catch(() => held.log); // A recovery kit: the paper share of the id's recovery device (stitch's // threshold recovery, one share of one) and the id's log. It is as secret as @@ -492,6 +497,16 @@ const KIT = "prism/recovery-kit/1"; const ONE_PAPER_SHARE = { threshold: 1, guardians: [{ paper: true }] }; const kitOf = (held, share) => ({ kind: KIT, prism: held.prism, share, records: [...held.log.values()] }); +// A QR code as one SVG path, with its four-module quiet zone. +function drawQr(svg, { size, modules }) { + let d = ""; + modules.forEach((row, y) => row.forEach((dark, x) => dark && (d += `M${x + 4} ${y + 4}h1v1h-1z`))); + svg.setAttribute("viewBox", `0 0 ${size + 8} ${size + 8}`); + const path = document.createElementNS("http://www.w3.org/2000/svg", "path"); + path.setAttribute("d", d); + svg.replaceChildren(path); +} + const json = (value) => new TextEncoder().encode(JSON.stringify(value)); const parse = (bytes) => JSON.parse(new TextDecoder().decode(bytes)); const short = (id) => `${id.slice(0, 15)}…${id.slice(-4)}`; @@ -522,7 +537,8 @@ const ACCOUNT_PANEL = `