diff --git a/common/authenticator-requests/src/v3/conversion.rs b/common/authenticator-requests/src/v3/conversion.rs index 15659271b2..2ceaeb0301 100644 --- a/common/authenticator-requests/src/v3/conversion.rs +++ b/common/authenticator-requests/src/v3/conversion.rs @@ -98,6 +98,16 @@ impl TryFrom for v2::response::Authenticato } } +impl From for v3::response::AuthenticatorResponse { + fn from(value: v2::response::AuthenticatorResponse) -> Self { + Self { + protocol: value.protocol, + data: value.data.into(), + reply_to: value.reply_to, + } + } +} + impl TryFrom for v2::response::AuthenticatorResponseData { type Error = crate::Error; @@ -129,6 +139,22 @@ impl TryFrom for v2::response::Authenti } } +impl From for v3::response::AuthenticatorResponseData { + fn from(value: v2::response::AuthenticatorResponseData) -> Self { + match value { + v2::response::AuthenticatorResponseData::PendingRegistration( + pending_registration_response, + ) => Self::PendingRegistration(pending_registration_response.into()), + v2::response::AuthenticatorResponseData::Registered(registered_response) => { + Self::Registered(registered_response.into()) + } + v2::response::AuthenticatorResponseData::RemainingBandwidth( + remaining_bandwidth_response, + ) => Self::RemainingBandwidth(remaining_bandwidth_response.into()), + } + } +} + impl From for v2::response::PendingRegistrationResponse { fn from(value: v3::response::PendingRegistrationResponse) -> Self { Self { @@ -139,6 +165,16 @@ impl From for v2::response::PendingRe } } +impl From for v3::response::PendingRegistrationResponse { + fn from(value: v2::response::PendingRegistrationResponse) -> Self { + Self { + request_id: value.request_id, + reply_to: value.reply_to, + reply: value.reply.into(), + } + } +} + impl From for v2::response::RegisteredResponse { fn from(value: v3::response::RegisteredResponse) -> Self { Self { @@ -149,6 +185,16 @@ impl From for v2::response::RegisteredResponse } } +impl From for v3::response::RegisteredResponse { + fn from(value: v2::response::RegisteredResponse) -> Self { + Self { + request_id: value.request_id, + reply_to: value.reply_to, + reply: value.reply.into(), + } + } +} + impl From for v2::response::RemainingBandwidthResponse { fn from(value: v3::response::RemainingBandwidthResponse) -> Self { Self { @@ -159,6 +205,16 @@ impl From for v2::response::RemainingB } } +impl From for v3::response::RemainingBandwidthResponse { + fn from(value: v2::response::RemainingBandwidthResponse) -> Self { + Self { + request_id: value.request_id, + reply_to: value.reply_to, + reply: value.reply.map(Into::into), + } + } +} + impl From for v2::registration::RegistrationData { fn from(value: v3::registration::RegistrationData) -> Self { Self { @@ -169,6 +225,16 @@ impl From for v2::registration::Registration } } +impl From for v3::registration::RegistrationData { + fn from(value: v2::registration::RegistrationData) -> Self { + Self { + nonce: value.nonce, + gateway_data: value.gateway_data.into(), + wg_port: value.wg_port, + } + } +} + impl From for v2::registration::RegistredData { fn from(value: v3::registration::RegistredData) -> Self { Self { @@ -179,6 +245,16 @@ impl From for v2::registration::RegistredData { } } +impl From for v3::registration::RegistredData { + fn from(value: v2::registration::RegistredData) -> Self { + Self { + pub_key: value.pub_key, + private_ip: value.private_ip, + wg_port: value.wg_port, + } + } +} + impl From for v2::registration::RemainingBandwidthData { fn from(value: v3::registration::RemainingBandwidthData) -> Self { Self { @@ -186,3 +262,11 @@ impl From for v2::registration::Remain } } } + +impl From for v3::registration::RemainingBandwidthData { + fn from(value: v2::registration::RemainingBandwidthData) -> Self { + Self { + available_bandwidth: value.available_bandwidth, + } + } +}