eleven / messenger Public

Clone
git clone https://amadan.net/eleven/messenger

Plain git — no account needed to clone.

Download

Download this file

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