using Microsoft.JSInterop; namespace Heimdall.Web.Services; /// Shared helper for auth-related JS interop calls. internal static class AuthHelper { /// Creates the middleware-level auth cookie via JS interop. /// True if the sign-in HTTP call succeeded (2xx). public static async Task SignInAsync(IJSRuntime jsRuntime, object user) { try { var ok = await jsRuntime.InvokeAsync("heimdallAuth.signIn", user); if (!ok) Console.Error.WriteLine("[AuthHelper] SignInAsync: /_auth/signin returned non-2xx status"); return ok; } catch (Exception ex) { Console.Error.WriteLine($"[AuthHelper] SignInAsync JS interop failed: {ex.Message}"); return false; } } /// Creates a sign-in payload object with the JWT access token. public static object CreateSignInPayload(string accessToken) => new { accessToken }; }