using System; using System.Threading; using System.Threading.Tasks; using CarpaNet.OAuth.Crypto; namespace CarpaNet.OAuth.Storage; /// /// Represents the state data stored during an OAuth authorization flow. /// public sealed class OAuthStateData { /// /// The authorization server issuer. /// public string Issuer { get; set; } = string.Empty; /// /// The DPoP key pair (serialized as JWK). /// public JsonWebKey DPoPKey { get; set; } = new(); /// /// The PKCE code verifier. /// public string Verifier { get; set; } = string.Empty; /// /// The client authentication method. /// public string? AuthMethod { get; set; } /// /// Optional application-defined state. /// public string? AppState { get; set; } /// /// The PDS URL for the resource server. /// public string? PdsUrl { get; set; } /// /// When this state expires. /// public DateTimeOffset ExpiresAt { get; set; } } /// /// Storage for OAuth authorization state (during auth flow). /// public interface IOAuthStateStore { /// /// Stores state data for an authorization flow. /// /// The state parameter (key). /// The state data to store. /// Cancellation token. Task StoreAsync(string state, OAuthStateData data, CancellationToken cancellationToken = default); /// /// Retrieves and deletes state data (atomically to prevent replay). /// /// The state parameter (key). /// Cancellation token. /// The state data if found and not expired, null otherwise. Task ConsumeAsync(string state, CancellationToken cancellationToken = default); }