mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 10:43:47 +00:00
Cursor 3.27 can store its app session as cursor-safe-storage:v1 ciphertext (Chromium v10, key in the "Cursor Safe Storage" keychain item), behind Cursor's own cursor.storage.authTokenEncryptionAtRest flag. CodeBurn read it as an expired login. The CLI and the menu bar now unlock it with that item and run the usual JWT checks; the newline `security -w` appends is trimmed before the KDF. Keychain consent is user-initiated, as for Claude: the first read happens on `codeburn import cursor --sync`, `codeburn quota`, or Retry/Reconnect on the menu bar's Cursor quota. Background syncs and dock refreshes read only after one such read succeeded, reuse the opened token per blob, and the first refused read switches that off again. Status never reads the keychain. No service-only keychain lookup, since after a Deny it asks again. Windows and Linux say CodeBurn cannot unlock the session there yet; the desktop app, VS Code and the Windows tray show the new `locked` line in all locales. Docs describe the prompt and what Always Allow grants. Closes #1801
33 lines
2.6 KiB
TypeScript
33 lines
2.6 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
import { cursorSyncLine } from './CursorSyncLine'
|
|
|
|
const NOW = Date.parse('2026-10-05T12:00:00Z')
|
|
const ago = (minutes: number) => new Date(NOW - minutes * 60_000).toISOString()
|
|
|
|
describe('cursorSyncLine', () => {
|
|
it('words each state, hiding the line when sync is off', () => {
|
|
expect(cursorSyncLine({ enabled: true, state: 'ok', lastSuccessAt: ago(0.5) }, NOW)).toEqual({ text: 'Synced from cursor.com just now', warn: false })
|
|
expect(cursorSyncLine({ enabled: true, state: 'ok', lastSuccessAt: ago(12) }, NOW)).toEqual({ text: 'Synced from cursor.com 12 minutes ago', warn: false })
|
|
expect(cursorSyncLine({ enabled: true, state: 'ok', lastSuccessAt: ago(180) }, NOW)?.text).toBe('Synced from cursor.com 3 hours ago')
|
|
expect(cursorSyncLine({ enabled: true, state: 'syncing-never', lastSuccessAt: null }, NOW)).toEqual({ text: 'Not synced from cursor.com yet', warn: false })
|
|
expect(cursorSyncLine({ enabled: false, state: 'off', lastSuccessAt: ago(5) }, NOW)).toBeNull()
|
|
})
|
|
|
|
it('maps error codes to fixed copy, never the CLI text', () => {
|
|
const error = 'raw text from somewhere'
|
|
expect(cursorSyncLine({ enabled: true, state: 'no-login', lastSuccessAt: null, errorCode: 'login', error }, NOW)).toEqual({ text: 'Cursor login expired, open Cursor to sign in again', warn: true })
|
|
expect(cursorSyncLine({ enabled: true, state: 'error', lastSuccessAt: ago(90), errorCode: 'network', error }, NOW)).toEqual({ text: "Couldn't reach cursor.com, will retry", warn: true })
|
|
expect(cursorSyncLine({ enabled: true, state: 'error', lastSuccessAt: null, errorCode: 'export', error }, NOW)?.text).toBe("Couldn't read the usage export from cursor.com, will retry")
|
|
expect(cursorSyncLine({ enabled: true, state: 'error', lastSuccessAt: null, errorCode: 'future' as 'export', error }, NOW)?.text).toBe("Couldn't read the usage export from cursor.com, will retry")
|
|
})
|
|
|
|
it('asks for the keychain prompt only on macOS', () => {
|
|
const locked = { enabled: true, state: 'error', lastSuccessAt: null, errorCode: 'locked', error: 'raw' } as const
|
|
vi.stubGlobal('window', { codeburn: { platform: 'win32' } })
|
|
expect(cursorSyncLine(locked, NOW)).toEqual({ text: "Cursor encrypted its app session, CodeBurn can't unlock it on this system yet", warn: true })
|
|
vi.stubGlobal('window', { codeburn: { platform: 'darwin' } })
|
|
expect(cursorSyncLine(locked, NOW)?.text).toBe('Cursor encrypted its app session, run codeburn import cursor --sync in Terminal and allow the Cursor Safe Storage keychain prompt')
|
|
vi.unstubAllGlobals()
|
|
})
|
|
})
|