Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Report encrypted vault counts for storage stats

Emre Sokulluf5ed3b991732
diff --git a/docs/privacy-and-data-flow.md b/docs/privacy-and-data-flow.md
index e329db994..66d882e93 100644
--- a/docs/privacy-and-data-flow.md
+++ b/docs/privacy-and-data-flow.md
@@ -359,9 +359,14 @@ encrypts it in the browser with AES-256-GCM. Its key is derived from the sync
password with PBKDF2-HMAC-SHA-256 (600,000 iterations). The password and derived
key are retained in memory only for the browser session.
-WebBrain Compass receives only ciphertext and cryptographic/version metadata. It
-cannot decrypt the vault or recover a forgotten password. Authentication uses a
-separate email-approved, scoped token; the billing device GUID alone cannot read
+WebBrain Compass receives ciphertext, cryptographic/version metadata, and three
+counts supplied by the extension with each vault upload: configured portable
+providers, saved memory records, and whether the freeform profile text is
+nonempty (0 or 1). These counts support the authenticated admin stats page;
+provider names, memory text, profile text, and API keys remain inside the
+encrypted vault. Older vaults have unknown counts until a newer extension syncs.
+WebBrain Compass cannot decrypt the vault or recover a forgotten password.
+Authentication uses a separate email-approved, scoped token; the billing device GUID alone cannot read
a vault. Sync is off by default, local writes continue while locked or offline,
and chat history, traces, tasks, permissions, and extraction queues are excluded.
diff --git a/package.json b/package.json
index 062324ebf..59bcbd99f 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"private": true,
"type": "module",
"scripts": {
- "test": "npm run test:markdown && npm run test:systemone && npm run test:systemone:fast && node --test test/browser-dialogs.mjs && npm run test:firefox-bidi && npm run test:runtime-lifecycle && npm run test:provider-limits && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && npm run test:pdf-read && npm run test:pdf-selection && npm run test:social-contract && npm run test:safesocial && npm run test:build-unpacked && npm run test:attachment-drop && node test/run.js && node test/selection-scope-restoration.mjs && node scripts/benchmark-offline-relevance.mjs && npm run test:security",
+ "test": "npm run test:markdown && npm run test:systemone && npm run test:systemone:fast && node --test test/browser-dialogs.mjs && npm run test:firefox-bidi && npm run test:runtime-lifecycle && npm run test:provider-limits && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && npm run test:pdf-read && npm run test:pdf-selection && npm run test:social-contract && npm run test:safesocial && npm run test:build-unpacked && npm run test:attachment-drop && node --test test/profile-sync-stats.mjs && node test/run.js && node test/selection-scope-restoration.mjs && node scripts/benchmark-offline-relevance.mjs && npm run test:security",
"test:provider-limits": "node test/provider-model-limits.mjs",
"test:markdown": "node --test test/markdown-render.mjs",
"test:accessibility-tree-benchmark": "node --test test/llm/lib/accessibility-tree-formats.test.mjs && node test/llm/accessibility-tree-benchmark.mjs --no-exact-tokenizer --check",
diff --git a/src/chrome/src/profile-sync.js b/src/chrome/src/profile-sync.js
index 70b681173..8b36e1852 100644
--- a/src/chrome/src/profile-sync.js
+++ b/src/chrome/src/profile-sync.js
@@ -68,6 +68,16 @@ function portableVault(vault, fallbackActiveProvider = '') {
};
}
+export function profileVaultSummary(vault) {
+ const providers = portableProviders(vault?.providers || {});
+ return {
+ version: 1,
+ provider_count: Object.values(providers).filter(config => config?.configured === true).length,
+ memory_count: normalizeUserMemoryStore(vault?.memory).records.length,
+ profile_count: String(vault?.profile?.text || '').trim() ? 1 : 0,
+ };
+}
+
export async function deriveProfileSyncKey(password, salt, iterations = ITERATIONS) {
const material = await crypto.subtle.importKey('raw', enc.encode(password), 'PBKDF2', false, ['deriveKey']);
return crypto.subtle.deriveKey({ name: 'PBKDF2', hash: 'SHA-256', salt, iterations }, material,
@@ -325,7 +335,7 @@ export class ProfileSyncManager {
const encrypted = await encryptProfileVault(local, password, runEnvelope ? { vaultId: runEnvelope.vaultId, salt: unb64(runEnvelope.kdf.salt), iterations: runEnvelope.kdf.iterations, key: runKey } : {});
if (generation !== this.sessionGeneration || this.password !== password) throw new Error('Cloud Sync was locked');
this.key = encrypted.key; this.envelope = encrypted.envelope;
- try { const put = await this.request('/vault', { method: 'PUT', headers: this.revision != null ? { 'If-Match': String(this.revision) } : {}, body: JSON.stringify({ envelope: encrypted.envelope }) }); this.revision = put.body.revision; }
+ try { const put = await this.request('/vault', { method: 'PUT', headers: this.revision != null ? { 'If-Match': String(this.revision) } : {}, body: JSON.stringify({ envelope: encrypted.envelope, summary: profileVaultSummary(local) }) }); this.revision = put.body.revision; }
catch (e) { if (e.status === 409) { this.revision = null; return this.runSync(); } throw e; }
this.status = 'current'; return this.state();
}
@@ -340,7 +350,7 @@ export class ProfileSyncManager {
const put = await this.request('/vault', {
method: 'PUT',
headers: { 'If-Match': String(this.revision) },
- body: JSON.stringify({ envelope: encrypted.envelope }),
+ body: JSON.stringify({ envelope: encrypted.envelope, summary: profileVaultSummary(local) }),
});
if (generation !== this.sessionGeneration) return this.state();
this.password = nextPassword;
@@ -366,7 +376,7 @@ export class ProfileSyncManager {
if (this.revision == null) { try { const current = await this.request('/vault'); this.revision = current.body.revision; } catch (error) { if (error.status !== 404) throw error; } }
const encrypted = await encryptProfileVault(local, password);
try {
- const put = await this.request('/vault', { method: 'PUT', headers: this.revision != null ? { 'If-Match': String(this.revision) } : {}, body: JSON.stringify({ envelope: encrypted.envelope }) });
+ const put = await this.request('/vault', { method: 'PUT', headers: this.revision != null ? { 'If-Match': String(this.revision) } : {}, body: JSON.stringify({ envelope: encrypted.envelope, summary: profileVaultSummary(local) }) });
if (generation !== this.sessionGeneration) return this.state();
this.password = password; this.key = encrypted.key; this.envelope = encrypted.envelope; this.revision = put.body.revision; this.status = 'current'; return this.state();
} catch (error) { if (error.status !== 409 || attempt === 1) throw error; this.revision = null; }
diff --git a/src/firefox/src/profile-sync.js b/src/firefox/src/profile-sync.js
index 35a588b99..bbe43493d 100644
--- a/src/firefox/src/profile-sync.js
+++ b/src/firefox/src/profile-sync.js
@@ -68,6 +68,16 @@ function portableVault(vault, fallbackActiveProvider = '') {
};
}
+export function profileVaultSummary(vault) {
+ const providers = portableProviders(vault?.providers || {});
+ return {
+ version: 1,
+ provider_count: Object.values(providers).filter(config => config?.configured === true).length,
+ memory_count: normalizeUserMemoryStore(vault?.memory).records.length,
+ profile_count: String(vault?.profile?.text || '').trim() ? 1 : 0,
+ };
+}
+
export async function deriveProfileSyncKey(password, salt, iterations = ITERATIONS) {
const material = await crypto.subtle.importKey('raw', enc.encode(password), 'PBKDF2', false, ['deriveKey']);
return crypto.subtle.deriveKey({ name: 'PBKDF2', hash: 'SHA-256', salt, iterations }, material,
@@ -330,7 +340,7 @@ export class ProfileSyncManager {
const encrypted = await encryptProfileVault(local, password, runEnvelope ? { vaultId: runEnvelope.vaultId, salt: unb64(runEnvelope.kdf.salt), iterations: runEnvelope.kdf.iterations, key: runKey } : {});
if (generation !== this.sessionGeneration || this.password !== password) throw new Error('Cloud Sync was locked');
this.key = encrypted.key; this.envelope = encrypted.envelope;
- try { const put = await this.request('/vault', { method: 'PUT', headers: this.revision != null ? { 'If-Match': String(this.revision) } : {}, body: JSON.stringify({ envelope: encrypted.envelope }) }); this.revision = put.body.revision; }
+ try { const put = await this.request('/vault', { method: 'PUT', headers: this.revision != null ? { 'If-Match': String(this.revision) } : {}, body: JSON.stringify({ envelope: encrypted.envelope, summary: profileVaultSummary(local) }) }); this.revision = put.body.revision; }
catch (e) { if (e.status === 409) { this.revision = null; return this.runSync(); } throw e; }
this.status = 'current'; return this.state();
}
@@ -345,7 +355,7 @@ export class ProfileSyncManager {
const put = await this.request('/vault', {
method: 'PUT',
headers: { 'If-Match': String(this.revision) },
- body: JSON.stringify({ envelope: encrypted.envelope }),
+ body: JSON.stringify({ envelope: encrypted.envelope, summary: profileVaultSummary(local) }),
});
if (generation !== this.sessionGeneration) return this.state();
this.password = nextPassword;
@@ -371,7 +381,7 @@ export class ProfileSyncManager {
if (this.revision == null) { try { const current = await this.request('/vault'); this.revision = current.body.revision; } catch (error) { if (error.status !== 404) throw error; } }
const encrypted = await encryptProfileVault(local, password);
try {
- const put = await this.request('/vault', { method: 'PUT', headers: this.revision != null ? { 'If-Match': String(this.revision) } : {}, body: JSON.stringify({ envelope: encrypted.envelope }) });
+ const put = await this.request('/vault', { method: 'PUT', headers: this.revision != null ? { 'If-Match': String(this.revision) } : {}, body: JSON.stringify({ envelope: encrypted.envelope, summary: profileVaultSummary(local) }) });
if (generation !== this.sessionGeneration) return this.state();
this.password = password; this.key = encrypted.key; this.envelope = encrypted.envelope; this.revision = put.body.revision; this.status = 'current'; return this.state();
} catch (error) { if (error.status !== 409 || attempt === 1) throw error; this.revision = null; }
diff --git a/test/profile-sync-stats.mjs b/test/profile-sync-stats.mjs
new file mode 100644
index 000000000..65a3f0fdb
--- /dev/null
+++ b/test/profile-sync-stats.mjs
@@ -0,0 +1,54 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+
+for (const browser of ['chrome', 'firefox']) {
+ test(`${browser} sync reports counts from the portable encrypted vault`, async () => {
+ const { ProfileSyncManager, profileVaultSummary } = await import(`../src/${browser}/src/profile-sync.js`);
+ const values = {
+ providers: {
+ openai: { configured: true, apiKey: 'private-key' },
+ anthropic: { configured: false },
+ webgpu: { type: 'webgpu', configured: true },
+ },
+ activeProvider: 'openai',
+ profileEnabled: true,
+ profileText: 'Saved profile text',
+ wb_user_memory_v1: { records: [
+ { id: 'first', text: 'Prefers concise answers' },
+ { id: 'second', text: 'Works in Istanbul' },
+ ] },
+ profileSyncEnabled: true,
+ profileSyncToken: 'scoped-token',
+ };
+ const manager = new ProfileSyncManager({ get: async () => values, set: async () => {} });
+ const local = await manager.localVault();
+ assert.deepEqual(profileVaultSummary(local), {
+ version: 1, provider_count: 1, memory_count: 2, profile_count: 1,
+ });
+ assert.deepEqual(profileVaultSummary({
+ ...local,
+ memory: { records: [
+ { id: 'first', text: 'Prefers concise answers' },
+ { id: 'duplicate', text: 'Prefers concise answers' },
+ ] },
+ profile: { text: ' ' },
+ }), { version: 1, provider_count: 1, memory_count: 1, profile_count: 0 });
+ let uploaded;
+ manager.request = async (path, options) => {
+ if (options?.method === 'PUT') {
+ uploaded = JSON.parse(options.body);
+ return { body: { revision: 1 } };
+ }
+ const error = new Error('No vault');
+ error.status = 404;
+ throw error;
+ };
+ manager.password = 'test password';
+ await manager.runSync({ create: true });
+ assert.deepEqual(uploaded.summary, {
+ version: 1, provider_count: 1, memory_count: 2, profile_count: 1,
+ });
+ assert.equal(JSON.stringify(uploaded.envelope).includes('private-key'), false);
+ assert.equal(JSON.stringify(uploaded.summary).includes('Saved profile text'), false);
+ });
+}