using System.Text.Json.Nodes;

namespace Eis.Application.Authentication;

public sealed record AuthenticationEndpointResult(int StatusCode, JsonObject Body, string? SetCookie = null);

public interface IAuthenticationService
{
    Task<AuthenticationEndpointResult> RegisterAsync(
        string name,
        string gender,
        string password,
        string schoolId,
        string classId,
        CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> GetCurrentUserAsync(string sessionToken, CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> LoginAsync(string username, string password, CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> CompleteTotpLoginAsync(
        string challenge,
        string code,
        CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> ChangePasswordAsync(
        string sessionToken,
        string currentPassword,
        string newPassword,
        CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> GetTotpStatusAsync(string sessionToken, CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> BeginTotpSetupAsync(
        string sessionToken,
        string currentPassword,
        CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> EnableTotpAsync(
        string sessionToken,
        string code,
        CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> RegenerateRecoveryCodesAsync(
        string sessionToken,
        string currentPassword,
        string code,
        CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> DisableTotpAsync(
        string sessionToken,
        string currentPassword,
        string code,
        CancellationToken cancellationToken);

    Task<AuthenticationEndpointResult> LogoutAsync(string sessionToken, CancellationToken cancellationToken);
}
