// Build stamp of the browser module: sha256 over the sources that compile into it (the core // library, the wasm facade, the workspace manifests and lock, the cargo config). Written into // pkg/ and pkg-proofs/ by scripts/wasm-build.sh; packages/core-wasm/tests/global-setup.ts // recomputes it and refuses to run the suites on a missing or stale module. // Usage: node scripts/wasm-stamp.mjs → prints the stamp. import { createHash } from 'node:crypto' import { readdirSync, readFileSync, statSync } from 'node:fs' import { join, relative, resolve } from 'node:path' import { fileURLToPath } from 'node:url' const ROOT = resolve(fileURLToPath(new URL('..', import.meta.url))) const INPUTS = [ 'Cargo.toml', 'Cargo.lock', '.cargo/config.toml', 'crates/core/Cargo.toml', 'crates/core/src', 'crates/wasm/Cargo.toml', 'crates/wasm/src', ] function files(path) { const absolute = join(ROOT, path) if (!statSync(absolute).isDirectory()) return [path] return readdirSync(absolute).flatMap((name) => files(join(path, name))) } export function wasmStamp() { const hash = createHash('sha256') const all = INPUTS.flatMap(files).map((f) => relative(ROOT, join(ROOT, f))) for (const file of all.sort()) { hash.update(`${file}\0`) hash.update(readFileSync(join(ROOT, file))) hash.update('\0') } return hash.digest('hex') } if (process.argv[1] === fileURLToPath(import.meta.url)) { process.stdout.write(`${wasmStamp()}\n`) }