Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Browser pane: Electron's own identity with per-site rules, and a site's refusal as a signal
milind-soni20b2300b7272
diff --git a/electron/browser-pane-identity.mjs b/electron/browser-pane-identity.mjsnew file mode 100644index 0000000000..6c66c317a9--- /dev/null+++ b/electron/browser-pane-identity.mjs@@ -0,0 +1,76 @@+// Which user agent a bot's browser pane presents. Electron's own, with only the app's product token taken out, is+// the default: Cloudflare's full-page check and Turnstile refuse a Chromium UA without Electron's token, and Google+// refuses sign-in from any identity that claims another browser. Client hints are never touched: Chromium's own+// (Chromium and a GREASE brand, no Google Chrome brand) already match Electron's UA.++/** "native": Electron's UA without the app token. "cleaned": also without `Electron/`, for a person who needs it. */+export const PANE_IDENTITY_MODES = Object.freeze(["native", "cleaned"]);++/**+ * Sites with their own rule. `identity`: "electron" is Electron's UA without the app token in either mode,+ * "no-electron-token" drops `Electron/` (in native mode only), "chrome-shaped" is the cleaned UA. `where`: "request"+ * changes only the request header; "tab" also the page's own `navigator.userAgent`. Add a site only after a reproduced+ * failure.+ */+export const PANE_IDENTITY_RULES = Object.freeze([+ // Google refuses sign-in from an identity claiming another browser. Subresources a sign-in page loads count too.+ Object.freeze({ hosts: Object.freeze(["accounts.google.com", "accounts.youtube.com"]), subdomains: false, identity: "electron", where: "request", referrer: true }),+ // Teams' server sends a request with Electron's UA to a blank page; its page script accepts Electron.+ Object.freeze({ hosts: Object.freeze(["teams.microsoft.com", "teams.live.com", "teams.cloud.microsoft"]), subdomains: false, identity: "no-electron-token", where: "request", referrer: false }),+ // Chase's sign-in script sends any Electron UA to its "System Requirements" page.+ Object.freeze({ hosts: Object.freeze(["chase.com"]), subdomains: true, identity: "chrome-shaped", where: "tab", referrer: false }),+]);++const hostOf = (url) => {+ try {+ return new URL(url).hostname.toLowerCase();+ } catch {+ return "";+ }+};++/** Every product token between the engine comment and `Chrome/`: the app's own name and version. */+export function withoutAppToken(userAgent) {+ return String(userAgent).replace(/(\(KHTML, like Gecko\)\s+)(?:[^\s()]+\s+)*?(Chrome\/)/, "$1$2");+}++export function withoutElectronToken(userAgent) {+ return String(userAgent).replace(/\s+Electron\/\S+/, "");+}++export function paneIdentityMode(value) {+ return value === "cleaned" ? "cleaned" : "native";+}++/** The pane's own UA: its session's, and so every page's and worker's unless a rule says otherwise. */+export function paneBaseUserAgent(electronUserAgent, mode) {+ const native = withoutAppToken(electronUserAgent);+ return paneIdentityMode(mode) === "cleaned" ? withoutElectronToken(native) : native;+}++function ruleFor(host) {+ if (!host) return null;+ return PANE_IDENTITY_RULES.find((rule) => rule.hosts.some((name) => host === name || (rule.subdomains && host.endsWith(`.${name}`)))) ?? null;+}++function identityOf(rule, electronUserAgent, mode) {+ const native = withoutAppToken(electronUserAgent);+ if (rule.identity === "electron") return native;+ if (rule.identity === "chrome-shaped") return withoutElectronToken(native);+ return paneIdentityMode(mode) === "native" ? withoutElectronToken(native) : paneBaseUserAgent(electronUserAgent, mode);+}++/** The User-Agent header of one request: `resourceType` and `referrer` as Electron's onBeforeSendHeaders reports them. */+export function paneRequestUserAgent(electronUserAgent, mode, { url, referrer = "", resourceType = "" }) {+ const rule = ruleFor(hostOf(url));+ if (rule) return identityOf(rule, electronUserAgent, mode);+ const from = ruleFor(hostOf(referrer));+ if (from?.referrer && resourceType !== "mainFrame") return identityOf(from, electronUserAgent, mode);+ return paneBaseUserAgent(electronUserAgent, mode);+}++/** The UA a tab's page itself reports while its main frame is at `url`. */+export function paneTabUserAgent(electronUserAgent, mode, url) {+ const rule = ruleFor(hostOf(url));+ return rule?.where === "tab" ? identityOf(rule, electronUserAgent, mode) : paneBaseUserAgent(electronUserAgent, mode);+}diff --git a/electron/browser-pane-identity.node-test.mjs b/electron/browser-pane-identity.node-test.mjsnew file mode 100644index 0000000000..7d460e5430--- /dev/null+++ b/electron/browser-pane-identity.node-test.mjs@@ -0,0 +1,57 @@+import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import test from "node:test";++import { PANE_IDENTITY_RULES, paneBaseUserAgent, paneIdentityMode, paneRequestUserAgent, paneTabUserAgent, withoutAppToken } from "./browser-pane-identity.mjs";++const ELECTRON = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) OpenMausBot/0.1.175 Chrome/146.0.7680.165 Electron/43.7.9 Safari/537.36";+const NATIVE = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.165 Electron/43.7.9 Safari/537.36";+const CLEANED = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.165 Safari/537.36";++test("by default a pane is Electron's own Chromium: only the app's token goes, Electron's and the real Chrome version stay", () => {+ assert.equal(paneBaseUserAgent(ELECTRON, "native"), NATIVE);+ assert.equal(paneBaseUserAgent(ELECTRON, undefined), NATIVE);+ assert.equal(paneIdentityMode("anything else"), "native");+ assert.equal(withoutAppToken(ELECTRON.replace("OpenMausBot/0.1.175", "MausBot/0.2.0 Extra/1")), NATIVE);+ assert.equal(paneBaseUserAgent(ELECTRON, "cleaned"), CLEANED);+});++test("Google's sign-in hosts always see Electron's own UA, their subresources too, in either mode", () => {+ for (const mode of ["native", "cleaned"]) {+ assert.equal(paneRequestUserAgent(ELECTRON, mode, { url: "https://accounts.google.com/v3/signin/identifier", resourceType: "mainFrame" }), NATIVE);+ assert.equal(paneRequestUserAgent(ELECTRON, mode, { url: "https://accounts.youtube.com/accounts/SetSID", resourceType: "subFrame" }), NATIVE);+ assert.equal(paneRequestUserAgent(ELECTRON, mode, { url: "https://ssl.gstatic.com/x.js", referrer: "https://accounts.google.com/", resourceType: "script" }), NATIVE);+ }+ // A navigation away from sign-in, referred by it, is the site's own again.+ assert.equal(paneRequestUserAgent(ELECTRON, "cleaned", { url: "https://example.com/", referrer: "https://accounts.google.com/", resourceType: "mainFrame" }), CLEANED);+ assert.equal(paneRequestUserAgent(ELECTRON, "native", { url: "https://mail.google.com/", resourceType: "mainFrame" }), NATIVE);+});++test("Teams' request header drops Electron's token, its page keeps it; Chase gets a Chrome-shaped tab", () => {+ for (const host of ["teams.microsoft.com", "teams.live.com", "teams.cloud.microsoft"]) {+ assert.equal(paneRequestUserAgent(ELECTRON, "native", { url: `https://${host}/v2/`, resourceType: "mainFrame" }), CLEANED);+ assert.equal(paneTabUserAgent(ELECTRON, "native", `https://${host}/v2/`), NATIVE);+ }+ assert.equal(paneRequestUserAgent(ELECTRON, "native", { url: "https://secure.chase.com/web/auth", resourceType: "mainFrame" }), CLEANED);+ assert.equal(paneTabUserAgent(ELECTRON, "native", "https://www.chase.com/"), CLEANED);+ assert.equal(paneTabUserAgent(ELECTRON, "native", "https://notchase.com/"), NATIVE);+ assert.equal(paneTabUserAgent(ELECTRON, "native", "https://example.com/"), NATIVE);+});++test("the rules are data: three sites, each with its reason, and nothing else", () => {+ assert.deepEqual(PANE_IDENTITY_RULES.map((rule) => [rule.hosts.join(","), rule.identity, rule.where]), [+ ["accounts.google.com,accounts.youtube.com", "electron", "request"],+ ["teams.microsoft.com,teams.live.com,teams.cloud.microsoft", "no-electron-token", "request"],+ ["chase.com", "chrome-shaped", "tab"],+ ]);+ assert.ok(Object.isFrozen(PANE_IDENTITY_RULES));+});++test("no identity is invented: no other browser's UA, no Chrome brand, no automation switch or script in the pane's code", () => {+ for (const file of ["./browser-pane-identity.mjs", "./browser-pane-main.mjs"]) {+ const source = readFileSync(new URL(file, import.meta.url), "utf8");+ for (const banned of [/Firefox/i, /Gecko\/\d/, /AutomationControlled/, /navigator\.webdriver/, /"Google Chrome"/, /userAgentFallback/, /appendSwitch/, /remote-debugging/, /executeJavaScript/, /sec-ch-ua/i]) {+ assert.doesNotMatch(source, banned, `${file} must not contain ${banned}`);+ }+ }+});diff --git a/electron/browser-pane-main.mjs b/electron/browser-pane-main.mjsindex 56664b235d..244b5f56c9 100644--- a/electron/browser-pane-main.mjs+++ b/electron/browser-pane-main.mjs@@ -6,7 +6,8 @@ import { randomUUID } from "node:crypto";import path from "node:path";import desktopWorkspace from "./desktop-workspace.cjs";-import { PANE_MESSAGE, PANE_PARTITION, PANE_TABS_PER_BROWSER, paneMessageToMain, paneUserAgent } from "./browser-pane-wire.mjs";+import { paneBaseUserAgent, paneIdentityMode, paneRequestUserAgent, paneTabUserAgent } from "./browser-pane-identity.mjs";+import { PANE_MESSAGE, PANE_PARTITION, PANE_TABS_PER_BROWSER, paneMessageToMain } from "./browser-pane-wire.mjs";const { normalizeDesktopWorkspaceBounds } = desktopWorkspace;const PERSON_INPUT = new Set(["mouseDown", "keyDown", "rawKeyDown", "char", "mouseWheel", "gestureScrollBegin", "touchStart"]);@@ -14,6 +15,9 @@ const PING_MS = 250;/** Input events this soon after the bot's own input count as the bot's, should Electron report debugger input too. */const BOT_INPUT_ECHO_MS = 150;const RESOLVE_MS = 5_000;+/** A window.open this soon after the person's own press or key, with Chromium's user gesture, is the person's. */+const GESTURE_MS = 1_000;+const POPUP_SIZE = { width: 520, height: 680 };const CAPTURE_MS = 10_000;const HIDDEN_SIZE = { width: 1280, height: 800 };/** Granted as a normal profile has them; everything else is refused without a prompt. */@@ -21,18 +25,21 @@ const GRANTED = new Set(["clipboard-sanitized-write", "fullscreen", "pointerLockconst BOT = /^[\w.-]{1,128}$/;const PROFILE = /^[\w.:-]{1,128}$/;-const hostOf = (url) => { try { return new URL(url).hostname; } catch { return ""; } };+const originOf = (url) => { try { return new URL(url).origin; } catch { return ""; } };const isObject = (value) => Object.prototype.toString.call(value) === "[object Object]";const NO_PANEL = Object.freeze({ botId: null, threadId: null, profile: null, wanted: false, bounds: null, browser: null });const samePanel = (a, b) => a.botId === b.botId && a.threadId === b.threadId && a.profile === b.profile;/**- * `createView(options)`: a WebContentsView. `fromPartition(name)`: Electron's session. `owner()`: the app window or null.- * `chromeVersion`: process.versions.chrome.+ * `createView(options)`: a WebContentsView. `createPopup(options)`: a BrowserWindow, for a sign-in popup the person+ * opened. `fromPartition(name)`: Electron's session. `owner()`: the app window or null. `chromeVersion`:+ * process.versions.chrome.*/-export function createBrowserPanes({ createView, fromPartition, owner, chromeVersion, log = () => {}, now = Date.now, captureMs = CAPTURE_MS }) {+export function createBrowserPanes({ createView, createPopup = null, fromPartition, owner, chromeVersion, log = () => {}, now = Date.now, captureMs = CAPTURE_MS }) {const browsers = new Map();const configured = new Set();+ /** Per partition: Electron's own UA, read before this module changed it, and the identity mode in force. */+ const identities = new Map();const pings = new Map();const resolving = new Map();const watched = new WeakSet();@@ -80,17 +87,19 @@ export function createBrowserPanes({ createView, fromPartition, owner, chromeVer});}- function configure(partition) {+ function configure(partition, mode) {const session = fromPartition(partition);+ if (!identities.has(partition)) identities.set(partition, { electron: session.getUserAgent(), mode });+ const identity = identities.get(partition);+ identity.mode = paneIdentityMode(mode);+ session.setUserAgent(paneBaseUserAgent(identity.electron, identity.mode));if (configured.has(partition)) return session;configured.add(partition);- const electronAgent = session.getUserAgent();- const agent = paneUserAgent(electronAgent);- session.setUserAgent(agent);+ // Only the User-Agent header: client hints stay Chromium's own.session.webRequest.onBeforeSendHeaders((details, callback) => {- const host = hostOf(details.url);- const wanted = host ? paneUserAgent(electronAgent, host) : agent;- callback({ requestHeaders: wanted === agent ? details.requestHeaders : { ...details.requestHeaders, "User-Agent": wanted } });+ const wanted = paneRequestUserAgent(identity.electron, identity.mode, details);+ const name = Object.keys(details.requestHeaders).find((header) => header.toLowerCase() === "user-agent") ?? "User-Agent";+ callback({ requestHeaders: details.requestHeaders[name] === wanted ? details.requestHeaders : { ...details.requestHeaders, [name]: wanted } });});session.setPermissionRequestHandler((_contents, permission, callback) => callback(GRANTED.has(permission)));session.setPermissionCheckHandler((_contents, permission) => GRANTED.has(permission));@@ -106,6 +115,7 @@ export function createBrowserPanes({ createView, fromPartition, owner, chromeVerconst win = owner();for (const [key, browser] of browsers) {for (const [tab, entry] of browser.tabs) {+ if (entry.popup) continue;const visible = Boolean(panel.wanted && panel.bounds && panel.browser === key && browser.active === tab);try {if (visible) {@@ -141,6 +151,7 @@ export function createBrowserPanes({ createView, fromPartition, owner, chromeVerfunction ping(key, entry) {if (entry.botInputs > 0 || now() - entry.botInputAt < BOT_INPUT_ECHO_MS) return;+ entry.personAt = now();const last = pings.get(key);if (last !== undefined && last.tab === entry.tab && now() - last.at < PING_MS) return;pings.set(key, { tab: entry.tab, at: now() });@@ -167,43 +178,100 @@ export function createBrowserPanes({ createView, fromPartition, owner, chromeVerreturn null;}- function createTab(key, { background = false, adopt, opener } = {}) {+ function webPreferences(browser) {+ return { partition: browser.partition, sandbox: true, contextIsolation: true, nodeIntegration: false, webviewTag: false, backgroundThrottling: false, safeDialogs: true };+ }++ /** A sign-in popup the person's own click opened: Chromium's user gesture, the person's input, no bot input. */+ function personOpened(entry, url) {+ const report = entry.windowOpen;+ return Boolean(report && report.userGesture && report.url === url && now() - report.at < GESTURE_MS)+ && now() - entry.personAt < GESTURE_MS && entry.botInputs === 0 && now() - entry.botInputAt >= GESTURE_MS;+ }++ /**+ * A popup the person opened becomes a real child window on the pane's session, the page's own child so its opener+ * stays; one per opener. Anything else (the bot's clicks, a late open) becomes a tab, its opener kept as well.+ */+ function openPopup(key, entry, details) {+ if (tabRefusal(key)) return { action: "deny" };+ if (createPopup && personOpened(entry, details.url)) {+ const open = entry.popupChild && browsers.get(key)?.tabs.get(entry.popupChild);+ if (open && !open.popup.isDestroyed()) {+ open.popup.focus();+ return { action: "deny" };+ }+ return {+ action: "allow",+ createWindow: (options) => {+ const child = createTab(key, { adopt: options?.webContents, opener: entry.tab, windowed: true });+ entry.popupChild = child.tab;+ void targetOf(child.contents).then((target) => { child.target = target; info(key, child); }, () => removeTab(key, child.tab));+ return child.contents;+ },+ };+ }+ return {+ action: "allow",+ createWindow: (options) => {+ const popup = createTab(key, { adopt: options?.webContents, opener: entry.tab });+ void targetOf(popup.contents).then((target) => { popup.target = target; info(key, popup); }, () => removeTab(key, popup.tab));+ return popup.contents;+ },+ };+ }++ function createTab(key, { background = false, adopt, opener, windowed = false } = {}) {const refusal = tabRefusal(key);if (refusal) throw new Error(refusal);const browser = browsers.get(key);const win = owner();- const view = createView({- webPreferences: { partition: browser.partition, sandbox: true, contextIsolation: true, nodeIntegration: false, webviewTag: false, backgroundThrottling: false, safeDialogs: true },- ...(adopt ? { webContents: adopt } : {}),- });- const contents = view.webContents;+ let view = null;+ let popup = null;+ if (windowed) {+ popup = createPopup({+ parent: win, modal: false, show: true, autoHideMenuBar: true, ...POPUP_SIZE,+ webPreferences: webPreferences(browser), ...(adopt ? { webContents: adopt } : {}),+ });+ } else {+ view = createView({ webPreferences: webPreferences(browser), ...(adopt ? { webContents: adopt } : {}) });+ }+ const contents = (popup ?? view).webContents;contents.setWebRTCIPHandlingPolicy("disable_non_proxied_udp");// DevTools would take the debugger from the bot: one client per webContents.contents.on("devtools-opened", () => contents.closeDevTools());- const entry = { tab: `p${++tabCount}`, view, contents, window: win, target: null, visible: false, botInputs: 0, botInputAt: -Infinity, ...(opener ? { opener } : {}) };+ const entry = { tab: `p${++tabCount}`, view, popup, contents, window: win, target: null, visible: false, botInputs: 0, botInputAt: -Infinity, personAt: -Infinity, windowOpen: null, ...(opener ? { opener } : {}) };contents.debugger.attach("1.3");browser.tabs.set(entry.tab, entry);contents.debugger.on("message", (_event, method, params, sessionId) => {+ if (method === "Page.windowOpen" && !sessionId && isObject(params)) entry.windowOpen = { url: String(params.url), userGesture: params.userGesture === true, at: now() };post({ op: "event", browser: key, tab: entry.tab, method, params: isObject(params) ? params : {}, ...(sessionId ? { session: sessionId } : {}) });});+ // Sites with a rule of their own see it in the page's navigator.userAgent too.+ contents.on("did-start-navigation", (_event, url, isInPlace, isMainFrame) => {+ if (!isMainFrame || isInPlace) return;+ const identity = identities.get(browser.partition);+ if (identity) contents.setUserAgent(paneTabUserAgent(identity.electron, identity.mode, url));+ });contents.debugger.on("detach", () => removeTab(key, entry.tab));contents.on("render-process-gone", () => removeTab(key, entry.tab, true));contents.on("destroyed", () => removeTab(key, entry.tab));for (const event of ["did-navigate", "did-navigate-in-page", "page-title-updated"]) contents.on(event, () => info(key, entry));contents.on("input-event", (_event, input) => { if (PERSON_INPUT.has(input?.type)) ping(key, entry); });- contents.setWindowOpenHandler(() => (tabRefusal(key) ? { action: "deny" } : {- action: "allow",- // OAuth pop-ups answer their opener, so the popup is the page's own child, made a tab here.- createWindow: (options) => {- const popup = createTab(key, { adopt: options?.webContents, opener: entry.tab });- void targetOf(popup.contents).then((target) => { popup.target = target; info(key, popup); }, () => removeTab(key, popup.tab));- return popup.contents;- },- }));- view.setBounds({ x: 0, y: 0, ...size() });- view.setVisible(false);- win.contentView.addChildView(view);- if (!background) browser.active = entry.tab;+ contents.setWindowOpenHandler((details) => openPopup(key, entry, details));+ if (popup) {+ // The person sees whose page this is, whatever its title says.+ popup.on("page-title-updated", (event) => {+ event.preventDefault();+ popup.setTitle(originOf(contents.getURL()));+ });+ popup.on("closed", () => removeTab(key, entry.tab));+ } else {+ view.setBounds({ x: 0, y: 0, ...size() });+ view.setVisible(false);+ win.contentView.addChildView(view);+ if (!background) browser.active = entry.tab;+ }layout();return entry;}@@ -214,8 +282,12 @@ export function createBrowserPanes({ createView, fromPartition, owner, chromeVerif (!entry) return;browser.tabs.delete(tab);if (browser.active === tab) browser.active = [...browser.tabs.keys()].at(-1) ?? null;- try { entry.view.setVisible(false); } catch {}- try { if (!entry.window.isDestroyed()) entry.window.contentView.removeChildView(entry.view); } catch {}+ if (entry.popup) {+ try { if (!entry.popup.isDestroyed()) entry.popup.close(); } catch {}+ } else {+ try { entry.view.setVisible(false); } catch {}+ try { if (!entry.window.isDestroyed()) entry.window.contentView.removeChildView(entry.view); } catch {}+ }try { if (entry.contents.debugger.isAttached()) entry.contents.debugger.detach(); } catch {}try { if (!entry.contents.isDestroyed()) entry.contents.close({ waitForBeforeUnload: false }); } catch {}post({ op: "tab-gone", browser: key, tab, ...(crashed ? { crashed: true } : {}) });@@ -242,7 +314,7 @@ export function createBrowserPanes({ createView, fromPartition, owner, chromeVer}try {closeBrowser(message.browser, false);- const session = configure(message.partition);+ const session = configure(message.partition, message.identity);// Security: the panes reach the network only through the profile's egress gate, as a launched Chrome does.await session.setProxy({ proxyRules: `socks5://127.0.0.1:${message.egress}`, proxyBypassRules: "<-loopback>" });browsers.set(message.browser, { partition: message.partition, downloads: message.downloads, tabs: new Map(), items: new Map(), active: null });diff --git a/electron/browser-pane-main.node-test.mjs b/electron/browser-pane-main.node-test.mjsindex 939c036a8e..d654e9f450 100644--- a/electron/browser-pane-main.node-test.mjs+++ b/electron/browser-pane-main.node-test.mjs@@ -4,7 +4,6 @@ import path from "node:path";import test from "node:test";import { createBrowserPanes } from "./browser-pane-main.mjs";-import { paneUserAgent } from "./browser-pane-wire.mjs";const PARTITION = "persist:omb-pane-0123456789abcdef01234567";const MSG = "openmausbot:browser-pane";@@ -43,6 +42,8 @@ function fakeElectron() {close() { this.closed = true; },devtoolsClosed: 0,closeDevTools() { this.devtoolsClosed++; },+ agent: null,+ setUserAgent(agent) { this.agent = agent; },});let attached = false;contents.debugger = Object.assign(debuggerEvents, {@@ -79,13 +80,26 @@ function fakeElectron() {}return sessions.get(name);};- return { views, sessions, window, createView, fromPartition };+ const popups = [];+ const createPopup = (options) => {+ const contents = options.webContents ?? new EventEmitter();+ const popup = Object.assign(new EventEmitter(), {+ options, focused: 0, destroyed: false, title: "",+ focus() { this.focused++; }, isDestroyed() { return this.destroyed; }, close() { this.destroyed = true; this.emit("closed"); }, setTitle(title) { this.title = title; },+ });+ // The window's contents get the same fake surface a view's would.+ popup.webContents = createView({ webContents: contents, webPreferences: options.webPreferences }).webContents;+ views.pop();+ popups.push(popup);+ return popup;+ };+ return { views, sessions, window, createView, createPopup, popups, fromPartition };}function setup({ captureMs } = {}) {const electron = fakeElectron();let clock = 0;- const panes = createBrowserPanes({ createView: electron.createView, fromPartition: electron.fromPartition, owner: () => (electron.window.destroyed ? null : electron.window), chromeVersion: "146.0.7680.0", now: () => clock, ...(captureMs ? { captureMs } : {}) });+ const panes = createBrowserPanes({ createView: electron.createView, createPopup: electron.createPopup, fromPartition: electron.fromPartition, owner: () => (electron.window.destroyed ? null : electron.window), chromeVersion: "146.0.7680.0", now: () => clock, ...(captureMs ? { captureMs } : {}) });const posted = [];const server = { postMessage: (message) => posted.push(message) };panes.attach(server);@@ -105,13 +119,13 @@ test("says hello to the server it starts, again when that server asks, and ignorassert.equal(panes.receive({}, { type: "something-else" }), false);});-test("opens a profile on its partition, behind its egress gate, with Electron's and the app's tokens out of the user agent", async () => {+test("opens a profile on its partition, behind its egress gate, as Electron's own Chromium without the app's token", async () => {const { send, last, electron } = setup();- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();const opened = last("opened");assert.equal(opened.version, "146.0.7680.0");- assert.equal(opened.userAgent, "Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.0 Safari/537.36");+ assert.equal(opened.userAgent, "Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.0 Electron/43.7.9 Safari/537.36");const session = electron.sessions.get(PARTITION);assert.deepEqual(session.proxy, { proxyRules: "socks5://127.0.0.1:41000", proxyBypassRules: "<-loopback>" });let granted = null;@@ -119,22 +133,38 @@ test("opens a profile on its partition, behind its egress gate, with Electron'sassert.equal(granted, false);assert.equal(session.check(null, "fullscreen"), true);assert.equal(session.check(null, "notifications"), false);- let sent = null;- session.headers({ url: "https://accounts.example/", requestHeaders: { "User-Agent": opened.userAgent, Accept: "*/*" } }, (answer) => { sent = answer; });- assert.deepEqual(sent.requestHeaders, { "User-Agent": opened.userAgent, Accept: "*/*" });+ const headers = (url, requestHeaders) => {+ let sent = null;+ session.headers({ url, referrer: "", resourceType: "mainFrame", requestHeaders }, (answer) => { sent = answer; });+ return sent.requestHeaders;+ };+ const hints = { "sec-ch-ua": '"Chromium";v="146", "Not-A.Brand";v="24"', "sec-ch-ua-platform": '"macOS"' };+ assert.deepEqual(headers("https://example.com/", { "User-Agent": opened.userAgent, ...hints }), { "User-Agent": opened.userAgent, ...hints });+ // Teams' request header alone drops Electron's token; Chromium's client hints are never touched.+ assert.deepEqual(headers("https://teams.microsoft.com/v2/", { "user-agent": opened.userAgent, ...hints }), {+ "user-agent": "Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.0 Safari/537.36", ...hints,+ });});-test("can give one host Electron's own user agent, and every other the stripped one", () => {- const electronAgent = "Mozilla/5.0 Chrome/146.0.7680.0 Electron/43.7.9 OpenMausBot/0.1.175 Safari/537.36";- const hosts = new Map([["accounts.example", "electron"]]);- assert.equal(paneUserAgent(electronAgent, "Accounts.Example", hosts), electronAgent);- assert.equal(paneUserAgent(electronAgent, "example.com", hosts), "Mozilla/5.0 Chrome/146.0.7680.0 Safari/537.36");- assert.equal(paneUserAgent(electronAgent), "Mozilla/5.0 Chrome/146.0.7680.0 Safari/537.36");+test("cleaned identity on request: Electron's token off everywhere but Google's sign-in, which keeps Electron's own UA", async () => {+ const { send, last, electron } = setup();+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "cleaned" });+ await tick();+ assert.equal(last("opened").userAgent, "Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.0 Safari/537.36");+ const session = electron.sessions.get(PARTITION);+ let sent = null;+ session.headers({ url: "https://accounts.google.com/v3/signin/identifier", referrer: "", resourceType: "mainFrame", requestHeaders: { "User-Agent": last("opened").userAgent } }, (answer) => { sent = answer; });+ assert.equal(sent.requestHeaders["User-Agent"], "Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.0 Electron/43.7.9 Safari/537.36");+ // Opened again as native, the same partition goes back to Electron's token.+ send({ op: "close", browser: "bot:a" });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });+ await tick();+ assert.match(last("opened").userAgent, / Electron\/43\.7\.9 /);});test("refuses a partition outside the pane pattern, and a profile without an egress gate", async () => {const { send, posted, electron } = setup();- send({ op: "open", browser: "bot:a", partition: "persist:openmausbot-app", egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: "persist:openmausbot-app", egress: 41000, downloads: DOWNLOADS, identity: "native" });send({ op: "open", browser: "bot:a", partition: PARTITION });await tick();assert.equal(posted.length, 1);@@ -143,7 +173,7 @@ test("refuses a partition outside the pane pattern, and a profile without an egrtest("creates a sandboxed view per tab, attaches its debugger and relays its CDP both ways", async () => {const { send, last, electron, posted } = setup();- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();send({ op: "create", browser: "bot:a", req: 1, url: "https://example.com/" });await tick();@@ -179,7 +209,7 @@ test("creates a sandboxed view per tab, attaches its debugger and relays its CDPtest("shows the bot's tab in front over the panel's rectangle and hides it under an overlay", async () => {const { send, panes, posted, electron } = setup();- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();send({ op: "create", browser: "bot:a", req: 1, url: "about:blank" });send({ op: "create", browser: "bot:a", req: 2, url: "about:blank", background: true });@@ -206,7 +236,7 @@ test("shows the bot's tab in front over the panel's rectangle and hides it undertest("makes a page's popup another tab of the same profile, with its opener", async () => {const { send, last, electron } = setup();- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();send({ op: "create", browser: "bot:a", req: 1, url: "about:blank" });await tick();@@ -225,7 +255,7 @@ test("makes a page's popup another tab of the same profile, with its opener", astest("tells the server when the person uses a pane, at most four times a second", async () => {const { send, posted, electron, advance } = setup();- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();send({ op: "create", browser: "bot:a", req: 1, url: "about:blank" });await tick();@@ -242,7 +272,7 @@ test("tells the server when the person uses a pane, at most four times a second"test("draws a hidden pane for a screenshot, then hides it again", async () => {const { send, last, electron } = setup();- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();send({ op: "create", browser: "bot:a", req: 1, url: "about:blank" });await tick();@@ -255,7 +285,7 @@ test("draws a hidden pane for a screenshot, then hides it again", async () => {test("closes a profile's views, detaches their debuggers, erases a partition and drops everything for a new server", async () => {const { send, panes, last, electron, posted } = setup();- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();send({ op: "create", browser: "bot:a", req: 1, url: "about:blank" });await tick();@@ -270,7 +300,7 @@ test("closes a profile's views, detaches their debuggers, erases a partition andawait tick();assert.equal(electron.sessions.get(PARTITION).erased, 1);- send({ op: "open", browser: "bot:b", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:b", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();send({ op: "create", browser: "bot:b", req: 2, url: "about:blank" });await tick();@@ -282,7 +312,7 @@ test("closes a profile's views, detaches their debuggers, erases a partition andtest("a crashed page or a detached debugger is a tab gone", async () => {const { send, last, electron } = setup();- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();send({ op: "create", browser: "bot:a", req: 1, url: "about:blank" });await tick();@@ -292,7 +322,7 @@ test("a crashed page or a detached debugger is a tab gone", async () => {test("hides the shown pane when the app's page reloads or its renderer crashes", async () => {const { send, panes, posted, electron } = setup();- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();send({ op: "create", browser: "bot:a", req: 1, url: "about:blank" });await tick();@@ -306,7 +336,7 @@ test("hides the shown pane when the app's page reloads or its renderer crashes",async function opened(options) {const context = setup(options);- context.send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ context.send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();context.send({ op: "create", browser: "bot:a", req: 1, url: "about:blank" });await tick();@@ -316,7 +346,7 @@ async function opened(options) {test("says no window can host a pane while the app window is closed", async () => {const { send, last, electron } = setup();electron.window.destroyed = true;- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();assert.deepEqual(last("failed"), { type: MSG, op: "failed", browser: "bot:a", error: "The app window is closed.", reason: "no-window" });assert.equal(electron.sessions.size, 0);@@ -396,7 +426,7 @@ test("asks again which browser a panel shows: after no answer, when a browser opassert.equal(whiches().length, 2);send({ op: "resolved", req: whiches().at(-1).req, browser: "bot:a" });await again;- send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS });+ send({ op: "open", browser: "bot:a", partition: PARTITION, egress: 41000, downloads: DOWNLOADS, identity: "native" });await tick();assert.equal(whiches().length, 3);send({ op: "resolved", req: whiches().at(-1).req, browser: "bot:a" });@@ -414,3 +444,61 @@ test("closes every pane when the app window closes", async () => {assert.equal(electron.views[0].webContents.closed, true);assert.equal(last("closed").browser, "bot:a");});++test("a tab on a site with a page-level rule reports that site's UA in the page too, and its own UA again after", async () => {+ const { electron } = await opened();+ const contents = electron.views[0].webContents;+ contents.emit("did-start-navigation", {}, "https://www.chase.com/", false, true);+ assert.equal(contents.agent, "Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.0 Safari/537.36");+ contents.emit("did-start-navigation", {}, "https://example.com/", false, true);+ assert.equal(contents.agent, "Mozilla/5.0 (Macintosh) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.7680.0 Electron/43.7.9 Safari/537.36");+});++test("a sign-in popup the person opened is a real child window on the pane's session, its opener kept, one per opener", async () => {+ const { posted, electron, advance } = await opened();+ advance(5_000);+ const opener = electron.views[0].webContents;+ opener.emit("input-event", {}, { type: "mouseDown" });+ opener.debugger.emit("message", {}, "Page.windowOpen", { url: "https://accounts.example/o/oauth2", windowName: "", windowFeatures: [], userGesture: true }, "");+ const answer = opener.openHandler({ url: "https://accounts.example/o/oauth2", disposition: "new-window" });+ assert.equal(answer.action, "allow");+ const guest = new EventEmitter();+ // Electron makes the guest the opener's child before createWindow: adopting it is what keeps window.opener.+ assert.equal(answer.createWindow({ webContents: guest, webPreferences: {} }), guest);+ const [popup] = electron.popups;+ assert.equal(popup.options.parent, electron.window);+ assert.equal(popup.options.webContents, guest);+ assert.equal(popup.options.webPreferences.partition, PARTITION);+ assert.equal(popup.options.webPreferences.sandbox, true);+ await tick();+ const tab = posted.filter((message) => message.op === "tab").at(-1);+ assert.deepEqual({ tab: tab.tab, opener: tab.opener }, { tab: "p2", opener: "p1" });+ assert.equal(electron.window.children.includes(popup), false);+ guest.url = "https://accounts.example/o/oauth2";+ popup.emit("page-title-updated", { preventDefault() {} }, "Sign in");+ assert.equal(popup.title, "https://accounts.example");++ opener.debugger.emit("message", {}, "Page.windowOpen", { url: "https://accounts.example/again", userGesture: true }, "");+ assert.deepEqual(opener.openHandler({ url: "https://accounts.example/again" }), { action: "deny" });+ assert.equal(popup.focused, 1);+ popup.close();+ assert.equal(posted.filter((message) => message.op === "tab-gone").at(-1).tab, "p2");+});++test("a popup the bot's click opened stays a tab, its opener kept", async () => {+ const { send, posted, electron, advance } = await opened();+ advance(5_000);+ const opener = electron.views[0].webContents;+ let finish;+ opener.debugger.sendCommand = (method) => (method === "Input.dispatchMouseEvent" ? new Promise((resolve) => { finish = resolve; }) : Promise.resolve({ frameTree: { frame: { id: "FRAME9" } } }));+ send({ op: "cdp", browser: "bot:a", req: 2, tab: "p1", method: "Input.dispatchMouseEvent", params: { type: "mousePressed", x: 1, y: 1 } });+ opener.debugger.emit("message", {}, "Page.windowOpen", { url: "https://accounts.example/o/oauth2", userGesture: true }, "");+ const answer = opener.openHandler({ url: "https://accounts.example/o/oauth2" });+ const guest = new EventEmitter();+ answer.createWindow({ webContents: guest });+ finish({});+ await tick();+ assert.equal(electron.popups.length, 0);+ assert.equal(electron.views.at(-1).options.webContents, guest);+ assert.equal(posted.filter((message) => message.op === "tab").at(-1).opener, "p1");+});diff --git a/electron/browser-pane-wire.d.mts b/electron/browser-pane-wire.d.mtsindex 5dc4d9b858..80340aecb5 100644--- a/electron/browser-pane-wire.d.mts+++ b/electron/browser-pane-wire.d.mts@@ -5,8 +5,9 @@ type Base = { type: "openmausbot:browser-pane" };export type PaneToMain = Base & (| { op: "hello" }/** `egress`: the loopback port of the profile's egress gate; every request of its panes goes through it.- * `downloads`: the folder every download of its panes is saved in, never asked of the person. */- | { op: "open"; browser: string; partition: string; egress: number; downloads: string }+ * `downloads`: the folder every download of its panes is saved in, never asked of the person.+ * `identity`: browserEngine.paneIdentity, the user agent its panes present. */+ | { op: "open"; browser: string; partition: string; egress: number; downloads: string; identity: "native" | "cleaned" }| { op: "cancel-download"; browser: string; guid: string }| { op: "create"; browser: string; req: number; url: string; background?: boolean }| { op: "cdp"; browser: string; req: number; tab: string; method: string; params: CdpParams; session?: string }@@ -38,5 +39,4 @@ export declare const PANE_TABS_PER_BROWSER: number;export declare const PANE_PARTITION: RegExp;export declare function paneMessageToMain(raw: unknown): PaneToMain | null;export declare function paneMessageToServer(raw: unknown): PaneToServer | null;-export declare const PANE_UA_HOSTS: Map<string, "electron">;-export declare function paneUserAgent(userAgent: string, host?: string, hosts?: ReadonlyMap<string, "electron">): string;+diff --git a/electron/browser-pane-wire.mjs b/electron/browser-pane-wire.mjsindex 49ca2febae..097f398cba 100644--- a/electron/browser-pane-wire.mjs+++ b/electron/browser-pane-wire.mjs@@ -36,7 +36,8 @@ function fieldsValid(message) {if ("params" in message && !isObject(message.params)) return false;if ("partition" in message && !text(message.partition, PANE_PARTITION)) return false;switch (op) {- case "open": return text(message.partition, PANE_PARTITION) && Number.isInteger(message.egress) && message.egress > 0 && message.egress < 65_536 && text(message.downloads, ABSOLUTE);+ case "open": return text(message.partition, PANE_PARTITION) && Number.isInteger(message.egress) && message.egress > 0 && message.egress < 65_536 && text(message.downloads, ABSOLUTE)+ && (message.identity === "native" || message.identity === "cleaned");case "failed": return typeof message.error === "string" && (message.reason === undefined || message.reason === "no-window");case "cancel-download": return text(message.guid, GUID);case "download": return text(message.tab, TAB) && text(message.guid, GUID) && DOWNLOAD_STATES.has(message.state)@@ -69,16 +70,3 @@ export function paneMessageToMain(raw) {export function paneMessageToServer(raw) {return read(raw, TO_SERVER);}--/**- * Hosts that get Electron's own user agent instead of the stripped one. Known open risk: sign-in walls (Google's- * "this browser may not be secure", Cloudflare Turnstile) judge embedded browsers by it, and which choice passes is not- * settled; a host goes here only after a live test in the app.- */-export const PANE_UA_HOSTS = new Map();--/** The user agent a pane sends to `host`: Electron's with the app's tokens taken out, so sites see the Chromium it is. */-export function paneUserAgent(userAgent, host = "", hosts = PANE_UA_HOSTS) {- if (hosts.get(String(host).toLowerCase()) === "electron") return String(userAgent);- return String(userAgent).replace(/\s(?:Electron|OpenMausBot|openmausbot)\/\S+/g, "").replace(/\s{2,}/g, " ").trim();-}diff --git a/electron/main.mjs b/electron/main.mjsindex ad4c0940b5..f28581dd9a 100644--- a/electron/main.mjs+++ b/electron/main.mjs@@ -156,7 +156,7 @@ cloudEntry.fromLaunch(process.argv); const teamLinks = installTeamJoin({ argv: plet pendingPackageInstallUrl = pendingOrganizationEntry ? null : packageUrlFromCommandLine(process.argv);let pendingChatLink = pendingOrganizationEntry ? null : chatLinkFromCommandLine(process.argv);let organizationEntryReady = false;-let mainWindow = null; const browserPanes = createBrowserPanes({ createView: (options) => new WebContentsView(options), fromPartition: (name) => session.fromPartition(name), owner: () => (mainWindow && !mainWindow.isDestroyed() ? mainWindow : null), chromeVersion: process.versions.chrome, log: (line) => slog(line) });+let mainWindow = null; const browserPanes = createBrowserPanes({ createView: (options) => new WebContentsView(options), createPopup: (options) => new BrowserWindow(options), fromPartition: (name) => session.fromPartition(name), owner: () => (mainWindow && !mainWindow.isDestroyed() ? mainWindow : null), chromeVersion: process.versions.chrome, log: (line) => slog(line) });const serverUnavailableWindows = new WeakSet();let unreadCount = 0;let unreadOverlayIcon;diff --git a/server/browser/backends.ts b/server/browser/backends.tsindex c7122ffad4..f23a3b28ea 100644--- a/server/browser/backends.ts+++ b/server/browser/backends.ts@@ -25,6 +25,12 @@ export interface BackendCaps {botPasskeys: boolean;}+export interface SiteRefusal {+ kind: "google-rejected" | "passkey";+ url: string;+ targetId: string;+}+export interface OpenRequest {key: string;mode: BrowserMode;@@ -44,6 +50,11 @@ export interface OpenedBrowser {readonly exited: Promise<void>;/** Chrome's own quit: session restore keeps the tabs and session cookies. */close(): Promise<void>;+ /** "pane" for the desktop app's native panes. */+ readonly surface?: "pane";+ /** A site turned this browser away (Google's refused sign-in, a passkey it cannot serve): the person's own Chrome or+ * their imported sign-ins are the way on. */+ onSiteRefusal?(listener: (refusal: SiteRefusal) => void): () => void;/** Where the person uses the page directly: called as they press, type or scroll in it. */onPersonInput?(listener: () => void): () => void;/** Where the person uses the page directly: holds the bot's input to a tab while the person has it (refs drop ondiff --git a/server/browser/config.test.ts b/server/browser/config.test.tsindex a74948bf7e..895a16ab7b 100644--- a/server/browser/config.test.ts+++ b/server/browser/config.test.ts@@ -23,6 +23,9 @@ describe("the desktop pane setting", () => {expect(browserPaneWanted({ browserEngine: { engine: "chrome", surface: "stream" } })).toBe(false);expect(browserPaneWanted({ browserEngine: { engine: "chrome", surface: "pane" } })).toBe(true);expect(browserEngineConfigSchema.safeParse({ surface: "window" }).success).toBe(false);+ expect(browserEngineConfigSchema.parse({ paneIdentity: "cleaned" }).paneIdentity).toBe("cleaned");+ expect(browserEngineConfigSchema.parse({}).paneIdentity).toBeUndefined();+ expect(browserEngineConfigSchema.safeParse({ paneIdentity: "firefox" }).success).toBe(false);});});diff --git a/server/browser/config.ts b/server/browser/config.tsindex a6fc422775..a167e6b6c1 100644--- a/server/browser/config.ts+++ b/server/browser/config.ts@@ -31,6 +31,8 @@ export const browserEngineConfigSchema = z.object({/** On a Linux server with Xvnc, the new engine's Chrome runs with its window on a private display that the browser panel* shows and a person drives as a remote desktop. Off by default. */cloudDisplay: z.boolean().optional(),+ /** The user agent the desktop pane presents: Electron's own ("native", the default) or without its Electron token ("cleaned"). */+ paneIdentity: z.enum(["native", "cleaned"]).optional(),});export interface BrowserEngineConfig {@@ -40,6 +42,7 @@ export interface BrowserEngineConfig {engine?: BrowserEngineKind;surface?: "stream" | "pane";cloudDisplay?: boolean;+ paneIdentity?: "native" | "cleaned";}export function browserEngineKind(cfg: { browserEngine?: BrowserEngineConfig }): BrowserEngineKind {diff --git a/server/browser/engines.ts b/server/browser/engines.tsindex 3f9aad76d5..3f21cb2001 100644--- a/server/browser/engines.ts+++ b/server/browser/engines.ts@@ -152,6 +152,12 @@ export class ChromeEngine {return { command: CHROME_ENGINE, args: [key], env: {} };}+ /** Whether a session's browser runs as desktop panes now. */+ onPane(spec: { command: string; args?: readonly string[] }): boolean {+ const key = spec.command === CHROME_ENGINE ? spec.args?.[0] : undefined;+ return key !== undefined && this.service.profiles().some((profile) => profile.key === key && profile.run?.opened.surface === "pane");+ }+target(session: string): BrowserTarget | null {const key = this.#targets.get(session);return key ? { session, key } : null;diff --git a/server/browser/pane/backend.ts b/server/browser/pane/backend.tsindex fa5f4a38c9..0ef9a5b848 100644--- a/server/browser/pane/backend.ts+++ b/server/browser/pane/backend.ts@@ -29,14 +29,20 @@ export class PaneBackend implements Backend {readonly #dataDir: string;readonly #egressPort: (key: string) => Promise<number>;readonly #platform: NodeJS.Platform;+ readonly #identity: () => "native" | "cleaned";#fallback: Backend | null = null;- /** `egressPort`: the profile's egress gate, which the panes' partition is proxied through as a launched Chrome is. */- constructor(link: PaneLink, dataDir: string, egressPort: (key: string) => Promise<number>, platform: NodeJS.Platform = process.platform) {+ /**+ * `egressPort`: the profile's egress gate, which the panes' partition is proxied through as a launched Chrome is.+ * `identity`: browserEngine.paneIdentity. The driver applies no identity of its own to a pane: no user agent or client+ * hint override, no automation flags; the pane is Electron's Chromium as it is.+ */+ constructor(link: PaneLink, dataDir: string, egressPort: (key: string) => Promise<number>, { platform = process.platform, identity = () => "native" }: { platform?: NodeJS.Platform; identity?: () => "native" | "cleaned" } = {}) {this.#link = link;this.#dataDir = dataDir;this.#egressPort = egressPort;this.#platform = platform;+ this.#identity = identity;}get available(): boolean {@@ -58,7 +64,7 @@ export class PaneBackend implements Backend {const partition = panePartition(this.#dataDir, request.key);let opened: OpenedPanes;try {- opened = await this.#link.open(request.key, partition, await this.#egressPort(request.key), request.downloadDir);+ opened = await this.#link.open(request.key, partition, await this.#egressPort(request.key), request.downloadDir, this.#identity());} catch (error) {if (error instanceof PaneUnavailable && this.#fallback) return this.#fallback.open(request);throw error;@@ -86,6 +92,8 @@ export class PaneBackend implements Backend {pid: null,version: opened.version,exited,+ surface: "pane",+ onSiteRefusal: (listener) => opened.endpoint.onRefusal(listener),onPersonInput: (listener) => opened.onPersonInput(listener),personControl: {hold: (targetId, held) => {diff --git a/server/browser/pane/endpoint.ts b/server/browser/pane/endpoint.tsindex 7bb4ef74fe..d82baa5016 100644--- a/server/browser/pane/endpoint.ts+++ b/server/browser/pane/endpoint.ts@@ -1,7 +1,10 @@// One profile's desktop panes as one browser-level CDP connection. Each pane is an Electron webContents whose debugger// speaks page-level CDP only (no Browser domain, no Target.createTarget): this endpoint answers the browser-level// commands itself and asks the main process for tabs, so the CDP driver runs on it unchanged.+import { GOOGLE_REJECTED, passkeyWallAt } from "../../../shared/passkey-wall.ts";+import type { SiteRefusal } from "../backends.ts";import type { Params } from "../cdp/connection.ts";+import { NO_PASSKEY_COMMANDS } from "../cdp/passkeys.ts";import type { CdpTransport, SendMeta } from "../cdp/transport.ts";export interface PaneTab {@@ -91,6 +94,7 @@ function heldAllows(method: string, readOnly: boolean): boolean {return HELD_READS.has(method) || HELD_SETUP.test(method) || (readOnly && RUNTIME_CALLS.has(method));}const PRIMED = ["Network.enable", "Page.enable", "Page.setLifecycleEventsEnabled"] as const;+const UA_OVERRIDES = new Set(["Emulation.setUserAgentOverride", "Network.setUserAgentOverride"]);const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));export class PaneEndpoint implements CdpTransport {@@ -101,6 +105,7 @@ export class PaneEndpoint implements CdpTransport {readonly #quietMs: number;readonly #maxHoldMs: number;readonly #primeMs: number;+ readonly #refusals = new Set<(refusal: SiteRefusal) => void>();#autoAttach = false;#viewerCount = 0;#lastInput = 0;@@ -174,6 +179,11 @@ export class PaneEndpoint implements CdpTransport {const state = this.#tabs.get(tab);if (!state) return;const page = pageSession(tab);+ // A frame left waiting for a debugger never runs its scripts: Google's sign-in then says the browser has no JavaScript.+ if (method === "Target.attachedToTarget" && params.waitingForDebugger === true && typeof params.sessionId === "string") {+ void this.#channel.command(tab, "Runtime.runIfWaitingForDebugger", {}, params.sessionId).catch(() => undefined);+ }+ if (method === "Page.frameNavigated" && !session) this.#refusedHere(state, params);if (session) {this.#event(method, renamed(method, params, page), `${page}:${session}`);return;@@ -190,6 +200,23 @@ export class PaneEndpoint implements CdpTransport {for (const viewer of state.viewers) this.#event(method, params, viewer);}+ /** Called when a site turns this browser away; the panel can offer the person's own Chrome or their sign-ins. */+ onRefusal(listener: (refusal: SiteRefusal) => void): () => void {+ this.#refusals.add(listener);+ return () => this.#refusals.delete(listener);+ }++ #refusedHere(tab: TabState, params: Params): void {+ const frame = params.frame as { id?: unknown; parentId?: unknown; url?: unknown; urlFragment?: unknown } | undefined;+ if (!frame || frame.parentId !== undefined || typeof frame.url !== "string") return;+ const url = frame.url;+ const kind = GOOGLE_REJECTED.test(url) ? "google-rejected" : passkeyWallAt(url) ? "passkey" : null;+ if (!kind) return;+ for (const listener of this.#refusals) {+ try { listener({ kind, url, targetId: tab.target }); } catch {}+ }+ }+/** The person pressed, typed or scrolled in one of these panes (`tab` when the app knows which). */personInput(tab?: string): void {this.#lastInput = Date.now();@@ -249,7 +276,8 @@ export class PaneEndpoint implements CdpTransport {if (!command.sessionId) return this.#browser(command.method, params);const route = this.#route(command.sessionId);if (route.kind !== "viewer" && route.tab.held && !heldAllows(command.method, command.readOnly === true)) throw new Refusal(PERSON_HOLDS_TAB);- if (route.kind === "child") return this.#channel.command(route.tab.tab, command.method, unrenamed(command.method, params), route.child);+ if (UA_OVERRIDES.has(command.method) && !params.userAgentMetadata) throw new Refusal("A desktop pane keeps Chromium's own client hints: a user agent override needs userAgentMetadata.");+ if (route.kind === "child") return this.#channel.command(route.tab.tab, command.method, unattached(command.method, unrenamed(command.method, params)), route.child);if (route.kind === "viewer") return this.#viewer(route.tab, command.sessionId, command.method, params);return this.#page(route.tab, command.method, params);}@@ -354,12 +382,18 @@ export class PaneEndpoint implements CdpTransport {} else {await ahead;}- // Real input follows window focus; a pane the person is not in must still take the bot's keys.- if (method === "Page.enable") void this.#channel.command(tab.tab, "Emulation.setFocusEmulationEnabled", { enabled: true }).catch(() => undefined);+ if (method === "Page.enable") this.#setUpPane(tab.tab);if (method === "Page.navigate" || method === "Page.reload") await this.#prime(tab.tab);- // The person's page outlives this server: a frame paused for it would stay frozen after a server restart.- const sent = method === "Target.setAutoAttach" ? { ...params, waitForDebuggerOnStart: false } : params;- return this.#channel.command(tab.tab, method, sent);+ return this.#channel.command(tab.tab, method, unattached(method, params));+ }++ /**+ * Real input follows window focus; a pane the person is not in must still take the bot's keys. Electron draws no+ * passkey sheet, so a passkey request would wait for good (Electron 43): it is turned down at once instead.+ */+ #setUpPane(tab: string): void {+ void this.#channel.command(tab, "Emulation.setFocusEmulationEnabled", { enabled: true }).catch(() => undefined);+ for (const [method, params] of NO_PASSKEY_COMMANDS) void this.#channel.command(tab, method, params).catch(() => undefined);}async #viewer(tab: TabState, sessionId: string, method: string, params: Params): Promise<Params> {@@ -451,6 +485,11 @@ function unrenamed(method: string, params: Params): Params {return params;}+/** The person's page outlives this server: a frame paused for it would stay frozen after a server restart. */+function unattached(method: string, params: Params): Params {+ return method === "Target.setAutoAttach" ? { ...params, waitForDebuggerOnStart: false } : params;+}+function errorOf(error: unknown): { message: string; code?: number } {if (error instanceof Refusal) return { message: error.message, code: -32000 };const code = (error as { code?: unknown } | null)?.code;diff --git a/server/browser/pane/link.ts b/server/browser/pane/link.tsindex 4ad1ee7c39..99078cc300 100644--- a/server/browser/pane/link.ts+++ b/server/browser/pane/link.ts@@ -85,7 +85,7 @@ export class PaneLink {this.#resolver = resolver;}- async open(browser: string, partition: string, egress: number, downloads: string): Promise<OpenedPanes> {+ async open(browser: string, partition: string, egress: number, downloads: string, identity: "native" | "cleaned" = "native"): Promise<OpenedPanes> {if (!this.available) throw new PaneUnavailable("The desktop app does not show browser panes here.");this.close(browser);const answer = await new Promise<{ version: string; userAgent: string }>((resolve, reject) => {@@ -99,7 +99,7 @@ export class PaneLink {resolve: (value) => { clearTimeout(timer); resolve(value); },reject: (error) => { clearTimeout(timer); reject(error); },});- this.#post({ op: "open", browser, partition, egress, downloads });+ this.#post({ op: "open", browser, partition, egress, downloads, identity });});const inputs = new Set<() => void>();const channel: PaneChannel = {diff --git a/server/browser/pane/pane.test.ts b/server/browser/pane/pane.test.tsindex 3a893ce3a2..5bbe09789c 100644--- a/server/browser/pane/pane.test.ts+++ b/server/browser/pane/pane.test.ts@@ -11,6 +11,7 @@ import { FakeBackend, FakeChrome, type FakeDocument } from "../testing/fake-chroimport { PaneBackend, panePartition } from "./backend.ts";import { PaneEndpoint, PERSON_HOLDS_TAB, type PaneChannel } from "./endpoint.ts";import { PaneLink } from "./link.ts";+import { withPasskeyNotice } from "../passkey-notice.ts";import { FakeMain } from "./testing/fake-main.ts";const FORM: FakeDocument = {@@ -36,7 +37,7 @@ function setup({ quietMs = 1_000, linkOptions = {} }: { quietMs?: number; linkOpfolders.push(dataDir);const main = new FakeMain(documents);const link = new PaneLink(main, { quietMs, maxHoldMs: 2_000, ...linkOptions });- const backend = new PaneBackend(link, dataDir, async () => 41_000, "darwin");+ const backend = new PaneBackend(link, dataDir, async () => 41_000, { platform: "darwin" });const service = new BrowserService({ dataDir, backend: () => backend, maxRunning: 4, idleMs: () => 600_000, takeoverMs: 200 });services.push(service);const target = { session: "bot-a", key: "bot:a" };@@ -296,6 +297,93 @@ describe("deleting a bot's browser with the pane", () => {});});+describe("the pane's identity", () => {+ it("is Electron's Chromium as it is: the driver sends no user agent, client hint, automation switch or main-world script", async () => {+ const { main, call } = setup();+ await call("agent_browser_open", { url: "https://example.com/form" });+ await call("agent_browser_fill", { selector: "#name", text: "Ada" });+ await call("agent_browser_click", { selector: "#go" });+ await call("agent_browser_open", { url: "https://example.com/b", tab: "new" });+ expect(main.toMain.filter((message) => message.op === "open").map((message) => (message as { identity: string }).identity)).toEqual(["native"]);+ const sent = main.commands;+ expect(sent.filter((command) => /UserAgentOverride|setDeviceMetricsOverride|setAutomationOverride/.test(command.method))).toEqual([]);+ expect(sent.filter((command) => command.method === "Page.addScriptToEvaluateOnNewDocument" && !command.params.worldName)).toEqual([]);+ expect(sent.filter((command) => (command.method === "Runtime.evaluate" || command.method === "Runtime.callFunctionOn") && command.params.contextId === undefined && command.params.objectId === undefined)).toEqual([]);+ expect(JSON.stringify(sent)).not.toMatch(/Firefox|webdriver|AutomationControlled|Google Chrome/);+ FORM.elements[1]!.value = "";+ });++ it("refuses a user agent override that would blank Chromium's client hints", async () => {+ const { main, service, call } = setup();+ await call("agent_browser_open", { url: "https://example.com/a" });+ const page = service.profiles()[0]!.run!.browser.activePage!;+ await expect(page.session.send("Emulation.setUserAgentOverride", { userAgent: "Mozilla/5.0 Chrome/146.0.0.0" })).rejects.toThrow(/needs userAgentMetadata/);+ await expect(page.session.send("Network.setUserAgentOverride", { userAgent: "x" })).rejects.toThrow(/needs userAgentMetadata/);+ expect(main.commands.some((command) => command.method.endsWith("UserAgentOverride"))).toBe(false);+ });++ it("passes the cleaned identity to the app when the config asks for it", async () => {+ const dataDir = mkdtempSync(join(tmpdir(), "omb-browser-pane-"));+ folders.push(dataDir);+ const main = new FakeMain(documents);+ const link = new PaneLink(main);+ await sleep(5);+ const backend = new PaneBackend(link, dataDir, async () => 41_000, { identity: () => "cleaned" });+ const opened = await backend.open({ key: "bot:c", mode: "headless", fresh: false, viewport: { width: 1280, height: 720 }, downloadDir: dataDir });+ expect(main.toMain.find((message) => message.op === "open")).toMatchObject({ identity: "cleaned" });+ await opened.close();+ });++ it("turns a passkey request down at once instead of leaving the page waiting for a sheet Electron never draws", async () => {+ const { main, call } = setup();+ await call("agent_browser_open", { url: "https://example.com/a" });+ expect(main.commands.filter((command) => command.method.startsWith("WebAuthn.")).map((command) => command.method)).toEqual(["WebAuthn.enable", "WebAuthn.addVirtualAuthenticator"]);+ });+});++describe("the pane's debugger and its frames", () => {+ it("never leaves a frame waiting: auto-attach never pauses, and a frame that arrives paused is run at once", async () => {+ const sent: Array<{ tab: string; method: string; params: Record<string, unknown>; session?: string }> = [];+ const endpoint = new PaneEndpoint({+ version: "146", userAgent: "ua", create: async () => ({ tab: "p9", target: "F9", url: "", title: "" }),+ command: async (tab, method, params, session) => { sent.push({ tab, method, params, ...(session ? { session } : {}) }); return {}; },+ front: () => {}, closeTab: () => {}, cancelDownload: () => {}, close: () => {},+ }, [{ tab: "p1", target: "F1", url: "https://a.test/", title: "A" }]);+ const connection = new CdpConnection(endpoint);+ await connection.root.send("Target.setAutoAttach", { autoAttach: true, waitForDebuggerOnStart: true, flatten: true });+ endpoint.pageEvent("p1", "Target.attachedToTarget", { sessionId: "IFR", targetInfo: { targetId: "X", type: "iframe", url: "https://accounts.google.com/", title: "" }, waitingForDebugger: true });+ await sleep(1);+ expect(sent).toContainEqual({ tab: "p1", method: "Runtime.runIfWaitingForDebugger", params: {}, session: "IFR" });+ await connection.session("pane-p1:IFR")!.send("Target.setAutoAttach", { autoAttach: true, waitForDebuggerOnStart: true, flatten: true });+ expect(sent.at(-1)).toEqual({ tab: "p1", method: "Target.setAutoAttach", params: { autoAttach: true, waitForDebuggerOnStart: false, flatten: true }, session: "IFR" });+ connection.close();+ });+});++describe("a site turning the pane away", () => {+ it("is reported when Google refuses sign-in or asks for a passkey, and the bot is told to use My Chrome", async () => {+ const { main, service, call } = setup();+ await call("agent_browser_open", { url: "https://example.com/a" });+ const run = service.profiles()[0]!.run!;+ const refusals: Array<{ kind: string; url: string }> = [];+ run.opened.onSiteRefusal!((refusal) => refusals.push({ kind: refusal.kind, url: refusal.url }));+ const frame = (url: string) => main.post({ op: "event", browser: "bot:a", tab: "p1", method: "Page.frameNavigated", params: { frame: { id: run.browser.activePage!.targetId, url, loaderId: "L" } } });+ frame("https://accounts.google.com/v3/signin/rejected?continue=x");+ frame("https://accounts.google.com/v3/signin/challenge/pk?TL=1");+ frame("https://accounts.google.com/v3/signin/identifier");+ await sleep(5);+ expect(refusals).toEqual([+ { kind: "google-rejected", url: "https://accounts.google.com/v3/signin/rejected?continue=x" },+ { kind: "passkey", url: "https://accounts.google.com/v3/signin/challenge/pk?TL=1" },+ ]);+ const told = withPasskeyNotice({ content: [{ type: "text", text: "Opened https://accounts.google.com/v3/signin/rejected in t1." }] }, "pane") as { content: Array<{ text: string }> };+ expect(told.content.at(-1)!.text).toContain("My Chrome");+ expect(told.content.at(-1)!.text).toContain("this app's built-in browser");+ const passkey = withPasskeyNotice({ content: [{ type: "text", text: "https://accounts.google.com/v3/signin/challenge/pk" }] }, "pane") as { content: Array<{ text: string }> };+ expect(passkey.content.at(-1)!.text).toContain("My Chrome");+ });+});+describe("the pane partition", () => {it("is per profile and per data folder, and in memory for a temporary profile", async () => {const one = mkdtempSync(join(tmpdir(), "omb-browser-pane-"));diff --git a/server/browser/passkey-notice.ts b/server/browser/passkey-notice.tsindex cbc137c9cb..b5ade140d3 100644--- a/server/browser/passkey-notice.ts+++ b/server/browser/passkey-notice.ts@@ -1,8 +1,11 @@-import { GOOGLE_PAGE, passkeyWallIn, type PasskeyWall } from "../../shared/passkey-wall.ts";+import { GOOGLE_PAGE, GOOGLE_REJECTED, passkeyWallIn, type PasskeyWall } from "../../shared/passkey-wall.ts";import { attachesToChrome } from "../browser-runtime.ts";-/** Where the bots' browsers run: only My Cloud has a person's lent PC to offer. */-export type BrowserPlace = "cloud" | "desktop" | "server";+/** Where the bots' browsers run: only My Cloud has a person's lent PC to offer; "pane" is the desktop app's own+ * browser the person also uses, where My Chrome is the way on. */+export type BrowserPlace = "cloud" | "desktop" | "server" | "pane";++const MY_CHROME = "The person can switch this bot's browser to My Chrome (their own Chrome, from the profile menu in the Browser panel)";const PROVIDER: Record<PasskeyWall, { name: string; apps: string; otherWay: string }> = {google: { name: "Google", apps: "Gmail, Calendar or Drive", otherWay: "Try another way" },@@ -12,11 +15,10 @@ const PROVIDER: Record<PasskeyWall, { name: string; apps: string; otherWay: striexport function passkeyNotice(wall: PasskeyWall, place: BrowserPlace): string {const { name, apps, otherWay } = PROVIDER[wall];return `Passkey step, from OpenMausBot: this ${name} account wants a passkey or security key, which lives on the person's own phone or computer. This browser has none, so it turns the request down at once and ${name} may say something went wrong: do not retry, wait, or press Continue or Try again. Choose "${otherWay}" on this page (the options can take a moment: take a snapshot to see them), or use the person's own computer's browser. What works, best first: 1) For ${apps}, use connected apps instead of this browser; if ${name} is not connected, call COMPOSIO_MANAGE_CONNECTIONS so the person can connect it. 2) If this browser must be signed in: with a saved login for this account, click "${otherWay}", choose the password and call fill_login; otherwise call request_sign_in and tell them to choose "${otherWay}" on this page, then use their password and a code (authenticator app, text message or backup code).`- + (place === "cloud" ? " 3) If they lend a PC to My Cloud (list_shared_computers), their own browser on it can use the passkey while they approve it at that PC." : "");+ + (place === "cloud" ? " 3) If they lend a PC to My Cloud (list_shared_computers), their own browser on it can use the passkey while they approve it at that PC." : "")+ + (place === "pane" ? ` 3) This is the app's built-in browser, which has no passkeys for the person either. ${MY_CHROME}, where their passkeys work.` : "");}-/** Google's refusal of an automated browser ("Couldn't sign you in: this browser or app may not be secure"). */-const GOOGLE_REJECTED = /https:\/\/accounts\.google\.com\/(?:v\d+\/)?signin\/(?:v\d+\/)?rejected\b/u;/** Its English wording: the heading, then the reason, so a page that only quotes the reason is no refusal. */const GOOGLE_REJECTED_WORDS = /\bcouldn(?:'|’)?t sign you in\b[\s\S]{0,300}\bthis browser or app may not be secure\b/iu;@@ -27,6 +29,9 @@ export function googleRefusalIn(text: string): boolean {/** Google turns down sign-in in a browser run by software, so the bot hands that step to the person. */export function googleRefusalNotice(place: BrowserPlace): string {+ if (place === "pane") {+ return `Google sign-in refused, from OpenMausBot: Google turned down this app's built-in browser, for the person as well as for you, and retrying, waiting or a new tab will not change that: do not retry Google sign-in here. What works, best first: 1) For Gmail, Calendar or Drive, use connected apps instead of this browser; if Google is not connected, call COMPOSIO_MANAGE_CONNECTIONS so the person can connect it. 2) ${MY_CHROME}, where Google sign-in works; tell them so in plain words. 3) For a site's "Sign in with Google", ask whether that site offers another way to sign in.`;+ }return "Google sign-in refused, from OpenMausBot: Google does not let a browser run by software sign in, and retrying, waiting, a new tab or a fresh page will not change that: do not retry Google sign-in in this browser. Hand this step to the person. What works, best first: 1) For Gmail, Calendar or Drive, use connected apps instead of this browser; if Google is not connected, call COMPOSIO_MANAGE_CONNECTIONS so the person can connect it. 2) For a site's \"Sign in with Google\": tell the person in plain words that Google refused the bot's browser, and ask whether that site offers another way to sign in (email and password, or a link by email); with a saved login use fill_login, otherwise request_sign_in, and they choose that other way, not Google. 3) Or the person does this step in their own computer's browser."+ (place === "cloud" ? " If they lend a PC to My Cloud (list_shared_computers), its own browser is an ordinary one, where Google sign-in usually works." : "");}diff --git a/server/host/browser.ts b/server/host/browser.tsindex d8a45660b6..3f45a9ae6f 100644--- a/server/host/browser.ts+++ b/server/host/browser.ts@@ -172,7 +172,7 @@ export function createBrowserHost(deps: BrowserHostDeps) {const chromeEngine = new ChromeEngine({dataDir: DATA_DIR,host,- ...(paneLink ? { pane: { backend: new PaneBackend(paneLink, DATA_DIR, (key) => browserEgress.open(key)), wanted: () => browserPaneWanted(cfg) } } : {}),+ ...(paneLink ? { pane: { backend: new PaneBackend(paneLink, DATA_DIR, (key) => browserEgress.open(key), { identity: () => cfg.browserEngine?.paneIdentity ?? "native" }), wanted: () => browserPaneWanted(cfg) } } : {}),egressPort: (key) => browserEgress.open(key),egressNotice: (key) => browserEgress.takeNotice(key),idleMs,@@ -237,7 +237,7 @@ export function createBrowserHost(deps: BrowserHostDeps) {if (!lender) return lentChromeGuidance("not-lent", null);return lender.online ? null : lentChromeGuidance("offline", lender);},- annotate: passkeyAnnotation(CLOUD_HOME ? "cloud" : DESKTOP_MANAGED ? "desktop" : "server"),+ annotate: (spec, result) => passkeyAnnotation(chromeEngine.onPane(spec) ? "pane" : CLOUD_HOME ? "cloud" : DESKTOP_MANAGED ? "desktop" : "server")(spec, result),// agent-browser's own error names only the CDP connection; the door knows what went wrong on the way.afterCall: (session, spec, answer) => {const result = withCeilingNote(session, answer);diff --git a/shared/passkey-wall.ts b/shared/passkey-wall.tsindex 31add0cdf1..a8845965ee 100644--- a/shared/passkey-wall.ts+++ b/shared/passkey-wall.ts@@ -8,6 +8,9 @@ export type PasskeyWall = "google" | "microsoft";/** Google's passkey (pk) and security key (sk) challenges, under /v3/signin/challenge/… and /signin/v2/challenge/…. */const GOOGLE_CHALLENGE = /^\/(?:v\d+\/)?signin\/(?:v\d+\/)?challenge\/(?:pk|sk)(?:\/|$)/u;+/** Google's refusal of a browser it will not let sign in ("Couldn't sign you in: this browser or app may not be secure"). */+export const GOOGLE_REJECTED = /https:\/\/accounts\.google\.com\/(?:v\d+\/)?signin\/(?:v\d+\/)?rejected\b/u;+/** The address of Google's passkey step, as a browser view or a page change names it. */export function passkeyWallAt(address: string): PasskeyWall | null {let url: URL;