mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-09 00:15:23 -04:00
cleaning up more cryptocrate
This commit is contained in:
@@ -25,15 +25,6 @@
|
||||
unused_qualifications
|
||||
)]
|
||||
|
||||
#[cfg(all(feature = "sled_state_store", feature = "indexeddb_state_store"))]
|
||||
compile_error!("sled_state_store and indexeddb_state_store are mutually exclusive and cannot be enabled together");
|
||||
|
||||
#[cfg(all(feature = "indexeddb_state_store", not(target_arch = "wasm32")))]
|
||||
compile_error!("indexeddb_state_store only works for wasm32 target");
|
||||
|
||||
#[cfg(all(feature = "sled_cryptostore", feature = "indexeddb_state_store"))]
|
||||
compile_error!("sled_cryptostore and indexeddb_state_store are mutually exclusive and cannot be enabled together");
|
||||
|
||||
pub use matrix_sdk_common::*;
|
||||
|
||||
pub use crate::{
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
// limitations under the License.
|
||||
|
||||
/// Implementing the state store
|
||||
|
||||
#[cfg(feature = "sled_state_store")]
|
||||
use std::path::Path;
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
ops::Deref,
|
||||
@@ -58,14 +55,13 @@ use crate::{
|
||||
pub(crate) mod ambiguity_map;
|
||||
mod memory_store;
|
||||
|
||||
#[cfg(not(any(feature = "sled_state_store", feature = "indexeddb_state_store")))]
|
||||
use self::memory_store::MemoryStore;
|
||||
pub use self::memory_store::MemoryStore;
|
||||
|
||||
/// State store specific error type.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum StoreError {
|
||||
#[error(transparent)]
|
||||
/// An error happened in the underlying sled database.
|
||||
/// An error happened in the underlying database backend.
|
||||
Backend(#[from] anyhow::Error),
|
||||
/// An error happened while serializing or deserializing some data.
|
||||
#[error(transparent)]
|
||||
|
||||
@@ -19,7 +19,6 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||
default = []
|
||||
qrcode = ["matrix-qrcode"]
|
||||
backups_v1 = []
|
||||
sled_cryptostore = []
|
||||
docsrs = []
|
||||
indexeddb_cryptostore = []
|
||||
|
||||
@@ -87,4 +86,3 @@ pprof = { version = "0.6.2", features = ["flamegraph", "criterion"] }
|
||||
[[bench]]
|
||||
name = "crypto_bench"
|
||||
harness = false
|
||||
required-features = ["sled_cryptostore"]
|
||||
|
||||
@@ -733,15 +733,13 @@ pub(crate) mod test {
|
||||
};
|
||||
use serde_json::json;
|
||||
|
||||
use super::testing::{device_id, other_key_query, other_user_id, own_key_query, user_id};
|
||||
use crate::{
|
||||
identities::IdentityManager,
|
||||
olm::{PrivateCrossSigningIdentity, ReadOnlyAccount},
|
||||
store::{CryptoStore, MemoryStore, Store},
|
||||
verification::VerificationMachine,
|
||||
};
|
||||
use super::testing::{
|
||||
user_id, other_user_id, device_id, other_key_query, own_key_query,
|
||||
};
|
||||
|
||||
#[async_test]
|
||||
async fn test_manager_creation() {
|
||||
|
||||
@@ -941,10 +941,9 @@ pub(crate) mod testing {
|
||||
use ruma::{api::client::r0::keys::get_keys::Response as KeyQueryResponse, user_id};
|
||||
|
||||
use super::{ReadOnlyOwnUserIdentity, ReadOnlyUserIdentity};
|
||||
use crate::{
|
||||
identities::{
|
||||
manager::testing::{other_key_query, own_key_query}, ReadOnlyDevice,
|
||||
},
|
||||
use crate::identities::{
|
||||
manager::testing::{other_key_query, own_key_query},
|
||||
ReadOnlyDevice,
|
||||
};
|
||||
|
||||
fn device(response: &KeyQueryResponse) -> (ReadOnlyDevice, ReadOnlyDevice) {
|
||||
@@ -982,7 +981,6 @@ pub(crate) mod testing {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test {
|
||||
use std::{convert::TryFrom, sync::Arc};
|
||||
@@ -991,6 +989,7 @@ pub(crate) mod test {
|
||||
use matrix_sdk_test::async_test;
|
||||
use ruma::{api::client::r0::keys::get_keys::Response as KeyQueryResponse, user_id};
|
||||
|
||||
use super::testing::{get_other_identity, get_own_identity};
|
||||
use super::{ReadOnlyOwnUserIdentity, ReadOnlyUserIdentities, ReadOnlyUserIdentity};
|
||||
use crate::{
|
||||
identities::{
|
||||
@@ -1001,7 +1000,6 @@ pub(crate) mod test {
|
||||
store::MemoryStore,
|
||||
verification::VerificationMachine,
|
||||
};
|
||||
use super::testing::{get_other_identity, get_own_identity};
|
||||
|
||||
#[test]
|
||||
fn own_identity_create() {
|
||||
|
||||
@@ -84,6 +84,7 @@ pub use file_encryption::{
|
||||
decrypt_key_export, encrypt_key_export, AttachmentDecryptor, AttachmentEncryptor,
|
||||
DecryptorError, KeyExportError, MediaEncryptionInfo,
|
||||
};
|
||||
pub use gossiping::GossipRequest;
|
||||
pub use identities::{
|
||||
Device, LocalTrust, MasterPubkey, OwnUserIdentity, ReadOnlyDevice, ReadOnlyOwnUserIdentity,
|
||||
ReadOnlyUserIdentities, ReadOnlyUserIdentity, UserDevices, UserIdentities, UserIdentity,
|
||||
@@ -93,12 +94,11 @@ pub use machine::OlmMachine;
|
||||
pub use matrix_qrcode;
|
||||
pub use olm::ReadOnlyAccount;
|
||||
pub use olm::{CrossSigningStatus, EncryptionSettings};
|
||||
pub use gossiping::GossipRequest;
|
||||
pub use requests::{
|
||||
IncomingResponse, KeysBackupRequest, KeysQueryRequest, OutgoingRequest, OutgoingRequests,
|
||||
OutgoingVerificationRequest, RoomMessageRequest, ToDeviceRequest, UploadSigningKeysRequest,
|
||||
};
|
||||
pub use store::{CrossSigningKeyExport, CryptoStoreError, SecretInfo, SecretImportError};
|
||||
pub use store::{CrossSigningKeyExport, CryptoStoreError, SecretImportError, SecretInfo};
|
||||
pub use verification::{AcceptSettings, CancelInfo, Emoji, Sas, Verification, VerificationRequest};
|
||||
#[cfg(feature = "qrcode")]
|
||||
pub use verification::{QrVerification, ScanError};
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#[cfg(feature = "sled_cryptostore")]
|
||||
use std::path::Path;
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet, HashSet},
|
||||
mem,
|
||||
@@ -54,8 +52,6 @@ use tracing::{debug, error, info, trace, warn};
|
||||
|
||||
#[cfg(feature = "backups_v1")]
|
||||
use crate::backups::BackupMachine;
|
||||
#[cfg(feature = "sled_cryptostore")]
|
||||
use crate::store::sled::SledStore;
|
||||
use crate::{
|
||||
error::{EventError, MegolmError, MegolmResult, OlmError, OlmResult},
|
||||
gossiping::GossipMachine,
|
||||
@@ -1559,8 +1555,6 @@ pub(crate) mod testing {
|
||||
pub fn response_from_file(json: &serde_json::Value) -> Response<Vec<u8>> {
|
||||
Response::builder().status(200).body(json.to_string().as_bytes().to_vec()).unwrap()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -1568,6 +1562,7 @@ pub(crate) mod test {
|
||||
|
||||
use std::{collections::BTreeMap, convert::TryInto, iter, sync::Arc};
|
||||
|
||||
use super::testing::response_from_file;
|
||||
use matrix_sdk_common::util::milli_seconds_since_unix_epoch;
|
||||
use matrix_sdk_test::{async_test, test_json};
|
||||
use ruma::{
|
||||
@@ -1593,7 +1588,6 @@ pub(crate) mod test {
|
||||
uint, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId,
|
||||
};
|
||||
use serde_json::json;
|
||||
use super::testing::response_from_file;
|
||||
|
||||
use crate::{
|
||||
machine::OlmMachine,
|
||||
|
||||
@@ -481,7 +481,7 @@ impl Account {
|
||||
pub struct ReadOnlyAccount {
|
||||
/// The user_id this account belongs to
|
||||
pub user_id: Arc<UserId>,
|
||||
/// The device_id of this entry
|
||||
/// The device_id of this entry
|
||||
pub device_id: Arc<DeviceId>,
|
||||
inner: Arc<Mutex<OlmAccount>>,
|
||||
/// The associated identity keys
|
||||
@@ -868,9 +868,7 @@ impl ReadOnlyAccount {
|
||||
self.sign(&canonical_json.to_string()).await
|
||||
}
|
||||
|
||||
pub async fn signed_one_time_keys_helper(
|
||||
&self,
|
||||
) -> BTreeMap<Box<DeviceKeyId>, Raw<OneTimeKey>> {
|
||||
pub async fn signed_one_time_keys_helper(&self) -> BTreeMap<Box<DeviceKeyId>, Raw<OneTimeKey>> {
|
||||
let one_time_keys = self.one_time_keys().await;
|
||||
let mut one_time_key_map = BTreeMap::new();
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ mod outbound;
|
||||
|
||||
pub use inbound::{InboundGroupSession, InboundGroupSessionPickle, PickledInboundGroupSession};
|
||||
pub use outbound::{
|
||||
OlmOutboundGroupSession, EncryptionSettings, OutboundGroupSession, PickledOutboundGroupSession, ShareInfo, ShareState,
|
||||
EncryptionSettings, OlmOutboundGroupSession, OutboundGroupSession, PickledOutboundGroupSession,
|
||||
ShareInfo, ShareState,
|
||||
};
|
||||
|
||||
/// The private session key of a group session.
|
||||
|
||||
@@ -27,13 +27,11 @@ use dashmap::DashMap;
|
||||
use matrix_sdk_common::{instant::Instant, locks::Mutex};
|
||||
pub use olm_rs::{
|
||||
account::IdentityKeys,
|
||||
session::{OlmMessage, PreKeyMessage},
|
||||
outbound_group_session::OlmOutboundGroupSession,
|
||||
session::{OlmMessage, PreKeyMessage},
|
||||
utility::OlmUtility,
|
||||
};
|
||||
use olm_rs::{
|
||||
errors::OlmGroupSessionError, PicklingMode,
|
||||
};
|
||||
use olm_rs::{errors::OlmGroupSessionError, PicklingMode};
|
||||
use ruma::{
|
||||
events::{
|
||||
room::{
|
||||
|
||||
@@ -27,7 +27,8 @@ pub(crate) use account::{Account, OlmDecryptionInfo, SessionType};
|
||||
pub use account::{AccountPickle, OlmMessageHash, PickledAccount, ReadOnlyAccount};
|
||||
pub use group_sessions::{
|
||||
EncryptionSettings, ExportedRoomKey, InboundGroupSession, InboundGroupSessionPickle,
|
||||
OlmOutboundGroupSession, OutboundGroupSession, PickledInboundGroupSession, PickledOutboundGroupSession, ShareInfo,
|
||||
OlmOutboundGroupSession, OutboundGroupSession, PickledInboundGroupSession,
|
||||
PickledOutboundGroupSession, ShareInfo,
|
||||
};
|
||||
pub use group_sessions::{GroupSessionKey, ShareState};
|
||||
use matrix_sdk_common::instant::{Duration, Instant};
|
||||
|
||||
@@ -45,8 +45,6 @@ mod pickle_key;
|
||||
#[macro_use]
|
||||
#[allow(missing_docs)]
|
||||
pub mod integration_tests;
|
||||
#[cfg(feature = "sled_cryptostore")]
|
||||
pub(crate) mod sled;
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
@@ -73,10 +71,6 @@ use zeroize::Zeroize;
|
||||
#[allow(unused_imports)]
|
||||
pub use olm_rs::{account::IdentityKeys, PicklingMode};
|
||||
|
||||
#[cfg(feature = "indexeddb_cryptostore")]
|
||||
pub use self::indexeddb::IndexeddbStore;
|
||||
#[cfg(feature = "sled_cryptostore")]
|
||||
pub use self::sled::SledStore;
|
||||
use crate::{
|
||||
error::SessionUnpicklingError,
|
||||
identities::{
|
||||
@@ -539,11 +533,6 @@ pub enum CryptoStoreError {
|
||||
#[error("can't save/load sessions or group sessions in the store before an account is stored")]
|
||||
AccountUnset,
|
||||
|
||||
/// Error in the internal database
|
||||
#[cfg(feature = "sled_cryptostore")]
|
||||
#[error(transparent)]
|
||||
Database(#[from] sled::Error),
|
||||
|
||||
/// An IO error occurred.
|
||||
#[error(transparent)]
|
||||
Io(#[from] IoError),
|
||||
|
||||
@@ -144,10 +144,10 @@ mod store_helpers {
|
||||
#[cfg(not(any(feature = "indexeddb_stores", feature = "sled_state_store")))]
|
||||
mod store_helpers {
|
||||
use super::Result;
|
||||
use matrix_sdk_base::state::MemoryStore as StateStore;
|
||||
use matrix_sdk_base::store::MemoryStore as StateStore;
|
||||
/// Open a new in-memory StateStore
|
||||
pub async fn default_store() -> Result<Box<StateStore>> {
|
||||
Ok(Box::new(StateStore::default()))
|
||||
Ok(Box::new(StateStore::new()))
|
||||
}
|
||||
|
||||
/// Alias for `default_store` - in Memory Stores are never named
|
||||
@@ -155,7 +155,7 @@ mod store_helpers {
|
||||
_name: &str,
|
||||
_passphrase: Option<&str>,
|
||||
) -> Result<Box<StateStore>> {
|
||||
Ok(Box::new(StateStore::default()))
|
||||
Ok(Box::new(StateStore::new()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user