using static System.Security.Cryptography.RandomNumberGenerator;

namespace Femto.Modules.Auth.Models;

public class Session(Guid userId, bool isStrong)
{
    public static readonly  TimeSpan ValidityPeriod = TimeSpan.FromMinutes(15);
    private static readonly TimeSpan RefreshBuffer = TimeSpan.FromMinutes(5);
    public string Id { get; } = Convert.ToBase64String(GetBytes(32));
    public Guid UserId { get; } = userId;
    public DateTimeOffset Expires { get; } = DateTimeOffset.UtcNow + ValidityPeriod;
    
    public bool ExpiresSoon => this.Expires < DateTimeOffset.UtcNow + RefreshBuffer;
    public bool IsStronglyAuthenticated { get; } = isStrong;
    public bool IsExpired  => this.Expires < DateTimeOffset.UtcNow;
}
