From 5766b65eeb0ae66d883fac58079c883cf0590600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 15 Mar 2022 12:37:27 +0100 Subject: [PATCH] feat(store-key): Add a feature flag to enable WASM support --- crates/matrix-store-key/Cargo.toml | 4 ++++ crates/matrix-store-key/README.md | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/crates/matrix-store-key/Cargo.toml b/crates/matrix-store-key/Cargo.toml index 358d7a796..38c408a8a 100644 --- a/crates/matrix-store-key/Cargo.toml +++ b/crates/matrix-store-key/Cargo.toml @@ -6,10 +6,14 @@ description = "Helpers for encrypted storage keys for the Matrix SDK" repository = "https://github.com/matrix-org/matrix-rust-sdk" license = "Apache-2.0" +[features] +js = ["getrandom/js"] + [dependencies] blake3 = "1.3.1" chacha20poly1305 = { version = "0.9.0", features = ["std"] } displaydoc = "0.2" +getrandom = { version = "0.2.5", optional = true } hmac = "0.12.1" pbkdf2 = "0.10.1" rand = "0.8.4" diff --git a/crates/matrix-store-key/README.md b/crates/matrix-store-key/README.md index db3683f18..e58ee11e4 100644 --- a/crates/matrix-store-key/README.md +++ b/crates/matrix-store-key/README.md @@ -70,3 +70,12 @@ used for non-Matrix specific data users need to ensure: 1. That individual values are chunked, otherwise decryption might be succeptible to a DOS attack. 2. The `StoreKey` is periodically rotated/rekeyed. + +# WASM support + +This crate relies on the `random` and `getrandom` crates which don't support +WASM automatically. + +Either turn the `js` feature on directly on this crate or depend on `getrandom` +with the `js` feature turned on. More info can be found in the [`getrandom` +docs](https://docs.rs/getrandom/latest/getrandom/index.html#webassembly-support).