open-standards/sandbox/sandbox-rs/crates/sandbox-proof-wasm/browser/run.mjs
Transaction Science ba1212361f Add aac, map, sandbox standards; catalog the standards family
Commit the previously-untracked standard directories and catalog them in the
root README alongside proof:

- aac/    — communication cargo class: portable boards + a ten-level
            offline-first cascade (Apache-2.0 code / CC-BY-4.0 spec).
- map/    — geospatial cargo class: range-requestable signed tilesets +
            an F0–F4 fidelity cascade (Apache-2.0 code / CC-BY-4.0 spec).
- sandbox/— isolated, metered, attested execution across the heterogeneous
            compute fabric (Apache-2.0 code / CC-BY-4.0 spec).
- jouleclaw-otel-authz, jouleclaw-trust — new jouleclaw reference crates.

Root README now lists aac, map, sandbox, and proof in the catalog, the tree,
and the contribution guide.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-07 17:04:36 -04:00

48 lines
1.8 KiB
JavaScript

// Drive the in-browser proof cell in a real headless Chromium and capture the
// signed cell it mints. Serves the crate dir over http (so the ES module + wasm
// load under a normal origin), navigates to the harness page, waits for the
// wasm to run prove(), and writes the resulting SignedProofCell JSON to stdout.
import { createServer } from "node:http";
import { readFile } from "node:fs/promises";
import { extname, join, normalize } from "node:path";
import { chromium } from "playwright";
const ROOT = normalize(join(import.meta.dirname, ".."));
const MIME = {
".html": "text/html",
".js": "text/javascript",
".mjs": "text/javascript",
".wasm": "application/wasm",
".json": "application/json",
};
const server = createServer(async (req, res) => {
try {
const path = normalize(join(ROOT, decodeURIComponent(req.url.split("?")[0])));
if (!path.startsWith(ROOT)) { res.writeHead(403).end(); return; }
const body = await readFile(path);
res.writeHead(200, { "content-type": MIME[extname(path)] ?? "application/octet-stream" });
res.end(body);
} catch {
res.writeHead(404).end("not found");
}
});
await new Promise((r) => server.listen(0, "127.0.0.1", r));
const port = server.address().port;
const browser = await chromium.launch({ headless: true });
const version = browser.version();
const page = await browser.newPage();
page.on("console", (m) => process.stderr.write(`[page] ${m.text()}\n`));
page.on("pageerror", (e) => process.stderr.write(`[pageerror] ${e}\n`));
await page.goto(`http://127.0.0.1:${port}/browser/index.html`);
const cell = await page.waitForFunction(() => window.__SANDBOX_CELL__, null, { timeout: 15000 })
.then((h) => h.jsonValue());
await browser.close();
server.close();
process.stderr.write(`engine: Chromium ${version}\n`);
process.stdout.write(cell + "\n");