feat(sessions): keep JWT in memory and wire IPC to the sessions API
Max Avatar can now call Max API's /sessions endpoints: session.ts keeps the access token in memory after login (never persisted, cleared on logout, same lifecycle as the existing email/keys state), a new sessionsClient.ts wraps the 4 endpoints with the Bearer header, and index.ts exposes them as sessions:create/get/send-objective-message/ confirm-objective IPC handlers (input-validated, requireLoggedIn() gated) surfaced to the renderer as window.api.sessions.*. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
ef4cd41ad4
commit
00619add9f
@@ -2,9 +2,11 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
|
||||
|
||||
const setSessionValues = vi.fn()
|
||||
const setCurrentUserEmail = vi.fn()
|
||||
const setAccessToken = vi.fn()
|
||||
vi.mock('../../src/main/auth/session', () => ({
|
||||
setSessionValues,
|
||||
setCurrentUserEmail
|
||||
setCurrentUserEmail,
|
||||
setAccessToken
|
||||
}))
|
||||
|
||||
const { loginAndLoadKeys } = await import('../../src/main/auth/authClient')
|
||||
@@ -56,6 +58,7 @@ describe('authClient.loginAndLoadKeys()', () => {
|
||||
])
|
||||
)
|
||||
expect(setCurrentUserEmail).toHaveBeenCalledWith('william@example.com')
|
||||
expect(setAccessToken).toHaveBeenCalledWith('jwt-token')
|
||||
|
||||
const calls = (global.fetch as unknown as { mock: { calls: [string, RequestInit][] } }).mock
|
||||
.calls
|
||||
|
||||
Reference in New Issue
Block a user