Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

feat(bridge): take any extension at protocol 22 or newer, let both store copies start the Bridge, and keep three pairing codes live — a store copy a version ahead is welcomed and proves itself at its own number, an older one is refused in words it already reads, and each session says which store it came from

Shahriar2e387e26713d
diff --git a/src/daemon/auth-store.test.ts b/src/daemon/auth-store.test.ts
index 76d6ad1..17072cd 100644
--- a/src/daemon/auth-store.test.ts
+++ b/src/daemon/auth-store.test.ts
@@ -49,10 +49,9 @@ describe('pairing codes', () => {
expect([/^[ABCDEFGHJKMNPQRSTWXYZ23456789]{8}$/.test(code), expiresAt - Date.now()]).toEqual([true, 10 * 60_000]);
});
- test('a new code replaces the one before it', () => {
- createPairing();
- const { code } = createPairing();
- expect(pendingPairings()).toEqual([code]);
+ test('a new code leaves the two before it working, and retires the oldest of four', () => {
+ const codes = [createPairing(), createPairing(), createPairing(), createPairing()].map(({ code }) => code);
+ expect(pendingPairings()).toEqual(codes.slice(1));
});
test('a code stops being pending once it expires', () => {
diff --git a/src/daemon/auth-store.ts b/src/daemon/auth-store.ts
index d99339f..b4177b8 100644
--- a/src/daemon/auth-store.ts
+++ b/src/daemon/auth-store.ts
@@ -8,6 +8,8 @@ const authPath = join(stateDir, 'auth.json');
const CODE_ALPHABET = 'ABCDEFGHJKMNPQRSTWXYZ23456789';
const CODE_LENGTH = 8;
const PAIRING_TTL_MS = 10 * 60 * 1000;
+/** The app, a terminal and a second terminal can each be showing one; a new code must not void theirs. */
+const LIVE_PAIRINGS = 3;
export interface Session {
key: string;
@@ -51,8 +53,10 @@ export function createPairing(): { code: string; expiresAt: number } {
{ length: CODE_LENGTH },
() => CODE_ALPHABET[randomInt(CODE_ALPHABET.length)],
).join('');
- const expiresAt = Date.now() + PAIRING_TTL_MS;
- write({ ...auth, pairings: [{ code, expiresAt }] });
+ const now = Date.now();
+ const expiresAt = now + PAIRING_TTL_MS;
+ const live = auth.pairings.filter((pairing) => pairing.expiresAt > now).slice(1 - LIVE_PAIRINGS);
+ write({ ...auth, pairings: [...live, { code, expiresAt }] });
return { code, expiresAt };
}
diff --git a/src/daemon/control.ts b/src/daemon/control.ts
index a73a4ec..4d9588d 100644
--- a/src/daemon/control.ts
+++ b/src/daemon/control.ts
@@ -2,6 +2,7 @@ import type { ActionResult } from '@/lib/actions/protocol';
import type { ToolDescriptor } from '@/lib/actions/manifest';
import type { AgentKind, AgentState } from '@/lib/agents/catalog';
import type { Preferences } from '@/lib/settings/preferences';
+import type { Source } from '@/lib/stores';
export interface BridgeStatus {
connected: boolean;
@@ -21,6 +22,8 @@ export interface SessionSummary {
id: string;
browser?: string;
origin: string;
+ /** Absent from a daemon before 0.8, which knew only the unpacked copy. */
+ source?: Source;
extensionVersion: string;
pairedAt: string;
lastSeenAt: string;
diff --git a/src/daemon/daemon.ts b/src/daemon/daemon.ts
index a9937e7..df2d251 100644
--- a/src/daemon/daemon.ts
+++ b/src/daemon/daemon.ts
@@ -5,6 +5,7 @@ import type { Duplex } from 'node:stream';
import { WebSocketServer, type WebSocket } from 'ws';
import {
EXTERNAL_RUN_ID,
+ MIN_EXTENSION_PROTOCOL,
SOCKET_PROTOCOL_VERSION,
failure,
isInstallId,
@@ -21,6 +22,7 @@ import { solveCaptcha } from '@/lib/actions/page/solve-captcha';
import { describeActions } from '@/lib/actions/registry';
import { RESERVED_PREFIX } from '@/lib/actions/reserved';
import { AGENTS, isAgentKind, type AgentState } from '@/lib/agents/catalog';
+import { sourceOf } from '@/lib/stores';
import { saveScreenshot } from './screenshots';
import { adoptDownload, listDownloads, resolveAttachment, sweepDownloads, type CapturedItem } from './downloads';
import {
@@ -106,6 +108,23 @@ function browserLabel(claimed: unknown): string | undefined {
return claimed.replace(/[^\x20-\x7E]/g, '').trim().slice(0, BROWSER_LABEL_MAX) || undefined;
}
+/**
+ * Why this extension cannot be let in, or null. An extension newer than the daemon is let in: it
+ * says how old a daemon it can live with, and anything it sends that the daemon does not know is
+ * left unanswered. Before 0.8 an extension read only "protocol version mismatch" as a refusal not
+ * worth retrying, so a too-old one is told in those words.
+ */
+export function protocolRefusal(hello: { protocolVersion: unknown; minDaemonProtocol?: unknown }): string | null {
+ const { protocolVersion, minDaemonProtocol } = hello;
+ if (typeof protocolVersion !== 'number' || protocolVersion < MIN_EXTENSION_PROTOCOL) {
+ return `protocol version mismatch: Browsentic Bridge speaks v${SOCKET_PROTOCOL_VERSION} and takes extensions from v${MIN_EXTENSION_PROTOCOL} on`;
+ }
+ if (typeof minDaemonProtocol === 'number' && minDaemonProtocol > SOCKET_PROTOCOL_VERSION) {
+ return `daemon too old: Browsentic Bridge speaks v${SOCKET_PROTOCOL_VERSION}, this extension needs v${minDaemonProtocol}`;
+ }
+ return null;
+}
+
export interface DaemonOptions {
version: string;
idleExit?: boolean;
@@ -228,6 +247,8 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
lock.port = port;
writeLockfile(lock);
releaseWake();
+ // A registration an older daemon wrote lets in only what it knew, which leaves the store copies out.
+ refreshNativeHost();
log(`daemon ${version} listening on 127.0.0.1:${port} (pid ${process.pid})`);
scheduleIdleExit();
@@ -279,9 +300,10 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
ws.close(1002, 'expected hello');
return;
}
- if (hello.protocolVersion !== SOCKET_PROTOCOL_VERSION) {
- log(`extension protocol v${hello.protocolVersion} != daemon v${SOCKET_PROTOCOL_VERSION}; closing`);
- ws.close(1002, `protocol version mismatch: daemon speaks v${SOCKET_PROTOCOL_VERSION}`);
+ const refusal = protocolRefusal(hello);
+ if (refusal) {
+ log(`extension protocol v${hello.protocolVersion} refused: ${refusal}; closing`);
+ ws.close(1002, refusal);
return;
}
if (!isNonce(hello.nonce)) {
@@ -301,8 +323,9 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
browser: browserLabel(hello.browser),
};
+ // At the extension's number, not ours: it proves what it said, and it said its own version.
const transcript: Transcript = {
- protocolVersion: SOCKET_PROTOCOL_VERSION,
+ protocolVersion: hello.protocolVersion,
extensionVersion: hello.extensionVersion,
manifestHash: hello.manifestHash,
clientNonce: hello.nonce,
@@ -322,7 +345,7 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
if (hello.auth?.kind === 'pair') {
const matched = await matchPairing(proven.proof, transcript);
if (!matched) {
- return reject('That pairing code is wrong or expired. Run "browsentic-mcp pair" for a new one.', true);
+ return reject('That pairing code is wrong or expired. Run "browsentic pair" for a new one.', true);
}
consumePairing(matched.code);
secret = matched.secret;
@@ -333,7 +356,7 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
} else if (hello.auth?.kind === 'session') {
const session = await matchSession(proven.proof, transcript, install);
if (!session) {
- return reject('This browser is no longer paired. Run "browsentic-mcp pair" to pair again.', false);
+ return reject('This browser is no longer paired. Run "browsentic pair" to pair again.', false);
}
claimSession(session.key, install);
secret = session.key;
@@ -490,7 +513,12 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
manifestInSync,
sealedSessionKey,
};
- accepted.send({ t: 'welcome', ...welcome, proof: await serverProof(secret, transcript, welcome) });
+ accepted.send({
+ t: 'welcome',
+ ...welcome,
+ protocolVersion: SOCKET_PROTOCOL_VERSION,
+ proof: await serverProof(secret, transcript, welcome),
+ });
scheduleIdleExit();
void pushAgentState(accepted);
watchModels();
@@ -837,7 +865,7 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
function sessionSummaries(): SessionSummary[] {
return listSessions().map(({ key: _key, installId: _installId, ...session }) => {
const id = sessionId({ installId: _installId, origin: session.origin });
- return { id, ...session, connected: links.get(id)?.isOpen === true };
+ return { id, ...session, source: sourceOf(session.origin), connected: links.get(id)?.isOpen === true };
});
}
diff --git a/src/daemon/native-host.test.ts b/src/daemon/native-host.test.ts
index d905e37..cfad89f 100644
--- a/src/daemon/native-host.test.ts
+++ b/src/daemon/native-host.test.ts
@@ -43,6 +43,15 @@ describe('allowedOrigins', () => {
expect(allowedOrigins(platform)).toContain(unpackedExtensionOrigin(extensionDir(), platform));
}
});
+
+ it('lets both store copies start the daemon before they have ever paired', () => {
+ expect(allowedOrigins('darwin')).toEqual(
+ expect.arrayContaining([
+ 'chrome-extension://npmocgldfflonjjmdadmdefpnfagnjmp/',
+ 'chrome-extension://cbkjhkgjcpihokphhdkbahilpcjojpdc/',
+ ]),
+ );
+ });
});
describe('hostTargets', () => {
@@ -136,14 +145,18 @@ describe('registering the host', () => {
mkdirSync(chromeHome, { recursive: true });
});
- it('registers with the browsers that are installed, letting in the unpacked extension', () => {
+ it('registers with the browsers that are installed, letting in both store copies and the unpacked one', () => {
const installed = installNativeHost('/opt/browsentic/dist/cli.js', 'linux');
expect(installed.browsers).toEqual(['Chrome']);
expect(modeOf(installed.launcher)).toBe(bits(0o755));
expect(JSON.parse(readFileSync(manifest, 'utf8'))).toMatchObject({
path: installed.launcher,
- allowed_origins: [unpackedExtensionOrigin(extensionDir(), 'linux')],
+ allowed_origins: [
+ 'chrome-extension://cbkjhkgjcpihokphhdkbahilpcjojpdc/',
+ unpackedExtensionOrigin(extensionDir(), 'linux'),
+ 'chrome-extension://npmocgldfflonjjmdadmdefpnfagnjmp/',
+ ].sort(),
});
expect(registeredBrowsers('linux')).toEqual(['Chrome']);
});
diff --git a/src/daemon/native-host.ts b/src/daemon/native-host.ts
index 6a9c032..0558aed 100644
--- a/src/daemon/native-host.ts
+++ b/src/daemon/native-host.ts
@@ -2,11 +2,13 @@
* Lets the browser start the daemon. Chrome, Edge, Brave and Firefox each launch a program
* registered as a native messaging host when the extension asks for it; ours only makes sure
* a daemon is running and exits. The registration lists the exact extension origins allowed
- * to launch it, recomputed on every setup and every pairing.
+ * to launch it: both store listings always, plus the unpacked folder and whatever has paired,
+ * recomputed on every setup and every pairing.
*/
import { execFileSync } from 'node:child_process';
import { NATIVE_HOST_NAME } from '@/lib/actions/protocol';
+import { FIREFOX_ADDON_ID, STORE_EXTENSION_IDS } from '@/lib/stores';
import { createHash } from 'node:crypto';
import { chmodSync, existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { homedir } from 'node:os';
@@ -18,7 +20,6 @@ import { log } from './log';
import { extensionDir } from './paths';
export { NATIVE_HOST_NAME };
-export const FIREFOX_ADDON_ID = '[email protected]';
type Family = 'chromium' | 'firefox';
@@ -107,7 +108,8 @@ export function allowedOrigins(platform: NodeJS.Platform = process.platform): st
.map((session) => session.origin)
.filter((origin) => origin.startsWith('chrome-extension://'));
const unpacked = unpackedExtensionOrigin(extensionDir(readAgentConfig().extensionDir), platform);
- return [...new Set([unpacked, ...paired].map(asOrigin))].sort();
+ const stores = STORE_EXTENSION_IDS.map((id) => `chrome-extension://${id}/`);
+ return [...new Set([...stores, unpacked, ...paired].map(asOrigin))].sort();
}
export function hostManifest(family: Family, launcher: string, origins: readonly string[]): Record<string, unknown> {
diff --git a/src/daemon/server.test.ts b/src/daemon/server.test.ts
index 448d253..5eb6828 100644
--- a/src/daemon/server.test.ts
+++ b/src/daemon/server.test.ts
@@ -305,11 +305,11 @@ describe('the status tool', () => {
]);
});
- test('an extension older than the daemon, and a tab it cannot read, are both explained', async () => {
+ test('an extension and a Bridge of different versions, and a tab it cannot read, are both explained', async () => {
const status = await statusOf({ 'page.getPageInfo': failure('TAB_UNREACHABLE', 'chrome:// page') }, { manifestInSync: false });
- expect({ activeTab: status.activeTab, stale: String(status.hint).includes('older build'), unreadable: String(status.hint).includes('Cannot read the active tab (TAB_UNREACHABLE)') }).toEqual({
+ expect({ activeTab: status.activeTab, drifted: String(status.hint).includes('different versions'), unreadable: String(status.hint).includes('Cannot read the active tab (TAB_UNREACHABLE)') }).toEqual({
activeTab: null,
- stale: true,
+ drifted: true,
unreadable: true,
});
});
diff --git a/src/daemon/test/fake-browser.ts b/src/daemon/test/fake-browser.ts
index c19dfc5..b3fdb47 100644
--- a/src/daemon/test/fake-browser.ts
+++ b/src/daemon/test/fake-browser.ts
@@ -22,6 +22,9 @@ export interface Profile {
target?: BrowserTarget;
/** What a drifted build reports instead of the registry's list. */
tools?: ToolDescriptor[];
+ /** The protocol its hello claims and proves; this checkout's own unless a test says otherwise. */
+ protocolVersion?: number;
+ minDaemonProtocol?: number;
}
export type Credential = { kind: 'pair'; code: string } | { kind: 'session'; key: string };
@@ -65,12 +68,15 @@ export class FakeBrowser {
static async connect(port: number, profile: Profile, credential: Credential): Promise<FakeBrowser> {
const socket = new WebSocket(`ws://127.0.0.1:${port}/extension`, { headers: { origin: profile.origin } });
const inbox = frames(socket);
+ const refused = new Promise<string>((resolve) => socket.once('close', (_code, reason) => resolve(String(reason))));
await new Promise((resolve, reject) => socket.once('open', resolve).once('error', reject));
+ const protocolVersion = profile.protocolVersion ?? SOCKET_PROTOCOL_VERSION;
const hello = { extensionVersion: EXTENSION_VERSION, manifestHash: hashManifest(toolsOf(profile)), nonce: newNonce() };
send(socket, {
t: 'hello',
- protocolVersion: SOCKET_PROTOCOL_VERSION,
+ protocolVersion,
+ minDaemonProtocol: profile.minDaemonProtocol,
auth: { kind: credential.kind },
installId: profile.installId,
browser: profile.browser,
@@ -78,9 +84,10 @@ export class FakeBrowser {
});
const challenge = await inbox.next();
- if (challenge?.t !== 'challenge') throw new Error(`expected a challenge, got ${challenge?.t}`);
+ if (!challenge) throw new Error(await refused);
+ if (challenge.t !== 'challenge') throw new Error(`expected a challenge, got ${challenge.t}`);
const transcript: Transcript = {
- protocolVersion: SOCKET_PROTOCOL_VERSION,
+ protocolVersion,
extensionVersion: hello.extensionVersion,
manifestHash: hello.manifestHash,
clientNonce: hello.nonce,
diff --git a/src/daemon/test/protocol-window.test.ts b/src/daemon/test/protocol-window.test.ts
new file mode 100644
index 0000000..38447d8
--- /dev/null
+++ b/src/daemon/test/protocol-window.test.ts
@@ -0,0 +1,78 @@
+import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';
+import { MIN_EXTENSION_PROTOCOL, SOCKET_PROTOCOL_VERSION } from '@/lib/actions/protocol';
+import { CHROME_WEB_STORE } from '@/lib/stores';
+import { clearAuth } from '../auth-store';
+import { startDaemon, type Daemon } from '../daemon';
+import { readLockfile } from '../lockfile';
+import { RemoteBridge } from '../remote-bridge';
+import { FakeBrowser, type Profile } from './fake-browser';
+
+const store: Profile = {
+ origin: `chrome-extension://${CHROME_WEB_STORE.id}`,
+ installId: 'install-store-chrome1',
+ browser: 'Google Chrome',
+};
+
+let daemon: Daemon;
+let opened: { close(): unknown }[] = [];
+
+beforeAll(async () => {
+ daemon = await startDaemon({ version: '0.0.0-test', idleExit: false });
+});
+
+afterAll(async () => {
+ await daemon?.stop();
+});
+
+afterEach(async () => {
+ for (const each of opened) each.close();
+ opened = [];
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ clearAuth();
+});
+
+async function control(): Promise<RemoteBridge> {
+ const bridge = await RemoteBridge.connect(daemon.port, readLockfile()!.token);
+ opened.push(bridge);
+ return bridge;
+}
+
+async function pair(profile: Profile): Promise<FakeBrowser> {
+ const { code } = await (await control()).pair();
+ const browser = await FakeBrowser.connect(daemon.port, profile, { kind: 'pair', code });
+ opened.push(browser);
+ return browser;
+}
+
+describe('the protocol window', () => {
+ test('a store copy a protocol ahead of the Bridge pairs, and comes back on its key', async () => {
+ const ahead = { ...store, protocolVersion: SOCKET_PROTOCOL_VERSION + 1 };
+ const paired = await pair(ahead);
+ paired.close();
+ const back = await FakeBrowser.connect(daemon.port, ahead, { kind: 'session', key: paired.sessionKey });
+ opened.push(back);
+ expect(back.isOpen).toBe(true);
+ });
+
+ test('the oldest extension the Bridge takes still pairs', async () => {
+ expect((await pair({ ...store, protocolVersion: MIN_EXTENSION_PROTOCOL })).isOpen).toBe(true);
+ });
+
+ test('an extension older than that is told the versions do not match', async () => {
+ await expect(pair({ ...store, protocolVersion: MIN_EXTENSION_PROTOCOL - 1 })).rejects.toThrow(
+ /^protocol version mismatch: Browsentic Bridge speaks v\d+ and takes extensions from v\d+ on$/,
+ );
+ });
+
+ test('an extension that needs a newer Bridge is told the Bridge is too old', async () => {
+ await expect(
+ pair({ ...store, protocolVersion: SOCKET_PROTOCOL_VERSION + 2, minDaemonProtocol: SOCKET_PROTOCOL_VERSION + 1 }),
+ ).rejects.toThrow(/^daemon too old: /);
+ });
+
+ test('a paired session says which store its extension came from', async () => {
+ await pair(store);
+ const [session] = await (await control()).sessions();
+ expect([session.source, session.connected]).toEqual(['chrome-web-store', true]);
+ });
+});
diff --git a/src/daemon/tool-host.ts b/src/daemon/tool-host.ts
index 30a948d..f80633c 100644
--- a/src/daemon/tool-host.ts
+++ b/src/daemon/tool-host.ts
@@ -224,7 +224,7 @@ async function status(bridge: Bridge): Promise<ActionResult> {
const hints = [
base.manifestInSync
? ''
- : 'The extension is running an older build than the daemon, so your tool list came from the extension and is stale — capabilities that exist in this repository may be missing entirely. You cannot fix this yourself: tell the user to run `yarn build && yarn daemon:build` and then press Reload on Browsentic at chrome://extensions. Do not improvise around a tool you think should exist.',
+ : 'The extension and Browsentic Bridge are different versions, which is normal while one of them waits on an update. Your tool list came from the extension, which is what runs the tools, so it is the right one. Use the tools you were given and do not improvise around one you think should exist.',
page.ok ? '' : `Cannot read the active tab (${page.error.code}). Use page_navigate to open an http(s) page first.`,
].filter(Boolean);
diff --git a/src/lib/actions/protocol.ts b/src/lib/actions/protocol.ts
index c639c6a..5738033 100644
--- a/src/lib/actions/protocol.ts
+++ b/src/lib/actions/protocol.ts
@@ -14,6 +14,14 @@ export const BRIDGE_CHANNEL = 'browsentic/bridge';
export const SOCKET_PROTOCOL_VERSION = 22;
+/**
+ * The oldest extension the daemon lets in. A store copy updates when its browser decides to, so it
+ * and the daemon are routinely a version apart: a change a peer can do without bumps
+ * SOCKET_PROTOCOL_VERSION and is sent only to a peer that speaks it, and only a change neither side
+ * can do without raises this.
+ */
+export const MIN_EXTENSION_PROTOCOL = 22;
+
export const EXTERNAL_RUN_ID = 'external';
export const DAEMON_PORTS = [8765, 8766, 8767] as const;
@@ -188,6 +196,8 @@ export type SocketFrame =
| {
t: 'hello';
protocolVersion: number;
+ /** The oldest daemon this extension works with. Absent from an extension that predates the window. */
+ minDaemonProtocol?: number;
extensionVersion: string;
manifestHash: string;
auth: SocketAuth;
@@ -204,6 +214,8 @@ export type SocketFrame =
| {
t: 'welcome';
daemonVersion: string;
+ /** What the daemon speaks, so a newer extension sends it nothing past that. Absent before 0.8. */
+ protocolVersion?: number;
manifestHash: string;
manifestInSync: boolean;
/** Proves the daemon holds the same secret, so a port squatter cannot pose as one. */
diff --git a/src/lib/stores.test.ts b/src/lib/stores.test.ts
new file mode 100644
index 0000000..596c5f3
--- /dev/null
+++ b/src/lib/stores.test.ts
@@ -0,0 +1,15 @@
+import { describe, expect, test } from 'vitest';
+import { sourceOf } from './stores';
+
+describe('sourceOf', () => {
+ test('names each store copy by its ID, a Firefox copy by its scheme, and any other Chromium copy unpacked', () => {
+ expect(
+ [
+ 'chrome-extension://npmocgldfflonjjmdadmdefpnfagnjmp',
+ 'chrome-extension://cbkjhkgjcpihokphhdkbahilpcjojpdc/',
+ 'moz-extension://0f1e2d3c-4b5a-6978-8796-a5b4c3d2e1f0',
+ 'chrome-extension://pplbfkdfiimmogofmehpibbmldcefgpc',
+ ].map(sourceOf),
+ ).toEqual(['chrome-web-store', 'edge-add-ons', 'firefox', 'unpacked']);
+ });
+});
diff --git a/src/lib/stores.ts b/src/lib/stores.ts
new file mode 100644
index 0000000..378515c
--- /dev/null
+++ b/src/lib/stores.ts
@@ -0,0 +1,39 @@
+/** Where each browser gets the extension, and how the daemon tells which copy a browser runs. */
+
+export const CHROME_WEB_STORE = {
+ id: 'npmocgldfflonjjmdadmdefpnfagnjmp',
+ url: 'https://chromewebstore.google.com/detail/browsentic/npmocgldfflonjjmdadmdefpnfagnjmp',
+} as const;
+
+/**
+ * Microsoft gives the listing its address only once it is published. Until then Edge is sent to the
+ * Chrome Web Store, which it installs from once "Allow extensions from other stores" is on, and the
+ * copy it installs carries the Chrome Web Store's ID.
+ */
+export const EDGE_ADD_ONS: { id: string; url: string | null } = {
+ id: 'cbkjhkgjcpihokphhdkbahilpcjojpdc',
+ url: null,
+};
+
+/** Signed by addons.mozilla.org for every release and installed from the GitHub release. */
+export const FIREFOX_ADDON_ID = '[email protected]';
+
+export const STORE_EXTENSION_IDS = [CHROME_WEB_STORE.id, EDGE_ADD_ONS.id];
+
+export type Source = 'chrome-web-store' | 'edge-add-ons' | 'firefox' | 'unpacked';
+
+export const SOURCE_LABEL: Record<Source, string> = {
+ 'chrome-web-store': 'Chrome Web Store',
+ 'edge-add-ons': 'Edge Add-ons',
+ firefox: 'Firefox add-on',
+ unpacked: 'unpacked',
+};
+
+/** A Chromium extension the stores did not sign is one somebody loaded from a folder. */
+export function sourceOf(origin: string): Source {
+ if (origin.startsWith('moz-extension://')) return 'firefox';
+ const id = origin.replace(/^chrome-extension:\/\//, '').replace(/\/$/, '');
+ if (id === CHROME_WEB_STORE.id) return 'chrome-web-store';
+ if (id === EDGE_ADD_ONS.id) return 'edge-add-ons';
+ return 'unpacked';
+}