From 5a34e7dfa8f3dfd473b916148078ec0923df22be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20=C3=85berg?= Date: Thu, 25 Sep 2025 11:06:52 +0200 Subject: [PATCH] MAYBE: Use KM owned ResponseModel? --- .../Models/Response/SyncResponseModel.cs | 3 +-- .../Response/UserDecryptionResponseModel.cs | 3 +-- .../WebAuthnPrfKeyManagementResponseModel.cs | 25 +++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/Core/KeyManagement/Models/Response/WebAuthnPrfKeyManagementResponseModel.cs diff --git a/src/Api/Vault/Models/Response/SyncResponseModel.cs b/src/Api/Vault/Models/Response/SyncResponseModel.cs index 5066ac61d7..6b5804b307 100644 --- a/src/Api/Vault/Models/Response/SyncResponseModel.cs +++ b/src/Api/Vault/Models/Response/SyncResponseModel.cs @@ -18,7 +18,6 @@ using Bit.Core.Vault.Entities; using Bit.Core.Vault.Models.Data; using Bit.Core.Auth.Entities; using Bit.Core.Auth.Enums; -using Bit.Core.Auth.Models.Api.Response; namespace Bit.Api.Vault.Models.Response; @@ -61,7 +60,7 @@ public class SyncResponseModel() : ResponseModel("sync") Sends = sends.Select(s => new SendResponseModel(s, globalSettings)); var webAuthnPrfOptions = webAuthnCredentials .Where(c => c.GetPrfStatus() == WebAuthnPrfStatus.Enabled) - .Select(c => new WebAuthnPrfDecryptionOption( + .Select(c => new WebAuthnPrfKeyManagementResponseModel( c.EncryptedPrivateKey, c.EncryptedUserKey, c.CredentialId, diff --git a/src/Core/KeyManagement/Models/Response/UserDecryptionResponseModel.cs b/src/Core/KeyManagement/Models/Response/UserDecryptionResponseModel.cs index 6816ef69c4..cdf883a617 100644 --- a/src/Core/KeyManagement/Models/Response/UserDecryptionResponseModel.cs +++ b/src/Core/KeyManagement/Models/Response/UserDecryptionResponseModel.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using Bit.Core.Auth.Models.Api.Response; namespace Bit.Core.KeyManagement.Models.Response; @@ -14,5 +13,5 @@ public class UserDecryptionResponseModel /// Gets or sets the WebAuthn PRF decryption keys. /// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public WebAuthnPrfDecryptionOption[]? WebAuthnPrfOptions { get; set; } + public WebAuthnPrfKeyManagementResponseModel[]? WebAuthnPrfOptions { get; set; } } diff --git a/src/Core/KeyManagement/Models/Response/WebAuthnPrfKeyManagementResponseModel.cs b/src/Core/KeyManagement/Models/Response/WebAuthnPrfKeyManagementResponseModel.cs new file mode 100644 index 0000000000..40eaa2acff --- /dev/null +++ b/src/Core/KeyManagement/Models/Response/WebAuthnPrfKeyManagementResponseModel.cs @@ -0,0 +1,25 @@ +namespace Bit.Core.KeyManagement.Models.Response; + +/// +/// Response model for WebAuthn PRF decryption options used in key management contexts. +/// This mirrors WebAuthnPrfDecryptionOption from Auth namespace but belongs to KeyManagement. +/// +public class WebAuthnPrfKeyManagementResponseModel +{ + public string EncryptedPrivateKey { get; } + public string EncryptedUserKey { get; } + public string CredentialId { get; } + public string[] Transports { get; } + + public WebAuthnPrfKeyManagementResponseModel( + string encryptedPrivateKey, + string encryptedUserKey, + string credentialId, + string[] transports) + { + EncryptedPrivateKey = encryptedPrivateKey; + EncryptedUserKey = encryptedUserKey; + CredentialId = credentialId; + Transports = transports; + } +} \ No newline at end of file