diff --git a/Cargo.toml b/Cargo.toml index 28b48a64..78c8ddd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,11 +63,11 @@ wasi = { version = "0.13", default-features = false } windows-targets = "0.52" # wasm_js -[target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", target_os = "unknown"))'.dependencies] -wasm-bindgen = { version = "0.2.89", default-features = false } -js-sys = "0.3" -[target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies] -wasm-bindgen-test = "0.3.39" +[target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))'.dependencies] +wasm-bindgen = { version = "0.2.96", default-features = false } +js-sys = "0.3.73" +[target.'cfg(all(getrandom_backend = "wasm_js", target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))'.dev-dependencies] +wasm-bindgen-test = "0.3" [features] # Implement std::error::Error for getrandom::Error and diff --git a/README.md b/README.md index d145c2fe..417ab92e 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ of randomness based on their specific needs: | `rdrand` | x86, x86-64 | `x86_64-*`, `i686-*` | [`RDRAND`] instruction | `rndr` | AArch64 | `aarch64-*` | [`RNDR`] register | `esp_idf` | ESP-IDF | `*‑espidf` | [`esp_fill_random`]. WARNING: can return low-quality entropy without proper hardware configuration! -| `wasm_js` | Web Browser, Node.js | `wasm32‑unknown‑unknown` | [`Crypto.getRandomValues`] if available, then [`crypto.randomFillSync`] if on Node.js (see [WebAssembly support]) +| `wasm_js` | Web Browser, Node.js | `wasm32‑unknown‑unknown`, `wasm32v1-none` | [`Crypto.getRandomValues`] if available, then [`crypto.randomFillSync`] if on Node.js (see [WebAssembly support]) | `custom` | All targets | `*` | User-provided custom implementation (see [custom backend]) Opt-in backends can be enabled using the `getrandom_backend` configuration flag. diff --git a/src/backends.rs b/src/backends.rs index a744a229..f7b720f5 100644 --- a/src/backends.rs +++ b/src/backends.rs @@ -150,7 +150,7 @@ cfg_if! { pub use rdrand::*; } else if #[cfg(all( target_arch = "wasm32", - target_os = "unknown", + any(target_os = "unknown", target_os = "none") ))] { compile_error!("the wasm32-unknown-unknown targets are not supported \ by default, you may need to enable the \"wasm_js\" \ diff --git a/src/backends/wasm_js.rs b/src/backends/wasm_js.rs index 1dd8e70f..f9cd98d1 100644 --- a/src/backends/wasm_js.rs +++ b/src/backends/wasm_js.rs @@ -8,7 +8,7 @@ use core::sync::atomic::{AtomicU8, Ordering}; pub use crate::util::{inner_u32, inner_u64}; -#[cfg(not(all(target_arch = "wasm32", target_os = "unknown",)))] +#[cfg(not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"))))] compile_error!("`wasm_js` backend can be enabled only for OS-less WASM targets!"); use js_sys::{global, Function, Uint8Array};