// Copyright (c) 2026 Duplicati Inc. All rights reserved.
namespace Duplicati.Proprietary.LicenseChecker;
///
/// The license data
///
public record LicenseData
{
///
/// The grace period after license expiration during which the software will still operate
///
private static readonly TimeSpan GracePeriod = TimeSpan.FromDays(30);
///
/// When the license is valid from
///
public required DateTimeOffset ValidFrom { get; init; }
///
/// When the license is valid to
///
public required DateTimeOffset ValidTo { get; init; }
///
/// The features enabled for this license
///
public required Dictionary Features { get; init; } = new();
///
/// The maximum number of machines allowed for this license
///
public required int MaxMachines { get; init; }
///
/// The organization ID associated with the license
///
public required string OrganizationId { get; init; }
///
/// The license ID
///
public required string LicenseId { get; init; }
///
/// When the license was generated
///
public required DateTimeOffset GeneratedAt { get; init; }
///
/// Determines if the license is currently valid
///
public bool IsValidNow => DateTimeOffset.UtcNow >= ValidFrom && DateTimeOffset.UtcNow <= ValidTo;
///
/// The expiration date including the grace period
///
public DateTimeOffset ValidToWithGrace => ValidTo.Add(GracePeriod);
///
/// Determines if the license is in its grace period
///
public bool IsInGracePeriod => DateTimeOffset.UtcNow > ValidTo && DateTimeOffset.UtcNow <= ValidToWithGrace;
}