From 74d0ac7c77a99809d5ecfc47fd57b6012e6cb2e8 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 7 Jun 2021 14:47:59 +0200 Subject: [PATCH] crypto: Depend on ruma directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … instead of using matrix_sdk_common's re-exports --- matrix_sdk_crypto/Cargo.toml | 1 + matrix_sdk_crypto/benches/crypto_bench.rs | 20 +++++----- matrix_sdk_crypto/src/error.rs | 2 +- .../src/file_encryption/attachments.rs | 2 +- .../src/file_encryption/key_export.rs | 6 +-- matrix_sdk_crypto/src/identities/device.rs | 11 ++---- matrix_sdk_crypto/src/identities/manager.rs | 17 ++++---- matrix_sdk_crypto/src/identities/user.rs | 11 +++--- matrix_sdk_crypto/src/key_request.rs | 16 ++++---- matrix_sdk_crypto/src/machine.rs | 39 ++++++++++--------- matrix_sdk_crypto/src/olm/account.rs | 24 ++++++------ .../src/olm/group_sessions/inbound.rs | 22 +++++------ .../src/olm/group_sessions/mod.rs | 8 ++-- .../src/olm/group_sessions/outbound.rs | 31 +++++++-------- matrix_sdk_crypto/src/olm/mod.rs | 10 ++--- matrix_sdk_crypto/src/olm/session.rs | 15 ++++--- matrix_sdk_crypto/src/olm/signing/mod.rs | 17 ++++---- .../src/olm/signing/pk_signing.rs | 14 +++---- matrix_sdk_crypto/src/olm/utility.rs | 7 +--- matrix_sdk_crypto/src/requests.rs | 17 ++++---- .../src/session_manager/group_sessions.rs | 23 +++++------ .../src/session_manager/sessions.rs | 24 ++++++------ matrix_sdk_crypto/src/store/caches.rs | 8 ++-- matrix_sdk_crypto/src/store/memorystore.rs | 11 ++---- matrix_sdk_crypto/src/store/mod.rs | 15 +++---- matrix_sdk_crypto/src/store/sled.rs | 21 ++++------ matrix_sdk_crypto/src/verification/cache.rs | 6 +-- .../src/verification/event_enums.rs | 6 +-- matrix_sdk_crypto/src/verification/machine.rs | 13 ++----- matrix_sdk_crypto/src/verification/mod.rs | 12 +++--- .../src/verification/requests.rs | 11 +++--- .../src/verification/sas/helpers.rs | 12 +++--- .../src/verification/sas/inner_sas.rs | 4 +- matrix_sdk_crypto/src/verification/sas/mod.rs | 10 ++--- .../src/verification/sas/sas_state.rs | 12 +++--- 35 files changed, 222 insertions(+), 256 deletions(-) diff --git a/matrix_sdk_crypto/Cargo.toml b/matrix_sdk_crypto/Cargo.toml index 108aebc4..764b1f2c 100644 --- a/matrix_sdk_crypto/Cargo.toml +++ b/matrix_sdk_crypto/Cargo.toml @@ -21,6 +21,7 @@ docs = ["sled_cryptostore"] [dependencies] matrix-sdk-common = { version = "0.2.0", path = "../matrix_sdk_common" } +ruma = { version = "0.1.2", features = ["client-api-c", "unstable-pre-spec"] } olm-rs = { version = "1.0.0", features = ["serde"] } getrandom = "0.2.2" diff --git a/matrix_sdk_crypto/benches/crypto_bench.rs b/matrix_sdk_crypto/benches/crypto_bench.rs index 95e74aaf..280d01af 100644 --- a/matrix_sdk_crypto/benches/crypto_bench.rs +++ b/matrix_sdk_crypto/benches/crypto_bench.rs @@ -4,17 +4,19 @@ mod perf; use std::sync::Arc; use criterion::*; -use matrix_sdk_common::{ - api::r0::{ - keys::{claim_keys, get_keys}, - to_device::send_event_to_device::Response as ToDeviceResponse, - }, - identifiers::{room_id, user_id, DeviceIdBox, UserId}, - uuid::Uuid, - IncomingResponse, -}; +use matrix_sdk_common::uuid::Uuid; use matrix_sdk_crypto::{EncryptionSettings, OlmMachine}; use matrix_sdk_test::response_from_file; +use ruma::{ + api::{ + client::r0::{ + keys::{claim_keys, get_keys}, + to_device::send_event_to_device::Response as ToDeviceResponse, + }, + IncomingResponse, + }, + room_id, user_id, DeviceIdBox, UserId, +}; use serde_json::Value; use tokio::runtime::Builder; diff --git a/matrix_sdk_crypto/src/error.rs b/matrix_sdk_crypto/src/error.rs index c93f0392..d7040f5c 100644 --- a/matrix_sdk_crypto/src/error.rs +++ b/matrix_sdk_crypto/src/error.rs @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -use matrix_sdk_common::identifiers::{DeviceId, Error as IdentifierError, UserId}; use olm_rs::errors::{OlmGroupSessionError, OlmSessionError}; +use ruma::{identifiers::Error as IdentifierError, DeviceId, UserId}; use serde_json::Error as SerdeError; use thiserror::Error; diff --git a/matrix_sdk_crypto/src/file_encryption/attachments.rs b/matrix_sdk_crypto/src/file_encryption/attachments.rs index d20392c8..14d7b75c 100644 --- a/matrix_sdk_crypto/src/file_encryption/attachments.rs +++ b/matrix_sdk_crypto/src/file_encryption/attachments.rs @@ -23,7 +23,7 @@ use aes_ctr::{ }; use base64::DecodeError; use getrandom::getrandom; -use matrix_sdk_common::events::room::{EncryptedFile, JsonWebKey, JsonWebKeyInit}; +use ruma::events::room::{EncryptedFile, JsonWebKey, JsonWebKeyInit}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use thiserror::Error; diff --git a/matrix_sdk_crypto/src/file_encryption/key_export.rs b/matrix_sdk_crypto/src/file_encryption/key_export.rs index a761d11d..95cc8bb6 100644 --- a/matrix_sdk_crypto/src/file_encryption/key_export.rs +++ b/matrix_sdk_crypto/src/file_encryption/key_export.rs @@ -76,7 +76,7 @@ pub enum KeyExportError { /// ```no_run /// # use std::io::Cursor; /// # use matrix_sdk_crypto::{OlmMachine, decrypt_key_export}; -/// # use matrix_sdk_common::identifiers::user_id; +/// # use ruma::user_id; /// # use futures::executor::block_on; /// # let alice = user_id!("@alice:example.org"); /// # let machine = OlmMachine::new(&alice, "DEVICEID".into()); @@ -127,7 +127,7 @@ pub fn decrypt_key_export( /// # Examples /// ```no_run /// # use matrix_sdk_crypto::{OlmMachine, encrypt_key_export}; -/// # use matrix_sdk_common::identifiers::{user_id, room_id}; +/// # use ruma::{user_id, room_id}; /// # use futures::executor::block_on; /// # let alice = user_id!("@alice:example.org"); /// # let machine = OlmMachine::new(&alice, "DEVICEID".into()); @@ -229,9 +229,9 @@ mod test { use std::io::Cursor; use indoc::indoc; - use matrix_sdk_common::identifiers::room_id; use matrix_sdk_test::async_test; use proptest::prelude::*; + use ruma::room_id; use super::{decode, decrypt_helper, decrypt_key_export, encrypt_helper, encrypt_key_export}; use crate::machine::test::get_prepared_machine; diff --git a/matrix_sdk_crypto/src/identities/device.rs b/matrix_sdk_crypto/src/identities/device.rs index d6f63541..0fef3a7a 100644 --- a/matrix_sdk_crypto/src/identities/device.rs +++ b/matrix_sdk_crypto/src/identities/device.rs @@ -23,8 +23,9 @@ use std::{ }; use atomic::Atomic; -use matrix_sdk_common::{ - api::r0::keys::SignedKey, +use matrix_sdk_common::locks::Mutex; +use ruma::{ + api::client::r0::keys::SignedKey, encryption::DeviceKeys, events::{ forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, @@ -33,7 +34,6 @@ use matrix_sdk_common::{ identifiers::{ DeviceId, DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, EventEncryptionAlgorithm, UserId, }, - locks::Mutex, }; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::{json, Value}; @@ -570,10 +570,7 @@ impl PartialEq for ReadOnlyDevice { pub(crate) mod test { use std::convert::TryFrom; - use matrix_sdk_common::{ - encryption::DeviceKeys, - identifiers::{user_id, DeviceKeyAlgorithm}, - }; + use ruma::{encryption::DeviceKeys, user_id, DeviceKeyAlgorithm}; use serde_json::json; use crate::identities::{LocalTrust, ReadOnlyDevice}; diff --git a/matrix_sdk_crypto/src/identities/manager.rs b/matrix_sdk_crypto/src/identities/manager.rs index 8705e0dc..0af468b7 100644 --- a/matrix_sdk_crypto/src/identities/manager.rs +++ b/matrix_sdk_crypto/src/identities/manager.rs @@ -19,10 +19,10 @@ use std::{ }; use futures::future::join_all; -use matrix_sdk_common::{ - api::r0::keys::get_keys::Response as KeysQueryResponse, +use matrix_sdk_common::executor::spawn; +use ruma::{ + api::client::r0::keys::get_keys::Response as KeysQueryResponse, encryption::DeviceKeys, - executor::spawn, identifiers::{DeviceId, DeviceIdBox, UserId}, }; use tracing::{trace, warn}; @@ -390,13 +390,12 @@ impl IdentityManager { pub(crate) mod test { use std::sync::Arc; - use matrix_sdk_common::{ - api::r0::keys::get_keys::Response as KeyQueryResponse, - identifiers::{user_id, DeviceIdBox, UserId}, - locks::Mutex, - IncomingResponse, - }; + use matrix_sdk_common::locks::Mutex; use matrix_sdk_test::async_test; + use ruma::{ + api::{client::r0::keys::get_keys::Response as KeyQueryResponse, IncomingResponse}, + user_id, DeviceIdBox, UserId, + }; use serde_json::json; use crate::{ diff --git a/matrix_sdk_crypto/src/identities/user.rs b/matrix_sdk_crypto/src/identities/user.rs index 66405c91..4142ea0f 100644 --- a/matrix_sdk_crypto/src/identities/user.rs +++ b/matrix_sdk_crypto/src/identities/user.rs @@ -21,9 +21,9 @@ use std::{ }, }; -use matrix_sdk_common::{ - api::r0::keys::{CrossSigningKey, KeyUsage}, - identifiers::{DeviceKeyId, UserId}, +use ruma::{ + api::client::r0::keys::{CrossSigningKey, KeyUsage}, + DeviceKeyId, UserId, }; use serde::{Deserialize, Serialize}; use serde_json::to_value; @@ -680,10 +680,9 @@ impl OwnUserIdentity { pub(crate) mod test { use std::{convert::TryFrom, sync::Arc}; - use matrix_sdk_common::{ - api::r0::keys::get_keys::Response as KeyQueryResponse, identifiers::user_id, locks::Mutex, - }; + use matrix_sdk_common::locks::Mutex; use matrix_sdk_test::async_test; + use ruma::{api::client::r0::keys::get_keys::Response as KeyQueryResponse, user_id}; use super::{OwnUserIdentity, UserIdentities, UserIdentity}; use crate::{ diff --git a/matrix_sdk_crypto/src/key_request.rs b/matrix_sdk_crypto/src/key_request.rs index 19876ce1..9732d8d4 100644 --- a/matrix_sdk_crypto/src/key_request.rs +++ b/matrix_sdk_crypto/src/key_request.rs @@ -23,15 +23,15 @@ use std::{collections::BTreeMap, sync::Arc}; use dashmap::{mapref::entry::Entry, DashMap, DashSet}; -use matrix_sdk_common::{ - api::r0::to_device::DeviceIdOrAllDevices, +use matrix_sdk_common::uuid::Uuid; +use ruma::{ + api::client::r0::to_device::DeviceIdOrAllDevices, events::{ forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, room_key_request::{Action, RequestedKeyInfo, RoomKeyRequestToDeviceEventContent}, AnyToDeviceEvent, EventType, ToDeviceEvent, }, identifiers::{DeviceId, DeviceIdBox, EventEncryptionAlgorithm, RoomId, UserId}, - uuid::Uuid, }; use serde::{Deserialize, Serialize}; use serde_json::value::to_raw_value; @@ -786,17 +786,17 @@ mod test { use std::{convert::TryInto, sync::Arc}; use dashmap::DashMap; - use matrix_sdk_common::{ - api::r0::to_device::DeviceIdOrAllDevices, + use matrix_sdk_common::locks::Mutex; + use matrix_sdk_test::async_test; + use ruma::{ + api::client::r0::to_device::DeviceIdOrAllDevices, events::{ forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, room::encrypted::EncryptedEventContent, room_key_request::RoomKeyRequestToDeviceEventContent, AnyToDeviceEvent, ToDeviceEvent, }, - identifiers::{room_id, user_id, DeviceIdBox, RoomId, UserId}, - locks::Mutex, + room_id, user_id, DeviceIdBox, RoomId, UserId, }; - use matrix_sdk_test::async_test; use super::{KeyRequestMachine, KeyshareDecision}; use crate::{ diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index 9f00046b..807d13cf 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -18,7 +18,12 @@ use std::{collections::BTreeMap, mem, sync::Arc}; use dashmap::DashMap; use matrix_sdk_common::{ - api::r0::{ + deserialized_responses::{AlgorithmInfo, EncryptionInfo, SyncRoomEvent, VerificationState}, + locks::Mutex, + uuid::Uuid, +}; +use ruma::{ + api::client::r0::{ keys::{ claim_keys::{Request as KeysClaimRequest, Response as KeysClaimResponse}, get_keys::Response as KeysQueryResponse, @@ -28,18 +33,12 @@ use matrix_sdk_common::{ sync::sync_events::{DeviceLists, ToDevice}, }, assign, - deserialized_responses::{AlgorithmInfo, EncryptionInfo, SyncRoomEvent, VerificationState}, events::{ room::encrypted::{EncryptedEventContent, EncryptedEventScheme}, room_key::RoomKeyToDeviceEventContent, AnyMessageEventContent, AnyRoomEvent, AnyToDeviceEvent, SyncMessageEvent, ToDeviceEvent, }, - identifiers::{ - DeviceId, DeviceIdBox, DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId, UserId, - }, - locks::Mutex, - uuid::Uuid, - UInt, + DeviceId, DeviceIdBox, DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId, UInt, UserId, }; use tracing::{debug, error, info, trace, warn}; @@ -412,7 +411,7 @@ impl OlmMachine { /// ``` /// # use std::convert::TryFrom; /// # use matrix_sdk_crypto::OlmMachine; - /// # use matrix_sdk_common::identifiers::UserId; + /// # use ruma::UserId; /// # use futures::executor::block_on; /// # let alice = UserId::try_from("@alice:example.org").unwrap(); /// # let machine = OlmMachine::new(&alice, "DEVICEID".into()); @@ -1031,7 +1030,7 @@ impl OlmMachine { /// ``` /// # use std::convert::TryFrom; /// # use matrix_sdk_crypto::OlmMachine; - /// # use matrix_sdk_common::identifiers::UserId; + /// # use ruma::UserId; /// # use futures::executor::block_on; /// # let alice = UserId::try_from("@alice:example.org").unwrap(); /// # let machine = OlmMachine::new(&alice, "DEVICEID".into()); @@ -1060,7 +1059,7 @@ impl OlmMachine { /// ``` /// # use std::convert::TryFrom; /// # use matrix_sdk_crypto::OlmMachine; - /// # use matrix_sdk_common::identifiers::UserId; + /// # use ruma::UserId; /// # use futures::executor::block_on; /// # let alice = UserId::try_from("@alice:example.org").unwrap(); /// # let machine = OlmMachine::new(&alice, "DEVICEID".into()); @@ -1092,7 +1091,7 @@ impl OlmMachine { /// ```no_run /// # use std::io::Cursor; /// # use matrix_sdk_crypto::{OlmMachine, decrypt_key_export}; - /// # use matrix_sdk_common::identifiers::user_id; + /// # use ruma::user_id; /// # use futures::executor::block_on; /// # let alice = user_id!("@alice:example.org"); /// # let machine = OlmMachine::new(&alice, "DEVICEID".into()); @@ -1179,7 +1178,7 @@ impl OlmMachine { /// /// ```no_run /// # use matrix_sdk_crypto::{OlmMachine, encrypt_key_export}; - /// # use matrix_sdk_common::identifiers::{user_id, room_id}; + /// # use ruma::{user_id, room_id}; /// # use futures::executor::block_on; /// # let alice = user_id!("@alice:example.org"); /// # let machine = OlmMachine::new(&alice, "DEVICEID".into()); @@ -1223,8 +1222,12 @@ pub(crate) mod test { }; use http::Response; - use matrix_sdk_common::{ - api::r0::keys::{claim_keys, get_keys, upload_keys, OneTimeKey}, + use matrix_sdk_test::test_json; + use ruma::{ + api::{ + client::r0::keys::{claim_keys, get_keys, upload_keys, OneTimeKey}, + IncomingResponse, + }, events::{ room::{ encrypted::EncryptedEventContent, @@ -1236,9 +1239,9 @@ pub(crate) mod test { identifiers::{ event_id, room_id, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId, }, - IncomingResponse, MilliSecondsSinceUnixEpoch, Raw, + serde::Raw, + uint, MilliSecondsSinceUnixEpoch, }; - use matrix_sdk_test::test_json; use serde_json::json; use crate::{ @@ -1251,8 +1254,6 @@ pub(crate) mod test { /// These keys need to be periodically uploaded to the server. type OneTimeKeys = BTreeMap; - use matrix_sdk_common::uint; - fn alice_id() -> UserId { user_id!("@alice:example.org") } diff --git a/matrix_sdk_crypto/src/olm/account.rs b/matrix_sdk_crypto/src/olm/account.rs index ddd527b9..2ed7750b 100644 --- a/matrix_sdk_crypto/src/olm/account.rs +++ b/matrix_sdk_crypto/src/olm/account.rs @@ -23,10 +23,17 @@ use std::{ }, }; +use matrix_sdk_common::{instant::Instant, locks::Mutex}; +use olm_rs::{ + account::{IdentityKeys, OlmAccount, OneTimeKeys}, + errors::{OlmAccountError, OlmSessionError}, + session::{OlmMessage, PreKeyMessage}, + PicklingMode, +}; #[cfg(test)] -use matrix_sdk_common::events::EventType; -use matrix_sdk_common::{ - api::r0::keys::{ +use ruma::events::EventType; +use ruma::{ + api::client::r0::keys::{ upload_keys, upload_signatures::Request as SignatureUploadRequest, OneTimeKey, SignedKey, }, encryption::DeviceKeys, @@ -38,15 +45,8 @@ use matrix_sdk_common::{ DeviceId, DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, EventEncryptionAlgorithm, RoomId, UserId, }, - instant::Instant, - locks::Mutex, - CanonicalJsonValue, Raw, UInt, -}; -use olm_rs::{ - account::{IdentityKeys, OlmAccount, OneTimeKeys}, - errors::{OlmAccountError, OlmSessionError}, - session::{OlmMessage, PreKeyMessage}, - PicklingMode, + serde::{CanonicalJsonValue, Raw}, + UInt, }; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; diff --git a/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs b/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs index 4dfc0c5e..e557d585 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs @@ -14,7 +14,16 @@ use std::{collections::BTreeMap, convert::TryFrom, fmt, mem, sync::Arc}; -use matrix_sdk_common::{ +use matrix_sdk_common::locks::Mutex; +pub use olm_rs::{ + account::IdentityKeys, + session::{OlmMessage, PreKeyMessage}, + utility::OlmUtility, +}; +use olm_rs::{ + errors::OlmGroupSessionError, inbound_group_session::OlmInboundGroupSession, PicklingMode, +}; +use ruma::{ events::{ forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, room::{ @@ -24,16 +33,7 @@ use matrix_sdk_common::{ AnySyncRoomEvent, SyncMessageEvent, }, identifiers::{DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId}, - locks::Mutex, - Raw, -}; -pub use olm_rs::{ - account::IdentityKeys, - session::{OlmMessage, PreKeyMessage}, - utility::OlmUtility, -}; -use olm_rs::{ - errors::OlmGroupSessionError, inbound_group_session::OlmInboundGroupSession, PicklingMode, + serde::Raw, }; use serde::{Deserialize, Serialize}; use serde_json::Value; diff --git a/matrix_sdk_crypto/src/olm/group_sessions/mod.rs b/matrix_sdk_crypto/src/olm/group_sessions/mod.rs index 89cac84a..f1ea29d2 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/mod.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/mod.rs @@ -14,11 +14,11 @@ use std::{collections::BTreeMap, convert::TryInto}; -use matrix_sdk_common::{ +use ruma::{ events::forwarded_room_key::{ ForwardedRoomKeyToDeviceEventContent, ForwardedRoomKeyToDeviceEventContentInit, }, - identifiers::{DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId}, + DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId, }; use serde::{Deserialize, Serialize}; use zeroize::Zeroize; @@ -130,9 +130,9 @@ mod test { time::{Duration, Instant}, }; - use matrix_sdk_common::{ + use ruma::{ events::{room::message::MessageEventContent, AnyMessageEventContent}, - identifiers::{room_id, user_id}, + room_id, user_id, }; use super::EncryptionSettings; diff --git a/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs b/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs index efca136a..513e81da 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/outbound.rs @@ -24,8 +24,17 @@ use std::{ }; use dashmap::DashMap; -use matrix_sdk_common::{ - api::r0::to_device::DeviceIdOrAllDevices, +use matrix_sdk_common::{instant::Instant, locks::Mutex, uuid::Uuid}; +pub use olm_rs::{ + account::IdentityKeys, + session::{OlmMessage, PreKeyMessage}, + utility::OlmUtility, +}; +use olm_rs::{ + errors::OlmGroupSessionError, outbound_group_session::OlmOutboundGroupSession, PicklingMode, +}; +use ruma::{ + api::client::r0::to_device::DeviceIdOrAllDevices, events::{ room::{ encrypted::{EncryptedEventContent, EncryptedEventScheme, MegolmV1AesSha2ContentInit}, @@ -35,18 +44,7 @@ use matrix_sdk_common::{ }, AnyMessageEventContent, EventContent, }, - identifiers::{DeviceId, DeviceIdBox, EventEncryptionAlgorithm, RoomId, UserId}, - instant::Instant, - locks::Mutex, - uuid::Uuid, -}; -pub use olm_rs::{ - account::IdentityKeys, - session::{OlmMessage, PreKeyMessage}, - utility::OlmUtility, -}; -use olm_rs::{ - errors::OlmGroupSessionError, outbound_group_session::OlmOutboundGroupSession, PicklingMode, + DeviceId, DeviceIdBox, EventEncryptionAlgorithm, RoomId, UserId, }; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; @@ -572,10 +570,9 @@ pub struct PickledOutboundGroupSession { mod test { use std::time::Duration; - use matrix_sdk_common::{ + use ruma::{ events::room::{encryption::EncryptionEventContent, history_visibility::HistoryVisibility}, - identifiers::EventEncryptionAlgorithm, - uint, + uint, EventEncryptionAlgorithm, }; use super::{EncryptionSettings, ROTATION_MESSAGES, ROTATION_PERIOD}; diff --git a/matrix_sdk_crypto/src/olm/mod.rs b/matrix_sdk_crypto/src/olm/mod.rs index 51f81fd3..e6fb4743 100644 --- a/matrix_sdk_crypto/src/olm/mod.rs +++ b/matrix_sdk_crypto/src/olm/mod.rs @@ -61,12 +61,12 @@ where pub(crate) mod test { use std::{collections::BTreeMap, convert::TryInto}; - use matrix_sdk_common::{ - api::r0::keys::SignedKey, - events::forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, - identifiers::{room_id, user_id, DeviceId, UserId}, - }; use olm_rs::session::OlmMessage; + use ruma::{ + api::client::r0::keys::SignedKey, + events::forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, room_id, user_id, + DeviceId, UserId, + }; use crate::olm::{InboundGroupSession, ReadOnlyAccount, Session}; diff --git a/matrix_sdk_crypto/src/olm/session.rs b/matrix_sdk_crypto/src/olm/session.rs index 586e7d02..be34a376 100644 --- a/matrix_sdk_crypto/src/olm/session.rs +++ b/matrix_sdk_crypto/src/olm/session.rs @@ -14,7 +14,13 @@ use std::{collections::BTreeMap, fmt, sync::Arc}; -use matrix_sdk_common::{ +use matrix_sdk_common::{instant::Instant, locks::Mutex}; +use olm_rs::{errors::OlmSessionError, session::OlmSession, PicklingMode}; +pub use olm_rs::{ + session::{OlmMessage, PreKeyMessage}, + utility::OlmUtility, +}; +use ruma::{ events::{ room::encrypted::{ CiphertextInfo, EncryptedEventContent, EncryptedEventScheme, @@ -23,13 +29,6 @@ use matrix_sdk_common::{ EventType, }, identifiers::{DeviceId, DeviceKeyAlgorithm, UserId}, - instant::Instant, - locks::Mutex, -}; -use olm_rs::{errors::OlmSessionError, session::OlmSession, PicklingMode}; -pub use olm_rs::{ - session::{OlmMessage, PreKeyMessage}, - utility::OlmUtility, }; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; diff --git a/matrix_sdk_crypto/src/olm/signing/mod.rs b/matrix_sdk_crypto/src/olm/signing/mod.rs index bbeacff6..8b1de7f2 100644 --- a/matrix_sdk_crypto/src/olm/signing/mod.rs +++ b/matrix_sdk_crypto/src/olm/signing/mod.rs @@ -22,13 +22,13 @@ use std::{ }, }; -use matrix_sdk_common::{ - api::r0::keys::{upload_signatures::Request as SignatureUploadRequest, KeyUsage}, - encryption::DeviceKeys, - identifiers::{DeviceKeyAlgorithm, DeviceKeyId, UserId}, - locks::Mutex, -}; +use matrix_sdk_common::locks::Mutex; use pk_signing::{MasterSigning, PickledSignings, SelfSigning, Signing, SigningError, UserSigning}; +use ruma::{ + api::client::r0::keys::{upload_signatures::Request as SignatureUploadRequest, KeyUsage}, + encryption::DeviceKeys, + DeviceKeyAlgorithm, DeviceKeyId, UserId, +}; use serde::{Deserialize, Serialize}; use serde_json::Error as JsonError; @@ -387,11 +387,8 @@ impl PrivateCrossSigningIdentity { mod test { use std::{collections::BTreeMap, sync::Arc}; - use matrix_sdk_common::{ - api::r0::keys::CrossSigningKey, - identifiers::{user_id, UserId}, - }; use matrix_sdk_test::async_test; + use ruma::{api::client::r0::keys::CrossSigningKey, user_id, UserId}; use super::{PrivateCrossSigningIdentity, Signing}; use crate::{ diff --git a/matrix_sdk_crypto/src/olm/signing/pk_signing.rs b/matrix_sdk_crypto/src/olm/signing/pk_signing.rs index 419fccd9..0da882d3 100644 --- a/matrix_sdk_crypto/src/olm/signing/pk_signing.rs +++ b/matrix_sdk_crypto/src/olm/signing/pk_signing.rs @@ -19,16 +19,16 @@ use aes_gcm::{ Aes256Gcm, }; use getrandom::getrandom; -use matrix_sdk_common::{ - api::r0::keys::{CrossSigningKey, KeyUsage}, - encryption::DeviceKeys, - identifiers::{DeviceKeyAlgorithm, DeviceKeyId, UserId}, - locks::Mutex, - CanonicalJsonValue, -}; +use matrix_sdk_common::locks::Mutex; use olm_rs::pk::OlmPkSigning; #[cfg(test)] use olm_rs::{errors::OlmUtilityError, utility::OlmUtility}; +use ruma::{ + api::client::r0::keys::{CrossSigningKey, KeyUsage}, + encryption::DeviceKeys, + serde::CanonicalJsonValue, + DeviceKeyAlgorithm, DeviceKeyId, UserId, +}; use serde::{Deserialize, Serialize}; use serde_json::{json, Error as JsonError, Value}; use thiserror::Error; diff --git a/matrix_sdk_crypto/src/olm/utility.rs b/matrix_sdk_crypto/src/olm/utility.rs index 95bd4d99..49922d18 100644 --- a/matrix_sdk_crypto/src/olm/utility.rs +++ b/matrix_sdk_crypto/src/olm/utility.rs @@ -14,11 +14,8 @@ use std::convert::TryInto; -use matrix_sdk_common::{ - identifiers::{DeviceKeyAlgorithm, DeviceKeyId, UserId}, - CanonicalJsonValue, -}; use olm_rs::utility::OlmUtility; +use ruma::{serde::CanonicalJsonValue, DeviceKeyAlgorithm, DeviceKeyId, UserId}; use serde_json::Value; use crate::error::SignatureError; @@ -97,7 +94,7 @@ impl Utility { #[cfg(test)] mod test { - use matrix_sdk_common::identifiers::{user_id, DeviceKeyAlgorithm, DeviceKeyId}; + use ruma::{user_id, DeviceKeyAlgorithm, DeviceKeyId}; use serde_json::json; use super::Utility; diff --git a/matrix_sdk_crypto/src/requests.rs b/matrix_sdk_crypto/src/requests.rs index 17e853c6..fc3faa9b 100644 --- a/matrix_sdk_crypto/src/requests.rs +++ b/matrix_sdk_crypto/src/requests.rs @@ -16,8 +16,9 @@ use std::{collections::BTreeMap, sync::Arc, time::Duration}; -use matrix_sdk_common::{ - api::r0::{ +use matrix_sdk_common::uuid::Uuid; +use ruma::{ + api::client::r0::{ keys::{ claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse, @@ -32,15 +33,14 @@ use matrix_sdk_common::{ to_device::{send_event_to_device::Response as ToDeviceResponse, DeviceIdOrAllDevices}, }, events::{AnyMessageEventContent, EventType}, - identifiers::{DeviceIdBox, RoomId, UserId}, - uuid::Uuid, + DeviceIdBox, RoomId, UserId, }; use serde::{Deserialize, Serialize}; use serde_json::value::RawValue as RawJsonValue; /// Customized version of -/// `ruma_client_api::r0::to_device::send_event_to_device::Request`, using a -/// UUID for the transaction ID. +/// `ruma_client_api::r0::to_device::send_event_to_device::Request`, +/// using a UUID for the transaction ID. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ToDeviceRequest { /// Type of event being sent to each device. @@ -91,8 +91,9 @@ pub struct UploadSigningKeysRequest { pub user_signing_key: Option, } -/// Customized version of `ruma_client_api::r0::keys::get_keys::Request`, -/// without any references. +/// Customized version of +/// `ruma_client_api::r0::keys::get_keys::Request`, without any +/// references. #[derive(Clone, Debug)] pub struct KeysQueryRequest { /// The time (in milliseconds) to wait when downloading keys from remote diff --git a/matrix_sdk_crypto/src/session_manager/group_sessions.rs b/matrix_sdk_crypto/src/session_manager/group_sessions.rs index b1d2ce6c..26269716 100644 --- a/matrix_sdk_crypto/src/session_manager/group_sessions.rs +++ b/matrix_sdk_crypto/src/session_manager/group_sessions.rs @@ -19,15 +19,14 @@ use std::{ use dashmap::DashMap; use futures::future::join_all; -use matrix_sdk_common::{ - api::r0::to_device::DeviceIdOrAllDevices, +use matrix_sdk_common::{executor::spawn, uuid::Uuid}; +use ruma::{ + api::client::r0::to_device::DeviceIdOrAllDevices, events::{ room::{encrypted::EncryptedEventContent, history_visibility::HistoryVisibility}, AnyMessageEventContent, EventType, }, - executor::spawn, - identifiers::{DeviceId, DeviceIdBox, RoomId, UserId}, - uuid::Uuid, + DeviceId, DeviceIdBox, RoomId, UserId, }; use serde_json::Value; use tracing::{debug, info, trace}; @@ -544,13 +543,15 @@ impl GroupSessionManager { #[cfg(test)] mod test { - use matrix_sdk_common::{ - api::r0::keys::{claim_keys, get_keys}, - identifiers::{room_id, user_id, DeviceIdBox, UserId}, - uuid::Uuid, - IncomingResponse, - }; + use matrix_sdk_common::uuid::Uuid; use matrix_sdk_test::response_from_file; + use ruma::{ + api::{ + client::r0::keys::{claim_keys, get_keys}, + IncomingResponse, + }, + room_id, user_id, DeviceIdBox, UserId, + }; use serde_json::Value; use crate::{EncryptionSettings, OlmMachine}; diff --git a/matrix_sdk_crypto/src/session_manager/sessions.rs b/matrix_sdk_crypto/src/session_manager/sessions.rs index e0634051..657de170 100644 --- a/matrix_sdk_crypto/src/session_manager/sessions.rs +++ b/matrix_sdk_crypto/src/session_manager/sessions.rs @@ -15,15 +15,15 @@ use std::{collections::BTreeMap, sync::Arc, time::Duration}; use dashmap::{DashMap, DashSet}; -use matrix_sdk_common::{ - api::r0::{ +use matrix_sdk_common::uuid::Uuid; +use ruma::{ + api::client::r0::{ keys::claim_keys::{Request as KeysClaimRequest, Response as KeysClaimResponse}, to_device::DeviceIdOrAllDevices, }, assign, events::EventType, - identifiers::{DeviceId, DeviceIdBox, DeviceKeyAlgorithm, UserId}, - uuid::Uuid, + DeviceId, DeviceIdBox, DeviceKeyAlgorithm, UserId, }; use serde_json::{json, value::to_raw_value}; use tracing::{error, info, warn}; @@ -297,12 +297,12 @@ mod test { use std::{collections::BTreeMap, sync::Arc}; use dashmap::DashMap; - use matrix_sdk_common::{ - api::r0::keys::claim_keys::Response as KeyClaimResponse, - identifiers::{user_id, DeviceIdBox, UserId}, - locks::Mutex, - }; + use matrix_sdk_common::locks::Mutex; use matrix_sdk_test::async_test; + use ruma::{ + api::client::r0::keys::claim_keys::Response as KeyClaimResponse, user_id, DeviceIdBox, + UserId, + }; use super::SessionManager; use crate::{ @@ -401,10 +401,8 @@ mod test { #[async_test] #[cfg(target_os = "linux")] async fn session_unwedging() { - use matrix_sdk_common::{ - identifiers::DeviceKeyAlgorithm, - instant::{Duration, Instant}, - }; + use matrix_sdk_common::instant::{Duration, Instant}; + use ruma::DeviceKeyAlgorithm; let manager = session_manager().await; let bob = bob_account(); diff --git a/matrix_sdk_crypto/src/store/caches.rs b/matrix_sdk_crypto/src/store/caches.rs index 0fba1cfa..abdd972c 100644 --- a/matrix_sdk_crypto/src/store/caches.rs +++ b/matrix_sdk_crypto/src/store/caches.rs @@ -20,10 +20,8 @@ use std::{collections::HashMap, sync::Arc}; use dashmap::DashMap; -use matrix_sdk_common::{ - identifiers::{DeviceId, DeviceIdBox, RoomId, UserId}, - locks::Mutex, -}; +use matrix_sdk_common::locks::Mutex; +use ruma::{DeviceId, DeviceIdBox, RoomId, UserId}; use crate::{ identities::ReadOnlyDevice, @@ -184,7 +182,7 @@ impl DeviceStore { #[cfg(test)] mod test { - use matrix_sdk_common::identifiers::room_id; + use ruma::room_id; use crate::{ identities::device::test::get_device, diff --git a/matrix_sdk_crypto/src/store/memorystore.rs b/matrix_sdk_crypto/src/store/memorystore.rs index 1b3804c5..348b0c79 100644 --- a/matrix_sdk_crypto/src/store/memorystore.rs +++ b/matrix_sdk_crypto/src/store/memorystore.rs @@ -18,13 +18,8 @@ use std::{ }; use dashmap::{DashMap, DashSet}; -use matrix_sdk_common::{ - async_trait, - events::room_key_request::RequestedKeyInfo, - identifiers::{DeviceId, DeviceIdBox, RoomId, UserId}, - locks::Mutex, - uuid::Uuid, -}; +use matrix_sdk_common::{async_trait, locks::Mutex, uuid::Uuid}; +use ruma::{events::room_key_request::RequestedKeyInfo, DeviceId, DeviceIdBox, RoomId, UserId}; use super::{ caches::{DeviceStore, GroupSessionStore, SessionStore}, @@ -273,7 +268,7 @@ impl CryptoStore for MemoryStore { #[cfg(test)] mod test { - use matrix_sdk_common::identifiers::room_id; + use ruma::room_id; use crate::{ identities::device::test::get_device, diff --git a/matrix_sdk_crypto/src/store/mod.rs b/matrix_sdk_crypto/src/store/mod.rs index c22a7281..1f41609d 100644 --- a/matrix_sdk_crypto/src/store/mod.rs +++ b/matrix_sdk_crypto/src/store/mod.rs @@ -26,7 +26,7 @@ //! # OlmMachine, //! # store::MemoryStore, //! # }; -//! # use matrix_sdk_common::identifiers::{user_id, DeviceIdBox}; +//! # use ruma::{user_id, DeviceIdBox}; //! # let user_id = user_id!("@example:localhost"); //! # let device_id: DeviceIdBox = "TEST".into(); //! let store = Box::new(MemoryStore::new()); @@ -51,20 +51,17 @@ use std::{ sync::Arc, }; -use matrix_sdk_common::{ - async_trait, +use matrix_sdk_common::{async_trait, locks::Mutex, uuid::Uuid, AsyncTraitDeps}; +pub use memorystore::MemoryStore; +use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError}; +pub use pickle_key::{EncryptedPickleKey, PickleKey}; +use ruma::{ events::room_key_request::RequestedKeyInfo, identifiers::{ DeviceId, DeviceIdBox, DeviceKeyAlgorithm, Error as IdentifierValidationError, RoomId, UserId, }, - locks::Mutex, - uuid::Uuid, - AsyncTraitDeps, }; -pub use memorystore::MemoryStore; -use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError}; -pub use pickle_key::{EncryptedPickleKey, PickleKey}; use serde_json::Error as SerdeError; use thiserror::Error; diff --git a/matrix_sdk_crypto/src/store/sled.rs b/matrix_sdk_crypto/src/store/sled.rs index 90117cfd..afa41a05 100644 --- a/matrix_sdk_crypto/src/store/sled.rs +++ b/matrix_sdk_crypto/src/store/sled.rs @@ -20,14 +20,9 @@ use std::{ }; use dashmap::DashSet; -use matrix_sdk_common::{ - async_trait, - events::room_key_request::RequestedKeyInfo, - identifiers::{DeviceId, DeviceIdBox, RoomId, UserId}, - locks::Mutex, - uuid, -}; +use matrix_sdk_common::{async_trait, locks::Mutex, uuid}; use olm_rs::{account::IdentityKeys, PicklingMode}; +use ruma::{events::room_key_request::RequestedKeyInfo, DeviceId, DeviceIdBox, RoomId, UserId}; pub use sled::Error; use sled::{ transaction::{ConflictableTransactionError, TransactionError}, @@ -758,14 +753,14 @@ impl CryptoStore for SledStore { mod test { use std::collections::BTreeMap; - use matrix_sdk_common::{ - api::r0::keys::SignedKey, - events::room_key_request::RequestedKeyInfo, - identifiers::{room_id, user_id, DeviceId, EventEncryptionAlgorithm, UserId}, - uuid::Uuid, - }; + use matrix_sdk_common::uuid::Uuid; use matrix_sdk_test::async_test; use olm_rs::outbound_group_session::OlmOutboundGroupSession; + use ruma::{ + api::client::r0::keys::SignedKey, + events::room_key_request::RequestedKeyInfo, + identifiers::{room_id, user_id, DeviceId, EventEncryptionAlgorithm, UserId}, + }; use tempfile::tempdir; use super::{CryptoStore, OutgoingKeyRequest, SledStore}; diff --git a/matrix_sdk_crypto/src/verification/cache.rs b/matrix_sdk_crypto/src/verification/cache.rs index 1d42b711..975f9fd6 100644 --- a/matrix_sdk_crypto/src/verification/cache.rs +++ b/matrix_sdk_crypto/src/verification/cache.rs @@ -15,10 +15,8 @@ use std::sync::Arc; use dashmap::DashMap; -use matrix_sdk_common::{ - identifiers::{DeviceId, UserId}, - uuid::Uuid, -}; +use matrix_sdk_common::uuid::Uuid; +use ruma::{DeviceId, UserId}; use super::{event_enums::OutgoingContent, sas::content_to_request, Sas, Verification}; use crate::{OutgoingRequest, RoomMessageRequest}; diff --git a/matrix_sdk_crypto/src/verification/event_enums.rs b/matrix_sdk_crypto/src/verification/event_enums.rs index f787b00f..c623a29a 100644 --- a/matrix_sdk_crypto/src/verification/event_enums.rs +++ b/matrix_sdk_crypto/src/verification/event_enums.rs @@ -17,7 +17,7 @@ use std::{ convert::{TryFrom, TryInto}, }; -use matrix_sdk_common::{ +use ruma::{ events::{ key::verification::{ accept::{AcceptEventContent, AcceptMethod, AcceptToDeviceEventContent}, @@ -34,7 +34,7 @@ use matrix_sdk_common::{ AnyMessageEvent, AnyMessageEventContent, AnyToDeviceEvent, AnyToDeviceEventContent, }, identifiers::{DeviceId, RoomId, UserId}, - CanonicalJsonValue, + serde::CanonicalJsonValue, }; use super::FlowId; @@ -676,7 +676,7 @@ impl TryFrom for OutgoingContent { type Error = (); fn try_from(value: ToDeviceRequest) -> Result { - use matrix_sdk_common::events::EventType; + use ruma::events::EventType; use serde_json::Value; let json: Value = serde_json::from_str( diff --git a/matrix_sdk_crypto/src/verification/machine.rs b/matrix_sdk_crypto/src/verification/machine.rs index f474e220..371c78de 100644 --- a/matrix_sdk_crypto/src/verification/machine.rs +++ b/matrix_sdk_crypto/src/verification/machine.rs @@ -15,11 +15,8 @@ use std::{convert::TryFrom, sync::Arc}; use dashmap::DashMap; -use matrix_sdk_common::{ - identifiers::{DeviceId, UserId}, - locks::Mutex, - uuid::Uuid, -}; +use matrix_sdk_common::{locks::Mutex, uuid::Uuid}; +use ruma::{DeviceId, UserId}; use tracing::{info, warn}; use super::{ @@ -314,10 +311,8 @@ mod test { time::{Duration, Instant}, }; - use matrix_sdk_common::{ - identifiers::{DeviceId, UserId}, - locks::Mutex, - }; + use matrix_sdk_common::locks::Mutex; + use ruma::{DeviceId, UserId}; use super::{Sas, VerificationMachine}; use crate::{ diff --git a/matrix_sdk_crypto/src/verification/mod.rs b/matrix_sdk_crypto/src/verification/mod.rs index b237fec2..736b9656 100644 --- a/matrix_sdk_crypto/src/verification/mod.rs +++ b/matrix_sdk_crypto/src/verification/mod.rs @@ -22,8 +22,9 @@ use std::sync::Arc; use event_enums::OutgoingContent; pub use machine::VerificationMachine; -use matrix_sdk_common::{ - api::r0::keys::upload_signatures::Request as SignatureUploadRequest, +pub use requests::VerificationRequest; +use ruma::{ + api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest, events::{ key::verification::{ cancel::{CancelCode, CancelEventContent, CancelToDeviceEventContent}, @@ -32,9 +33,8 @@ use matrix_sdk_common::{ }, AnyMessageEventContent, AnyToDeviceEventContent, }, - identifiers::{DeviceId, EventId, RoomId, UserId}, + DeviceId, EventId, RoomId, UserId, }; -pub use requests::VerificationRequest; pub use sas::{AcceptSettings, Sas}; use tracing::{error, info, trace, warn}; @@ -445,9 +445,9 @@ impl IdentitiesBeingVerified { #[cfg(test)] pub(crate) mod test { - use matrix_sdk_common::{ + use ruma::{ events::{AnyToDeviceEvent, AnyToDeviceEventContent, EventType, ToDeviceEvent}, - identifiers::UserId, + UserId, }; use serde_json::Value; diff --git a/matrix_sdk_crypto/src/verification/requests.rs b/matrix_sdk_crypto/src/verification/requests.rs index ea41d749..819d2dc4 100644 --- a/matrix_sdk_crypto/src/verification/requests.rs +++ b/matrix_sdk_crypto/src/verification/requests.rs @@ -16,8 +16,9 @@ use std::sync::{Arc, Mutex}; -use matrix_sdk_common::{ - api::r0::to_device::DeviceIdOrAllDevices, +use matrix_sdk_common::uuid::Uuid; +use ruma::{ + api::client::r0::to_device::DeviceIdOrAllDevices, events::{ key::verification::{ cancel::CancelCode, @@ -29,9 +30,7 @@ use matrix_sdk_common::{ room::message::KeyVerificationRequestEventContent, AnyMessageEventContent, AnyToDeviceEventContent, }, - identifiers::{DeviceId, DeviceIdBox, EventId, RoomId, UserId}, - uuid::Uuid, - MilliSecondsSinceUnixEpoch, + DeviceId, DeviceIdBox, EventId, MilliSecondsSinceUnixEpoch, RoomId, UserId, }; use tracing::{info, warn}; @@ -677,8 +676,8 @@ struct Done {} mod test { use std::convert::TryFrom; - use matrix_sdk_common::identifiers::{event_id, room_id, DeviceIdBox, UserId}; use matrix_sdk_test::async_test; + use ruma::{event_id, room_id, DeviceIdBox, UserId}; use super::VerificationRequest; use crate::{ diff --git a/matrix_sdk_crypto/src/verification/sas/helpers.rs b/matrix_sdk_crypto/src/verification/sas/helpers.rs index fd365037..4d4794e5 100644 --- a/matrix_sdk_crypto/src/verification/sas/helpers.rs +++ b/matrix_sdk_crypto/src/verification/sas/helpers.rs @@ -14,8 +14,10 @@ use std::{collections::BTreeMap, convert::TryInto}; -use matrix_sdk_common::{ - api::r0::to_device::DeviceIdOrAllDevices, +use matrix_sdk_common::uuid::Uuid; +use olm_rs::sas::OlmSas; +use ruma::{ + api::client::r0::to_device::DeviceIdOrAllDevices, events::{ key::verification::{ cancel::CancelCode, @@ -24,10 +26,8 @@ use matrix_sdk_common::{ }, AnyMessageEventContent, AnyToDeviceEventContent, EventType, }, - identifiers::{DeviceKeyAlgorithm, DeviceKeyId, UserId}, - uuid::Uuid, + DeviceKeyAlgorithm, DeviceKeyId, UserId, }; -use olm_rs::sas::OlmSas; use sha2::{Digest, Sha256}; use tracing::{trace, warn}; @@ -557,8 +557,8 @@ pub fn content_to_request( #[cfg(test)] mod test { - use matrix_sdk_common::events::key::verification::start::StartToDeviceEventContent; use proptest::prelude::*; + use ruma::events::key::verification::start::StartToDeviceEventContent; use serde_json::json; use super::{ diff --git a/matrix_sdk_crypto/src/verification/sas/inner_sas.rs b/matrix_sdk_crypto/src/verification/sas/inner_sas.rs index c509cca9..b9b37475 100644 --- a/matrix_sdk_crypto/src/verification/sas/inner_sas.rs +++ b/matrix_sdk_crypto/src/verification/sas/inner_sas.rs @@ -16,9 +16,9 @@ use std::sync::Arc; #[cfg(test)] use std::time::Instant; -use matrix_sdk_common::{ +use ruma::{ events::key::verification::{cancel::CancelCode, ShortAuthenticationString}, - identifiers::{EventId, RoomId, UserId}, + EventId, RoomId, UserId, }; use super::{ diff --git a/matrix_sdk_crypto/src/verification/sas/mod.rs b/matrix_sdk_crypto/src/verification/sas/mod.rs index 827c62dc..d8b0330f 100644 --- a/matrix_sdk_crypto/src/verification/sas/mod.rs +++ b/matrix_sdk_crypto/src/verification/sas/mod.rs @@ -22,8 +22,9 @@ use std::time::Instant; pub use helpers::content_to_request; use inner_sas::InnerSas; -use matrix_sdk_common::{ - api::r0::keys::upload_signatures::Request as SignatureUploadRequest, +use matrix_sdk_common::uuid::Uuid; +use ruma::{ + api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest, events::{ key::verification::{ accept::{AcceptEventContent, AcceptMethod, AcceptToDeviceEventContent}, @@ -32,8 +33,7 @@ use matrix_sdk_common::{ }, AnyMessageEventContent, AnyToDeviceEventContent, }, - identifiers::{DeviceId, EventId, RoomId, UserId}, - uuid::Uuid, + DeviceId, EventId, RoomId, UserId, }; use tracing::trace; @@ -486,7 +486,7 @@ impl AcceptSettings { mod test { use std::{convert::TryFrom, sync::Arc}; - use matrix_sdk_common::identifiers::{DeviceId, UserId}; + use ruma::{DeviceId, UserId}; use super::Sas; use crate::{ diff --git a/matrix_sdk_crypto/src/verification/sas/sas_state.rs b/matrix_sdk_crypto/src/verification/sas/sas_state.rs index ac571309..96373f38 100644 --- a/matrix_sdk_crypto/src/verification/sas/sas_state.rs +++ b/matrix_sdk_crypto/src/verification/sas/sas_state.rs @@ -19,7 +19,9 @@ use std::{ time::{Duration, Instant}, }; -use matrix_sdk_common::{ +use matrix_sdk_common::uuid::Uuid; +use olm_rs::sas::OlmSas; +use ruma::{ events::{ key::verification::{ accept::{ @@ -38,10 +40,8 @@ use matrix_sdk_common::{ }, AnyMessageEventContent, AnyToDeviceEventContent, }, - identifiers::{DeviceId, EventId, RoomId, UserId}, - uuid::Uuid, + DeviceId, EventId, RoomId, UserId, }; -use olm_rs::sas::OlmSas; use tracing::info; use super::{ @@ -1088,12 +1088,12 @@ impl SasState { mod test { use std::convert::TryFrom; - use matrix_sdk_common::{ + use ruma::{ events::key::verification::{ accept::{AcceptMethod, CustomContent}, start::{CustomContent as CustomStartContent, StartMethod}, }, - identifiers::{DeviceId, UserId}, + DeviceId, UserId, }; use super::{Accepted, Created, SasState, Started};