/**
* The one interop invariant this port cannot get wrong: the OrbitDB address.
*
* BOARD_TS=1 node test/vectors/generate-orbit-address.mjs
*
* PROTOCOL.md §5 — "every member independently computes the same address" — the
* CID of the manifest {name, type, accessController}. If the port derived a
* different dbName, or the hardened controller's manifest drifted from the
* vanilla one, every CLJS client would silently open a DIFFERENT database from
* every deployed browser in the room: no error, no missing message, just two
* disjoint histories.
*
* Not reachable from any pure function — it needs a real libp2p, a real Helia
* and a real @orbitdb/core open. So this boots the TypeScript build through
* helpers/orbit-address.mjs and records what it produces;
* test/orbit-address.test.mjs boots the ClojureScript build the same way and
* demands the same strings.
*/
import { writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { installDom } from "../harness/dom.mjs";
installDom();
const { mods, TS_MODE } = await import("../helpers/load.mjs");
if (!TS_MODE) throw new Error("run with BOARD_TS=1: fixtures come from the TypeScript, never from the port");
const M = await mods();
const { addressCases, openAddressCase } = await import("../helpers/orbit-address.mjs");
const OUT = dirname(fileURLToPath(import.meta.url));
const out = [];
for (const c of addressCases) {
out.push(await openAddressCase(M, c));
console.log(`${c.appSalt} identity=${c.withIdentity}: ${out.at(-1).address}`);
}
writeFileSync(join(OUT, "orbit-address.json"), `${JSON.stringify(out, null, 2)}\n`);
console.log("wrote orbit-address.json");
process.exit(0);