feat(browser): add Helium as a Chromium cookie-import source (#6768)

Register Helium (imput, bundle id net.imput.helium) so it is auto-detected
and importable from the picker on macOS like Chrome/Edge/Arc/Brave/Comet,
instead of only via the "From File..." JSON path. Reuses the existing macOS
Chromium decryption path unchanged.

Helium quirks (verified on a real install): its Keychain entry is service
"Helium Storage Key" / account "Helium" (not the usual "<Browser> Safe
Storage"), it stores data under its bundle id, and it keeps cookies at the
legacy <Profile>/Cookies path. Mac-only for now; Windows/Linux data dirs are
unverified so winRoot/linuxRoot are omitted and the source defaults off there.

Claude-Session: https://claude.ai/code/session_01SZzX6ktZaaCUg5PWnzniuC
This commit is contained in:
Nicholas Zolton
2026-06-29 13:21:20 -07:00
committed by GitHub
parent c80dc43ed2
commit 4febefd454
8 changed files with 262 additions and 5 deletions
@@ -0,0 +1,219 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type * as childProcessModule from 'node:child_process'
import type * as fsModule from 'node:fs'
const { sessionFromPartitionMock, dialogShowOpenDialogMock } = vi.hoisted(() => ({
sessionFromPartitionMock: vi.fn(),
dialogShowOpenDialogMock: vi.fn()
}))
vi.mock('electron', () => ({
BrowserWindow: { fromWebContents: vi.fn() },
dialog: { showOpenDialog: dialogShowOpenDialogMock },
session: { fromPartition: sessionFromPartitionMock }
}))
import { BROWSER_FAMILY_LABELS } from '../../shared/constants'
function slashPath(pathValue: string): string {
return pathValue.replaceAll('\\', '/')
}
describe('detectInstalledBrowsers — Helium', () => {
const originalPlatform = process.platform
const originalHome = process.env.HOME
beforeEach(() => {
// Why: browser-cookie-import.ts uses destructured named imports from
// 'node:fs' which are bound at module-load time. resetModules must run
// BEFORE each doMock so the next import() picks up the fresh mock factory.
vi.resetModules()
Object.defineProperty(process, 'platform', { value: 'darwin' })
process.env.HOME = '/Users/test'
})
afterEach(() => {
Object.defineProperty(process, 'platform', { value: originalPlatform })
process.env.HOME = originalHome
vi.restoreAllMocks()
})
it('detects Helium under its bundle-id data dir via the legacy Cookies path', async () => {
vi.doMock('node:fs', async () => {
const actual = await vi.importActual<typeof fsModule>('node:fs')
return {
...actual,
existsSync: (p: string) => {
const normalizedPath = slashPath(p)
// Why: Helium stores cookies at the legacy <Profile>/Cookies path, so the
// newer Network/Cookies probe must miss and the legacy fallback must fire.
if (normalizedPath.includes('net.imput.helium/Default/Network/Cookies')) {
return false
}
if (normalizedPath.endsWith('net.imput.helium/Default/Cookies')) {
return true
}
if (normalizedPath.includes('net.imput.helium/Local State')) {
return true
}
return false
},
readFileSync: (p: string, enc?: string) => {
if (typeof p === 'string' && slashPath(p).includes('net.imput.helium/Local State')) {
return JSON.stringify({ profile: { info_cache: { Default: { name: 'Default' } } } })
}
return actual.readFileSync(p as never, enc as never)
}
}
})
const { detectInstalledBrowsers } = await import('./browser-cookie-import')
const detected = detectInstalledBrowsers()
const helium = detected.find((b) => b.family === 'helium')
expect(helium).toBeDefined()
expect(helium?.label).toBe('Helium')
expect(slashPath(helium?.cookiesPath ?? '')).toContain('net.imput.helium/Default/Cookies')
expect(slashPath(helium?.cookiesPath ?? '')).not.toContain('Network/Cookies')
expect(helium?.keychainService).toBe('Helium Storage Key')
expect(helium?.keychainAccount).toBe('Helium')
})
it('does not list Helium when its data directory is absent', async () => {
vi.doMock('node:fs', async () => {
const actual = await vi.importActual<typeof fsModule>('node:fs')
return {
...actual,
existsSync: () => false
}
})
const { detectInstalledBrowsers } = await import('./browser-cookie-import')
const detected = detectInstalledBrowsers()
expect(detected.find((b) => b.family === 'helium')).toBeUndefined()
})
it('enumerates all Helium profiles from Local State info_cache', async () => {
vi.doMock('node:fs', async () => {
const actual = await vi.importActual<typeof fsModule>('node:fs')
return {
...actual,
existsSync: (p: string) => {
const normalizedPath = slashPath(p)
if (normalizedPath.endsWith('net.imput.helium/Default/Cookies')) {
return true
}
if (normalizedPath.includes('net.imput.helium/Local State')) {
return true
}
return false
},
readFileSync: (p: string, enc?: string) => {
if (typeof p === 'string' && slashPath(p).includes('net.imput.helium/Local State')) {
return JSON.stringify({
profile: {
info_cache: {
Default: { name: 'Personal' },
'Profile 1': { name: 'Work' }
}
}
})
}
return actual.readFileSync(p as never, enc as never)
}
}
})
const { detectInstalledBrowsers } = await import('./browser-cookie-import')
const detected = detectInstalledBrowsers()
const helium = detected.find((b) => b.family === 'helium')
expect(helium).toBeDefined()
const directories = helium!.profiles.map((p) => p.directory).sort()
expect(directories).toEqual(['Default', 'Profile 1'])
})
it('rejects explicit Helium profile selections that escape the browser root', async () => {
vi.doMock('node:fs', async () => {
const actual = await vi.importActual<typeof fsModule>('node:fs')
return {
...actual,
existsSync: (p: string) => slashPath(p).includes('Application Support/Outside/Cookies')
}
})
const { selectBrowserProfile } = await import('./browser-cookie-import')
const selected = selectBrowserProfile(
{
family: 'helium',
label: 'Helium',
cookiesPath: '/Users/test/Library/Application Support/net.imput.helium/Default/Cookies',
keychainService: 'Helium Storage Key',
keychainAccount: 'Helium',
profiles: [{ name: 'Outside', directory: '../Outside' }],
selectedProfile: 'Default'
},
'../Outside'
)
expect(selected).toBeNull()
})
})
describe('getUserAgentForBrowser — Helium', () => {
const originalPlatform = process.platform
beforeEach(() => {
vi.resetModules()
Object.defineProperty(process, 'platform', { value: 'darwin' })
})
afterEach(() => {
Object.defineProperty(process, 'platform', { value: originalPlatform })
vi.restoreAllMocks()
})
it('returns a Chrome-shaped UA string when Helium plist version reads successfully', async () => {
vi.doMock('node:child_process', async () => {
const actual = await vi.importActual<typeof childProcessModule>('node:child_process')
return {
...actual,
execFileSync: (cmd: string, args: readonly string[]) => {
if (cmd === 'defaults' && args[1]?.includes('/Applications/Helium.app/Contents/Info')) {
return '120.0.6099.71\n'
}
return actual.execFileSync(cmd, args as never)
}
}
})
const { getUserAgentForBrowser } = await import('./browser-cookie-import')
const ua = getUserAgentForBrowser('helium')
expect(ua).not.toBeNull()
expect(ua).toContain('Macintosh; Intel Mac OS X 10_15_7')
expect(ua).toContain('AppleWebKit/537.36')
expect(ua).toContain('Chrome/120.0.6099.71')
expect(ua).toContain('Safari/537.36')
})
it('returns null when reading the Helium plist version throws', async () => {
vi.doMock('node:child_process', async () => {
const actual = await vi.importActual<typeof childProcessModule>('node:child_process')
return {
...actual,
execFileSync: () => {
throw new Error('defaults: domain not found')
}
}
})
const { getUserAgentForBrowser } = await import('./browser-cookie-import')
const ua = getUserAgentForBrowser('helium')
expect(ua).toBeNull()
})
})
describe('BROWSER_FAMILY_LABELS — Helium', () => {
it('maps the helium family key to the user-facing label "Helium"', () => {
expect(BROWSER_FAMILY_LABELS.helium).toBe('Helium')
})
})
+10 -1
View File
@@ -347,7 +347,16 @@ describe('detectInstalledBrowsers', () => {
it('each detected browser has a valid family', () => {
const browsers = detectInstalledBrowsers()
const validFamilies = ['chrome', 'edge', 'arc', 'chromium', 'firefox', 'safari', 'comet']
const validFamilies = [
'chrome',
'edge',
'arc',
'chromium',
'firefox',
'safari',
'comet',
'helium'
]
for (const browser of browsers) {
expect(validFamilies).toContain(browser.family)
}
+16
View File
@@ -153,6 +153,16 @@ const CHROMIUM_BROWSERS: ChromiumBrowserDef[] = [
macRoot: 'Comet',
winRoot: 'Comet/User Data'
// linuxRoot intentionally omitted — Comet does not ship a Linux build as of 2026-05-15
},
{
family: 'helium',
// Why: Helium deviates from the '<Browser> Safe Storage'/'<Browser>' convention —
// its Keychain entry is literally service 'Helium Storage Key', account 'Helium'.
label: 'Helium',
keychainService: 'Helium Storage Key',
keychainAccount: 'Helium',
macRoot: 'net.imput.helium'
// winRoot/linuxRoot intentionally omitted — only the macOS install is verified
}
]
@@ -767,6 +777,12 @@ export function getUserAgentForBrowser(
const v = readBrowserVersion('/Applications/Comet.app')
return v ? `Mozilla/5.0 (${platform}) ${chromeBase} Chrome/${v} Safari/537.36` : null
}
case 'helium': {
// Why: Helium is Chromium-based and ships a Chrome-shaped version in its plist.
// Use the same UA shape as Chrome itself so Google-bound auth cookies survive import.
const v = readBrowserVersion('/Applications/Helium.app')
return v ? `Mozilla/5.0 (${platform}) ${chromeBase} Chrome/${v} Safari/537.36` : null
}
case 'firefox':
case 'safari':
case 'manual':
@@ -7,6 +7,7 @@ const SUPPORTED_LABELS = [
'Arc',
'Brave',
'Comet',
'Helium',
'Firefox',
'Safari'
]
@@ -46,7 +47,7 @@ describe('formatBrowserImportSummary', () => {
detectedBrowsersLoaded: false,
supportedImportLabels: SUPPORTED_LABELS
})
).toBe('Import from: Google Chrome, Microsoft Edge, Arc, Brave, +3 more.')
).toBe('Import from: Google Chrome, Microsoft Edge, Arc, Brave, +4 more.')
})
it('falls back to supported import sources when detection finds nothing', () => {
@@ -56,6 +57,6 @@ describe('formatBrowserImportSummary', () => {
detectedBrowsersLoaded: true,
supportedImportLabels: SUPPORTED_LABELS
})
).toBe('Import from: Google Chrome, Microsoft Edge, Arc, Brave, +3 more.')
).toBe('Import from: Google Chrome, Microsoft Edge, Arc, Brave, +4 more.')
})
})
@@ -9,6 +9,7 @@ describe('getBrowserCookieImportSourceLabels', () => {
'Arc',
'Brave',
'Comet',
'Helium',
'Firefox',
'Safari'
])
+2 -1
View File
@@ -5,7 +5,8 @@ const CHROMIUM_COOKIE_IMPORT_SOURCES = [
{ label: 'Microsoft Edge', mac: true, win: true, linux: true },
{ label: 'Arc', mac: true, win: false, linux: false },
{ label: 'Brave', mac: true, win: true, linux: true },
{ label: 'Comet', mac: true, win: true, linux: false }
{ label: 'Comet', mac: true, win: true, linux: false },
{ label: 'Helium', mac: true, win: false, linux: false }
] as const
export function getBrowserCookieImportSourceLabels(
+1
View File
@@ -73,6 +73,7 @@ export const BROWSER_FAMILY_LABELS: Record<string, string> = {
chrome: 'Google Chrome',
chromium: 'Chromium',
comet: 'Comet',
helium: 'Helium',
arc: 'Arc',
edge: 'Microsoft Edge',
brave: 'Brave',
+10 -1
View File
@@ -938,7 +938,16 @@ export type BrowserTab = BrowserWorkspace
export type BrowserSessionProfileScope = 'default' | 'isolated' | 'imported'
export type BrowserSessionProfileSource = {
browserFamily: 'chrome' | 'chromium' | 'arc' | 'edge' | 'firefox' | 'safari' | 'comet' | 'manual'
browserFamily:
| 'chrome'
| 'chromium'
| 'arc'
| 'edge'
| 'firefox'
| 'safari'
| 'comet'
| 'helium'
| 'manual'
profileName?: string
importedAt: number
}