using System.Security.Claims;
using Microsoft.IdentityModel.Tokens;

namespace adas_core.Authentication.Interfaces;

public interface ITokenService
{
    int RefreshTokenValidityInDays { get; }
    /// <summary>
    /// Retrieves a <see cref="SecurityToken"/> associated with the specified username and claims.
    /// Returns <see langword="null"/> when no matching token is found.
    /// </summary>
    /// <param name="username">The username used to look up the security token.</param>
    /// <param name="claims">The list of claims associated with the token.</param>
    /// <returns>A <see cref="SecurityToken"/> if a matching token is found; otherwise, <see langword="null"/>.</returns>
    /// <!-- aidoc:v1 sig=78fe633 -->
    SecurityToken? GetToken(string username, List<Claim> claims);

    /// <summary>
    /// Retrieves the current refresh token used to obtain new access tokens for authentication.
    /// </summary>
    /// <returns>The refresh token as a string.</returns>
    /// <!-- aidoc:v1 sig=575d89a -->
    string GetRefreshToken();

    /// <summary>
    /// Serializes the specified security token into its string representation.
    /// </summary>
    /// <param name="token">The security token to serialize.</param>
    /// <returns>A string containing the serialized form of the security token.</returns>
    /// <!-- aidoc:v1 sig=0e94bd2 -->
    string Serialize(SecurityToken token);
}