using System.Diagnostics.CodeAnalysis;
namespace StellaOps.Cryptography.Kms;
///
/// Configuration for the AWS KMS-backed .
///
public sealed class AwsKmsOptions
{
private TimeSpan metadataCacheDuration = TimeSpan.FromMinutes(5);
private TimeSpan publicKeyCacheDuration = TimeSpan.FromMinutes(10);
///
/// Gets or sets the AWS region identifier (e.g. us-east-1).
///
public string Region { get; set; } = "us-east-1";
///
/// Gets or sets an optional custom service endpoint (useful for local stacks or VPC endpoints).
///
public string? Endpoint { get; set; }
///
/// Gets or sets a value indicating whether to use the FIPS endpoint for AWS KMS.
///
public bool UseFipsEndpoint { get; set; }
///
/// Gets or sets the cache duration for key metadata lookups.
///
public TimeSpan MetadataCacheDuration
{
get => metadataCacheDuration;
set => metadataCacheDuration = EnsurePositive(value, TimeSpan.FromMinutes(5));
}
///
/// Gets or sets the cache duration for exported public key material.
///
public TimeSpan PublicKeyCacheDuration
{
get => publicKeyCacheDuration;
set => publicKeyCacheDuration = EnsurePositive(value, TimeSpan.FromMinutes(10));
}
///
/// Gets or sets an optional factory that can provide a custom AWS facade. Primarily used for testing.
///
public Func? FacadeFactory { get; set; }
private static TimeSpan EnsurePositive(TimeSpan value, TimeSpan @default)
=> value <= TimeSpan.Zero ? @default : value;
}