From 1309ed40ae6d601a8a8cd354577fd98a7c3ca3ed Mon Sep 17 00:00:00 2001 From: Kegan Dougal <7190048+kegsay@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:11:36 +0100 Subject: [PATCH 1/4] Add mark_all_tracked_users_as_dirty This is required for SSS in Element-Web. Had to run `cargo update matrix-sdk-crypto` to pull in the latest code with this function. Hopefully I've done it right. --- Cargo.lock | 68 ++++++++++---------------------------------------- src/machine.rs | 14 +++++++++++ 2 files changed, 27 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc34479b0..16d779506 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -360,22 +360,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", - "der_derive", - "flagset", "zeroize", ] -[[package]] -name = "der_derive" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8034092389675178f570469e6c3b0465d3d30b4505c294a6550db47f3c17ad18" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "deranged" version = "0.3.11" @@ -463,12 +450,6 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" -[[package]] -name = "flagset" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3ea1ec5f8307826a5b71094dd91fc04d4ae75d5709b20ad351c7fb4815c86ec" - [[package]] name = "fnv" version = "1.0.7" @@ -842,7 +823,7 @@ dependencies = [ [[package]] name = "matrix-sdk-common" version = "0.7.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#07aa6d7bc7f8d40809226c01e68f3539c85372c9" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#2408df8bf55683821005112a0a9c01154750e597" dependencies = [ "async-trait", "futures-core", @@ -863,7 +844,7 @@ dependencies = [ [[package]] name = "matrix-sdk-crypto" version = "0.7.2" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#07aa6d7bc7f8d40809226c01e68f3539c85372c9" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#2408df8bf55683821005112a0a9c01154750e597" dependencies = [ "aes", "as_variant", @@ -930,7 +911,7 @@ dependencies = [ [[package]] name = "matrix-sdk-indexeddb" version = "0.7.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#07aa6d7bc7f8d40809226c01e68f3539c85372c9" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#2408df8bf55683821005112a0a9c01154750e597" dependencies = [ "anyhow", "async-trait", @@ -958,7 +939,7 @@ dependencies = [ [[package]] name = "matrix-sdk-qrcode" version = "0.7.1" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#07aa6d7bc7f8d40809226c01e68f3539c85372c9" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#2408df8bf55683821005112a0a9c01154750e597" dependencies = [ "byteorder", "qrcode", @@ -970,7 +951,7 @@ dependencies = [ [[package]] name = "matrix-sdk-store-encryption" version = "0.7.0" -source = "git+https://github.com/matrix-org/matrix-rust-sdk#07aa6d7bc7f8d40809226c01e68f3539c85372c9" +source = "git+https://github.com/matrix-org/matrix-rust-sdk#2408df8bf55683821005112a0a9c01154750e597" dependencies = [ "base64", "blake3", @@ -1096,17 +1077,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkcs7" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d79178be066405e0602bf3035946edef6b11b3f9dde46dfe5f8bfd7dea4b77e7" -dependencies = [ - "der", - "spki", - "x509-cert", -] - [[package]] name = "pkcs8" version = "0.10.2" @@ -1312,7 +1282,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.10.1" -source = "git+https://github.com/matrix-org/ruma?rev=17f6e555528512319e706bb2cfe68a12ec5603b6#17f6e555528512319e706bb2cfe68a12ec5603b6" +source = "git+https://github.com/matrix-org/ruma?rev=bb6d4c531aebb571fed4b1948df0118244762741#bb6d4c531aebb571fed4b1948df0118244762741" dependencies = [ "assign", "js_int", @@ -1326,7 +1296,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.18.0" -source = "git+https://github.com/matrix-org/ruma?rev=17f6e555528512319e706bb2cfe68a12ec5603b6#17f6e555528512319e706bb2cfe68a12ec5603b6" +source = "git+https://github.com/matrix-org/ruma?rev=bb6d4c531aebb571fed4b1948df0118244762741#bb6d4c531aebb571fed4b1948df0118244762741" dependencies = [ "as_variant", "assign", @@ -1349,7 +1319,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.13.0" -source = "git+https://github.com/matrix-org/ruma?rev=17f6e555528512319e706bb2cfe68a12ec5603b6#17f6e555528512319e706bb2cfe68a12ec5603b6" +source = "git+https://github.com/matrix-org/ruma?rev=bb6d4c531aebb571fed4b1948df0118244762741#bb6d4c531aebb571fed4b1948df0118244762741" dependencies = [ "as_variant", "base64", @@ -1381,7 +1351,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.28.1" -source = "git+https://github.com/matrix-org/ruma?rev=17f6e555528512319e706bb2cfe68a12ec5603b6#17f6e555528512319e706bb2cfe68a12ec5603b6" +source = "git+https://github.com/matrix-org/ruma?rev=bb6d4c531aebb571fed4b1948df0118244762741#bb6d4c531aebb571fed4b1948df0118244762741" dependencies = [ "as_variant", "indexmap", @@ -1404,7 +1374,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.9.5" -source = "git+https://github.com/matrix-org/ruma?rev=17f6e555528512319e706bb2cfe68a12ec5603b6#17f6e555528512319e706bb2cfe68a12ec5603b6" +source = "git+https://github.com/matrix-org/ruma?rev=bb6d4c531aebb571fed4b1948df0118244762741#bb6d4c531aebb571fed4b1948df0118244762741" dependencies = [ "js_int", "thiserror", @@ -1413,8 +1383,9 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.13.0" -source = "git+https://github.com/matrix-org/ruma?rev=17f6e555528512319e706bb2cfe68a12ec5603b6#17f6e555528512319e706bb2cfe68a12ec5603b6" +source = "git+https://github.com/matrix-org/ruma?rev=bb6d4c531aebb571fed4b1948df0118244762741#bb6d4c531aebb571fed4b1948df0118244762741" dependencies = [ + "cfg-if", "once_cell", "proc-macro-crate", "proc-macro2", @@ -1947,8 +1918,7 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vodozemac" version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051d4af70b53b42adf2aac459a305851b8d754f210aaf11ab509e1065beff422" +source = "git+https://github.com/matrix-org/vodozemac?rev=57cbf7e939d7b54d20207e8361b7135bd65c9cc2#57cbf7e939d7b54d20207e8361b7135bd65c9cc2" dependencies = [ "aes", "arrayvec", @@ -1962,7 +1932,6 @@ dependencies = [ "hkdf", "hmac", "matrix-pickle", - "pkcs7", "prost", "rand", "serde", @@ -2150,17 +2119,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "x509-cert" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1301e935010a701ae5f8655edc0ad17c44bad3ac5ce8c39185f75453b720ae94" -dependencies = [ - "const-oid", - "der", - "spki", -] - [[package]] name = "zerocopy" version = "0.6.6" diff --git a/src/machine.rs b/src/machine.rs index 584109a80..a30d07539 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -178,6 +178,20 @@ impl OlmMachine { future_to_promise(async move { Ok(me.display_name().await?) }) } + /// Mark all tracked users as dirty. + /// + /// All users *whose device lists we are tracking* are flagged as needing a + /// key query. Users whose devices we are not tracking are ignored. + #[wasm_bindgen(js_name = "markAllTrackedUsersAsDirty")] + pub fn mark_all_tracked_users_as_dirty(&self) -> Promise { + let machine = self.inner.clone(); + + future_to_promise(async move { + machine.mark_all_tracked_users_as_dirty().await?; + Ok(JsValue::UNDEFINED) + }) + } + /// Whether automatic transmission of room key requests is enabled. /// /// Room key requests allow the device to request room keys that it might From 35b376820138d437198b89ff323b4769c3429622 Mon Sep 17 00:00:00 2001 From: Kegan Dougal <7190048+kegsay@users.noreply.github.com> Date: Fri, 13 Sep 2024 12:21:23 +0100 Subject: [PATCH 2/4] Add changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c87a46ad3..14a06aa7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # UNRELEASED +**Other changes** + +- Add `OlmMachine.markAllTrackedUsersAsDirty` to invalidate the device lists + for all known users. This is required for [MSC4186](https://github.com/matrix-org/matrix-spec-proposals/pull/4186) + clients as the server may give up trying to persist device list updates for + the client at some point, after which the client must treat all devices as dirty. + # matrix-sdk-crypto-wasm v8.0.0 **BREAKING CHANGES** From d97ea0d7d914534d4d497750aad8c1080f992754 Mon Sep 17 00:00:00 2001 From: Kegan Dougal <7190048+kegsay@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:46:52 +0100 Subject: [PATCH 3/4] Review comments --- src/machine.rs | 24 ++++++++++-------------- tests/machine.test.ts | 5 +++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/machine.rs b/src/machine.rs index a30d07539..36401c36b 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -178,20 +178,6 @@ impl OlmMachine { future_to_promise(async move { Ok(me.display_name().await?) }) } - /// Mark all tracked users as dirty. - /// - /// All users *whose device lists we are tracking* are flagged as needing a - /// key query. Users whose devices we are not tracking are ignored. - #[wasm_bindgen(js_name = "markAllTrackedUsersAsDirty")] - pub fn mark_all_tracked_users_as_dirty(&self) -> Promise { - let machine = self.inner.clone(); - - future_to_promise(async move { - machine.mark_all_tracked_users_as_dirty().await?; - Ok(JsValue::UNDEFINED) - }) - } - /// Whether automatic transmission of room key requests is enabled. /// /// Room key requests allow the device to request room keys that it might @@ -275,6 +261,16 @@ impl OlmMachine { }) } + /// Mark all tracked users as dirty. + /// + /// All users *whose device lists we are tracking* are flagged as needing a + /// key query. Users whose devices we are not tracking are ignored. + #[wasm_bindgen(js_name = "markAllTrackedUsersAsDirty")] + pub async fn mark_all_tracked_users_as_dirty(&self) -> Result<(), JsError> { + self.inner.mark_all_tracked_users_as_dirty().await?; + Ok(()) + } + /// Handle to-device events and one-time key counts from a sync /// response. /// diff --git a/tests/machine.test.ts b/tests/machine.test.ts index 5f050a180..2dbd6cdd3 100644 --- a/tests/machine.test.ts +++ b/tests/machine.test.ts @@ -725,6 +725,11 @@ describe(OlmMachine.name, () => { } }); + test("can mark all tracked users as dirty", async () => { + const m = await machine(); + await m.markAllTrackedUsersAsDirty(); + }); + test("can get own user identity", async () => { const m = await machine(); let _ = m.bootstrapCrossSigning(true); From 802a6ff385210d42248985895d524ef8784ac9fb Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 17 Sep 2024 15:38:36 +0100 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6229c4623..f4b885573 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ clients as the server may give up trying to persist device list updates for the client at some point, after which the client must treat all devices as dirty. +- Update matrix-rust-sdk to `2408df8bf`. No changes relevant to these bindings. + # matrix-sdk-crypto-wasm v8.0.0 **BREAKING CHANGES**