GithubHelp home page GithubHelp logo

Comments (13)

jo avatar jo commented on August 24, 2024

I suggest to use browserify for this:

This solves all the requirements stated above (it also considers self), except AMD support.
Its the route we took successfully with PouchDB.

from tweetnacl-js.

dchest avatar dchest commented on August 24, 2024

Thanks, I'll think about it, but I don't want to introduce another build tool just for a few lines of code.

from tweetnacl-js.

jo avatar jo commented on August 24, 2024

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.

from tweetnacl-js.

dchest avatar dchest commented on August 24, 2024

@RainaBatwing do you think it will solve #59?

@jo where can I take a look at what browserify replaces Buffer with? Thanks!

from tweetnacl-js.

jo avatar jo commented on August 24, 2024

https://github.com/feross/buffer

from tweetnacl-js.

dchest avatar dchest commented on August 24, 2024

@jo thank you! It's kinda big, but would solve #44, #38, and #59. Unfortunately, it's using MIT license, and I'd like to keep TweetNaCl public domain. Maybe I'll write my own? :-) Does browserify allows custom replacements for Node objects?

from tweetnacl-js.

jo avatar jo commented on August 24, 2024

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.

from tweetnacl-js.

RainaBatwing avatar RainaBatwing commented on August 24, 2024

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?

from tweetnacl-js.

dchest avatar dchest commented on August 24, 2024

Thanks for opinions, everyone. I'm sorry that I'm so picky about this change, but I just can't handle this little fact:

  • Buffer.js — 38 KB
  • nacl.js — 33 KB

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.

from tweetnacl-js.

alax avatar alax commented on August 24, 2024

So it seems like the arguments are:

Node Buffers (and browserify shim):

  • One code base to audit for buffers
  • In theory, better audited since it's more widely used
  • More consistent buffer implementations
  • Solves a few outlying bugs

TweetNaCl typed arrays:

  • Typed arrays are native to the browser
  • Small, concise code that should be easy to audit

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.

from tweetnacl-js.

dchest avatar dchest commented on August 24, 2024

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.

from tweetnacl-js.

RainaBatwing avatar RainaBatwing commented on August 24, 2024

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.

from tweetnacl-js.

tarun1475 avatar tarun1475 commented on August 24, 2024

Use react-native-tweetnacl npm package for using tweetnacl in mobile apps.

from tweetnacl-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.