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:
william
2026-10-31 21:41:35 +01:00
co-authored by Claude Sonnet 5
parent ef4cd41ad4
commit 00619add9f
11 changed files with 1820 additions and 16 deletions
+14 -1
View File
@@ -2,6 +2,11 @@ import { contextBridge, ipcRenderer } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
import type { VoiceTurnResult } from '../shared/voice'
import type { AuthStatus, LoginResult } from '../shared/auth'
import type {
ObjectiveMessageResponse,
SessionObjectiveResponse,
SessionResponse
} from '../shared/session'
const api = {
setIgnoreMouseEvents: (ignore: boolean, options?: { forward: boolean }): void => {
@@ -40,7 +45,15 @@ const api = {
},
login: (email: string, password: string): Promise<LoginResult> =>
ipcRenderer.invoke('auth-login', email, password),
getAuthStatus: (): Promise<AuthStatus> => ipcRenderer.invoke('get-auth-status')
getAuthStatus: (): Promise<AuthStatus> => ipcRenderer.invoke('get-auth-status'),
sessions: {
create: (): Promise<SessionResponse> => ipcRenderer.invoke('sessions:create'),
get: (id: number): Promise<SessionResponse> => ipcRenderer.invoke('sessions:get', id),
sendObjectiveMessage: (id: number, message: string): Promise<ObjectiveMessageResponse> =>
ipcRenderer.invoke('sessions:send-objective-message', id, message),
confirmObjective: (id: number): Promise<SessionObjectiveResponse> =>
ipcRenderer.invoke('sessions:confirm-objective', id)
}
}
// contextIsolation est toujours actif (regle de securite absolue, jamais desactivee) : le seul