-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
node and bun compatibility #14
Conversation
Co-authored-by: Lucas Garron <code@garron.net>
isolatedModules is recommended by esbuild at https://esbuild.github.io/content-types/#isolated-modules module is required by moduleResolution. Co-authored-by: Lucas Garron <code@garron.net>
Co-authored-by: Lucas Garron <code@garron.net>
Co-authored-by: Lucas Garron <code@garron.net>
So huh, I guess the const assignment I am doing in non-test code is also not ok, but happens to work because non-crypto functions don't need to await ready. I hate this. |
Apparently you can't even take the function pointer of crypto functions before sodium.ready. We continue to take the pointer for non-crypto functions since we do it in format.ts.
e880ee0
to
0e7577f
Compare
47fa9af
to
16e694a
Compare
If you do the // before
import { crypto_hash_sha256, from_hex, to_hex } from "libsodium-wrappers-sumo"; // after
import sodium from "libsodium-wrappers-sumo"
await sodium.ready
const { crypto_hash_sha256, from_hex, to_hex } = sodium; // now we can get crypto as well as non-crypto exports Or you could just YOLO and make all your APIs async (which would have the benefit of allowing automatic offloading to a web worker for key derivation in the future if you want). 😛 |
I filed jedisct1/libsodium.js#327 to hopefully get even the crypto functions to be safe to assign before In the test files it's a matter of switching the order, but in
I had that in a previous iteration and kinda hated that it gave the impression the whole operation would be async, and then we'd block for scrypt after maybe awaiting ready (the first time). |
Reopening #13 which I merged by mistake.