import client from "./client"; import type { User } from "../types/models"; interface TokenResponse { access_token: string; token_type: string; } /** Authenticate and return the access token. */ export async function login( username: string, password: string, ): Promise { const params = new URLSearchParams(); params.append("username", username); params.append("password", password); const { data } = await client.post("/auth/login", params, { headers: { "Content-Type": "application/x-www-form-urlencoded" }, }); return data.access_token; } /** Fetch the currently authenticated user profile. */ export async function getMe(): Promise { const { data } = await client.get("/auth/me"); return data; }