namespace Femto.Modules.Auth.Models;

internal class UserSession
{
    private static TimeSpan SessionTimeout { get; } = TimeSpan.FromMinutes(30);
    private static TimeSpan ExpiryBuffer { get; } = TimeSpan.FromMinutes(5);
    public string Id { get; private set; }
    public DateTimeOffset Expires { get; private set; }
    public bool ExpiresSoon => Expires < DateTimeOffset.UtcNow + ExpiryBuffer;
    
    private UserSession() {}

    public static UserSession Create()
    {
        return new()
        {
            Id = Convert.ToBase64String(System.Security.Cryptography.RandomNumberGenerator.GetBytes(32)),
            Expires = DateTimeOffset.UtcNow + SessionTimeout
        };
    }
}