using System.Net.Http.Json; namespace Distribution.Features.Auth; /// /// Proxies own-user auth calls (login/register/getUserDetails/logout) to the external AuthHex /// identity service. AuthHex owns credentials and issues the RS256-signed JWT this app validates; /// this app never sees or stores a plaintext/hashed password. /// public class AuthHexClient(HttpClient http) : IAuthHexClient { public async Task CallAsync(string functionName, object? payload, string? reference = null, CancellationToken ct = default) { var body = new { functionName, payload, reference }; var response = await http.PostAsJsonAsync("/api/user", body, ct); var result = await response.Content.ReadFromJsonAsync(cancellationToken: ct); return result ?? new AuthHexResponse((int)response.StatusCode, false, "Empty response from AuthHex.", null); } }