import { clearAuthToken, request, setAuthToken } from "./client"; export interface LoginResponse { token: string; expiresAt: string; } export interface AuthStatus { enabled: boolean; } export async function login(username: string, password: string): Promise { const result = await request("/auth/login", { method: "POST", body: { username, password }, skipAuth: true }); setAuthToken(result.token); return result; } export function signOut() { clearAuthToken(); } export function setToken(token: string | null) { if (token) { setAuthToken(token); } else { clearAuthToken(); } } export async function fetchAuthStatus(): Promise { return request("/auth/status", { method: "GET", skipAuth: true }); }