Merge remote-tracking branch 'origin/main' into gnunicorn/issue133

This commit is contained in:
Benjamin Kampmann
2022-05-02 11:51:26 +02:00
39 changed files with 165 additions and 220 deletions

View File

@@ -12,7 +12,7 @@ criterion = { version = "0.3.5", features = ["async", "async_tokio", "html_repor
matrix-sdk-crypto = { path = "../crates/matrix-sdk-crypto" }
matrix-sdk-sled = { path = "../crates/matrix-sdk-sled", default-features = false, features = ["crypto-store"] }
matrix-sdk-test = { path = "../crates/matrix-sdk-test" }
ruma = { git = "https://github.com/ruma/ruma", rev = "4014e6959" }
ruma = "0.6.1"
serde_json = "1.0.79"
tempfile = "3.3.0"
tokio = { version = "1.17.0", default-features = false, features = ["rt-multi-thread"] }

View File

@@ -15,6 +15,7 @@ hmac = "0.12.1"
http = "0.2.6"
pbkdf2 = "0.11.0"
rand = "0.8.5"
ruma = { version = "0.6.1", features = ["client-api-c"] }
serde = "1.0.136"
serde_json = "1.0.79"
sha2 = "0.10.2"
@@ -40,19 +41,14 @@ path = "../matrix-sdk-sled"
default_features = false
features = ["crypto-store"]
[dependencies.vodozemac]
git = "https://github.com/matrix-org/vodozemac"
rev = "e09c93f2c8df9770793abeec57ed984d5e1f3834"
[dependencies.tokio]
version = "1.17.0"
default_features = false
features = ["rt-multi-thread"]
[dependencies.ruma]
git = "https://github.com/ruma/ruma"
rev = "4014e6959"
features = ["client-api-c"]
[dependencies.vodozemac]
git = "https://github.com/matrix-org/vodozemac"
rev = "e09c93f2c8df9770793abeec57ed984d5e1f3834"
[build-dependencies]
uniffi_build = { version = "0.17.0", features = ["builtin-bindgen"] }

View File

@@ -24,8 +24,8 @@ base64 = "0.13.0"
byteorder = "1.4.3"
image = { version = "0.23.0", optional = true }
qrcode = { version = "0.12.0", default-features = false }
ruma-common = { git = "https://github.com/ruma/ruma", rev = "4014e6959" }
rqrr = { version = "0.4.0", optional = true }
ruma-common = "0.9.0"
thiserror = "1.0.30"
[dependencies.vodozemac]

View File

@@ -29,7 +29,7 @@ http = "0.2.6"
matrix-sdk = { version = "0.4", path = "../matrix-sdk", default-features = false, features = ["appservice"] }
percent-encoding = "2.1.0"
regex = "1.5.5"
ruma = { git = "https://github.com/ruma/ruma", rev = "4014e6959", features = ["client-api-c", "appservice-api-s"] }
ruma = { version = "0.6.1", features = ["client-api-c", "appservice-api-s"] }
serde = "1.0.136"
serde_json = "1.0.79"
serde_yaml = "0.8.23"

View File

@@ -21,30 +21,36 @@ encryption = ["matrix-sdk-crypto"]
qrcode = ["matrix-sdk-crypto/qrcode"]
# helpers for testing features build upon this
testing = [ "http" ]
testing = ["http"]
[dependencies]
anyhow = "1.0.57"
async-stream = "0.3.3"
async-trait = "0.1.53"
chacha20poly1305 = { version = "0.9.0", optional = true }
dashmap = "5.2.0"
futures-channel = "0.3.21"
futures-core = "0.3.21"
futures-util = { version = "0.3.21", default-features = false }
futures-channel = "0.3.21"
hmac = { version = "0.12.1", optional = true }
http = { version = "0.2.6", optional = true }
lru = "0.7.5"
matrix-sdk-common = { version = "0.4.0", path = "../matrix-sdk-common" }
matrix-sdk-crypto = { version = "0.4.0", path = "../matrix-sdk-crypto", optional = true }
pbkdf2 = { version = "0.11.0", default-features = false, optional = true }
rand = { version = "0.8.5", optional = true }
ruma = { git = "https://github.com/ruma/ruma", rev = "4014e6959", features = ["client-api-c", "signatures"] }
serde = { version = "1.0.136", features = ["rc"] }
serde_json = "1.0.79"
sha2 = { version = "0.10.2", optional = true }
thiserror = "1.0.30"
tracing = "0.1.34"
zeroize = { version = "1.3.0", features = ["zeroize_derive"] }
anyhow = "1.0.57"
http = { version = "0.2.6", optional = true }
[target.'cfg(target_arch = "wasm32")'.dependencies]
ruma = { version = "0.6.1", features = ["client-api-c", "js", "signatures"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
ruma = { version = "0.6.1", features = ["client-api-c", "signatures"] }
[dev-dependencies]
futures = { version = "0.3.21", default-features = false, features = ["executor"] }
@@ -53,10 +59,7 @@ http = "0.2.6"
assign = "1.1.1"
env_logger = "0.9.0"
matrix-sdk-test = { version = "0.4.0", path = "../matrix-sdk-test" }
tokio = { version = "1.17.0", default-features = false, features = [
"rt-multi-thread",
"macros",
] }
tokio = { version = "1.17.0", default-features = false, features = ["rt-multi-thread", "macros"] }
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.30"

View File

@@ -31,7 +31,6 @@ use matrix_sdk_common::{
},
instant::Instant,
locks::RwLock,
util::milli_seconds_since_unix_epoch,
};
#[cfg(feature = "encryption")]
use matrix_sdk_crypto::{
@@ -61,7 +60,7 @@ use ruma::{
},
push::{Action, PushConditionRoomCtx, Ruleset},
serde::Raw,
OwnedUserId, RoomId, UInt, UserId,
MilliSecondsSinceUnixEpoch, OwnedUserId, RoomId, UInt, UserId,
};
use tracing::{info, trace, warn};
@@ -365,7 +364,7 @@ impl BaseClient {
event.event.clone(),
false,
room_id.to_owned(),
milli_seconds_since_unix_epoch(),
MilliSecondsSinceUnixEpoch::now(),
),
);
}

View File

@@ -119,10 +119,7 @@ impl BaseRoomInfo {
self.create = Some(c.content.clone());
}
AnySyncStateEvent::RoomHistoryVisibility(h) => {
self.history_visibility = match h {
SyncStateEvent::Original(h) => h.content.history_visibility.clone(),
SyncStateEvent::Redacted(h) => h.content.history_visibility.clone(),
};
self.history_visibility = h.history_visibility().clone();
}
AnySyncStateEvent::RoomGuestAccess(g) => {
self.guest_access = g
@@ -130,10 +127,7 @@ impl BaseRoomInfo {
.map_or(GuestAccess::Forbidden, |g| g.content.guest_access.clone());
}
AnySyncStateEvent::RoomJoinRules(c) => {
self.join_rule = match c {
SyncStateEvent::Original(c) => c.content.join_rule.clone(),
SyncStateEvent::Redacted(c) => c.content.join_rule.clone(),
};
self.join_rule = c.join_rule().clone();
}
AnySyncStateEvent::RoomCanonicalAlias(a) => {
self.canonical_alias = a.as_original().and_then(|a| a.content.alias.clone());

View File

@@ -35,7 +35,7 @@ macro_rules! statestore_integration_tests {
use futures_util::StreamExt;
use matrix_sdk_test::{async_test, test_json};
use matrix_sdk_common::ruma::{
use ruma::{
api::{
client::{
media::get_content_thumbnail::v3::Method,

View File

@@ -18,10 +18,11 @@ use std::{
};
use async_stream::stream;
use async_trait::async_trait;
use dashmap::{DashMap, DashSet};
use lru::LruCache;
#[allow(unused_imports)]
use matrix_sdk_common::{async_trait, instant::Instant, locks::Mutex};
use matrix_sdk_common::{instant::Instant, locks::Mutex};
use ruma::{
events::{
presence::PresenceEvent,

View File

@@ -32,8 +32,9 @@ use std::{
#[macro_use]
pub mod integration_tests;
use async_trait::async_trait;
use dashmap::DashMap;
use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps};
use matrix_sdk_common::{locks::RwLock, AsyncTraitDeps};
#[cfg(feature = "encryption")]
use matrix_sdk_crypto::store::CryptoStore;
use ruma::{

View File

@@ -16,17 +16,15 @@ default-target = "x86_64-unknown-linux-gnu"
targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"]
[dependencies]
async-trait = "0.1.53"
ruma = { git = "https://github.com/ruma/ruma", rev = "4014e6959", features = ["client-api-c"] }
ruma = { version = "0.6.1", features = ["client-api-c"] }
serde = "1.0.136"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1.17.0", default-features = false, features = ["rt", "sync"] }
instant = { version = "0.1.12", features = ["now"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
async-lock = "2.5.0"
instant = { version = "0.1.12", features = ["wasm-bindgen", "inaccurate"] }
futures-util = { version = "0.3.21", default-features = false, features = ["channel"] }
wasm-bindgen-futures = "0.4.30"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1.17.0", default-features = false, features = ["rt", "sync"] }
instant = { version = "0.1.12", features = ["now"] }

View File

@@ -1,14 +1,11 @@
#![doc = include_str!("../README.md")]
#![warn(missing_debug_implementations)]
pub use async_trait::async_trait;
pub use instant;
pub use ruma;
pub mod deserialized_responses;
pub mod executor;
pub mod locks;
pub mod util;
/// Super trait that is used for our store traits, this trait will differ if
/// it's used on WASM. WASM targets will not require `Send` and `Sync` to have

View File

@@ -1,28 +0,0 @@
use instant::{Duration, SystemTime};
use ruma::{MilliSecondsSinceUnixEpoch, SecondsSinceUnixEpoch};
/// Platform agnostic helper function to create MilliSecondsSinceUnixEpoch
pub fn milli_seconds_since_unix_epoch() -> MilliSecondsSinceUnixEpoch {
let duration =
SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).expect("now is always higher");
let millis =
duration.as_millis().try_into().expect("can't convert milliseconds since UNIXEPOCH");
MilliSecondsSinceUnixEpoch(millis)
}
/// Platform agnostic helper function to create SecondsSinceUnixEpoch
pub fn seconds_since_unix_epoch() -> SecondsSinceUnixEpoch {
modified_seconds_since_unix_epoch(|e| e)
}
/// Platform agnostic helper function to create SecondsSinceUnixEpoch with
/// modifications
pub fn modified_seconds_since_unix_epoch<F: Fn(Duration) -> Duration>(
f: F,
) -> SecondsSinceUnixEpoch {
let duration =
f(SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).expect("now is always higher"));
let millis = duration.as_secs().try_into().expect("can't convert seconds since UNIXEPOCH");
SecondsSinceUnixEpoch(millis)
}

View File

@@ -27,7 +27,9 @@ testing = ["http"]
[dependencies]
aes = "0.8.1"
aes-gcm = "0.9.4"
anyhow = "1.0.57"
atomic = "0.5.1"
async-trait = "0.1.53"
base64 = "0.13.0"
bs58 = { version = "0.4.0", optional = true }
byteorder = "1.4.3"
@@ -35,6 +37,7 @@ ctr = "0.9.1"
dashmap = "5.2.0"
futures-util = { version = "0.3.21", default-features = false, features = ["alloc"] }
hmac = "0.12.1"
http = { version = "0.2.6", optional = true } # feature = testing only
matrix-qrcode = { version = "0.2.0", path = "../matrix-qrcode", optional = true }
matrix-sdk-common = { version = "0.4.0", path = "../matrix-sdk-common" }
olm-rs = { version = "2.2.0", features = ["serde"], optional = true }
@@ -46,29 +49,24 @@ sha2 = "0.10.2"
thiserror = "1.0.30"
tracing = "0.1.34"
zeroize = { version = "1.3.0", features = ["zeroize_derive"] }
anyhow = "1.0.57"
# feature = testing only
http = { version = "0.2.6", optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.vodozemac]
git = "https://github.com/matrix-org/vodozemac"
rev = "e09c93f2c8df9770793abeec57ed984d5e1f3834"
[target.'cfg(target_arch = "wasm32")'.dev-dependencies.getrandom]
version = "0.2.6"
features = ["js"]
[target.'cfg(target_arch = "wasm32")'.dependencies.ruma]
version = "0.6.1"
features = ["client-api-c", "js", "rand", "unstable-msc2676", "unstable-msc2677"]
[target.'cfg(target_arch = "wasm32")'.dependencies.vodozemac]
git = "https://github.com/matrix-org/vodozemac"
rev = "e09c93f2c8df9770793abeec57ed984d5e1f3834"
features = ["js"]
[dependencies.ruma]
git = "https://github.com/ruma/ruma"
rev = "4014e6959"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.ruma]
version = "0.6.1"
features = ["client-api-c", "rand", "unstable-msc2676", "unstable-msc2677"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.vodozemac]
git = "https://github.com/matrix-org/vodozemac"
rev = "e09c93f2c8df9770793abeec57ed984d5e1f3834"
[dev-dependencies]
futures = { version = "0.3.21", default-features = false, features = ["executor"] }
http = "0.2.6"
@@ -80,4 +78,5 @@ proptest = { version = "1.0.0", default-features = false, features = ["std"] }
tokio = { version = "1.7.0", default-features = false, features = ["macros", "rt-multi-thread"] }
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
getrandom = { version = "0.2.6", features = ["js"] }
wasm-bindgen-test = "0.3.24"

View File

@@ -1526,10 +1526,8 @@ pub(crate) mod testing {
#[cfg(test)]
pub(crate) mod tests {
use std::{collections::BTreeMap, convert::TryInto, iter, sync::Arc};
use matrix_sdk_common::util::milli_seconds_since_unix_epoch;
use matrix_sdk_test::{async_test, test_json};
use ruma::{
api::{
@@ -1552,7 +1550,8 @@ pub(crate) mod tests {
},
room_id,
serde::Raw,
uint, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, OwnedDeviceKeyId, UserId,
uint, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch,
OwnedDeviceKeyId, UserId,
};
use serde_json::json;
use vodozemac::Ed25519PublicKey;
@@ -1970,7 +1969,7 @@ pub(crate) mod tests {
let event = OriginalSyncMessageLikeEvent {
event_id: event_id!("$xxxxx:example.org").to_owned(),
origin_server_ts: milli_seconds_since_unix_epoch(),
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
sender: alice.user_id().to_owned(),
content: encrypted_content,
unsigned: MessageLikeUnsigned::default(),

View File

@@ -23,7 +23,7 @@ use std::{
},
};
use matrix_sdk_common::{locks::Mutex, util::seconds_since_unix_epoch};
use matrix_sdk_common::locks::Mutex;
use ruma::{
api::client::keys::{
upload_keys,
@@ -37,7 +37,7 @@ use ruma::{
},
serde::{CanonicalJsonValue, Raw},
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, EventEncryptionAlgorithm, OwnedDeviceId,
OwnedDeviceKeyId, OwnedUserId, RoomId, UInt, UserId,
OwnedDeviceKeyId, OwnedUserId, RoomId, SecondsSinceUnixEpoch, UInt, UserId,
};
use serde::{Deserialize, Serialize};
use serde_json::{value::RawValue as RawJsonValue, Value};
@@ -927,7 +927,7 @@ impl ReadOnlyAccount {
) -> Session {
let session = self.inner.lock().await.create_outbound_session(identity_key, one_time_key);
let now = seconds_since_unix_epoch();
let now = SecondsSinceUnixEpoch::now();
let session_id = session.session_id();
Session {
@@ -1023,7 +1023,7 @@ impl ReadOnlyAccount {
let result =
self.inner.lock().await.create_inbound_session(&their_identity_key, message)?;
let now = seconds_since_unix_epoch();
let now = SecondsSinceUnixEpoch::now();
let session_id = result.session.session_id();
let session = Session {

View File

@@ -24,7 +24,7 @@ use std::{
};
use dashmap::DashMap;
use matrix_sdk_common::{locks::Mutex, util::seconds_since_unix_epoch};
use matrix_sdk_common::locks::Mutex;
use ruma::{
events::{
room::{
@@ -175,7 +175,7 @@ impl OutboundGroupSession {
device_id,
account_identity_keys: identity_keys,
session_id: session_id.into(),
creation_time: seconds_since_unix_epoch(),
creation_time: SecondsSinceUnixEpoch::now(),
message_count: Arc::new(AtomicU64::new(0)),
shared: Arc::new(AtomicBool::new(false)),
invalidated: Arc::new(AtomicBool::new(false)),
@@ -307,7 +307,7 @@ impl OutboundGroupSession {
fn elapsed(&self) -> bool {
let creation_time = Duration::from_secs(self.creation_time.get().into());
let now = Duration::from_secs(seconds_since_unix_epoch().get().into());
let now = Duration::from_secs(SecondsSinceUnixEpoch::now().get().into());
// Since the encryption settings are provided by users and not
// checked someone could set a really low rotation period so
@@ -608,7 +608,6 @@ mod tests {
use std::time::Duration;
use atomic::Ordering;
use matrix_sdk_common::util::modified_seconds_since_unix_epoch;
use matrix_sdk_test::async_test;
use ruma::{
device_id,
@@ -643,6 +642,8 @@ mod tests {
#[async_test]
#[cfg(any(target_os = "linux", target_arch = "wasm32"))]
async fn expiration() -> Result<(), MegolmError> {
use ruma::SecondsSinceUnixEpoch;
let settings = EncryptionSettings { rotation_period_msgs: 1, ..Default::default() };
let account = ReadOnlyAccount::new(user_id!("@alice:example.org"), device_id!("DEVICEID"));
@@ -671,9 +672,9 @@ mod tests {
.unwrap();
assert!(!session.expired());
// FIXME: this might break on macosx and windows
session.creation_time =
modified_seconds_since_unix_epoch(|e| e - Duration::from_secs(60 * 60));
let now = SecondsSinceUnixEpoch::now();
session.creation_time = SecondsSinceUnixEpoch(now.get() - uint!(3600));
assert!(session.expired());
let settings = EncryptionSettings { rotation_period_msgs: 0, ..Default::default() };

View File

@@ -14,7 +14,7 @@
use std::{collections::BTreeMap, fmt, sync::Arc};
use matrix_sdk_common::{locks::Mutex, util::seconds_since_unix_epoch};
use matrix_sdk_common::locks::Mutex;
use ruma::{
events::{
room::encrypted::{
@@ -83,7 +83,7 @@ impl Session {
/// * `message` - The Olm message that should be decrypted.
pub async fn decrypt(&mut self, message: &OlmMessage) -> Result<String, DecryptionError> {
let plaintext = self.inner.lock().await.decrypt(message)?;
self.last_use_time = seconds_since_unix_epoch();
self.last_use_time = SecondsSinceUnixEpoch::now();
Ok(plaintext)
}
@@ -101,7 +101,7 @@ impl Session {
/// * `plaintext` - The plaintext that should be encrypted.
pub(crate) async fn encrypt_helper(&mut self, plaintext: &str) -> OlmMessage {
let message = self.inner.lock().await.encrypt(plaintext);
self.last_use_time = seconds_since_unix_epoch();
self.last_use_time = SecondsSinceUnixEpoch::now();
message
}

View File

@@ -19,7 +19,6 @@ use std::{
};
use dashmap::{DashMap, DashSet};
use matrix_sdk_common::util::seconds_since_unix_epoch;
use ruma::{
api::client::keys::claim_keys::v3::{
Request as KeysClaimRequest, Response as KeysClaimResponse,
@@ -27,7 +26,7 @@ use ruma::{
assign,
events::{dummy::ToDeviceDummyEventContent, AnyToDeviceEventContent},
DeviceId, DeviceKeyAlgorithm, EventEncryptionAlgorithm, OwnedDeviceId, OwnedTransactionId,
OwnedUserId, TransactionId, UserId,
OwnedUserId, SecondsSinceUnixEpoch, TransactionId, UserId,
};
use tracing::{debug, error, info, warn};
@@ -97,7 +96,7 @@ impl SessionManager {
);
let creation_time = Duration::from_secs(session.creation_time.get().into());
let now = Duration::from_secs(seconds_since_unix_epoch().get().into());
let now = Duration::from_secs(SecondsSinceUnixEpoch::now().get().into());
let should_unwedge = now
.checked_sub(creation_time)

View File

@@ -7,7 +7,7 @@ macro_rules! cryptostore_integration_tests {
use super::get_store;
use matrix_sdk_test::async_test;
use matrix_sdk_common::ruma::{
use ruma::{
encryption::SignedKey, events::room_key_request::RequestedKeyInfo,
serde::Base64, user_id, TransactionId, DeviceId, EventEncryptionAlgorithm, UserId,
room_id, device_id,

View File

@@ -17,8 +17,9 @@ use std::{
sync::Arc,
};
use async_trait::async_trait;
use dashmap::{DashMap, DashSet};
use matrix_sdk_common::{async_trait, locks::Mutex};
use matrix_sdk_common::locks::Mutex;
use ruma::{
DeviceId, OwnedDeviceId, OwnedTransactionId, OwnedUserId, RoomId, TransactionId, UserId,
};

View File

@@ -54,7 +54,8 @@ use std::{
sync::Arc,
};
use matrix_sdk_common::{async_trait, locks::Mutex, AsyncTraitDeps};
use async_trait::async_trait;
use matrix_sdk_common::{locks::Mutex, AsyncTraitDeps};
pub use memorystore::MemoryStore;
pub use pickle_key::{EncryptedPickleKey, PickleKey};
use ruma::{

View File

@@ -63,11 +63,11 @@ impl AnyEvent<'_> {
}
}
pub fn timestamp(&self) -> Option<&MilliSecondsSinceUnixEpoch> {
pub fn timestamp(&self) -> Option<MilliSecondsSinceUnixEpoch> {
match self {
AnyEvent::Room(e) => Some(e.origin_server_ts()),
AnyEvent::ToDevice(e) => match e {
AnyToDeviceEvent::KeyVerificationRequest(e) => Some(&e.content.timestamp),
AnyToDeviceEvent::KeyVerificationRequest(e) => Some(e.content.timestamp),
_ => None,
},
}

View File

@@ -18,15 +18,15 @@ use std::{
};
use dashmap::DashMap;
use matrix_sdk_common::{locks::Mutex, util::milli_seconds_since_unix_epoch};
use matrix_sdk_common::locks::Mutex;
use ruma::{
events::{
key::verification::VerificationMethod, AnyToDeviceEvent, AnyToDeviceEventContent,
ToDeviceEvent,
},
serde::Raw,
DeviceId, EventId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId, RoomId,
TransactionId, UserId,
uint, DeviceId, EventId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId, RoomId,
SecondsSinceUnixEpoch, TransactionId, UInt, UserId,
};
use tracing::{info, trace, warn};
@@ -191,9 +191,7 @@ impl VerificationMachine {
self.verifications.get_sas(user_id, flow_id)
}
fn is_timestamp_valid(timestamp: &MilliSecondsSinceUnixEpoch) -> bool {
use ruma::{uint, UInt};
fn is_timestamp_valid(timestamp: MilliSecondsSinceUnixEpoch) -> bool {
// The event should be ignored if the event is older than 10 minutes
let old_timestamp_threshold: UInt = uint!(600);
// The event should be ignored if the event is 5 minutes or more into the
@@ -201,7 +199,7 @@ impl VerificationMachine {
let timestamp_threshold: UInt = uint!(300);
let timestamp = timestamp.as_secs();
let now = milli_seconds_since_unix_epoch().as_secs();
let now = SecondsSinceUnixEpoch::now().get();
!(now.saturating_sub(timestamp) > old_timestamp_threshold
|| timestamp.saturating_sub(now) > timestamp_threshold)

View File

@@ -19,7 +19,7 @@ use std::{
#[cfg(feature = "qrcode")]
use matrix_qrcode::QrVerificationData;
use matrix_sdk_common::{instant::Instant, util::milli_seconds_since_unix_epoch};
use matrix_sdk_common::instant::Instant;
use ruma::{
events::{
key::verification::{
@@ -33,7 +33,8 @@ use ruma::{
AnyMessageLikeEventContent, AnyToDeviceEventContent,
},
to_device::DeviceIdOrAllDevices,
DeviceId, OwnedDeviceId, OwnedUserId, RoomId, TransactionId, UserId,
DeviceId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId, RoomId, TransactionId,
UserId,
};
use tracing::{info, trace, warn};
@@ -159,7 +160,7 @@ impl VerificationRequest {
self.account.device_id().into(),
self.flow_id().as_str().into(),
methods,
milli_seconds_since_unix_epoch(),
MilliSecondsSinceUnixEpoch::now(),
);
ToDeviceRequest::for_recipients(

View File

@@ -12,12 +12,15 @@ default-target = "wasm32-unknown-unknown"
[dependencies]
anyhow = "1.0.57"
async-trait = "0.1.53"
base64 = "0.13.0"
dashmap = "5.2.0"
futures-util = { version = "0.3.21", default-features = false }
indexed_db_futures = "0.2.3"
matrix-sdk-base = { path = "../matrix-sdk-base" }
matrix-sdk-crypto = { path = "../matrix-sdk-crypto", optional = true }
matrix-sdk-store-encryption = { path = "../matrix-sdk-store-encryption" }
ruma = "0.6.1"
serde = "1.0.136"
serde_json = "1.0.79"
thiserror = "1.0.30"
@@ -25,16 +28,13 @@ tracing = "0.1.34"
wasm-bindgen = { version = "0.2.80", features = ["serde-serialize"] }
web-sys = { version = "0.3.57", features = ["IdbKeyRange"] }
matrix-sdk-crypto = { path = "../matrix-sdk-crypto", optional = true }
[target.'cfg(target_arch = "wasm32")'.dependencies]
# for wasm32 we need to activate this
getrandom = { version = "0.2.6", features = ["js"] }
[dev-dependencies]
matrix-sdk-common = { path = "../matrix-sdk-common" }
matrix-sdk-base = { path = "../matrix-sdk-base", features = ["testing"] }
matrix-sdk-base = { path = "../matrix-sdk-base", features = ["testing"] }
matrix-sdk-common = { path = "../matrix-sdk-common" }
matrix-sdk-crypto = { path = "../matrix-sdk-crypto", features = ["testing"] }
matrix-sdk-test = { path = "../matrix-sdk-test" }
uuid = "1.0.0"

View File

@@ -18,13 +18,10 @@ use std::{
};
use anyhow::anyhow;
use async_trait::async_trait;
use dashmap::DashSet;
use indexed_db_futures::prelude::*;
use matrix_sdk_base::{
async_trait,
locks::Mutex,
ruma::{DeviceId, OwnedDeviceId, OwnedUserId, RoomId, TransactionId, UserId},
};
use matrix_sdk_base::locks::Mutex;
use matrix_sdk_crypto::{
olm::{
IdentityKeys, InboundGroupSession, OlmMessageHash, OutboundGroupSession,
@@ -36,6 +33,7 @@ use matrix_sdk_crypto::{
GossipRequest, ReadOnlyAccount, ReadOnlyDevice, ReadOnlyUserIdentities, SecretInfo,
};
use matrix_sdk_store_encryption::StoreCipher;
use ruma::{DeviceId, OwnedDeviceId, OwnedUserId, RoomId, TransactionId, UserId};
use serde::{Deserialize, Serialize};
use wasm_bindgen::JsValue;

View File

@@ -1,12 +1,12 @@
#![allow(dead_code)]
use base64::{encode_config as base64_encode, STANDARD_NO_PAD};
use matrix_sdk_base::ruma::{
use matrix_sdk_store_encryption::StoreCipher;
use ruma::{
events::{GlobalAccountDataEventType, RoomAccountDataEventType, StateEventType},
receipt::ReceiptType,
DeviceId, EventId, MxcUri, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, TransactionId,
UserId,
};
use matrix_sdk_store_encryption::StoreCipher;
use wasm_bindgen::JsValue;
use web_sys::IdbKeyRange;

View File

@@ -15,33 +15,33 @@
use std::{collections::BTreeSet, sync::Arc};
use anyhow::anyhow;
use async_trait::async_trait;
use futures_util::stream;
use indexed_db_futures::prelude::*;
use matrix_sdk_base::{
async_trait,
deserialized_responses::{MemberEvent, SyncRoomEvent},
deserialized_responses::SyncRoomEvent,
media::{MediaRequest, UniqueKey},
ruma::{
events::{
presence::PresenceEvent,
receipt::Receipt,
room::{
member::{MembershipState, RoomMemberEventContent},
redaction::SyncRoomRedactionEvent,
},
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageLikeEvent,
AnySyncRoomEvent, AnySyncStateEvent, GlobalAccountDataEventType,
RoomAccountDataEventType, StateEventType,
},
receipt::ReceiptType,
serde::Raw,
signatures::{redact_in_place, CanonicalJsonObject},
EventId, MxcUri, OwnedEventId, OwnedUserId, RoomId, RoomVersionId, UserId,
},
store::{BoxStream, Result as StoreResult, StateChanges, StateStore, StoreError},
RoomInfo,
};
use matrix_sdk_store_encryption::{Error as EncryptionError, StoreCipher};
use ruma::{
events::{
presence::PresenceEvent,
receipt::Receipt,
room::{
member::{MembershipState, OriginalSyncRoomMemberEvent, RoomMemberEventContent},
redaction::SyncRoomRedactionEvent,
},
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageLikeEvent,
AnySyncRoomEvent, AnySyncStateEvent, GlobalAccountDataEventType, RoomAccountDataEventType,
StateEventType,
},
receipt::ReceiptType,
serde::Raw,
signatures::{redact_in_place, CanonicalJsonObject},
EventId, MxcUri, OwnedEventId, OwnedUserId, RoomId, RoomVersionId, UserId,
};
use serde::{Deserialize, Serialize};
use tracing::{info, warn};
use wasm_bindgen::JsValue;

View File

@@ -10,29 +10,28 @@ state-store = ["matrix-sdk-base"]
crypto-store = ["matrix-sdk-crypto"]
[dependencies]
anyhow = "1.0.57"
async-stream = "0.3.3"
async-trait = "0.1.53"
dashmap = "5.2.0"
futures-core = "0.3.21"
futures-util = { version = "0.3.21", default-features = false }
matrix-sdk-base = { path = "../matrix-sdk-base", optional = true }
matrix-sdk-common = { path = "../matrix-sdk-common" }
matrix-sdk-crypto = { path = "../matrix-sdk-crypto", optional = true }
matrix-sdk-store-encryption = { path = "../matrix-sdk-store-encryption" }
async-stream = "0.3.3"
ruma = "0.6.1"
serde = "1.0.136"
serde_json = "1.0.79"
sled = "0.34.7"
thiserror = "1.0.30"
tokio = { version = "1.17.0", default-features = false, features = ["sync", "fs"] }
tracing = "0.1.34"
anyhow = "1.0.57"
dashmap = "5.2.0"
[dev-dependencies]
matrix-sdk-base = { path = "../matrix-sdk-base", features = ["testing"] }
matrix-sdk-crypto = { path = "../matrix-sdk-crypto", features = ["testing"] }
matrix-sdk-test = { version = "0.4.0", path = "../matrix-sdk-test" }
once_cell = "1.10.0"
tempfile = "3.3.0"
matrix-sdk-test = { version = "0.4.0", path = "../matrix-sdk-test" }
matrix-sdk-crypto = { path = "../matrix-sdk-crypto", features = ["testing"] }
matrix-sdk-base = { path = "../matrix-sdk-base", features = ["testing"] }
tokio = { version = "1.17.0", default-features = false, features = [
"rt-multi-thread",
"macros",
] }
tokio = { version = "1.17.0", default-features = false, features = ["rt-multi-thread", "macros"] }

View File

@@ -20,15 +20,9 @@ use std::{
};
use anyhow::anyhow;
use async_trait::async_trait;
use dashmap::DashSet;
use matrix_sdk_common::{
async_trait,
locks::Mutex,
ruma::{
events::room_key_request::RequestedKeyInfo, DeviceId, OwnedDeviceId, OwnedUserId, RoomId,
TransactionId, UserId,
},
};
use matrix_sdk_common::locks::Mutex;
use matrix_sdk_crypto::{
olm::{
IdentityKeys, InboundGroupSession, OutboundGroupSession, PickledInboundGroupSession,
@@ -41,6 +35,10 @@ use matrix_sdk_crypto::{
GossipRequest, ReadOnlyAccount, ReadOnlyDevice, ReadOnlyUserIdentities, SecretInfo,
};
use matrix_sdk_store_encryption::StoreCipher;
use ruma::{
events::room_key_request::RequestedKeyInfo, DeviceId, OwnedDeviceId, OwnedUserId, RoomId,
TransactionId, UserId,
};
use serde::{Deserialize, Serialize};
pub use sled::Error;
use sled::{

View File

@@ -1,6 +1,7 @@
use std::{borrow::Cow, ops::Deref};
use matrix_sdk_common::ruma::{
use matrix_sdk_store_encryption::StoreCipher;
use ruma::{
events::{
secret::request::SecretName, GlobalAccountDataEventType, RoomAccountDataEventType,
StateEventType,
@@ -9,7 +10,6 @@ use matrix_sdk_common::ruma::{
DeviceId, EventEncryptionAlgorithm, EventId, MxcUri, OwnedEventId, OwnedRoomId, OwnedUserId,
RoomId, TransactionId, UserId,
};
use matrix_sdk_store_encryption::StoreCipher;
pub const ENCODE_SEPARATOR: u8 = 0xff;

View File

@@ -21,6 +21,7 @@ use std::{
use anyhow::anyhow;
use async_stream::stream;
use async_trait::async_trait;
use futures_core::stream::Stream;
use futures_util::stream::{self, StreamExt, TryStreamExt};
use matrix_sdk_base::{
@@ -29,27 +30,24 @@ use matrix_sdk_base::{
store::{BoxStream, Result as StoreResult, StateChanges, StateStore, StoreError},
RoomInfo,
};
use matrix_sdk_common::{
async_trait,
ruma::{
events::{
presence::PresenceEvent,
receipt::Receipt,
room::{
member::{MembershipState, RoomMemberEventContent},
redaction::SyncRoomRedactionEvent,
},
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageLikeEvent,
AnySyncRoomEvent, AnySyncStateEvent, GlobalAccountDataEventType,
RoomAccountDataEventType, StateEventType,
},
receipt::ReceiptType,
serde::Raw,
signatures::{redact_in_place, CanonicalJsonObject},
EventId, IdParseError, MxcUri, OwnedEventId, OwnedUserId, RoomId, RoomVersionId, UserId,
},
};
use matrix_sdk_store_encryption::{Error as KeyEncryptionError, StoreCipher};
use ruma::{
events::{
presence::PresenceEvent,
receipt::Receipt,
room::{
member::{MembershipState, RoomMemberEventContent},
redaction::SyncRoomRedactionEvent,
},
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageLikeEvent,
AnySyncRoomEvent, AnySyncStateEvent, GlobalAccountDataEventType, RoomAccountDataEventType,
StateEventType,
},
receipt::ReceiptType,
serde::Raw,
signatures::{redact_in_place, CanonicalJsonObject},
EventId, IdParseError, MxcUri, OwnedEventId, OwnedUserId, RoomId, RoomVersionId, UserId,
};
use serde::{Deserialize, Serialize};
use sled::{
transaction::{ConflictableTransactionError, TransactionError},

View File

@@ -18,6 +18,6 @@ appservice = []
http = "0.2.6"
matrix-sdk-test-macros = { version = "0.1.0", path = "../matrix-sdk-test-macros" }
once_cell = "1.10.0"
ruma = { git = "https://github.com/ruma/ruma", rev = "4014e6959", features = ["client-api-c"] }
ruma = { version = "0.6.1", features = ["client-api-c"] }
serde = "1.0.136"
serde_json = "1.0.79"

View File

@@ -51,6 +51,8 @@ docsrs = [
[dependencies]
anyhow = { version = "1.0.57", optional = true }
anymap2 = "0.13.0"
async-stream = "0.3.3"
async-trait = "0.1.53"
bytes = "1.1.0"
dashmap = "5.2.0"
event-listener = "2.5.2"
@@ -59,6 +61,8 @@ futures-core = "0.3.21"
futures-util = { version = "0.3.21", default-features = false }
http = "0.2.6"
matrix-sdk-common = { version = "0.4.0", path = "../matrix-sdk-common" }
matrix-sdk-indexeddb = { path = "../matrix-sdk-indexeddb", default-features = false, optional = true }
matrix-sdk-sled = { path = "../matrix-sdk-sled", default-features = false, optional = true }
mime = "0.3.16"
rand = { version = "0.8.5", optional = true }
serde = "1.0.136"
@@ -67,10 +71,6 @@ thiserror = "1.0.30"
tracing = "0.1.34"
url = "2.2.2"
zeroize = "1.3.0"
async-stream = "0.3.3"
matrix-sdk-sled = { path = "../matrix-sdk-sled", default-features = false, optional = true }
matrix-sdk-indexeddb = { path = "../matrix-sdk-indexeddb", default-features = false, optional = true }
[dependencies.image]
version = "0.24.2"
@@ -102,8 +102,7 @@ version = "0.11.10"
default_features = false
[dependencies.ruma]
git = "https://github.com/ruma/ruma"
rev = "4014e6959"
version = "0.6.1"
features = ["client-api-c", "compat", "rand", "unstable-msc2448"]
[dependencies.tokio-stream]
@@ -117,16 +116,11 @@ default-features = false
optional = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-timer= "0.2.5"
wasm-timer = "0.2.5"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.backoff]
version = "0.4.0"
features = ["tokio"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
version = "1.17.0"
default-features = false
features = ["fs", "rt"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
backoff = { version = "0.4.0", features = ["tokio"] }
tokio = { version = "1.17.0", default-features = false, features = ["fs", "rt"] }
[dev-dependencies]
anyhow = "1.0.57"
@@ -140,16 +134,13 @@ serde_json = "1.0.79"
tempfile = "3.3.0"
tracing-subscriber = { version = "0.3.11", features = ["env-filter"] }
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies.tokio]
version = "1.17.0"
default-features = false
features = ["rt-multi-thread", "macros"]
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
getrandom = { version = "0.2.6", default-features = false, features = ["js"] }
wasm-bindgen-test = "0.3.30"
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
tokio = { version = "1.17.0", default-features = false, features = ["rt-multi-thread", "macros"] }
[[example]]
name = "cross_signing_bootstrap"
required-features = ["encryption"]

View File

@@ -14,9 +14,10 @@
use std::{any::type_name, convert::TryFrom, fmt::Debug, sync::Arc, time::Duration};
use async_trait::async_trait;
use bytes::{Bytes, BytesMut};
use http::Response as HttpResponse;
use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps};
use matrix_sdk_common::{locks::RwLock, AsyncTraitDeps};
use reqwest::Response;
use ruma::api::{
error::FromHttpResponseError, AuthScheme, IncomingResponse, MatrixVersion, OutgoingRequest,

View File

@@ -29,6 +29,7 @@ compile_error!("'sso-login' cannot be enabled on 'wasm32' arch");
#[cfg(all(feature = "image-rayon", target_arch = "wasm32"))]
compile_error!("'image-rayon' cannot be enabled on 'wasm32' arch");
pub use async_trait::async_trait;
pub use bytes;
pub use matrix_sdk_base::{
media, Room as BaseRoom, RoomInfo, RoomMember as BaseRoomMember, RoomType, Session,

View File

@@ -10,6 +10,7 @@ clap = "3.1.12"
futures = { version = "0.3.21", default-features = false, features = ["executor"] }
matrix-sdk-base = { path = "../../crates/matrix-sdk-base" }
matrix-sdk-sled = { path = "../../crates/matrix-sdk-sled" }
ruma = "0.6.1"
rustyline = "9.1.2"
rustyline-derive = "0.6.0"
serde = "1.0.136"

View File

@@ -3,11 +3,9 @@ use std::{convert::TryFrom, fmt::Debug, sync::Arc};
use atty::Stream;
use clap::{Arg, ArgMatches, Command as Argparse};
use futures::executor::block_on;
use matrix_sdk_base::{
ruma::{events::StateEventType, OwnedRoomId, OwnedUserId, RoomId},
RoomInfo, Store,
};
use matrix_sdk_base::{RoomInfo, Store};
use matrix_sdk_sled::StateStore;
use ruma::{events::StateEventType, OwnedRoomId, OwnedUserId, RoomId};
use rustyline::{
completion::{Completer, Pair},
error::ReadlineError,