-
Notifications
You must be signed in to change notification settings - Fork 294
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
Need a better module wrapping #66
Comments
I suggest to use browserify for this:
This solves all the requirements stated above (it also considers |
Thanks, I'll think about it, but I don't want to introduce another build tool just for a few lines of code. |
I totally understand your objections. Just to add: since here is already a build step (uglifyjs) it does not add more maintenance efford. And browserify has been made exactly for this purpose. |
@RainaBatwing do you think it will solve #59? @jo where can I take a look at what browserify replaces Buffer with? Thanks! |
Yes, I think in package.json you can just point to a file or (a node module): "browser": {
"buffer": "./lib/buffer.js"
} https://github.com/substack/node-browserify#browser-field Extensive docu can be found in the Browserify Handbook. |
I would like to see this change, but I'd much rather you use the browserify Buffer than invent a new one. MIT license is not a restrictive one, and having more code that can potentially introduce bugs seems antithetical to the spirit of tweetnacl as a small audit-able library. If there really are users who cannot use MIT-licensed software but can accept third party public domain code, they could open an issue later and we can reconsider then? |
Thanks for opinions, everyone. I'm sorry that I'm so picky about this change, but I just can't handle this little fact:
I know, an average image on a website is bigger than that, but still I'd like to avoid including a library for frigging byte arrays that's bigger than the whole project. Especially, since Buffer is here mostly for Node.js, which is better served by a native NaCl. |
So it seems like the arguments are: Node Buffers (and browserify shim):
TweetNaCl typed arrays:
Personally, I'd say stick with the typed arrays, since it does make more sense in the browser. TweetNaCl is great for the client-side, and if you'd like to run it under Node, that's easily doable even with the typed arrays. But, like @dchest mentioned, under Node you really could just use a library with native NaCl bindings, which would definitely offer better performance, and would probably use buffers as well. So, +1 for the current implementation from me. Small and simple on the client-side, but still fairly simple to use on the server-side if necessary. |
Another option is to implement both Buffers and typed arrays as @RainaBatwing proposed in #59. If you pass a Buffer to functions, they will return Buffers, if you pass a typed array, they will return typed arrays. |
My interest in using tweetnacl-js is because I'm developing cross platform p2p apps using NW.js and depending on platform-specific code makes software update distribution much more complicated. For my things, there are no clients or servers. I'd like to have just one version which works on every platform, and I'd like all the application specific code to be in javascript, so anyone can take it and alter it easily. I strongly dislike the idea of shipping binary packages, but most users do not have C build tools on their computer. |
Use react-native-tweetnacl npm package for using tweetnacl in mobile apps. |
We need something like UMD for module wrapping with these features:
nacl
/window.nacl
.require('crypto')
require('crypto')
emulation (without this workaround).root
object inside the module, which can benull
orundefined
for Node,window
for browsers,self
(?) for webworkers in browsers (to fix Way to use nacl in web workers #65)The text was updated successfully, but these errors were encountered: