Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log instead of crashing when WebAssembly can't be used #132

Closed
ffflorian opened this issue Feb 15, 2018 · 3 comments
Closed

Log instead of crashing when WebAssembly can't be used #132

ffflorian opened this issue Feb 15, 2018 · 3 comments

Comments

@ffflorian
Copy link
Contributor

ffflorian commented Feb 15, 2018

Hi @jedisct1,
at Wire we were really happy to see the latest version of libsodium.js includes WebAssembly! 🎉

However, version 0.7.3 throws an error on a site with CSP headers using Chrome:

Uncaught (in promise) abort({}). Build with -s ASSERTIONS=1 for more info.

As we found out, this happens because WebAssembly can't be used without unsafe-eval in Chrome for now, so this is already known.

As far as I understood, libsodium.js has pure JavaScript fallbacks for all functions if WebAssembly can't be used, right? So it would be great if a more meaningful message (and log instead of crashing) could be returned when this happens.

HTML example
<html>
  <head>
    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; connect-src 'self' data:; script-src 'self' 'unsafe-inline'">
  </head>
  <body>
    <script>
      window.sodium = {
        onload: function (sodium) {
          let key = sodium.crypto_sign_keypair();
          console.log(key);
        }
      };
    </script>
    <script src="sodium.js" async></script>
  </body>
</html>
@jedisct1
Copy link
Owner

Hi Florian,

Do you know how to do this?

@ffflorian
Copy link
Contributor Author

@jedisct1,

I didn't know how to do this so I asked the people at emscripten: emscripten-core/emscripten#5911 (comment)

So this is rather an emscripten issue than a libsodium.js issue and we'll have to wait for the fix (or fix it ourselves).

@jedisct1
Copy link
Owner

Good to know, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants