Replies: 2 comments 2 replies
-
I found a workaround: add by myself the definition of
However I guess it would still be interesting to fix compatibility with ESM in the library. |
Beta Was this translation helpful? Give feedback.
0 replies
-
We are currently looking for the webcrypto object in Exposing that object would be easier and more future proof than having to reimplement |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
As I was trying to use
randombytes
primitive into an ES module I encountered an error.Indeed, in
src/libsodium/randombytes/randombytes.c:69
there is avar crypto = require('crypto');
andrequire
is not defined in ESM.A solution would be to modify it to
var crypto = await import('crypto');
(ifrequire
fails). It works but since the function is notasync
I had to modify it into:However, the
Module.getRandomValue
is set asynchronously so I guess such a modification would not be accepted.In conclusion, would you have any idea on how to make
randombytes
work both with CommonJS and ESM?By the way, this is the only
require
occurrence in the entire library.Thanks for reading,
Jérôme
Beta Was this translation helpful? Give feedback.
All reactions