Closed Mubelotix closed 2 months ago
Note that I didn't remove the feature for backward compatibility, but that should happen eventually. I can add a warning if you had like to
This is only the right thing to do when wasm32-unknown-unknown
is used for a web target like WebAssembly in the web platform or in a browser extension. If wasm32-unknown-unknown
is being used in a different environment then the "custom" feature of getrandom
should be used instead, I guess.
As of today, you would have to fork rustls to enable the feature on ring.
In your own project's Cargo.toml, you can add this:
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
ring = { version = "...", features = ["wasm32_unknown_unknown_js"]
or for non-web situations:
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
ring = { version = "...", features = ["less-safe-getrandom-custom-or-rdrand"] }
You can do this even if your project doesn't directly use any ring APIs.
This is only the right thing to do when
wasm32-unknown-unknown
is used for a web target like WebAssembly in the web platform or in a browser extension. Ifwasm32-unknown-unknown
is being used in a different environment then the "custom" feature ofgetrandom
should be used instead, I guess.
Hm, I didn't know getrandom supported custom implementations.
You can do this even if your project doesn't directly use any ring APIs.
Oh, that works, I thought cargo would refuse to add a feature on a crate used by dependencies. Thank you
As of today ring support the web platform by allowing users to enable the
wasm32_unknown_unknown_js
feature. The issue is that it might be difficult for users whenring
is used by a dependency (ex: by rustls). The dependency you add to your project might not have included any way of a enabling ring's feature. As of today, you would have to fork rustls to enable the feature on ring.The good thing is that all this feature does is enabling the
js
feature ongetrandom
. This can be done without a feature onring
! Note that there is no scenario when you wouldn't wantgetrandom/js
enabled when building onwasm32-unknown-unknown
, because any build ofgetrandom
without itsjs
feature onwasm32-unknown-unknown
will fail anyway.