diff --git a/crates/matrix-sdk-crypto-js/.gitignore b/crates/matrix-sdk-crypto-js/.gitignore index 5dffd5f39..4029dd2a8 100644 --- a/crates/matrix-sdk-crypto-js/.gitignore +++ b/crates/matrix-sdk-crypto-js/.gitignore @@ -1,3 +1,3 @@ /docs /node_modules -/package-lock.json \ No newline at end of file +/package-lock.json diff --git a/crates/matrix-sdk-crypto-js/Cargo.toml b/crates/matrix-sdk-crypto-js/Cargo.toml index 7c58d489f..492cf2daf 100644 --- a/crates/matrix-sdk-crypto-js/Cargo.toml +++ b/crates/matrix-sdk-crypto-js/Cargo.toml @@ -27,8 +27,8 @@ qrcode = ["matrix-sdk-crypto/qrcode"] docsrs = [] [dependencies] -matrix-sdk-crypto = { version = "0.5.0", path = "../matrix-sdk-crypto" } matrix-sdk-common = { version = "0.5.0", path = "../matrix-sdk-common" } +matrix-sdk-crypto = { version = "0.5.0", path = "../matrix-sdk-crypto" } ruma = { version = "0.6.2", features = ["client-api-c", "js", "rand", "unstable-msc2676", "unstable-msc2677"] } vodozemac = { git = "https://github.com/matrix-org/vodozemac/", rev = "d0e744287a14319c2a9148fef3747548c740fc36", features = ["js"] } wasm-bindgen = "0.2.80" diff --git a/crates/matrix-sdk-crypto-js/README.md b/crates/matrix-sdk-crypto-js/README.md index 6ac2d6e5e..7ff2e718a 100644 --- a/crates/matrix-sdk-crypto-js/README.md +++ b/crates/matrix-sdk-crypto-js/README.md @@ -1,19 +1,19 @@ # `matrix-sdk-crypto-js` Welcome to the [WebAssembly] + JavaScript binding for the Rust -[`matrix-sdk-crypto`] library! WebAssembly can run anywhere, but this -binding is designed to run on a JavaScript host. This binding is part -of the [`matrix-rust-sdk`] project, which is a library implementation -of a [Matrix] client-server. +[`matrix-sdk-crypto`] library! WebAssembly can run anywhere, but these +bindings are designed to run on a JavaScript host. These bindings are +part of the [`matrix-rust-sdk`] project, which is a library +implementation of a [Matrix] client-server. -`matrix-sdk-crypto-js` is a no-network-IO implementation of a state +`matrix-sdk-crypto` is a no-network-IO implementation of a state machine, named `OlmMachine`, that handles E2EE ([End-to-End Encryption](https://en.wikipedia.org/wiki/End-to-end_encryption)) for [Matrix] clients. ## Usage -This WebAssembly binding is written in [Rust]. To build this binding, you +These WebAssembly bindings are written in [Rust]. To build them, you need to install the Rust compiler, see [the Install Rust Page](https://www.rust-lang.org/tools/install). Then, the workflow is pretty classical by using [npm], see [the Downloading and installing @@ -29,8 +29,9 @@ $ npm run build $ npm run test ``` -A `matrix_sdk_crypto.js`, `matrix_sdk_crypto.d.ts` and a `matrix_sdk_crypto_bg.wasm` files should be -generated in the `pkg/` directory. +A `matrix_sdk_crypto.js`, `matrix_sdk_crypto.d.ts` and a +`matrix_sdk_crypto_bg.wasm` files should be generated in the `pkg/` +directory. TBD diff --git a/crates/matrix-sdk-crypto-js/src/machine.rs b/crates/matrix-sdk-crypto-js/src/machine.rs index 1dafec33d..e6f45175d 100644 --- a/crates/matrix-sdk-crypto-js/src/machine.rs +++ b/crates/matrix-sdk-crypto-js/src/machine.rs @@ -84,9 +84,9 @@ impl OlmMachine { pub fn tracked_users(&self) -> Set { let set = Set::new(&JsValue::UNDEFINED); - self.inner.tracked_users().into_iter().map(identifiers::UserId::from).for_each(|user| { - set.add(&user.into()); - }); + for user in self.inner.tracked_users() { + set.add(&identifiers::UserId::from(user).into()); + } set }