Add browser UI with in-browser signature verification

Every node now serves a search and listing-detail UI at GET /. It is
vanilla TypeScript, bundled unminified into web/dist (committed) and
embedded with go:embed, so `go build` is enough to run a node.

The browser verifies each listing itself (certificate, binding, validity,
signature, proof-of-work) with pure-JS ed25519, so a gateway can withhold
listings but not forge them. Unverifiable results are hidden and their
content is never shown. Listing text is only inserted via textContent and
the UI is served with a strict CSP.

Canonical JSON is reimplemented in TypeScript and tested against a golden
fixture signed by the Go code. /api/v1/status now reports difficulty.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 18:29:40 +01:00
co-authored by Claude Sonnet 5.5
parent 918e16ed37
commit 3fd40241bc
30 changed files with 6418 additions and 5 deletions
+36
View File
@@ -0,0 +1,36 @@
// Tiny DOM builder. Listing content comes from strangers, so it is only ever
// inserted as text nodes or attribute values, never as HTML.
export type Child = Node | string | number | null | undefined | false;
export type Props = Record<string, string | number | boolean | ((e: Event) => void) | undefined>;
export function h<K extends keyof HTMLElementTagNameMap>(
tag: K,
props: Props | null = null,
...children: Child[]
): HTMLElementTagNameMap[K] {
const el = document.createElement(tag);
for (const [key, value] of Object.entries(props ?? {})) {
if (value === undefined || value === false) continue;
if (typeof value === "function") {
el.addEventListener(key.replace(/^on/, "").toLowerCase(), value);
} else if (value === true) {
el.setAttribute(key, "");
} else {
el.setAttribute(key, String(value));
}
}
append(el, children);
return el;
}
export function append(parent: Node, children: Child[]): void {
for (const c of children) {
if (c === null || c === undefined || c === false) continue;
parent.appendChild(typeof c === "object" ? c : document.createTextNode(String(c)));
}
}
export function clear(el: Element): void {
while (el.firstChild) el.removeChild(el.firstChild);
}