import { API_BASE_URL } from "../core/config"; // import { showLogin } from "../navigation"; import type { Headers, User, WebSocketMessage } from "../core/types"; import { clearAlerts } from "./auth"; import { request } from "../websocket"; /** * Generates authentication headers for API requests * @param {boolean} json - Whether to include JSON content type header * @returns {Headers} Headers object with authentication and content type */ export function getAuthHeaders(token: string | null, json: boolean = true): Headers { const headers: Headers = {}; if (json) { headers["Content-Type"] = "application/json"; } if (token) { headers['Authorization'] = `Bearer ${token}`; } return headers; } /** * Checks authentication status on page load */ export async function checkAuthStatus(): Promise { // For JWT, we don't have a persistent token on page load // So we'll just show the login form // showLogin(); } /** * Logs out the current user and clears session data */ // export async function logout(): Promise { // try { // await fetch(`${API_BASE_URL}/logout`, { // method: 'GET', // headers: getAuthHeaders() // }); // } catch (error) { // console.error('Logout error:', error); // } // currentUser = null; // authToken = null; // // showLogin(); // clearAlerts(); // }