A desktop coding agent with free access to frontier models.
TypeScript
test(desktop): intercepting-proxy check for OS trust store handling
Samrat Talukdara0904f4e9e97
diff --git a/apps/desktop/scripts/system-ca/intercept-proxy.mjs b/apps/desktop/scripts/system-ca/intercept-proxy.mjsnew file mode 100644index 00000000..fef2df7a--- /dev/null+++ b/apps/desktop/scripts/system-ca/intercept-proxy.mjs@@ -0,0 +1,82 @@+// Test-only TLS-intercepting proxy: the way antivirus HTTPS scanning or a+// corporate proxy sits in front of omnirush.ai. It terminates TLS for the+// given host names with a leaf issued by its own root CA (served together+// with that root, as those products do), and relays the bytes to the real+// server over a verified TLS connection.+//+// Point the host names at 127.0.0.1 (hosts file or container /etc/hosts),+// trust <dir>/root.pem in the throwaway system store, then run:+// node intercept-proxy.mjs --dir <dir> [--port 443] [--hosts omnirush.ai,www.omnirush.ai]+// node intercept-proxy.mjs --dir <dir> --certs-only+// The upstream address is resolved with DNS directly (dns.resolve4), so the+// hosts-file override does not loop back into the proxy.+import { execFileSync } from "node:child_process";+import dns from "node:dns/promises";+import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";+import path from "node:path";+import tls from "node:tls";++function arg(name, fallback) {+ const index = process.argv.indexOf(`--${name}`);+ return index >= 0 ? process.argv[index + 1] : fallback;+}++const dir = path.resolve(arg("dir", "intercept-ca"));+const port = Number(arg("port", "443"));+const hosts = String(arg("hosts", "omnirush.ai")).split(",").map((host) => host.trim()).filter(Boolean);+const openssl = process.env.OPENSSL_BIN || "openssl";++function ensureCertificates() {+ mkdirSync(dir, { recursive: true });+ const root = path.join(dir, "root.pem");+ if (existsSync(root) && existsSync(path.join(dir, "chain.pem"))) return;+ const run = (...args) => execFileSync(openssl, args, { cwd: dir, stdio: "ignore" });+ writeFileSync(path.join(dir, "root.ext"), "basicConstraints=critical,CA:TRUE\nkeyUsage=critical,keyCertSign,cRLSign\nsubjectKeyIdentifier=hash\n");+ run("req", "-new", "-newkey", "rsa:2048", "-nodes", "-keyout", "root.key", "-out", "root.csr", "-subj", "/CN=OmniRush.ai Test Interception Root/O=Test Only");+ run("x509", "-req", "-in", "root.csr", "-signkey", "root.key", "-out", "root.pem", "-days", "3", "-sha256", "-extfile", "root.ext");+ writeFileSync(path.join(dir, "leaf.ext"), `basicConstraints=CA:FALSE\nkeyUsage=critical,digitalSignature,keyEncipherment\nextendedKeyUsage=serverAuth\nsubjectAltName=${hosts.map((host) => `DNS:${host}`).join(",")}\n`);+ run("req", "-new", "-newkey", "rsa:2048", "-nodes", "-keyout", "leaf.key", "-out", "leaf.csr", "-subj", `/CN=${hosts[0]}`);+ run("x509", "-req", "-in", "leaf.csr", "-CA", "root.pem", "-CAkey", "root.key", "-set_serial", String(Date.now()), "-out", "leaf.pem", "-days", "2", "-sha256", "-extfile", "leaf.ext");+ writeFileSync(path.join(dir, "chain.pem"), `${readFileSync(path.join(dir, "leaf.pem"), "utf8")}${readFileSync(root, "utf8")}`);+ // DER copy for Windows certutil / Import-Certificate.+ run("x509", "-in", "root.pem", "-outform", "DER", "-out", "root.cer");+}++ensureCertificates();+if (process.argv.includes("--certs-only")) {+ console.log(`[intercept] certificates in ${dir}`);+ process.exit(0);+}++const upstream = new Map();+for (const host of hosts) {+ const addresses = await dns.resolve4(host);+ upstream.set(host, addresses[0]);+}++let intercepted = 0;+const server = tls.createServer({+ key: readFileSync(path.join(dir, "leaf.key")),+ cert: readFileSync(path.join(dir, "chain.pem")),+}, (client) => {+ const servername = client.servername || hosts[0];+ const address = upstream.get(servername) ?? upstream.get(hosts[0]);+ intercepted += 1;+ const remote = tls.connect({ host: address, port: 443, servername, ALPNProtocols: ["http/1.1"] });+ remote.on("secureConnect", () => {+ client.pipe(remote);+ remote.pipe(client);+ });+ const close = () => { client.destroy(); remote.destroy(); };+ remote.on("error", (error) => { console.error(`[intercept] upstream ${servername}: ${error.message}`); close(); });+ client.on("error", close);+ client.on("close", () => remote.destroy());+ remote.on("close", () => client.destroy());+});+server.on("tlsClientError", (error) => console.error(`[intercept] client TLS: ${error.message}`));+server.listen(port, "127.0.0.1", () => {+ console.log(`[intercept] listening on 127.0.0.1:${port} for ${hosts.join(", ")} -> ${[...upstream.values()].join(", ")}`);+});+setInterval(() => {+ writeFileSync(path.join(dir, "intercepted.txt"), `${intercepted}\n`);+}, 1000).unref?.();diff --git a/apps/desktop/scripts/system-ca/os-check.mjs b/apps/desktop/scripts/system-ca/os-check.mjsnew file mode 100644index 00000000..23122342--- /dev/null+++ b/apps/desktop/scripts/system-ca/os-check.mjs@@ -0,0 +1,214 @@+// Test-only, for throwaway CI runners (it edits the hosts file and the OS+// trust store): checks the desktop's HTTPS paths behind a TLS-intercepting+// proxy whose root CA is only in the OS trust store, as antivirus HTTPS+// scanning and corporate proxies install it.+// Windows: LocalMachine\Root (and CurrentUser\Root when it imports without+// a prompt); needs an elevated shell.+// macOS: the System keychain, as a trusted root; needs passwordless sudo.+// Linux: /usr/local/share/ca-certificates; needs passwordless sudo and Xvfb.+//+// node apps/desktop/scripts/system-ca/os-check.mjs [--compare-ref origin/main]+//+// Writes results to apps/desktop/dist-electron/system-ca/*.json. Exits 1 when+// the build under test fails a check; the compare ref is only reported.+import { execFileSync, spawn, spawnSync } from "node:child_process";+import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, appendFileSync, cpSync } from "node:fs";+import os from "node:os";+import path from "node:path";+import { createRequire } from "node:module";+import { fileURLToPath } from "node:url";++const here = path.dirname(fileURLToPath(import.meta.url));+const desktopDir = path.resolve(here, "..", "..");+const repoDir = path.resolve(desktopDir, "..", "..");+const outDir = path.join(desktopDir, "dist-electron", "system-ca");+const workDir = path.join(os.tmpdir(), "omnirush-system-ca-check");+const compareIndex = process.argv.indexOf("--compare-ref");+const compareRef = compareIndex >= 0 ? process.argv[compareIndex + 1] : "origin/main";+const opensslCandidates = [process.env.OPENSSL_BIN, "C:\\Program Files\\Git\\usr\\bin\\openssl.exe", "C:\\Program Files\\Git\\mingw64\\bin\\openssl.exe"].filter(Boolean);+const openssl = opensslCandidates.find((candidate) => existsSync(candidate)) ?? "openssl";++const isWindows = process.platform === "win32";++const log = (...args) => console.log("[system-ca]", ...args);+// Windows PowerShell 5.1 cannot load its own modules (no Cert: drive) with the+// PSModulePath that a PowerShell 7 parent (the runner's shell) exports.+const cleanEnv = Object.fromEntries(Object.entries(process.env).filter(([key]) => key.toUpperCase() !== "PSMODULEPATH"));+const ps = (script) => execFileSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], { encoding: "utf8", env: cleanEnv }).trim();++rmSync(workDir, { recursive: true, force: true });+mkdirSync(workDir, { recursive: true });+mkdirSync(outDir, { recursive: true });+const caDir = path.join(workDir, "intercept");++// 1. The comparison build's electron sources, next to the build under test so+// they resolve the same node_modules.+const compareDir = path.join(desktopDir, "electron-compare");+rmSync(compareDir, { recursive: true, force: true });+let compareAvailable = false;+try {+ execFileSync("git", ["-C", repoDir, "fetch", "-q", "--depth", "1", "origin", compareRef.replace(/^origin\//, "")], { stdio: "inherit" });+ const archive = path.join(workDir, "compare.tar");+ execFileSync("git", ["-C", repoDir, "archive", "-o", archive, "FETCH_HEAD", "apps/desktop/electron"], { stdio: "inherit" });+ const extract = path.join(workDir, "compare");+ mkdirSync(extract, { recursive: true });+ execFileSync("tar", ["-xf", archive, "-C", extract], { stdio: "inherit" });+ cpSync(path.join(extract, "apps", "desktop", "electron"), compareDir, { recursive: true });+ compareAvailable = true;+} catch (error) {+ log("compare ref unavailable:", error.message);+}++// 2. Root + leaf for omnirush.ai.+execFileSync(process.execPath, [path.join(here, "intercept-proxy.mjs"), "--dir", caDir, "--certs-only"], { stdio: "inherit", env: { ...process.env, OPENSSL_BIN: openssl } });+const rootCer = path.join(caDir, "root.cer");+const rootPem = path.join(caDir, "root.pem");+const thumbprint = isWindows ? ps(`(New-Object System.Security.Cryptography.X509Certificates.X509Certificate2('${rootCer}')).Thumbprint`) : null;++const sudo = (...args) => execFileSync("sudo", ["-n", ...args], { stdio: "inherit" });++// 3. Hosts file -> proxy on 127.0.0.1:443.+if (isWindows) {+ const hostsFile = path.join(process.env.SystemRoot || "C:\\Windows", "System32", "drivers", "etc", "hosts");+ appendFileSync(hostsFile, "\r\n127.0.0.1 omnirush.ai\r\n");+ spawnSync("ipconfig", ["/flushdns"], { stdio: "ignore" });+} else {+ sudo("sh", "-c", "printf '\\n127.0.0.1 omnirush.ai\\n' >> /etc/hosts");+ if (process.platform === "darwin") {+ spawnSync("sudo", ["-n", "dscacheutil", "-flushcache"], { stdio: "ignore" });+ spawnSync("sudo", ["-n", "killall", "-HUP", "mDNSResponder"], { stdio: "ignore" });+ }+}+const proxyLog = path.join(outDir, "proxy.log");+const proxyArgs = [path.join(here, "intercept-proxy.mjs"), "--dir", caDir, "--port", "443"];+const proxy = isWindows+ ? spawn(process.execPath, proxyArgs, { stdio: ["ignore", "pipe", "pipe"] })+ : spawn("sudo", ["-n", "-E", process.execPath, ...proxyArgs], { stdio: ["ignore", "pipe", "pipe"] });+proxy.stdout.on("data", (chunk) => appendFileSync(proxyLog, chunk));+proxy.stderr.on("data", (chunk) => appendFileSync(proxyLog, chunk));+await new Promise((resolve) => setTimeout(resolve, 3000));+log(readFileSync(proxyLog, "utf8").trim());++const electronBin = createRequire(path.join(desktopDir, "package.json"))("electron");+log("electron:", electronBin, existsSync(electronBin));+function smoke(label, electronDir, extraEnv = {}) {+ const out = path.join(outDir, `${label}.json`);+ // Linux runners have no display: Electron needs one even without windows.+ const [command, args] = process.platform === "linux"+ ? ["xvfb-run", ["-a", electronBin, "--no-sandbox", path.join(here, "smoke.mjs")]]+ : [electronBin, [path.join(here, "smoke.mjs")]];+ const result = spawnSync(command, args, {+ cwd: desktopDir,+ env: { ...cleanEnv, ...extraEnv, SMOKE_URL: "https://omnirush.ai/", SMOKE_ROOT_PEM: rootPem, SMOKE_ELECTRON_DIR: electronDir, SMOKE_OUT: out },+ encoding: "utf8",+ timeout: 180_000,+ });+ log(`${label}:\n${result.stdout}${result.stderr}${result.error ? `\nspawn error: ${result.error.message}` : ""}`);+ return existsSync(out) ? JSON.parse(readFileSync(out, "utf8")) : { fatal: `no result (exit ${result.status})` };+}++function runScenario(store, extraEnv = {}) {+ const results = {};+ if (compareAvailable) results.compare = smoke(`${store}-compare`, compareDir, extraEnv);+ results.branch = smoke(`${store}-branch`, path.join(desktopDir, "electron"), extraEnv);+ return results;+}++/**+ * A root CA that Windows (and OpenSSL) accept but BoringSSL, Electron's TLS+ * library, refuses: its version field is BER- rather than DER-encoded (a+ * non-minimal length). Legacy and vendor certificates in real Windows stores+ * have such encodings.+ */+function berEncodedRoot() {+ const dir = path.join(workDir, "ber");+ mkdirSync(dir, { recursive: true });+ execFileSync(openssl, ["req", "-x509", "-newkey", "rsa:2048", "-nodes", "-keyout", "ber.key", "-out", "ber-src.pem", "-subj", "/CN=OmniRush.ai Test BER-encoded Root", "-days", "3"], { cwd: dir, stdio: "ignore" });+ const der = Buffer.from(readFileSync(path.join(dir, "ber-src.pem"), "utf8").replace(/-----[^-]+-----|\s+/g, ""), "base64");+ const version = der.indexOf(Buffer.from([0xa0, 0x03, 0x02, 0x01, 0x02]));+ if (version < 0) throw new Error("unexpected certificate layout");+ let ber = Buffer.concat([der.subarray(0, version), Buffer.from([0xa0, 0x04, 0x02, 0x81, 0x01, 0x02]), der.subarray(version + 5)]);+ for (const offset of [0, 4]) {+ if (ber[offset] !== 0x30 || ber[offset + 1] !== 0x82) throw new Error("unexpected certificate layout");+ ber.writeUInt16BE(ber.readUInt16BE(offset + 2) + 1, offset + 2);+ }+ const file = path.join(dir, "ber.cer");+ writeFileSync(file, ber);+ return file;+}++const scenarios = {};++if (isWindows) {+// 4a. CurrentUser\Root. Adding a root there can raise a confirmation dialog,+// so the import runs in a job with a timeout and is verified afterwards.+const currentUser = ps(`+$job = Start-Job -ScriptBlock { param($p)+ $c = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($p)+ $s = New-Object System.Security.Cryptography.X509Certificates.X509Store('Root', 'CurrentUser')+ $s.Open('ReadWrite'); $s.Add($c); $s.Close() } -ArgumentList '${rootCer}'+if (-not (Wait-Job $job -Timeout 45)) { Stop-Job $job }+[bool](Get-ChildItem Cert:\\CurrentUser\\Root | Where-Object { $_.Thumbprint -eq '${thumbprint}' })`);+log("CurrentUser\\Root import:", currentUser);+if (currentUser === "True") {+ scenarios.currentUserRoot = runScenario("currentuser");+ ps(`Get-ChildItem Cert:\\CurrentUser\\Root | Where-Object { $_.Thumbprint -eq '${thumbprint}' } | Remove-Item`);+}++// 4b. LocalMachine\Root (where antivirus products install their root).+execFileSync("certutil", ["-addstore", "-f", "Root", rootCer], { stdio: "ignore" });+log("LocalMachine\\Root import:", ps(`[bool](Get-ChildItem Cert:\\LocalMachine\\Root | Where-Object { $_.Thumbprint -eq '${thumbprint}' })`));+scenarios.localMachineRoot = runScenario("localmachine");++// 4c. The same, plus a root in LocalMachine\Root that BoringSSL cannot parse.+try {+ const ber = berEncodedRoot();+ execFileSync("certutil", ["-addstore", "-f", "Root", ber], { stdio: "ignore" });+ const berThumb = ps(`(New-Object System.Security.Cryptography.X509Certificates.X509Certificate2('${ber}')).Thumbprint`);+ log("BER-encoded root in LocalMachine\\Root:", ps(`[bool](Get-ChildItem Cert:\\LocalMachine\\Root | Where-Object { $_.Thumbprint -eq '${berThumb}' })`));+ scenarios.localMachineRootWithUnparsableCert = runScenario("localmachine-unparsable");+ execFileSync("certutil", ["-delstore", "Root", berThumb], { stdio: "ignore" });+} catch (error) {+ log("BER scenario unavailable:", error.message);+}++} else if (process.platform === "darwin") {+ // 4. The System keychain, trusted as a root (where MDM, antivirus and proxy+ // installers put theirs).+ sudo("security", "add-trusted-cert", "-d", "-r", "trustRoot", "-k", "/Library/Keychains/System.keychain", rootPem);+ scenarios.systemKeychain = runScenario("system-keychain");+} else {+ // 4. The distribution store (/etc/ssl), which Node reads as the system store.+ sudo("cp", rootPem, "/usr/local/share/ca-certificates/omnirush-test-intercept.crt");+ sudo("update-ca-certificates");+ scenarios.distributionStore = runScenario("distribution-store");+}++// 5. The same, with NODE_EXTRA_CA_CERTS already set (to an unrelated CA+// file, as developer tooling or IT often leave it).+{+ const unrelated = path.join(workDir, "unrelated-ca.pem");+ execFileSync(openssl, ["req", "-x509", "-newkey", "rsa:2048", "-nodes", "-keyout", path.join(workDir, "unrelated.key"), "-out", unrelated, "-subj", "/CN=Unrelated Corporate CA", "-days", "3"], { stdio: "ignore" });+ scenarios.withNodeExtraCaCerts = runScenario("extra-ca", { NODE_EXTRA_CA_CERTS: unrelated });+}++if (isWindows) proxy.kill(); else spawnSync("sudo", ["-n", "pkill", "-f", "intercept-proxy.mjs"], { stdio: "ignore" });+const intercepted = existsSync(path.join(caDir, "intercepted.txt")) ? readFileSync(path.join(caDir, "intercepted.txt"), "utf8").trim() : "0";++const REQUIRED = ["app-external-fetch", "node-fetch-after-app-ca-setup", "child-node-fetch"];+let failed = false;+const summary = { intercepted: Number(intercepted), scenarios: {} };+for (const [name, runs] of Object.entries(scenarios)) {+ summary.scenarios[name] = {};+ for (const [which, result] of Object.entries(runs)) {+ const checks = Object.fromEntries(Object.entries(result.checks ?? {}).map(([key, value]) => [key, value.ok ? "ok" : `FAILED: ${value.error ?? value.output}`]));+ summary.scenarios[name][which] = { checks, rootInNodeSystemStore: result.systemRootInNodeSystemStore, rootInPlatformStore: result.systemRootInPlatformStore, bulkSecureContext: result.bulkSecureContext, unparsablePlatformCerts: result.unparsablePlatformCerts, logs: result.logs, fatal: result.fatal };+ if (which !== "branch") continue;+ if (result.checks?.["node-fetch-bundled"]?.ok !== false) { failed = true; log(`${name}: the proxy was not in the path`); }+ for (const key of REQUIRED) if (!result.checks?.[key]?.ok) failed = true;+ if (result.checks?.["child-bun-fetch"] && !result.checks["child-bun-fetch"].ok) failed = true;+ }+}+writeFileSync(path.join(outDir, "summary.json"), `${JSON.stringify(summary, null, 2)}\n`);+console.log(JSON.stringify(summary, null, 2));+process.exit(failed ? 1 : 0);diff --git a/apps/desktop/scripts/system-ca/smoke.mjs b/apps/desktop/scripts/system-ca/smoke.mjsnew file mode 100644index 00000000..a9ba4446--- /dev/null+++ b/apps/desktop/scripts/system-ca/smoke.mjs@@ -0,0 +1,121 @@+// Test-only: run as the Electron main entry (`electron smoke.mjs`) behind+// intercept-proxy.mjs. It reports which of the desktop's HTTPS paths accept+// a TLS-intercepting root that only the OS trust store knows about.+//+// env: SMOKE_URL https URL routed through the proxy+// NODE_EXTRA_CA_CERTS optional, as a user or IT may have set it+// SMOKE_ROOT_PEM the proxy's root (for diagnostics only; never trusted directly)+// SMOKE_ELECTRON_DIR apps/desktop/electron of the build under test+// SMOKE_OUT JSON results file+import { spawnSync } from "node:child_process";+import { X509Certificate } from "node:crypto";+import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";+import os from "node:os";+import path from "node:path";+import tls from "node:tls";+import { pathToFileURL } from "node:url";++import { app, net, session } from "electron";++const target = process.env.SMOKE_URL || "https://omnirush.ai/";+const electronDir = path.resolve(process.env.SMOKE_ELECTRON_DIR || path.join(import.meta.dirname, "..", "..", "electron"));+const out = process.env.SMOKE_OUT || path.join(process.cwd(), "system-ca-smoke.json");+const rootPem = process.env.SMOKE_ROOT_PEM && existsSync(process.env.SMOKE_ROOT_PEM)+ ? readFileSync(process.env.SMOKE_ROOT_PEM, "utf8").trim()+ : null;+const results = { target, electronDir, platform: process.platform, versions: { electron: process.versions.electron, node: process.versions.node }, checks: {}, logs: [] };++function describe(error) {+ const cause = error?.cause;+ return [error?.message, cause?.code, cause?.message].filter(Boolean).join(" | ");+}++async function check(name, run) {+ try {+ const response = await run();+ await response.arrayBuffer().catch(() => null);+ results.checks[name] = { ok: true, status: response.status };+ } catch (error) {+ results.checks[name] = { ok: false, error: describe(error) };+ }+ console.log(`[smoke] ${name}: ${JSON.stringify(results.checks[name])}`);+}++function fingerprint(pem) {+ try { return new X509Certificate(pem).fingerprint256; } catch { return null; }+}++app.whenReady().then(async () => {+ const userDataDir = mkdtempSync(path.join(os.tmpdir(), "omnirush-system-ca-smoke-"));+ const rootPrint = rootPem ? fingerprint(rootPem) : null;+ try {+ // Node's fetch with the bundled roots only: the reported failure.+ await check("node-fetch-bundled", () => fetch(target, { cache: "no-store" }));+ // Chromium's own stack (OS verifier, OS store, system proxy), in a session of its own+ // so that its verification result is not cached for the app's default session.+ await check("electron-net-fetch", () => session.fromPartition("smoke-raw-chromium").fetch(target, { cache: "no-store", credentials: "omit" }));++ const systemCerts = (() => { try { return tls.getCACertificates("system"); } catch { return []; } })();+ results.systemRootInNodeSystemStore = rootPrint ? systemCerts.some((pem) => fingerprint(pem) === rootPrint) : null;+ results.nodeSystemCount = systemCerts.length;++ const systemCa = await import(pathToFileURL(path.join(electronDir, "system-ca.mjs")).href);+ const platformCerts = await systemCa.systemPlatformCertificateLoader(process.platform).load().catch(() => []);+ results.platformCount = platformCerts.length;+ results.systemRootInPlatformStore = rootPrint ? platformCerts.some((pem) => fingerprint(pem) === rootPrint) : null;+ results.unparsablePlatformCerts = platformCerts.filter((pem) => fingerprint(pem) === null).length;+ try {+ tls.createSecureContext({ ca: [...systemCerts, ...platformCerts] });+ results.bulkSecureContext = "ok";+ } catch (error) {+ results.bulkSecureContext = describe(error);+ }++ // The desktop's own main-process CA setup, exactly as the build under test runs it.+ const runtime = await import(pathToFileURL(path.join(electronDir, "runtime.mjs")).href);+ // As main.mjs does at startup, before any request: Chromium also anchors on the OS roots+ // the app enumerated (on Linux, Chromium reads NSS rather than /etc/ssl).+ if (typeof runtime.createSystemCaCertificateVerifyProc === "function") {+ session.defaultSession.setCertificateVerifyProc(runtime.createSystemCaCertificateVerifyProc([...systemCerts, ...platformCerts]));+ }+ const childEnv = await runtime.resolveSystemCaEnv({+ userDataDir,+ // As the app passes it: a NODE_EXTRA_CA_CERTS from the user's environment is honored.+ parentEnv: process.env.NODE_EXTRA_CA_CERTS ? { NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS } : {},+ logInfo: (message) => results.logs.push(String(message)),+ });+ results.childEnv = childEnv;+ await check("node-fetch-after-app-ca-setup", () => fetch(target, { cache: "no-store" }));++ const externalFetchModule = path.join(electronDir, "external-fetch.mjs");+ if (existsSync(externalFetchModule)) {+ const { createExternalFetch } = await import(pathToFileURL(externalFetchModule).href);+ const externalFetch = createExternalFetch({ net });+ await check("app-external-fetch", () => externalFetch(new URL(target), { method: "GET" }));+ }++ // A Node child with the environment the desktop gives its sidecars.+ const child = spawnSync(process.execPath, ["-e", `fetch(${JSON.stringify(target)}).then((r) => { console.log("status", r.status); }, (e) => { console.log("error", e.message, e.cause && e.cause.message); process.exitCode = 1; })`], {+ env: { ...process.env, ...childEnv, ELECTRON_RUN_AS_NODE: "1" },+ encoding: "utf8",+ timeout: 60_000,+ });+ results.checks["child-node-fetch"] = { ok: child.status === 0, output: `${child.stdout}${child.stderr}`.trim().slice(0, 400) };+ console.log(`[smoke] child-node-fetch: ${JSON.stringify(results.checks["child-node-fetch"])}`);++ // A Bun child (the engine sidecar's runtime) with the same environment.+ const bun = spawnSync(process.platform === "win32" ? "bun.exe" : "bun", ["-e", `fetch(${JSON.stringify(target)}).then((r) => { console.log("status", r.status); }, (e) => { console.log("error", e.message); process.exitCode = 1; })`], {+ env: { ...process.env, ...childEnv },+ encoding: "utf8",+ timeout: 60_000,+ });+ if (!bun.error) {+ results.checks["child-bun-fetch"] = { ok: bun.status === 0, output: `${bun.stdout}${bun.stderr}`.trim().slice(0, 400) };+ console.log(`[smoke] child-bun-fetch: ${JSON.stringify(results.checks["child-bun-fetch"])}`);+ }+ } catch (error) {+ results.fatal = describe(error);+ }+ writeFileSync(out, `${JSON.stringify(results, null, 2)}\n`);+ app.quit();+});