using System.Security.Claims;

namespace DramaLing.Api.Services.Infrastructure.Authentication;

/// <summary>
/// Token 處理服務介面
/// </summary>
public interface ITokenService
{
    /// <summary>
    /// 驗證 JWT Token
    /// </summary>
    Task<ClaimsPrincipal?> ValidateTokenAsync(string token);

    /// <summary>
    /// 從 Token 提取用戶 ID
    /// </summary>
    Task<Guid?> ExtractUserIdAsync(string token);

    /// <summary>
    /// 從 Authorization Header 提取用戶 ID
    /// </summary>
    Task<Guid?> GetUserIdFromHeaderAsync(string? authorizationHeader);

    /// <summary>
    /// 檢查 Token 是否有效
    /// </summary>
    Task<bool> IsTokenValidAsync(string token);

    /// <summary>
    /// 取得 Token 的過期時間
    /// </summary>
    Task<DateTime?> GetTokenExpiryAsync(string token);
}

/// <summary>
/// 用戶身份服務介面
/// </summary>
public interface IUserIdentityService
{
    /// <summary>
    /// 取得當前用戶 ID
    /// </summary>
    Task<Guid?> GetCurrentUserIdAsync();

    /// <summary>
    /// 檢查用戶是否為 Premium
    /// </summary>
    Task<bool> IsCurrentUserPremiumAsync();

    /// <summary>
    /// 取得用戶角色
    /// </summary>
    Task<IEnumerable<string>> GetUserRolesAsync(Guid userId);

    /// <summary>
    /// 檢查用戶權限
    /// </summary>
    Task<bool> HasPermissionAsync(Guid userId, string permission);
}