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 ],41 { cwd: browserRoot, stdio: "inherit" },42);43execFileSync(44 resolve(androidRoot, "gradlew"),45 [46 "--no-configuration-cache",47 "testDebugUnitTest",48 "--tests",49 "com.peachpasswords.sync.SyncCoordinatorTest",50 "--tests",51 "com.peachpasswords.sync.LockedSyncSpoolModelTest",52 "--tests",53 "com.peachpasswords.sync.SyncPaddingTest",54 "--tests",55 "com.peachpasswords.sync.DeviceManifestSupportTest",56 "--tests",57 "com.peachpasswords.CrossPlatformKATTest",58 "--tests",59 "com.peachpasswords.vault.PeachScriptTest",60 "--tests",61 "com.peachpasswords.sync.SyncEntryEnvelopeKatTest",62 ],63 {64 cwd: androidRoot,65 env: { ...process.env, ...(javaHome ? { JAVA_HOME: javaHome } : {}) },66 stdio: "inherit",67 },68);6970console.log("Cross-client sync protocol gate passed.");