// Theseus Navigator — Electron main process. // Native .bch via a custom `bns://` protocol: resolves names with the shared // portable resolver (Argus/resolver-web.js) and serves content itself (on-chain // h, Sia s3, direct ip, redirect u). Tabs, nav controls, a search box, a home // page, and optional Tor onion routing. No system daemon; the app is the trust // boundary. const { app, BrowserWindow, WebContentsView, ipcMain, protocol, session, Menu, clipboard } = require("electron"); const path = require("path"); const http = require("http"); const https = require("https"); const { spawn } = require("child_process"); const fs = require("fs"); const WebSocket = require("ws"); // Packaged builds ship the resolver and tor/ as unpacked resources (they can't // run from inside app.asar); dev runs read them from the repo. const RES_DIR = app.isPackaged ? process.resourcesPath : __dirname; // Bundled as .mjs so it loads as ES module in the packaged app (no package.json // sits next to it in resources/, so a bare .js would be treated as CommonJS and // fail on `export`). Dev reads the engine copy directly (Argus is type:module). const RESOLVER = app.isPackaged ? path.join(RES_DIR, "resolver-web.mjs") : path.join(__dirname, "..", "Argus", "src", "lib", "resolver-web.js"); // Search engines the user can pick from (default persisted in settings.searchEngine). const SEARCH_ENGINES = { duckduckgo: { name: "DuckDuckGo", url: (q) => "https://duckduckgo.com/?q=" + encodeURIComponent(q) }, google: { name: "Google", url: (q) => "https://www.google.com/search?q=" + encodeURIComponent(q) }, bing: { name: "Bing", url: (q) => "https://www.bing.com/search?q=" + encodeURIComponent(q) }, yandex: { name: "Yandex", url: (q) => "https://yandex.com/search/?text=" + encodeURIComponent(q) }, brave: { name: "Brave", url: (q) => "https://search.brave.com/search?q=" + encodeURIComponent(q) }, startpage: { name: "Startpage", url: (q) => "https://www.startpage.com/sp/search?query=" + encodeURIComponent(q) }, }; const SEARCH = (q) => (SEARCH_ENGINES[settings.searchEngine] || SEARCH_ENGINES.duckduckgo).url(q); // Public content relay (secret-free): serves s3/ip/h/u without shipping keys. const GATEWAY = "https://navigate.st"; // ---- BNS name detection (multi-TLD) -------------------------------------- // The engine (resolver-web.js) resolves any