Fix CSP error for wasm bindgen#92
Conversation
|
I think we would be better off using js_sys to get the global object, as that seems to be the more supported way of doing things |
|
The |
josephlr
left a comment
There was a problem hiding this comment.
@evq that makes sense. @newpavlov we should think about using js_sys/web_sys in a different PR, but I think merging this and fixing #91 before releasing 0.1.10 is a good idea.
|
I think we can discuss it in #63, but I still don't see a reason why we would want to use crates built on top of |
Fixes #91
Access the global object via
selfdirectly instead of the currentreturn thisfunction created from a string. Creating a function from a string results in a CSP error as it requiresunsafe-eval.See tweetnacl which uses this strategy (although it also checks for
msCryptofor IE11 compatibility - here we don't because IE11 does not have wasm support).Tested on node, firefox and brave (chromium) using the wasm-pack test.