dchest / tweetnacl-js

Port of TweetNaCl cryptographic library to JavaScript
https://tweetnacl.js.org
The Unlicense
1.77k stars 293 forks source link

ES6 modules #170

Open dchest opened 5 years ago

dchest commented 5 years ago

What's the minimal amount of changes needed to support ES6 module-style export?

hakanols commented 4 years ago

I have published a NPM package that is a modification of this to only handle es6 https://www.npmjs.com/package/tweetnacl-es6 https://github.com/hakanols/tweetnacl-es6

evbogue commented 4 years ago

@dchest any progress on this issue?

dchest commented 4 years ago

@evbogue not yet, sorry. I hope to work on it some time soon though.

evbogue commented 4 years ago

@dchest cool. I got @hakanols 's fork working in Deno just a moment ago.

But, I'd want to use this library in the future, if possible.

roopakv commented 4 years ago

@dchest would love to see this one pushed through. Am willing to help, so if there is anything I can do please let me know

dchest commented 4 years ago

@roopakv thank you! I’ll try to get some time to work on it this weekend.

bcomnes commented 3 years ago

If you end up tackling this, it would be great to also get https://github.com/dchest/nacl-stream-js with native esm exports. Happy to help out there once you set an example of how you want this tackled.

If you are sticking with using npm for publishing native semantically versioned esm, unpkg in ?module mode can provide browser and deno compatibility.

dyoder commented 3 years ago

FYI, we've published an interim module similar to @hakanols except supporting dual imports (using the exports field in packag.json):

https://www.npmjs.com/package/@dashkite/tweetnacl
https://github.com/dashkite/tweetnacl-js

bmdelacruz commented 2 years ago

Check out my fork https://github.com/bmdelacruz/tweetnacl-js/commit/5c4460f83dece9ff03071b252f15c35f11c2636b!

It's completely tested and (somewhat) backwards compatible. The only breaking change is that consumers now need to call one of the new functions called setPRNG, setGlobalCryptoPRNG, and setNodeCryptoPRNG when using functions that depends on the PRNG, e.g. nacl.sign.keyPair and nacl.box.keyPair. The resulting nacl-fast.min.js is now slightly larger though (31.4 KB -> 36.4 KB). nacl.min.js too: (18 KB -> 18.6 KB).