实现客户端登录七天滑动续期

需求:解决短效访问令牌到期后客户端一小时掉登录的问题。

实现:由 Electron Main 加密管理并轮换刷新凭据,按真实用户活动续期,七天闲置后清理会话,并补齐并发、迁移和终态回归测试。
This commit is contained in:
2026-08-07 16:11:10 +08:00
parent 7b23cce67a
commit 86ece3a430
20 changed files with 2941 additions and 326 deletions

View File

@@ -25,6 +25,12 @@ vi.mock('electron', () => ({
ipcMain: { on: vi.fn(), handle: vi.fn(), removeHandler: vi.fn() },
dialog: { showOpenDialog: vi.fn(), showMessageBox: vi.fn() },
shell: { openExternal: vi.fn() },
safeStorage: {
isEncryptionAvailable: vi.fn().mockReturnValue(true),
getSelectedStorageBackend: vi.fn().mockReturnValue('gnome_libsecret'),
encryptString: vi.fn((value: string) => Buffer.from(`encrypted:${value}`, 'utf8')),
decryptString: vi.fn((value: Buffer) => value.toString('utf8').replace(/^encrypted:/, '')),
},
session: { defaultSession: { webRequest: { onBeforeSendHeaders: vi.fn() } } },
utilityProcess: {},
}));