diff --git a/src/Api/KeyManagement/Models/Response/PrivateKeysResponseModel.cs b/src/Api/KeyManagement/Models/Response/PrivateKeysResponseModel.cs index 32b5928cc6..30f10a5fbe 100644 --- a/src/Api/KeyManagement/Models/Response/PrivateKeysResponseModel.cs +++ b/src/Api/KeyManagement/Models/Response/PrivateKeysResponseModel.cs @@ -1,5 +1,4 @@ -using System.Text.Json.Serialization; -using Bit.Core.KeyManagement.Models.Data; +using Bit.Core.KeyManagement.Models.Data; using Bit.Core.Models.Api; namespace Bit.Api.KeyManagement.Models.Response; @@ -14,11 +13,10 @@ namespace Bit.Api.KeyManagement.Models.Response; /// public class PrivateKeysResponseModel : ResponseModel { - [JsonConstructor] [System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute] public PrivateKeysResponseModel(UserAccountKeysData accountKeys) : base("privateKeys") { - PublicKeyEncryptionKeyPair = accountKeys.PublicKeyEncryptionKeyPairData; + PublicKeyEncryptionKeyPair = new PublicKeyEncryptionKeyPairModel(accountKeys.PublicKeyEncryptionKeyPairData); if (accountKeys == null) { throw new ArgumentNullException(nameof(accountKeys)); @@ -26,12 +24,12 @@ public class PrivateKeysResponseModel : ResponseModel if (accountKeys.SignatureKeyPairData != null) { - SignatureKeyPair = accountKeys.SignatureKeyPairData; + SignatureKeyPair = new SignatureKeyPairResponseModel(accountKeys.SignatureKeyPairData); } } // Not all accounts have signature keys, but all accounts have public encryption keys. - public SignatureKeyPairData? SignatureKeyPair { get; set; } - public required PublicKeyEncryptionKeyPairData PublicKeyEncryptionKeyPair { get; set; } + public SignatureKeyPairResponseModel? SignatureKeyPair { get; set; } + public required PublicKeyEncryptionKeyPairModel PublicKeyEncryptionKeyPair { get; set; } } diff --git a/src/Api/KeyManagement/Models/Response/PublicKeyEncryptionKeyPairResponseModel.cs b/src/Api/KeyManagement/Models/Response/PublicKeyEncryptionKeyPairResponseModel.cs new file mode 100644 index 0000000000..db25e498aa --- /dev/null +++ b/src/Api/KeyManagement/Models/Response/PublicKeyEncryptionKeyPairResponseModel.cs @@ -0,0 +1,14 @@ +using Bit.Core.KeyManagement.Models.Data; +using Bit.Core.Models.Api; + +namespace Bit.Api.KeyManagement.Models.Response; + +[method: System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute] +#nullable enable + +public class PublicKeyEncryptionKeyPairModel(PublicKeyEncryptionKeyPairData keyPair) : ResponseModel("publicKeyEncryptionKeyPair") +{ + public required string WrappedPrivateKey { get; set; } = keyPair.WrappedPrivateKey; + public required string PublicKey { get; set; } = keyPair.PublicKey; + public string? SignedPublicKey { get; set; } = keyPair.SignedPublicKey; +} diff --git a/src/Api/KeyManagement/Models/Response/SignatureKeyPairResponseModel.cs b/src/Api/KeyManagement/Models/Response/SignatureKeyPairResponseModel.cs new file mode 100644 index 0000000000..59b5ca20c2 --- /dev/null +++ b/src/Api/KeyManagement/Models/Response/SignatureKeyPairResponseModel.cs @@ -0,0 +1,13 @@ +using Bit.Core.KeyManagement.Models.Data; +using Bit.Core.Models.Api; + +namespace Bit.Api.KeyManagement.Models.Response; + +[method: System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute] +#nullable enable + +public class SignatureKeyPairResponseModel(SignatureKeyPairData signatureKeyPair) : ResponseModel("signatureKeyPair") +{ + public required string WrappedSigningKey { get; set; } = signatureKeyPair.WrappedSigningKey; + public required string VerifyingKey { get; set; } = signatureKeyPair.VerifyingKey; +}