• Closes the authentication window if it exists

    Safely closes the authentication window and cleans up resources, handling any errors that might occur during window closure. This function is idempotent and can be called multiple times without error, even if the window is already closed.

    Returns void

    // Close the authentication window when tokens are received
    closeAuthWindow();
    export function closeAuthWindow(): void {
    if (authWindow) {
    try {
    authWindow.close();
    saveLog("OAuth authentication window closed", "DEBUG");
    } catch (error) {
    saveLog(`Error closing OAuth window: ${error}`, "WARNING");
    } finally {
    authWindow = null;
    }
    }
    }