crypto: Depend on ruma directly

… instead of using matrix_sdk_common's re-exports
This commit is contained in:
Jonas Platte 2021-06-07 14:47:59 +02:00
parent 3bac536daf
commit 74d0ac7c77
No known key found for this signature in database
GPG key ID: CC154DE0E30B7C67
35 changed files with 222 additions and 256 deletions

View file

@ -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"

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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};

View file

@ -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::{

View file

@ -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::{

View file

@ -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::{

View file

@ -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<DeviceKeyId, OneTimeKey>;
use matrix_sdk_common::uint;
fn alice_id() -> UserId {
user_id!("@alice:example.org")
}

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -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};

View file

@ -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};

View file

@ -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};

View file

@ -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::{

View file

@ -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;

View file

@ -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;

View file

@ -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<CrossSigningKey>,
}
/// 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

View file

@ -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};

View file

@ -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();

View file

@ -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,

View file

@ -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,

View file

@ -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;

View file

@ -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};

View file

@ -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};

View file

@ -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<ToDeviceRequest> for OutgoingContent {
type Error = ();
fn try_from(value: ToDeviceRequest) -> Result<Self, Self::Error> {
use matrix_sdk_common::events::EventType;
use ruma::events::EventType;
use serde_json::Value;
let json: Value = serde_json::from_str(

View file

@ -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::{

View file

@ -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;

View file

@ -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::{

View file

@ -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::{

View file

@ -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::{

View file

@ -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::{

View file

@ -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<Cancelled> {
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};