1import { execFileSync } from "node:child_process";2import { existsSync, readFileSync } from "node:fs";3import { dirname, resolve } from "node:path";4import { fileURLToPath } from "node:url";56const browserRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");7const androidRoot = resolve(browserRoot, "../peach-android");8const localJavaHome = "/opt/homebrew/opt/openjdk@17";9const javaHome = process.env.JAVA_HOME ??10 (existsSync(localJavaHome) ? localJavaHome : undefined);11const browserCoordinator = readFileSync(12 resolve(browserRoot, "src/background/sync-coordinator.ts"),13 "utf8",14);15const androidCoordinator = readFileSync(16 resolve(androidRoot, "app/src/main/java/com/peachpasswords/sync/SyncCoordinator.kt"),17 "utf8",18);1920if (browserCoordinator.includes('helloIn.version === localVersion')) {21 throw new Error("Browser still contains the forbidden equal-version fast path");22}23if (!browserCoordinator.includes("helloIn.deviceManifestVersion === DEVICE_MANIFEST_VERSION")) {24 throw new Error("Browser does not negotiate device manifests from SYNC_HELLO");25}26if (!androidCoordinator.includes("val exchangeDeviceManifest = vault.negotiatesDeviceManifest(hello)")) {27 throw new Error("Android does not negotiate device manifests from SYNC_HELLO");28}2930execFileSync(31 "npm",32 [33 "test", "--", "--run",34 "src/background/sync-coordinator.test.ts",35 "src/shared/sync-padding.test.ts",36 "src/shared/rendezvous.test.ts",37 "src/shared/device-manifest.test.ts",38 "src/crypto/peachPayload.test.ts",39 "src/shared/sync-entry-envelope.kat.test.ts",40 "src/shared/vault-adopt.test.ts",41 ],42 { cwd: browserRoot, stdio: "inherit" },43);44execFileSync(45 resolve(androidRoot, "gradlew"),46 [47 "--no-configuration-cache",48 "testDebugUnitTest",49 "--tests",50 "com.peachpasswords.sync.SyncCoordinatorTest",51 "--tests",52 "com.peachpasswords.sync.LockedSyncSpoolModelTest",53 "--tests",54 "com.peachpasswords.sync.SyncPaddingTest",55 "--tests",56 "com.peachpasswords.sync.DeviceManifestSupportTest",57 "--tests",58 "com.peachpasswords.CrossPlatformKATTest",59 "--tests",60 "com.peachpasswords.vault.PeachScriptTest",61 "--tests",62 "com.peachpasswords.sync.SyncEntryEnvelopeKatTest",63 "--tests",64 "com.peachpasswords.sync.VaultAdoptTest",65 ],66 {67 cwd: androidRoot,68 env: { ...process.env, ...(javaHome ? { JAVA_HOME: javaHome } : {}) },69 stdio: "inherit",70 },71);7273console.log("Cross-client sync protocol gate passed.");