mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-08-17 19:47:08 +08:00
feat: 为本地 HTTP API 增加 Token 鉴权与安全加固
- 使用 Electron safeStorage 加密存储并自动初始化 API Token - 为 health 以外的接口增加 Bearer Token 鉴权 - 限制 CORS 仅允许可信本地 Origin - 增加鉴权、Token rotation、safeStorage 和手动验收测试
This commit is contained in:
@@ -105,6 +105,22 @@ describe('preload IPC contract', () => {
|
||||
expect(api).not.toHaveProperty('send')
|
||||
})
|
||||
|
||||
it('exposes only the intentional API token IPC operations', async () => {
|
||||
const api = await loadApi()
|
||||
invoke.mockResolvedValue({ available: true, hasToken: true, maskedToken: '••••' })
|
||||
|
||||
await api.apiTokenStatus()
|
||||
expect(invoke).toHaveBeenLastCalledWith('api:tokenStatus')
|
||||
await api.revealApiToken()
|
||||
expect(invoke).toHaveBeenLastCalledWith('api:revealToken')
|
||||
await api.copyApiToken()
|
||||
expect(invoke).toHaveBeenLastCalledWith('api:copyToken')
|
||||
await api.rotateApiToken()
|
||||
expect(invoke).toHaveBeenLastCalledWith('api:rotateToken')
|
||||
await api.copyLocalApiCurl({ endpointId: 'contact' })
|
||||
expect(invoke).toHaveBeenLastCalledWith('api:copyCurl', { endpointId: 'contact' })
|
||||
})
|
||||
|
||||
it('unsubscribes the same listener registered for native database changes', async () => {
|
||||
const api = await loadApi()
|
||||
const callback = vi.fn()
|
||||
|
||||
Reference in New Issue
Block a user