import axios from 'axios' import { getRuntimeConfig } from './runtime-config' import type { AuthSession } from './auth-storage' export type LoginPayload = { email: string; password: string } type LoginResponse = { accessToken: string refreshToken: string tokenType: string user: { id: string; email: string } } type RefreshResponse = { accessToken: string refreshToken: string tokenType: string } function centerClient() { const cfg = getRuntimeConfig() return axios.create({ baseURL: cfg.centerApiBase, timeout: 10000, }) } export async function loginCenter(payload: LoginPayload): Promise { const res = await centerClient().post('/auth/login', payload) return res.data } export async function refreshCenter(refreshToken: string): Promise { const res = await centerClient().post('/auth/refresh', { refreshToken }) return res.data } export async function logoutCenter(refreshToken: string): Promise { await centerClient().post('/auth/logout', { refreshToken }) }