export async function fetchAuthStatus () { const response = await fetch("/auth/status", { cache: "no-store" }); if (!response.ok) { return { authenticated: false }; } return response.json(); } export function loginUrl (returnTo = location.pathname + location.search) { return `/auth/login?return_to=${encodeURIComponent(returnTo)}`; } export function logoutUrl (returnTo = "/") { return `/auth/logout?return_to=${encodeURIComponent(returnTo)}`; } export function formatAccountLabel (status) { if (!status?.authenticated) { return "Signed out"; } if (status.username) { return status.username; } return status.authSubject ?? "Signed in"; }