|
31 | 31 | //! | Emscripten | `*‑emscripten` | `/dev/random` (identical to `/dev/urandom`) |
32 | 32 | //! | WASI | `wasm32‑wasi` | [`random_get`] |
33 | 33 | //! | Web Browser | `wasm32‑*‑unknown` | [`Crypto.getRandomValues`], see [WebAssembly support] |
34 | | -//! | Node.js | `wasm32‑*‑unknown` | [`crypto.randomBytes`], see [WebAssembly support] |
| 34 | +//! | Node.js | `wasm32‑*‑unknown` | [`crypto.randomFillSync`], see [WebAssembly support] |
35 | 35 | //! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes` |
36 | 36 | //! | Nintendo 3DS | `armv6k-nintendo-3ds` | [`getrandom`][1] |
37 | 37 | //! |
|
91 | 91 | //! |
92 | 92 | //! This feature has no effect on targets other than `wasm32-unknown-unknown`. |
93 | 93 | //! |
| 94 | +//! #### Node.js ES6 Module support |
| 95 | +//! |
| 96 | +//! Due to limitations in wasm-bindgen's [`module`] support, we cannot directly |
| 97 | +//! support Node.js running in an ESM context. However, on Node v15 and later, |
| 98 | +//! the module author can add a simple shim to support the Web Cryptography API: |
| 99 | +//! ```js |
| 100 | +//! import { webcrypto } from 'node:crypto' |
| 101 | +//! globalThis.crypto = webcrypto |
| 102 | +//! ``` |
| 103 | +//! This crate will then use the provided `webcrypto` implementation. |
| 104 | +//! |
94 | 105 | //! ### Custom implementations |
95 | 106 | //! |
96 | 107 | //! The [`register_custom_getrandom!`] macro allows a user to mark their own |
|
154 | 165 | //! [`RDRAND`]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide |
155 | 166 | //! [`SecRandomCopyBytes`]: https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc |
156 | 167 | //! [`cprng_draw`]: https://fuchsia.dev/fuchsia-src/zircon/syscalls/cprng_draw |
157 | | -//! [`crypto.randomBytes`]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback |
| 168 | +//! [`crypto.randomFillSync`]: https://nodejs.org/api/crypto.html#cryptorandomfillsyncbuffer-offset-size |
158 | 169 | //! [`esp_fill_random`]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/random.html#_CPPv415esp_fill_randomPv6size_t |
159 | 170 | //! [`random_get`]: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-random_getbuf-pointeru8-buf_len-size---errno |
160 | 171 | //! [WebAssembly support]: #webassembly-support |
161 | 172 | //! [`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen |
| 173 | +//! [`module`]: https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-js-imports/module.html |
162 | 174 |
|
163 | 175 | #![doc( |
164 | 176 | html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", |
|
0 commit comments