diff --git a/crates/matrix-sdk-common/CHANGELOG.md b/crates/matrix-sdk-common/CHANGELOG.md index 6332d992a..181daeb32 100644 --- a/crates/matrix-sdk-common/CHANGELOG.md +++ b/crates/matrix-sdk-common/CHANGELOG.md @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file. ### Features +- [**breaking**] Change to the stable identifiers for `m.history_not_shared`. + We still support reading the unstable identifier. + ([#6467](https://github.com/matrix-org/matrix-rust-sdk/pull/6467)) - Add a method to check the validity of edits. ([#6454](https://github.com/matrix-org/matrix-rust-sdk/pull/6454)) - A background task monitor has been added, that can spawn background tasks and monitor their diff --git a/crates/matrix-sdk-common/src/deserialized_responses.rs b/crates/matrix-sdk-common/src/deserialized_responses.rs index 389284829..50eeae8ab 100644 --- a/crates/matrix-sdk-common/src/deserialized_responses.rs +++ b/crates/matrix-sdk-common/src/deserialized_responses.rs @@ -1249,7 +1249,7 @@ pub enum WithheldCode { /// that the session was not marked as "shared_history". /// /// [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 - #[ruma_enum(rename = "io.element.msc4268.history_not_shared", alias = "m.history_not_shared")] + #[ruma_enum(rename = "m.history_not_shared", alias = "io.element.msc4268.history_not_shared")] HistoryNotShared, #[doc(hidden)] diff --git a/crates/matrix-sdk-crypto/CHANGELOG.md b/crates/matrix-sdk-crypto/CHANGELOG.md index 24dd362c7..e91073be4 100644 --- a/crates/matrix-sdk-crypto/CHANGELOG.md +++ b/crates/matrix-sdk-crypto/CHANGELOG.md @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file. ### Features +- [**breaking**] Change to the stable identifiers for `m.room_key_bundle` and + `m.history_not_shared`. We still support reading the unstable identifiers. + ([#6467](https://github.com/matrix-org/matrix-rust-sdk/pull/6467)) - Add support for MSC4385. ([#6164](https://github.com/matrix-org/matrix-rust-sdk/pull/6164)) - Add new method `OlmMachine::push_secret_to_verified_devices`. diff --git a/crates/matrix-sdk-crypto/src/machine/mod.rs b/crates/matrix-sdk-crypto/src/machine/mod.rs index cd0d4a099..a25740758 100644 --- a/crates/matrix-sdk-crypto/src/machine/mod.rs +++ b/crates/matrix-sdk-crypto/src/machine/mod.rs @@ -960,8 +960,7 @@ impl OlmMachine { } } - /// Handle a received, decrypted, `io.element.msc4268.room_key_bundle` - /// to-device event. + /// Handle a received, decrypted, `m.room_key_bundle` to-device event. #[instrument()] async fn receive_room_key_bundle_data( &self, diff --git a/crates/matrix-sdk-crypto/src/store/snapshots/matrix_sdk_crypto__store__tests__build_room_key_bundle.snap b/crates/matrix-sdk-crypto/src/store/snapshots/matrix_sdk_crypto__store__tests__build_room_key_bundle.snap index d212f2c25..73b724d9e 100644 --- a/crates/matrix-sdk-crypto/src/store/snapshots/matrix_sdk_crypto__store__tests__build_room_key_bundle.snap +++ b/crates/matrix-sdk-crypto/src/store/snapshots/matrix_sdk_crypto__store__tests__build_room_key_bundle.snap @@ -28,7 +28,7 @@ expression: bundle "withheld": [ { "algorithm": "[algorithm]", - "code": "io.element.msc4268.history_not_shared", + "code": "m.history_not_shared", "from_device": "BOB", "reason": "The sender disabled sharing encrypted history.", "room_id": "!room1:localhost", diff --git a/crates/matrix-sdk-crypto/src/types/events/olm_v1.rs b/crates/matrix-sdk-crypto/src/types/events/olm_v1.rs index ac28d0520..3c240ddfb 100644 --- a/crates/matrix-sdk-crypto/src/types/events/olm_v1.rs +++ b/crates/matrix-sdk-crypto/src/types/events/olm_v1.rs @@ -83,7 +83,7 @@ impl DecryptedForwardedRoomKeyEvent { /// `m.olm.v1.curve25519-aes-sha2` algorithm pub type DecryptedSecretSendEvent = DecryptedOlmV1Event; -/// An `io.element.msc4268.room_key_bundle` to-device event which has +/// An `m.room_key_bundle` to-device event which has /// been decrypted using using the `m.olm.v1.curve25519-aes-sha2` algorithm pub type DecryptedRoomKeyBundleEvent = DecryptedOlmV1Event; @@ -104,7 +104,7 @@ pub enum AnyDecryptedOlmEvent { SecretSend(DecryptedSecretSendEvent), /// The `m.dummy` decrypted to-device event. Dummy(DecryptedDummyEvent), - /// The `io.element.msc4268.room_key_bundle` decrypted to-device event. + /// The `m.room_key_bundle` decrypted to-device event. RoomKeyBundle(DecryptedRoomKeyBundleEvent), /// The `io.element.msc4385.secret.push` decrypted to-device event. #[cfg(feature = "experimental-push-secrets")] @@ -352,7 +352,7 @@ impl<'de> Deserialize<'de> for AnyDecryptedOlmEvent { } SecretSendContent::EVENT_TYPE => AnyDecryptedOlmEvent::SecretSend(from_str(json)?), DummyEventContent::EVENT_TYPE => AnyDecryptedOlmEvent::Dummy(from_str(json)?), - RoomKeyBundleContent::EVENT_TYPE => { + RoomKeyBundleContent::EVENT_TYPE | RoomKeyBundleContent::UNSTABLE_EVENT_TYPE => { AnyDecryptedOlmEvent::RoomKeyBundle(from_str(json)?) } #[cfg(feature = "experimental-push-secrets")] @@ -479,7 +479,7 @@ mod tests { }) } - fn room_key_bundle_event_unstable() -> Value { + fn room_key_bundle_event(stable: bool) -> Value { json!({ "sender": "@u:s.co", "recipient": "@x:s.co", @@ -508,10 +508,18 @@ mod tests { "hashes": {} } }, - "type": "io.element.msc4268.room_key_bundle" + "type": if stable { "m.room_key_bundle" } else { "io.element.msc4268.room_key_bundle" } }) } + fn room_key_bundle_event_stable() -> Value { + room_key_bundle_event(true) + } + + fn room_key_bundle_event_unstable() -> Value { + room_key_bundle_event(false) + } + /// Return the JSON for creating sender device keys, and the matching /// `DeviceKeys` object that should be created when the JSON is /// deserialized. @@ -624,6 +632,9 @@ mod tests { dummy_event => Dummy, // `m.room_key_bundle` + room_key_bundle_event_stable => RoomKeyBundle, + + // `m.io.element.msc4268.room_key_bundle` room_key_bundle_event_unstable => RoomKeyBundle, ); @@ -693,7 +704,7 @@ mod tests { let event = DecryptedRoomKeyBundleEvent::new(sender, recipient, key, None, content); - assert_eq!(serde_json::to_value(&event).unwrap(), room_key_bundle_event_unstable()); + assert_eq!(serde_json::to_value(&event).unwrap(), room_key_bundle_event_stable()); } #[test] diff --git a/crates/matrix-sdk-crypto/src/types/events/room_key_bundle.rs b/crates/matrix-sdk-crypto/src/types/events/room_key_bundle.rs index 96cd4bfc1..dc69b6ec8 100644 --- a/crates/matrix-sdk-crypto/src/types/events/room_key_bundle.rs +++ b/crates/matrix-sdk-crypto/src/types/events/room_key_bundle.rs @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Types for `io.element.msc4268.room_key_bundle` to-device events, per -//! [MSC4268]. +//! Types for `m.room_key_bundle` to-device events, per [MSC4268]. //! //! [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 @@ -22,7 +21,7 @@ use serde::{Deserialize, Serialize}; use super::EventType; -/// The `io.element.msc4268.room_key_bundle` event content. See [MSC4268]. +/// The `m.room_key_bundle` event content. See [MSC4268]. /// /// [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268 #[derive(Clone, Debug, Serialize, Deserialize)] @@ -34,6 +33,11 @@ pub struct RoomKeyBundleContent { pub file: EncryptedFile, } -impl EventType for RoomKeyBundleContent { - const EVENT_TYPE: &'static str = "io.element.msc4268.room_key_bundle"; +impl RoomKeyBundleContent { + /// The unstable event type for MSC4268 m.room_key_bundle + pub const UNSTABLE_EVENT_TYPE: &'static str = "io.element.msc4268.room_key_bundle"; +} + +impl EventType for RoomKeyBundleContent { + const EVENT_TYPE: &'static str = "m.room_key_bundle"; } diff --git a/testing/matrix-sdk-integration-testing/src/tests/e2ee/shared_history.rs b/testing/matrix-sdk-integration-testing/src/tests/e2ee/shared_history.rs index 5490fe1bc..cda89a161 100644 --- a/testing/matrix-sdk-integration-testing/src/tests/e2ee/shared_history.rs +++ b/testing/matrix-sdk-integration-testing/src/tests/e2ee/shared_history.rs @@ -1648,9 +1648,9 @@ fn assert_received_room_key_bundle(sync_response: matrix_sdk::sync::SyncResponse "Expected the to-device event to be decrypted" ); assert_eq!( - "io.element.msc4268.room_key_bundle", + "m.room_key_bundle", raw.get_field::("type").unwrap().unwrap(), - "Expected the event type to be 'io.element.msc4268.room_key_bundle'" + "Expected the event type to be 'm.room_key_bundle'" ); } diff --git a/testing/matrix-sdk-integration-testing/src/tests/e2ee/state_events.rs b/testing/matrix-sdk-integration-testing/src/tests/e2ee/state_events.rs index aeaae6c0c..97ba58fa2 100644 --- a/testing/matrix-sdk-integration-testing/src/tests/e2ee/state_events.rs +++ b/testing/matrix-sdk-integration-testing/src/tests/e2ee/state_events.rs @@ -99,10 +99,7 @@ async fn test_e2ee_state_events() -> Result<()> { assert_eq!(bob_response.to_device.len(), 1); let to_device_event = &bob_response.to_device[0]; assert_let!(ProcessedToDeviceEvent::Decrypted { raw, .. } = to_device_event); - assert_eq!( - raw.get_field::("type").unwrap().unwrap(), - "io.element.msc4268.room_key_bundle" - ); + assert_eq!(raw.get_field::("type").unwrap().unwrap(), "m.room_key_bundle"); bob.get_room(alice_room.room_id()).expect("Bob should have received the invite");