From d3679c190214f368f6ed474d6876b2378cf928bb Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 14 Dec 2021 15:37:00 +0100 Subject: [PATCH] federation-api: Use Raw around CrossSigningKey, DeviceKeys, OneTimeKey --- .../ruma-federation-api/src/device/get_devices/v1.rs | 5 +++-- crates/ruma-federation-api/src/keys/claim_keys/v1.rs | 3 ++- crates/ruma-federation-api/src/keys/get_keys/v1.rs | 11 +++++++---- crates/ruma-federation-api/src/transactions/edu.rs | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/crates/ruma-federation-api/src/device/get_devices/v1.rs b/crates/ruma-federation-api/src/device/get_devices/v1.rs index ce9534a9..ea82570c 100644 --- a/crates/ruma-federation-api/src/device/get_devices/v1.rs +++ b/crates/ruma-federation-api/src/device/get_devices/v1.rs @@ -4,6 +4,7 @@ use js_int::UInt; use ruma_api::ruma_api; use ruma_common::encryption::DeviceKeys; use ruma_identifiers::{DeviceId, UserId}; +use ruma_serde::Raw; use serde::{Deserialize, Serialize}; ruma_api! { @@ -63,7 +64,7 @@ pub struct UserDevice { pub device_id: Box, /// Identity keys for the device. - pub keys: DeviceKeys, + pub keys: Raw, /// Optional display name for the device #[serde(skip_serializing_if = "Option::is_none")] @@ -72,7 +73,7 @@ pub struct UserDevice { impl UserDevice { /// Creates a new `UserDevice` with the given device id and keys. - pub fn new(device_id: Box, keys: DeviceKeys) -> Self { + pub fn new(device_id: Box, keys: Raw) -> Self { Self { device_id, keys, device_display_name: None } } } diff --git a/crates/ruma-federation-api/src/keys/claim_keys/v1.rs b/crates/ruma-federation-api/src/keys/claim_keys/v1.rs index 4c43caee..7b853108 100644 --- a/crates/ruma-federation-api/src/keys/claim_keys/v1.rs +++ b/crates/ruma-federation-api/src/keys/claim_keys/v1.rs @@ -6,6 +6,7 @@ use std::collections::BTreeMap; use ruma_api::ruma_api; use ruma_common::encryption::OneTimeKey; use ruma_identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId}; +use ruma_serde::Raw; use serde::{Deserialize, Serialize}; ruma_api! { @@ -48,7 +49,7 @@ pub type OneTimeKeyClaims = BTreeMap, BTreeMap, Device /// One time keys for use in pre-key messages pub type OneTimeKeys = - BTreeMap, BTreeMap, BTreeMap, OneTimeKey>>>; + BTreeMap, BTreeMap, BTreeMap, Raw>>>; /// A key and its signature #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/crates/ruma-federation-api/src/keys/get_keys/v1.rs b/crates/ruma-federation-api/src/keys/get_keys/v1.rs index 4ca2efea..844cbdfa 100644 --- a/crates/ruma-federation-api/src/keys/get_keys/v1.rs +++ b/crates/ruma-federation-api/src/keys/get_keys/v1.rs @@ -7,6 +7,7 @@ use ruma_api::ruma_api; use ruma_common::encryption::CrossSigningKey; use ruma_common::encryption::DeviceKeys; use ruma_identifiers::{DeviceId, UserId}; +use ruma_serde::Raw; ruma_api! { metadata: { @@ -28,17 +29,17 @@ ruma_api! { #[derive(Default)] response: { /// Keys from the queried devices. - pub device_keys: BTreeMap, BTreeMap, DeviceKeys>>, + pub device_keys: BTreeMap, BTreeMap, Raw>>, /// Information on the master cross-signing keys of the queried users. #[cfg(feature = "unstable-pre-spec")] #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] - pub master_keys: BTreeMap, CrossSigningKey>, + pub master_keys: BTreeMap, Raw>, /// Information on the self-signing keys of the queried users. #[cfg(feature = "unstable-pre-spec")] #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] - pub self_signing_keys: BTreeMap, CrossSigningKey>, + pub self_signing_keys: BTreeMap, Raw>, } } @@ -51,7 +52,9 @@ impl Request { impl Response { /// Creates a new `Response` with the given device keys. - pub fn new(device_keys: BTreeMap, BTreeMap, DeviceKeys>>) -> Self { + pub fn new( + device_keys: BTreeMap, BTreeMap, Raw>>, + ) -> Self { Self { device_keys, ..Default::default() } } } diff --git a/crates/ruma-federation-api/src/transactions/edu.rs b/crates/ruma-federation-api/src/transactions/edu.rs index f1b5a925..80e4cad4 100644 --- a/crates/ruma-federation-api/src/transactions/edu.rs +++ b/crates/ruma-federation-api/src/transactions/edu.rs @@ -228,7 +228,7 @@ pub struct DeviceListUpdateContent { /// The updated identity keys (if any) for this device. #[serde(skip_serializing_if = "Option::is_none")] - pub keys: Option, + pub keys: Option>, } impl DeviceListUpdateContent {