diff --git a/Cargo.lock b/Cargo.lock index 86a0e338c..b47ef58cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -196,7 +196,7 @@ dependencies = [ "quote", "serde", "syn", - "toml", + "toml 0.5.10", ] [[package]] @@ -402,12 +402,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "base64" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" - [[package]] name = "base64" version = "0.21.0" @@ -2802,7 +2796,7 @@ dependencies = [ "assert_matches", "async-trait", "atomic", - "base64 0.20.0", + "base64 0.21.0", "bs58", "byteorder", "cfg-if", @@ -2839,7 +2833,7 @@ name = "matrix-sdk-crypto-ffi" version = "0.1.0" dependencies = [ "anyhow", - "base64 0.20.0", + "base64 0.21.0", "futures-util", "hmac", "http", @@ -2939,7 +2933,7 @@ version = "0.2.0" dependencies = [ "anyhow", "async-trait", - "base64 0.20.0", + "base64 0.21.0", "dashmap", "derive_builder", "getrandom 0.2.8", @@ -2981,7 +2975,7 @@ dependencies = [ name = "matrix-sdk-qrcode" version = "0.4.0" dependencies = [ - "base64 0.20.0", + "base64 0.21.0", "byteorder", "image 0.23.14", "qrcode", @@ -3292,6 +3286,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -3838,7 +3841,7 @@ checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" dependencies = [ "once_cell", "thiserror", - "toml", + "toml 0.5.10", ] [[package]] @@ -4257,8 +4260,9 @@ dependencies = [ [[package]] name = "ruma" -version = "0.7.4" -source = "git+https://github.com/ruma/ruma?rev=00045e559f864eabff08295d603f7b3238288b6f#00045e559f864eabff08295d603f7b3238288b6f" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca6cc9a6b4bf261181565b731357675bbbb1d86a8bdf60e9e472e44cd5e03c6" dependencies = [ "assign", "js_int", @@ -4271,8 +4275,9 @@ dependencies = [ [[package]] name = "ruma-appservice-api" -version = "0.7.0" -source = "git+https://github.com/ruma/ruma?rev=00045e559f864eabff08295d603f7b3238288b6f#00045e559f864eabff08295d603f7b3238288b6f" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14663651249acd74bafe5a3649bc2e083599cbc8525ceca427ebf4c8acda051c" dependencies = [ "js_int", "ruma-common", @@ -4282,8 +4287,9 @@ dependencies = [ [[package]] name = "ruma-client-api" -version = "0.15.3" -source = "git+https://github.com/ruma/ruma?rev=00045e559f864eabff08295d603f7b3238288b6f#00045e559f864eabff08295d603f7b3238288b6f" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20c119ef6280061723e8d7c66fdeb42179da0d178844cf8990c6a677413d2174" dependencies = [ "assign", "bytes", @@ -4299,10 +4305,11 @@ dependencies = [ [[package]] name = "ruma-common" -version = "0.10.5" -source = "git+https://github.com/ruma/ruma?rev=00045e559f864eabff08295d603f7b3238288b6f#00045e559f864eabff08295d603f7b3238288b6f" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f47f6e788aa925333c3d4ccf575a1c1aaced727af60acd2817432c3f2d12ee0d" dependencies = [ - "base64 0.20.0", + "base64 0.21.0", "bytes", "form_urlencoded", "getrandom 0.2.8", @@ -4330,8 +4337,9 @@ dependencies = [ [[package]] name = "ruma-federation-api" -version = "0.6.0" -source = "git+https://github.com/ruma/ruma?rev=00045e559f864eabff08295d603f7b3238288b6f#00045e559f864eabff08295d603f7b3238288b6f" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e9055c70716e412d30648b4bb8f7e5ad79491ebfea0b9347ce19cf8bc2a0721" dependencies = [ "js_int", "ruma-common", @@ -4342,7 +4350,8 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.9.0" -source = "git+https://github.com/ruma/ruma?rev=00045e559f864eabff08295d603f7b3238288b6f#00045e559f864eabff08295d603f7b3238288b6f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabac62d16465a87435579c779d74dceabb93b09e44c766af6085050f3cc4275" dependencies = [ "js_int", "thiserror", @@ -4350,8 +4359,9 @@ dependencies = [ [[package]] name = "ruma-macros" -version = "0.10.5" -source = "git+https://github.com/ruma/ruma?rev=00045e559f864eabff08295d603f7b3238288b6f#00045e559f864eabff08295d603f7b3238288b6f" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d17fefd01ca9d84016b256f85532185b818ecd9e7a67a4c09a8e0d9eeeec094c" dependencies = [ "once_cell", "proc-macro-crate", @@ -4360,7 +4370,7 @@ dependencies = [ "ruma-identifiers-validation", "serde", "syn", - "toml", + "toml 0.7.2", ] [[package]] @@ -4650,6 +4660,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "serde_spanned" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -5228,6 +5247,40 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6a7712b49e1775fb9a7b998de6635b299237f48b404dde71704f2e0e7f37e5" +dependencies = [ + "indexmap", + "nom8", + "serde", + "serde_spanned", + "toml_datetime", +] + [[package]] name = "tonic" version = "0.8.3" @@ -5597,7 +5650,7 @@ dependencies = [ "paste", "serde", "serde_json", - "toml", + "toml 0.5.10", "uniffi_meta", "uniffi_testing", "weedle2", @@ -5654,7 +5707,7 @@ dependencies = [ "quote", "serde", "syn", - "toml", + "toml 0.5.10", "uniffi_build", "uniffi_meta", ] diff --git a/Cargo.toml b/Cargo.toml index 8e5fad15c..2ac018527 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,13 +23,13 @@ rust-version = "1.65" anyhow = "1.0.68" async-stream = "0.3.3" async-trait = "0.1.60" -base64 = "0.20.0" +base64 = "0.21.0" byteorder = "1.4.3" ctor = "0.1.26" dashmap = "5.2.0" http = "0.2.6" -ruma = { git = "https://github.com/ruma/ruma", rev = "00045e559f864eabff08295d603f7b3238288b6f", features = ["client-api-c"] } -ruma-common = { git = "https://github.com/ruma/ruma", rev = "00045e559f864eabff08295d603f7b3238288b6f" } +ruma = { version = "0.8.0", features = ["client-api-c"] } +ruma-common = "0.11.2" once_cell = "1.16.0" serde = "1.0.151" serde_html_form = "0.2.0" diff --git a/bindings/matrix-sdk-crypto-ffi/src/verification.rs b/bindings/matrix-sdk-crypto-ffi/src/verification.rs index 6eafbb889..fda5a6989 100644 --- a/bindings/matrix-sdk-crypto-ffi/src/verification.rs +++ b/bindings/matrix-sdk-crypto-ffi/src/verification.rs @@ -1,8 +1,9 @@ use std::sync::Arc; use base64::{ - alphabet, decode_engine, encode_engine, - engine::fast_portable::{self, FastPortable}, + alphabet, + engine::{general_purpose, GeneralPurpose}, + Engine, }; use futures_util::{Stream, StreamExt}; use matrix_sdk_crypto::{ @@ -16,8 +17,8 @@ use tokio::runtime::Handle; use crate::{CryptoStoreError, OutgoingVerificationRequest, SignatureUploadRequest}; -const STANDARD_NO_PAD: FastPortable = - FastPortable::from(&alphabet::STANDARD, fast_portable::NO_PAD); +const STANDARD_NO_PAD: GeneralPurpose = + GeneralPurpose::new(&alphabet::STANDARD, general_purpose::NO_PAD); /// Listener that will be passed over the FFI to report changes to a SAS /// verification. @@ -407,7 +408,7 @@ impl QrCode { /// decoded on the other side before it can be put through a QR code /// generator. pub fn generate_qr_code(&self) -> Option { - self.inner.to_bytes().map(|data| encode_engine(data, &STANDARD_NO_PAD)).ok() + self.inner.to_bytes().map(|data| STANDARD_NO_PAD.encode(data)).ok() } /// Set a listener for changes in the QrCode verification process. @@ -709,7 +710,7 @@ impl VerificationRequest { /// * `data` - The data that was extracted from the scanned QR code as an /// base64 encoded string, without padding. pub fn scan_qr_code(&self, data: &str) -> Option { - let data = decode_engine(data, &STANDARD_NO_PAD).ok()?; + let data = STANDARD_NO_PAD.decode(data).ok()?; let data = QrVerificationData::from_bytes(data).ok()?; if let Some(qr) = self.runtime.block_on(self.inner.scan_qr_code(data)).ok()? { diff --git a/crates/matrix-sdk-crypto/src/utilities.rs b/crates/matrix-sdk-crypto/src/utilities.rs index 36d37d84e..09c7626dd 100644 --- a/crates/matrix-sdk-crypto/src/utilities.rs +++ b/crates/matrix-sdk-crypto/src/utilities.rs @@ -22,22 +22,23 @@ use std::{ pub use base64::DecodeError; use base64::{ - alphabet, decode_engine, encode_engine, - engine::fast_portable::{self, FastPortable}, + alphabet, + engine::{general_purpose, GeneralPurpose}, + Engine, }; use matrix_sdk_common::instant::Instant; -const STANDARD_NO_PAD: FastPortable = - FastPortable::from(&alphabet::STANDARD, fast_portable::NO_PAD); +const STANDARD_NO_PAD: GeneralPurpose = + GeneralPurpose::new(&alphabet::STANDARD, general_purpose::NO_PAD); /// Decode the input as base64 with no padding. pub fn decode(input: impl AsRef<[u8]>) -> Result, DecodeError> { - decode_engine(input, &STANDARD_NO_PAD) + STANDARD_NO_PAD.decode(input) } /// Encode the input as base64 with no padding. pub fn encode(input: impl AsRef<[u8]>) -> String { - encode_engine(input, &STANDARD_NO_PAD) + STANDARD_NO_PAD.encode(input) } #[cfg(test)] diff --git a/crates/matrix-sdk-indexeddb/src/safe_encode.rs b/crates/matrix-sdk-indexeddb/src/safe_encode.rs index 4838bda40..8a9f89397 100644 --- a/crates/matrix-sdk-indexeddb/src/safe_encode.rs +++ b/crates/matrix-sdk-indexeddb/src/safe_encode.rs @@ -1,7 +1,8 @@ #![allow(dead_code)] use base64::{ - alphabet, encode_engine as base64_encode, - engine::fast_portable::{self, FastPortable}, + alphabet, + engine::{general_purpose, GeneralPurpose}, + Engine, }; use matrix_sdk_store_encryption::StoreCipher; use ruma::{ @@ -25,8 +26,8 @@ pub const RANGE_END: &str = "\u{001E}"; /// (though super unlikely) pub const ESCAPED: &str = "\u{001E}\u{001D}"; -const STANDARD_NO_PAD: FastPortable = - FastPortable::from(&alphabet::STANDARD, fast_portable::NO_PAD); +const STANDARD_NO_PAD: GeneralPurpose = + GeneralPurpose::new(&alphabet::STANDARD, general_purpose::NO_PAD); /// Encode value as String/JsValue/IdbKeyRange for the JS APIs in a /// safe, escaped manner. @@ -58,10 +59,8 @@ pub trait SafeEncode { /// `store_cipher` hash_key, returns the value as a base64 encoded /// string without any padding. fn as_secure_string(&self, table_name: &str, store_cipher: &StoreCipher) -> String { - base64_encode( - store_cipher.hash_key(table_name, self.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ) + STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.as_encoded_string().as_bytes())) } /// encode self into a JsValue, internally using `as_encoded_string` @@ -120,15 +119,11 @@ where fn as_secure_string(&self, table_name: &str, store_cipher: &StoreCipher) -> String { [ - &base64_encode( - store_cipher.hash_key(table_name, self.0.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ), + &STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.0.as_encoded_string().as_bytes())), KEY_SEPARATOR, - &base64_encode( - store_cipher.hash_key(table_name, self.1.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ), + &STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.1.as_encoded_string().as_bytes())), ] .concat() } @@ -155,20 +150,14 @@ where fn as_secure_string(&self, table_name: &str, store_cipher: &StoreCipher) -> String { [ - &base64_encode( - store_cipher.hash_key(table_name, self.0.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ), + &STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.0.as_encoded_string().as_bytes())), KEY_SEPARATOR, - &base64_encode( - store_cipher.hash_key(table_name, self.1.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ), + &STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.1.as_encoded_string().as_bytes())), KEY_SEPARATOR, - &base64_encode( - store_cipher.hash_key(table_name, self.2.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ), + &STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.2.as_encoded_string().as_bytes())), ] .concat() } @@ -198,25 +187,17 @@ where fn as_secure_string(&self, table_name: &str, store_cipher: &StoreCipher) -> String { [ - &base64_encode( - store_cipher.hash_key(table_name, self.0.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ), + &STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.0.as_encoded_string().as_bytes())), KEY_SEPARATOR, - &base64_encode( - store_cipher.hash_key(table_name, self.1.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ), + &STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.1.as_encoded_string().as_bytes())), KEY_SEPARATOR, - &base64_encode( - store_cipher.hash_key(table_name, self.2.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ), + &STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.2.as_encoded_string().as_bytes())), KEY_SEPARATOR, - &base64_encode( - store_cipher.hash_key(table_name, self.3.as_encoded_string().as_bytes()), - &STANDARD_NO_PAD, - ), + &STANDARD_NO_PAD + .encode(store_cipher.hash_key(table_name, self.3.as_encoded_string().as_bytes())), ] .concat() }