matrix-sdk: Split out the crypto part of the sdk into a separate crate.

master
Damir Jelić 2020-04-29 09:48:00 +02:00
parent cf9ecbd0e8
commit 5fef444d61
71 changed files with 250 additions and 158 deletions

View File

@ -1,68 +1,6 @@
[package]
authors = ["Damir Jelić <poljar@termina.org.uk"]
description = "A high level Matrix client-server library."
edition = "2018"
homepage = "https://github.com/matrix-org/matrix-rust-sdk"
keywords = ["matrix", "chat", "messaging", "ruma", "nio"]
license = "Apache-2.0"
name = "matrix-sdk"
readme = "README.md"
repository = "https://github.com/matrix-org/matrix-rust-sdk"
version = "0.1.0"
[features]
default = []
encryption = ["olm-rs", "serde/derive", "serde_json", "cjson", "zeroize"]
sqlite-cryptostore = ["sqlx", "zeroize"]
[dependencies]
futures = "0.3.4"
reqwest = "0.10.4"
http = "0.2.1"
url = "2.1.1"
async-trait = "0.1.30"
# Ruma dependencies
js_int = "0.1.5"
ruma-api = "0.16.0-rc.2"
ruma-client-api = { version = "0.8.0-rc.5" }
ruma-events = { version = "0.21.0-beta.1" }
ruma-identifiers = "0.16.0"
uuid = { version = "0.8.1", features = ["v4"] }
# Dependencies for the encryption support
olm-rs = { version = "0.5.0", optional = true, features = ["serde"]}
serde = { version = "1.0.106", optional = true, features = ["derive"] }
serde_json = { version = "1.0.51", optional = true }
cjson = { version = "0.1.0", optional = true }
zeroize = { version = "1.1.0", optional = true, features = ["zeroize_derive"] }
# Misc dependencies
thiserror = "1.0.14"
tracing = "0.1.13"
atomic = "0.4.5"
dashmap = "3.10.0"
[dependencies.tracing-futures]
version = "0.2.3"
default-features = false
features = ["std", "std-future"]
[dependencies.tokio]
version = "0.2.16"
default-features = false
features = ["sync", "time"]
[dependencies.sqlx]
version = "0.3.3"
optional = true
default-features = false
features = ["runtime-tokio", "sqlite"]
[dev-dependencies]
tokio = { version = "0.2.16", features = ["rt-threaded", "macros"] }
ruma-identifiers = { version = "0.16.0", features = ["rand"] }
serde_json = "1.0.51"
tracing-subscriber = "0.2.4"
tempfile = "3.1.0"
mockito = "0.25.1"
[workspace]
members = [
"matrix_sdk",
"matrix_sdk_crypto",
"matrix_sdk_types",
]

View File

@ -1,12 +1,12 @@
all: build
build:
cargo build --features 'encryption sqlite-cryptostore'
cargo build
test:
cargo test --features 'encryption sqlite-cryptostore'
cargo test
coverage:
cargo tarpaulin --features 'encryption sqlite-cryptostore' -v
cargo tarpaulin -v
clean:
cargo clean

64
matrix_sdk/Cargo.toml Normal file
View File

@ -0,0 +1,64 @@
[package]
authors = ["Damir Jelić <poljar@termina.org.uk"]
description = "A high level Matrix client-server library."
edition = "2018"
homepage = "https://github.com/matrix-org/matrix-rust-sdk"
keywords = ["matrix", "chat", "messaging", "ruma", "nio"]
license = "Apache-2.0"
name = "matrix-sdk"
readme = "README.md"
repository = "https://github.com/matrix-org/matrix-rust-sdk"
version = "0.1.0"
[features]
default = ["encryption", "sqlite-cryptostore"]
encryption = ["matrix-sdk-crypto"]
sqlite-cryptostore = ["matrix-sdk-crypto/sqlite-cryptostore"]
[dependencies]
futures = "0.3.4"
reqwest = "0.10.4"
http = "0.2.1"
url = "2.1.1"
async-trait = "0.1.30"
matrix-sdk-types = { path = "../matrix_sdk_types" }
matrix-sdk-crypto = { path = "../matrix_sdk_crypto", optional = true }
# Ruma dependencies
js_int = "0.1.5"
ruma-api = "0.16.0-rc.2"
ruma-client-api = { version = "0.8.0-rc.5" }
ruma-events = { version = "0.21.0-beta.1" }
ruma-identifiers = "0.16.0"
uuid = { version = "0.8.1", features = ["v4"] }
# Misc dependencies
thiserror = "1.0.14"
tracing = "0.1.13"
atomic = "0.4.5"
dashmap = "3.10.0"
[dependencies.tracing-futures]
version = "0.2.3"
default-features = false
features = ["std", "std-future"]
[dependencies.tokio]
version = "0.2.16"
default-features = false
features = ["sync", "time"]
[dependencies.sqlx]
version = "0.3.3"
optional = true
default-features = false
features = ["runtime-tokio", "sqlite"]
[dev-dependencies]
tokio = { version = "0.2.16", features = ["rt-threaded", "macros"] }
ruma-identifiers = { version = "0.16.0", features = ["rand"] }
serde_json = "1.0.51"
tracing-subscriber = "0.2.4"
tempfile = "3.1.0"
mockito = "0.25.1"

View File

@ -1116,9 +1116,9 @@ mod test {
let uid = UserId::try_from("@example:localhost").unwrap();
let mut bld = EventBuilder::default()
.add_room_event_from_file("./tests/data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file("../test_data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file(
"./tests/data/events/power_levels.json",
"../test_data/events/power_levels.json",
RoomEvent::RoomPowerLevels,
)
.build_client_runner(rid, uid);
@ -1145,9 +1145,9 @@ mod test {
let client = AsyncClient::new(homeserver, Some(session)).unwrap();
let mut bld = EventBuilder::default()
.add_room_event_from_file("./tests/data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file("../test_data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file(
"./tests/data/events/power_levels.json",
"../test_data/events/power_levels.json",
RoomEvent::RoomPowerLevels,
)
.build_mock_runner(
@ -1169,7 +1169,7 @@ mod test {
let _m = mock("POST", "/_matrix/client/r0/login")
.with_status(403)
.with_body_from_file("tests/data/login_response_error.json")
.with_body_from_file("../test_data/login_response_error.json")
.create();
let client = AsyncClient::new(homeserver, None).unwrap();

View File

@ -41,7 +41,7 @@ use tokio::sync::Mutex;
use tokio::sync::RwLock;
#[cfg(feature = "encryption")]
use crate::crypto::{OlmMachine, OneTimeKeys};
use matrix_sdk_crypto::{OlmMachine, OneTimeKeys};
#[cfg(feature = "encryption")]
use ruma_client_api::r0::client_exchange::send_event_to_device;
#[cfg(feature = "encryption")]
@ -820,7 +820,7 @@ mod test {
Matcher::Regex(r"^/_matrix/client/r0/sync\?.*$".to_string()),
)
.with_status(200)
.with_body_from_file("tests/data/sync.json")
.with_body_from_file("../test_data/sync.json")
.create();
let client = AsyncClient::new(homeserver, Some(session)).unwrap();

View File

@ -23,7 +23,7 @@ use thiserror::Error;
use url::ParseError;
#[cfg(feature = "encryption")]
use crate::crypto::OlmError;
use matrix_sdk_crypto::OlmError;
/// Result type of the rust-sdk.
pub type Result<T> = std::result::Result<T, Error>;

View File

@ -238,7 +238,7 @@ mod test {
Matcher::Regex(r"^/_matrix/client/r0/sync\?.*$".to_string()),
)
.with_status(200)
.with_body_from_file("tests/data/sync.json")
.with_body_from_file("../test_data/sync.json")
.create();
let vec = Arc::new(Mutex::new(Vec::new()));

View File

@ -44,14 +44,11 @@ mod session;
#[cfg(test)]
pub mod test_builder;
#[cfg(feature = "encryption")]
mod crypto;
pub use async_client::{AsyncClient, AsyncClientConfig, SyncSettings};
pub use base_client::Client;
#[cfg(feature = "encryption")]
pub use crypto::{Device, TrustState};
pub use event_emitter::EventEmitter;
#[cfg(feature = "encryption")]
pub use matrix_sdk_crypto::{Device, TrustState};
pub use models::Room;
pub use request_builder::{MessagesRequestBuilder, RoomBuilder};

View File

@ -484,7 +484,7 @@ mod test {
Matcher::Regex(r"^/_matrix/client/r0/sync\?.*$".to_string()),
)
.with_status(200)
.with_body_from_file("tests/data/sync.json")
.with_body_from_file("../test_data/sync.json")
.create();
let client = AsyncClient::new(homeserver, Some(session)).unwrap();
@ -514,9 +514,9 @@ mod test {
let uid = UserId::try_from("@example:localhost").unwrap();
let mut bld = EventBuilder::default()
.add_room_event_from_file("./tests/data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file("../test_data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file(
"./tests/data/events/power_levels.json",
"../test_data/events/power_levels.json",
RoomEvent::RoomPowerLevels,
)
.build_room_runner(&rid, &uid);
@ -542,7 +542,7 @@ mod test {
let uid = UserId::try_from("@example:localhost").unwrap();
let mut bld = EventBuilder::default()
.add_state_event_from_file("./tests/data/events/aliases.json", StateEvent::RoomAliases)
.add_state_event_from_file("../test_data/events/aliases.json", StateEvent::RoomAliases)
.build_room_runner(&rid, &uid);
let room = bld.to_room();
@ -557,7 +557,7 @@ mod test {
let mut bld = EventBuilder::default()
.add_state_event_from_file(
"./tests/data/events/alias.json",
"../test_data/events/alias.json",
StateEvent::RoomCanonicalAlias,
)
.build_room_runner(&rid, &uid);
@ -573,7 +573,7 @@ mod test {
let uid = UserId::try_from("@example:localhost").unwrap();
let mut bld = EventBuilder::default()
.add_state_event_from_file("./tests/data/events/name.json", StateEvent::RoomName)
.add_state_event_from_file("../test_data/events/name.json", StateEvent::RoomName)
.build_room_runner(&rid, &uid);
let room = bld.to_room();
@ -587,7 +587,7 @@ mod test {
let mut bld = EventBuilder::default().build_with_response(
// this sync has no room.name or room.alias events so only relies on summary
"tests/data/sync_with_summary.json",
"../test_data/sync_with_summary.json",
"GET",
Matcher::Regex(r"^/_matrix/client/r0/sync\?.*$".to_string()),
);

View File

@ -199,9 +199,9 @@ mod test {
let rid = RoomId::try_from("!roomid:room.com").unwrap();
let uid = UserId::try_from("@example:localhost").unwrap();
let mut bld = EventBuilder::default()
.add_room_event_from_file("./tests/data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file("../test_data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file(
"./tests/data/events/power_levels.json",
"../test_data/events/power_levels.json",
RoomEvent::RoomPowerLevels,
)
.build_room_runner(&rid, &uid);
@ -220,12 +220,12 @@ mod test {
let rid = RoomId::try_from("!roomid:room.com").unwrap();
let uid = UserId::try_from("@example:localhost").unwrap();
let mut bld = EventBuilder::default()
.add_room_event_from_file("./tests/data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file("../test_data/events/member.json", RoomEvent::RoomMember)
.add_room_event_from_file(
"./tests/data/events/power_levels.json",
"../test_data/events/power_levels.json",
RoomEvent::RoomPowerLevels,
)
.add_presence_event_from_file("./tests/data/events/presence.json")
.add_presence_event_from_file("../test_data/events/presence.json")
.build_room_runner(&rid, &uid);
let room = bld.to_room();

View File

@ -307,7 +307,7 @@ mod test {
let _m = mock("POST", "/_matrix/client/r0/createRoom")
.with_status(200)
.with_body_from_file("./tests/data/room_id.json")
.with_body_from_file("../test_data/room_id.json")
.create();
let session = Session {
@ -354,7 +354,7 @@ mod test {
Matcher::Regex(r"^/_matrix/client/r0/rooms/.*/messages".to_string()),
)
.with_status(200)
.with_body_from_file("./tests/data/room_messages.json")
.with_body_from_file("../test_data/room_messages.json")
.create();
let session = Session {

View File

@ -14,7 +14,7 @@ async fn login() {
let _m = mock("POST", "/_matrix/client/r0/login")
.with_status(200)
.with_body_from_file("tests/data/login_response.json")
.with_body_from_file("../test_data/login_response.json")
.create();
let client = AsyncClient::new(homeserver, None).unwrap();
@ -43,7 +43,7 @@ async fn sync() {
Matcher::Regex(r"^/_matrix/client/r0/sync\?.*$".to_string()),
)
.with_status(200)
.with_body_from_file("tests/data/sync.json")
.with_body_from_file("../test_data/sync.json")
.create();
let client = AsyncClient::new(homeserver, Some(session)).unwrap();
@ -72,7 +72,7 @@ async fn room_names() {
Matcher::Regex(r"^/_matrix/client/r0/sync\?.*$".to_string()),
)
.with_status(200)
.with_body_from_file("tests/data/sync.json")
.with_body_from_file("../test_data/sync.json")
.create();
let client = AsyncClient::new(homeserver, Some(session)).unwrap();

View File

@ -0,0 +1,58 @@
[package]
authors = ["Damir Jelić <poljar@termina.org.uk"]
description = "Matrix encryption library"
edition = "2018"
homepage = "https://github.com/matrix-org/matrix-rust-sdk"
keywords = ["matrix", "chat", "messaging", "ruma", "nio"]
license = "Apache-2.0"
name = "matrix-sdk-crypto"
readme = "README.md"
repository = "https://github.com/matrix-org/matrix-rust-sdk"
version = "0.1.0"
[features]
default = []
sqlite-cryptostore = ["sqlx"]
[dependencies]
futures = "0.3.4"
async-trait = "0.1.30"
matrix-sdk-types = { path = "../matrix_sdk_types" }
olm-rs = { version = "0.5.0", features = ["serde"]}
serde = { version = "1.0.106", features = ["derive"] }
serde_json = { version = "1.0.51" }
cjson = { version = "0.1.0" }
zeroize = { version = "1.1.0", features = ["zeroize_derive"] }
uuid = { version = "0.8.1", features = ["v4"] }
url = "2.1.1"
# Misc dependencies
thiserror = "1.0.14"
tracing = "0.1.13"
atomic = "0.4.5"
dashmap = "3.10.0"
[dependencies.tracing-futures]
version = "0.2.3"
default-features = false
features = ["std", "std-future"]
[dependencies.tokio]
version = "0.2.16"
default-features = false
features = ["sync", "time"]
[dependencies.sqlx]
version = "0.3.3"
optional = true
default-features = false
features = ["runtime-tokio", "sqlite"]
[dev-dependencies]
tokio = { version = "0.2.16", features = ["rt-threaded", "macros"] }
ruma-identifiers = { version = "0.16.0", features = ["rand"] }
serde_json = "1.0.51"
tempfile = "3.1.0"
http = "*"

View File

@ -23,9 +23,9 @@ use atomic::Atomic;
#[cfg(test)]
use super::OlmMachine;
use crate::api::r0::keys::{DeviceKeys, KeyAlgorithm};
use crate::events::Algorithm;
use crate::identifiers::{DeviceId, UserId};
use matrix_sdk_types::api::r0::keys::{DeviceKeys, KeyAlgorithm};
use matrix_sdk_types::events::Algorithm;
use matrix_sdk_types::identifiers::{DeviceId, UserId};
/// A device represents a E2EE capable client of an user.
#[derive(Debug, Clone)]
@ -131,7 +131,7 @@ impl Device {
for (key_id, key) in device_keys.keys.iter() {
let key_id = key_id.0;
keys.insert(key_id, key.clone());
let _ = keys.insert(key_id, key.clone());
}
let display_name = Arc::new(
@ -141,12 +141,12 @@ impl Device {
.map(|d| d.device_display_name.clone()),
);
mem::replace(
let _ = mem::replace(
&mut self.algorithms,
Arc::new(device_keys.algorithms.clone()),
);
mem::replace(&mut self.keys, Arc::new(keys));
mem::replace(&mut self.display_name, display_name);
let _ = mem::replace(&mut self.keys, Arc::new(keys));
let _ = mem::replace(&mut self.display_name, display_name);
}
/// Mark the device as deleted.
@ -190,7 +190,7 @@ impl From<&DeviceKeys> for Device {
for (key_id, key) in device_keys.keys.iter() {
let key_id = key_id.0;
keys.insert(key_id, key.clone());
let _ = keys.insert(key_id, key.clone());
}
Device {
@ -221,9 +221,9 @@ pub(crate) mod test {
use serde_json::json;
use std::convert::{From, TryFrom};
use crate::api::r0::keys::{DeviceKeys, KeyAlgorithm};
use crate::crypto::device::{Device, TrustState};
use crate::identifiers::UserId;
use crate::device::{Device, TrustState};
use matrix_sdk_types::api::r0::keys::{DeviceKeys, KeyAlgorithm};
use matrix_sdk_types::identifiers::UserId;
fn device_keys() -> DeviceKeys {
let user_id = UserId::try_from("@alice:example.org").unwrap();

View File

@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! This is the encryption part of the matrix-sdk. It contains a state machine
//! that will aid in adding encryption support to a client library.
mod device;
mod error;
mod machine;

View File

@ -31,8 +31,8 @@ use super::store::memorystore::MemoryStore;
use super::store::sqlite::SqliteStore;
use super::{device::Device, CryptoStore};
use crate::api;
use crate::events::{
use matrix_sdk_types::api;
use matrix_sdk_types::events::{
collections::all::RoomEvent,
room::encrypted::{
CiphertextInfo, EncryptedEvent, EncryptedEventContent, MegolmV1AesSha2Content,
@ -45,7 +45,7 @@ use crate::events::{
},
Algorithm, EventJson, EventType,
};
use crate::identifiers::{DeviceId, RoomId, UserId};
use matrix_sdk_types::identifiers::{DeviceId, RoomId, UserId};
use api::r0::keys;
use api::r0::{
@ -94,7 +94,7 @@ impl std::fmt::Debug for OlmMachine {
}
impl OlmMachine {
const ALGORITHMS: &'static [&'static ruma_events::Algorithm] = &[
const ALGORITHMS: &'static [&'static Algorithm] = &[
&Algorithm::OlmV1Curve25519AesSha2,
&Algorithm::MegolmV1AesSha2,
];
@ -136,7 +136,6 @@ impl OlmMachine {
}
};
// TODO load the tracked users here.
Ok(OlmMachine {
user_id: user_id.clone(),
device_id: device_id.to_owned(),
@ -1100,7 +1099,15 @@ impl OlmMachine {
}
// TODO accept an algorithm here
pub(crate) async fn share_group_session<'a, I>(
/// Get to-device requests to share a group session with users in a room.
///
/// # Arguments
///
/// `room_id` - The room id of the room where the group session will be
/// used.
///
/// `users` - The list of users that should receive the group session.
pub async fn share_group_session<'a, I>(
&mut self,
room_id: &RoomId,
users: I,
@ -1395,7 +1402,7 @@ mod test {
static USER_ID: &str = "@bob:example.org";
static DEVICE_ID: &str = "DEVICEID";
use js_int::UInt;
use matrix_sdk_types::js_int::UInt;
use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::fs::File;
@ -1403,12 +1410,16 @@ mod test {
use std::sync::atomic::AtomicU64;
use std::time::SystemTime;
use http::Response;
use serde_json::json;
use crate::api::r0::{client_exchange::send_event_to_device::Request as ToDeviceRequest, keys};
use crate::crypto::machine::{OlmMachine, OneTimeKeys};
use crate::crypto::Device;
use crate::events::{
use crate::machine::{OlmMachine, OneTimeKeys};
use crate::Device;
use matrix_sdk_types::api::r0::{
client_exchange::send_event_to_device::Request as ToDeviceRequest, keys,
};
use matrix_sdk_types::events::{
collections::all::RoomEvent,
room::{
encrypted::{EncryptedEvent, EncryptedEventContent},
@ -1417,9 +1428,7 @@ mod test {
to_device::{AnyToDeviceEvent, ToDeviceEncrypted},
EventJson, EventType,
};
use crate::identifiers::{DeviceId, EventId, RoomId, UserId};
use http::Response;
use matrix_sdk_types::identifiers::{DeviceId, EventId, RoomId, UserId};
fn alice_id() -> UserId {
UserId::try_from("@alice:example.org").unwrap()
@ -1444,12 +1453,12 @@ mod test {
}
fn keys_upload_response() -> keys::upload_keys::Response {
let data = response_from_file("tests/data/keys_upload.json");
let data = response_from_file("../test_data/keys_upload.json");
keys::upload_keys::Response::try_from(data).expect("Can't parse the keys upload response")
}
fn keys_query_response() -> keys::get_keys::Response {
let data = response_from_file("tests/data/keys_query.json");
let data = response_from_file("../test_data/keys_query.json");
keys::get_keys::Response::try_from(data).expect("Can't parse the keys upload response")
}

View File

@ -20,7 +20,7 @@ use tokio::sync::Mutex;
use super::device::Device;
use super::olm::{InboundGroupSession, Session};
use crate::identifiers::{DeviceId, RoomId, UserId};
use matrix_sdk_types::identifiers::{DeviceId, RoomId, UserId};
/// In-memory store for Olm Sessions.
#[derive(Debug)]
@ -210,11 +210,11 @@ impl DeviceStore {
mod test {
use std::convert::TryFrom;
use crate::crypto::device::test::get_device;
use crate::crypto::memory_stores::{DeviceStore, GroupSessionStore, SessionStore};
use crate::crypto::olm::test::get_account_and_session;
use crate::crypto::olm::{InboundGroupSession, OutboundGroupSession};
use crate::identifiers::RoomId;
use crate::device::test::get_device;
use crate::memory_stores::{DeviceStore, GroupSessionStore, SessionStore};
use crate::olm::test::get_account_and_session;
use crate::olm::{InboundGroupSession, OutboundGroupSession};
use matrix_sdk_types::identifiers::RoomId;
#[tokio::test]
async fn test_session_store() {

View File

@ -35,8 +35,8 @@ pub use olm_rs::{
utility::OlmUtility,
};
use crate::api::r0::keys::SignedKey;
use crate::identifiers::RoomId;
use matrix_sdk_types::api::r0::keys::SignedKey;
use matrix_sdk_types::identifiers::RoomId;
/// The Olm account.
/// An account is the central identity for encrypted communication between two
@ -620,10 +620,10 @@ impl std::fmt::Debug for OutboundGroupSession {
#[cfg(test)]
pub(crate) mod test {
use crate::crypto::olm::{Account, InboundGroupSession, OutboundGroupSession, Session};
use crate::identifiers::RoomId;
use crate::olm::{Account, InboundGroupSession, OutboundGroupSession, Session};
use matrix_sdk_types::api::r0::keys::SignedKey;
use matrix_sdk_types::identifiers::RoomId;
use olm_rs::session::OlmMessage;
use ruma_client_api::r0::keys::SignedKey;
use std::collections::BTreeMap;
use std::convert::TryFrom;

View File

@ -19,9 +19,9 @@ use async_trait::async_trait;
use tokio::sync::Mutex;
use super::{Account, CryptoStore, InboundGroupSession, Result, Session};
use crate::crypto::device::Device;
use crate::crypto::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices};
use crate::identifiers::{DeviceId, RoomId, UserId};
use crate::device::Device;
use crate::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices};
use matrix_sdk_types::identifiers::{DeviceId, RoomId, UserId};
#[derive(Debug)]
pub struct MemoryStore {
@ -107,12 +107,12 @@ impl CryptoStore for MemoryStore {
mod test {
use std::convert::TryFrom;
use crate::crypto::device::test::get_device;
use crate::crypto::olm::test::get_account_and_session;
use crate::crypto::olm::{InboundGroupSession, OutboundGroupSession};
use crate::crypto::store::memorystore::MemoryStore;
use crate::crypto::store::CryptoStore;
use crate::identifiers::RoomId;
use crate::device::test::get_device;
use crate::olm::test::get_account_and_session;
use crate::olm::{InboundGroupSession, OutboundGroupSession};
use crate::store::memorystore::MemoryStore;
use crate::store::CryptoStore;
use matrix_sdk_types::identifiers::RoomId;
#[tokio::test]
async fn test_session_store() {

View File

@ -26,7 +26,7 @@ use tokio::sync::Mutex;
use super::device::Device;
use super::memory_stores::UserDevices;
use super::olm::{Account, InboundGroupSession, Session};
use crate::identifiers::{DeviceId, RoomId, UserId};
use matrix_sdk_types::identifiers::{DeviceId, RoomId, UserId};
use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError};
pub mod memorystore;

View File

@ -29,11 +29,11 @@ use tokio::sync::Mutex;
use zeroize::Zeroizing;
use super::{Account, CryptoStore, CryptoStoreError, InboundGroupSession, Result, Session};
use crate::api::r0::keys::KeyAlgorithm;
use crate::crypto::device::{Device, TrustState};
use crate::crypto::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices};
use crate::events::Algorithm;
use crate::identifiers::{DeviceId, RoomId, UserId};
use crate::device::{Device, TrustState};
use crate::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices};
use matrix_sdk_types::api::r0::keys::KeyAlgorithm;
use matrix_sdk_types::events::Algorithm;
use matrix_sdk_types::identifiers::{DeviceId, RoomId, UserId};
pub struct SqliteStore {
user_id: Arc<String>,
@ -639,9 +639,9 @@ impl std::fmt::Debug for SqliteStore {
#[cfg(test)]
mod test {
use crate::api::r0::keys::SignedKey;
use crate::crypto::device::test::get_device;
use crate::crypto::olm::GroupSessionKey;
use crate::device::test::get_device;
use crate::olm::GroupSessionKey;
use matrix_sdk_types::api::r0::keys::SignedKey;
use olm_rs::outbound_group_session::OlmOutboundGroupSession;
use std::collections::BTreeMap;
use tempfile::tempdir;

View File

@ -0,0 +1,18 @@
[package]
authors = ["Damir Jelić <poljar@termina.org.uk"]
description = "Collection of Matrix types used in the matrix-sdk"
edition = "2018"
homepage = "https://github.com/matrix-org/matrix-rust-sdk"
keywords = ["matrix", "chat", "messaging", "ruma", "nio"]
license = "Apache-2.0"
name = "matrix-sdk-types"
readme = "README.md"
repository = "https://github.com/matrix-org/matrix-rust-sdk"
version = "0.1.0"
[dependencies]
js_int = "0.1.5"
ruma-api = "0.16.0-rc.2"
ruma-client-api = { version = "0.8.0-rc.5" }
ruma-events = { version = "0.21.0-beta.1" }
ruma-identifiers = "0.16.0"

View File

@ -0,0 +1,5 @@
pub use js_int;
pub use ruma_api::Endpoint;
pub use ruma_client_api as api;
pub use ruma_events as events;
pub use ruma_identifiers as identifiers;