Pyramid web app for inspecting arborist Merkle trees over sharded SQLite: document roots, inclusion proofs, an interactive 3D Merkle lattice (six.js / WebGL with graceful fallback), audit-chain linkage, and a live SSE event stream. Generated artifacts (env/, vendored static/six/ bundles, demo databases) are gitignored and rebuilt via the Makefile (venv, six, init-db, serve).
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
// Audit-page composer.
|
|
|
|
import { chunkHex } from "./hash.js";
|
|
|
|
export async function mountAuditPage(eventHash) {
|
|
const bodyEl = document.getElementById("audit-body");
|
|
const chainEl = document.getElementById("audit-chain-list");
|
|
|
|
try {
|
|
const ev = await fetchJSON(`/api/audit/${eventHash}`);
|
|
bodyEl.textContent = JSON.stringify(ev, null, 2);
|
|
} catch (err) {
|
|
bodyEl.textContent = `error: ${err.message}`;
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const chain = await fetchJSON(`/api/audit/chain/${eventHash}?limit=20`);
|
|
chainEl.innerHTML = "";
|
|
for (const ev of (chain.events || [])) {
|
|
const li = document.createElement("li");
|
|
li.innerHTML = `<span class="lbl">[${ev.event_type}]</span> <a href="/audit/${ev.event_hash}" class="mono" title="${ev.event_hash}">${shortHex(ev.event_hash)}</a> subj=<a href="/proof/${ev.subject_root}" class="mono" title="${ev.subject_root || ''}">${shortHex(ev.subject_root || '')}</a>`;
|
|
chainEl.appendChild(li);
|
|
}
|
|
} catch (err) {
|
|
chainEl.innerHTML = `<li class="muted">chain lookup failed: ${err.message}</li>`;
|
|
}
|
|
}
|
|
|
|
async function fetchJSON(url) {
|
|
const res = await fetch(url);
|
|
const j = await res.json().catch(() => ({}));
|
|
if (!res.ok && !j.error) throw new Error(`HTTP ${res.status}`);
|
|
return j;
|
|
}
|