using System;
using System.Text.Json.Serialization;

namespace StellaOps.Authority.Revocation;

internal sealed class RevocationExportResponse
{
    [JsonPropertyName("schemaVersion")]
    public required string SchemaVersion { get; init; }

    [JsonPropertyName("bundleId")]
    public required string BundleId { get; init; }

    [JsonPropertyName("sequence")]
    public required long Sequence { get; init; }

    [JsonPropertyName("issuedAt")]
    public required DateTimeOffset IssuedAt { get; init; }

    [JsonPropertyName("signingKeyId")]
    public string? SigningKeyId { get; init; }

    [JsonPropertyName("bundle")]
    public required RevocationExportPayload Bundle { get; init; }

    [JsonPropertyName("signature")]
    public required RevocationExportSignature Signature { get; init; }

    [JsonPropertyName("digest")]
    public required RevocationExportDigest Digest { get; init; }
}

internal sealed class RevocationExportPayload
{
    [JsonPropertyName("fileName")]
    public string FileName { get; init; } = "revocation-bundle.json";

    [JsonPropertyName("contentType")]
    public string ContentType { get; init; } = "application/json";

    [JsonPropertyName("encoding")]
    public string Encoding { get; init; } = "base64";

    [JsonPropertyName("data")]
    public required string Data { get; init; }
}

internal sealed class RevocationExportSignature
{
    [JsonPropertyName("fileName")]
    public string FileName { get; init; } = "revocation-bundle.json.jws";

    [JsonPropertyName("algorithm")]
    public required string Algorithm { get; init; }

    [JsonPropertyName("keyId")]
    public required string KeyId { get; init; }

    [JsonPropertyName("provider")]
    public required string Provider { get; init; }

    [JsonPropertyName("value")]
    public required string Value { get; init; }
}

internal sealed class RevocationExportDigest
{
    [JsonPropertyName("algorithm")]
    public string Algorithm { get; init; } = "sha256";

    [JsonPropertyName("value")]
    public required string Value { get; init; }
}
