diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b0fbdb..772962a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # UNRELEASED +- Update matrix-rust-sdk to `75683d268fc2e`. + +**BREAKING CHANGES** + +- Remove `SignedCurve25519` variant of `DeviceKeyAlgorithm`. + # matrix-sdk-crypto-wasm v10.1.0 - Update matrix-rust-sdk to `ce9dc73376b4ee` diff --git a/Cargo.lock b/Cargo.lock index 9b55df8..4b534dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -826,7 +826,7 @@ dependencies = [ [[package]] name = "matrix-sdk-common" version = "0.7.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#6752cf73df944ad8e62d8e1b9056680d4e1ce346" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#75683d268fc2e0fc1c21e038ac9c59706a9b9180" dependencies = [ "async-trait", "futures-core", @@ -847,7 +847,7 @@ dependencies = [ [[package]] name = "matrix-sdk-crypto" version = "0.7.2" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#6752cf73df944ad8e62d8e1b9056680d4e1ce346" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#75683d268fc2e0fc1c21e038ac9c59706a9b9180" dependencies = [ "aes", "as_variant", @@ -913,7 +913,7 @@ dependencies = [ [[package]] name = "matrix-sdk-indexeddb" version = "0.7.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#6752cf73df944ad8e62d8e1b9056680d4e1ce346" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#75683d268fc2e0fc1c21e038ac9c59706a9b9180" dependencies = [ "anyhow", "async-trait", @@ -941,7 +941,7 @@ dependencies = [ [[package]] name = "matrix-sdk-qrcode" version = "0.7.1" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#6752cf73df944ad8e62d8e1b9056680d4e1ce346" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#75683d268fc2e0fc1c21e038ac9c59706a9b9180" dependencies = [ "byteorder", "qrcode", @@ -953,7 +953,7 @@ dependencies = [ [[package]] name = "matrix-sdk-store-encryption" version = "0.7.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#6752cf73df944ad8e62d8e1b9056680d4e1ce346" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#75683d268fc2e0fc1c21e038ac9c59706a9b9180" dependencies = [ "base64", "blake3", @@ -1300,8 +1300,9 @@ dependencies = [ [[package]] name = "ruma" -version = "0.10.1" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d719b9e1ce5b34a1e0b6e2ba4707f7923ce7fb3474881d771466456d68f3e485" dependencies = [ "assign", "js_int", @@ -1314,8 +1315,9 @@ dependencies = [ [[package]] name = "ruma-client-api" -version = "0.18.0" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "325e054db8d5545c00767d9868356d61e63f2c6cb8b54768346d66696ea4ad48" dependencies = [ "as_variant", "assign", @@ -1337,8 +1339,9 @@ dependencies = [ [[package]] name = "ruma-common" -version = "0.13.0" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4717eb215175df5087fdd79da2c9a4198c9a50fe747db0afbc23c8ac18a25da8" dependencies = [ "as_variant", "base64", @@ -1369,8 +1372,9 @@ dependencies = [ [[package]] name = "ruma-events" -version = "0.28.1" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "969cfed397d22f0338d99457409aa9c9dd4def4a5ce8d6567e914a320bad30da" dependencies = [ "as_variant", "indexmap", @@ -1392,8 +1396,9 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" -version = "0.9.5" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7f9b534a65698d7db3c08d94bf91de0046fe6c7893a7b360502f65e7011ac4" dependencies = [ "js_int", "thiserror", @@ -1401,8 +1406,9 @@ dependencies = [ [[package]] name = "ruma-macros" -version = "0.13.0" -source = "git+https://github.com/ruma/ruma?rev=26165b23fc2ae9928c5497a21db3d31f4b44cc2a#26165b23fc2ae9928c5497a21db3d31f4b44cc2a" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d57d3cb20e8e758e8f7c5e408ce831d46758003b615100099852e468631934" dependencies = [ "cfg-if", "once_cell", diff --git a/src/identifiers.rs b/src/identifiers.rs index e090a73..5044478 100644 --- a/src/identifiers.rs +++ b/src/identifiers.rs @@ -120,7 +120,16 @@ impl DeviceKeyId { /// Returns device ID of the device key ID. #[wasm_bindgen(getter, js_name = "deviceId")] pub fn device_id(&self) -> DeviceId { - self.inner.device_id().to_owned().into() + // TODO: when https://github.com/ruma/ruma/issues/1940 is fixed, + // this should just be: + //self.inner.key_name().to_owned().into() + + let key_id = self.inner.to_string(); + + let colon_pos = + key_id.find(":").expect("Key should not have parsed if it did not contain ':'"); + + DeviceId::new(&key_id[(colon_pos + 1)..]) } /// Return the device key ID as a string. @@ -163,17 +172,14 @@ impl DeviceKeyAlgorithm { #[derive(Debug)] pub enum DeviceKeyAlgorithmName { /// The Ed25519 signature algorithm. - Ed25519, + Ed25519 = 0, /// The Curve25519 ECDH algorithm. - Curve25519, - - /// The Curve25519 ECDH algorithm, but the key also contains - /// signatures. - SignedCurve25519, + Curve25519 = 1, + // SignedCurve25519 = 2 used to exist but was removed from Ruma /// An unknown device key algorithm. - Unknown, + Unknown = 3, } impl TryFrom for ruma::DeviceKeyAlgorithm { @@ -185,7 +191,6 @@ impl TryFrom for ruma::DeviceKeyAlgorithm { Ok(match value { Ed25519 => Self::Ed25519, Curve25519 => Self::Curve25519, - SignedCurve25519 => Self::SignedCurve25519, Unknown => { return Err(JsError::new( "The `DeviceKeyAlgorithmName.Unknown` variant cannot be converted", @@ -202,7 +207,6 @@ impl From for DeviceKeyAlgorithmName { match value { Ed25519 => Self::Ed25519, Curve25519 => Self::Curve25519, - SignedCurve25519 => Self::SignedCurve25519, _ => Self::Unknown, } } diff --git a/src/machine.rs b/src/machine.rs index 71ae99f..c0c5ba5 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -13,7 +13,7 @@ use js_sys::{Array, Function, JsString, Map, Promise, Set}; use matrix_sdk_common::{ deserialized_responses::TimelineEvent, ruma::{ - self, events::secret::request::SecretName, serde::Raw, DeviceKeyAlgorithm, OwnedDeviceId, + self, events::secret::request::SecretName, serde::Raw, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedTransactionId, OwnedUserId, UInt, }, }; @@ -309,13 +309,13 @@ impl OlmMachine { ) -> Result { let to_device_events = serde_json::from_str(to_device_events)?; let changed_devices = changed_devices.inner.clone(); - let one_time_keys_counts: BTreeMap = one_time_keys_counts + let one_time_keys_counts: BTreeMap = one_time_keys_counts .entries() .into_iter() .filter_map(|js_value| { let pair = Array::from(&js_value.ok()?); let (key, value) = ( - DeviceKeyAlgorithm::from(pair.at(0).as_string()?), + OneTimeKeyAlgorithm::from(pair.at(0).as_string()?), UInt::new(pair.at(1).as_f64()? as u64)?, ); @@ -323,14 +323,14 @@ impl OlmMachine { }) .collect(); - // Convert the unused_fallback_keys JS Set to a `Vec` - let unused_fallback_keys: Option> = + // Convert the unused_fallback_keys JS Set to a `Vec` + let unused_fallback_keys: Option> = unused_fallback_keys.map(|fallback_keys| { fallback_keys .values() .into_iter() .filter_map(|js_value| { - Some(DeviceKeyAlgorithm::from(js_value.ok()?.as_string()?)) + Some(OneTimeKeyAlgorithm::from(js_value.ok()?.as_string()?)) }) .collect() }); diff --git a/src/requests.rs b/src/requests.rs index 819132c..051c663 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -712,7 +712,7 @@ pub(crate) mod tests { claim_keys::v3::Request as OriginalKeysClaimRequest, upload_keys::v3::Request as OriginalKeysUploadRequest, }, - device_id, user_id, DeviceKeyAlgorithm, + device_id, user_id, OneTimeKeyAlgorithm, }; use matrix_sdk_crypto::requests::KeysQueryRequest as OriginalKeysQueryRequest; use serde_json::Value; @@ -727,7 +727,7 @@ pub(crate) mod tests { user_id!("@alice:localhost").to_owned(), BTreeMap::from([( device_id!("ABCDEFG").to_owned(), - DeviceKeyAlgorithm::SignedCurve25519, + OneTimeKeyAlgorithm::SignedCurve25519, )]), )])); let request = KeysClaimRequest::try_from(("ID".to_string(), &rust_request)).unwrap(); @@ -743,7 +743,7 @@ pub(crate) mod tests { user_id!("@alice:localhost").to_owned(), BTreeMap::from([( device_id!("ABCDEFG").to_owned(), - DeviceKeyAlgorithm::SignedCurve25519, + OneTimeKeyAlgorithm::SignedCurve25519, )]), )])); rust_request.timeout = None; diff --git a/tests/identifiers.test.js b/tests/identifiers.test.js index d3b3c29..d4b9027 100644 --- a/tests/identifiers.test.js +++ b/tests/identifiers.test.js @@ -61,14 +61,6 @@ describe(DeviceKeyId.name, () => { deviceId: "foobar", }, - { - name: "signed curve25519", - id: "signed_curve25519:foobar", - algorithmName: DeviceKeyAlgorithmName.SignedCurve25519, - algorithm: "signed_curve25519", - deviceId: "foobar", - }, - { name: "unknown", id: "hello:foobar", @@ -92,7 +84,6 @@ describe("DeviceKeyAlgorithmName", () => { test("has the correct variants", () => { expect(DeviceKeyAlgorithmName.Ed25519).toStrictEqual(0); expect(DeviceKeyAlgorithmName.Curve25519).toStrictEqual(1); - expect(DeviceKeyAlgorithmName.SignedCurve25519).toStrictEqual(2); expect(DeviceKeyAlgorithmName.Unknown).toStrictEqual(3); }); });