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

namespace Lactose.Utils;

public class TokenGenerator(SigningCredentials credentials, Func<SecurityTokenDescriptor, string> handler) {
    readonly TokenBuilder                          builder = new TokenBuilder(credentials);

    public string Generate(ClaimsIdentity claims, int expireTime) {
        builder.ExpireTime(expireTime)
            .SetClaims(claims);
        return builder.GenerateToken(handler);
    }
    public string Generate(int expireTime) {
        builder.ExpireTime(expireTime);
        return builder.GenerateToken(handler);
    }
    
}