// The reverse-direction cross-implementation gate: the committed fixture was // encrypted by the NATIVE client (LChatCore's GroupKey.encryptJSON — see // NativeMessageVectorTests, regenerated with RECORD_VECTORS=1 swift test), and // the web's crypto.js must open it. messageblob.test.mjs proves web→native; // this proves native→web — together they pin the native send path, so a // message sent from the Mac app provably renders for every web member. import { readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; import { dirname, join } from "node:path"; import { importKey, decrypt } from "../web/static/crypto.js"; const here = dirname(fileURLToPath(import.meta.url)); const fixturePath = join( here, "..", "ios", "LChatCore", "Tests", "LChatCoreTests", "Fixtures", "native-message-vector.json" ); function assert(cond, msg) { if (!cond) { console.error("FAIL:", msg); process.exit(1); } } const fx = JSON.parse(readFileSync(fixturePath, "utf8")); const got = await decrypt(await importKey(fx.keyB64), fx.blob); for (const [k, v] of Object.entries(fx.expect)) { assert(JSON.stringify(got[k]) === JSON.stringify(v), `field ${k}: ${JSON.stringify(got[k])} != ${JSON.stringify(v)}`); } console.log("nativeblob.test.mjs OK");