antelle / argon2-browser

Argon2 library compiled for browser runtime
https://antelle.net/argon2-browser
MIT License
383 stars 81 forks source link

Bundled version / just one js file in released version? #61

Closed JsBergbau closed 3 years ago

JsBergbau commented 3 years ago

Is it possible to provide a bundled version in the releases? So you have one js file which you can include via <script src> and you can start. This would save really a lot of time and issues like https://github.com/antelle/argon2-browser/issues/60

antelle commented 3 years ago

It is possible, but needs some work.

JsBergbau commented 3 years ago

Thanks for your extremly fast reply. From my point of view this work would save a lot of people's work and time so it would be a great investment.

JsBergbau commented 3 years ago

For users that just want a fast argon2 javascript implementation it would also help a lot to add that to README.md like:

Note: argon2.js is not the whole library which needs to integrated. If you want a quick start it is recommended to use all requirements bundled into one js file. Therefore please go to examples\webpack and exec npm i npx webpack After that you have file bundle.js in dist-folder. You can use this file via <script src=> to use argon2 in your Webpage.

Or put this text in \examples\webpack folder. Same with npm i for "vanilla" folder. I mean for you as JavaScript developer this is basics. For me who just wants a fast solution for a little projects I need quite a lot of time to learn these things compared to just use a prebuild all in one file. With bundled file pre-build you save a lot of people time installing npm, reading all the instructions for just building a bundled argon2 Javascript library. I would call this bundled js file something like argon2LibReadyToUse or something similar, just to make clear that this file needs just to be included via <script src>.

For those who find this issue, I've attached version 1.15.4 as bundled-js file argon2Library.zip

EDIT: It is not as easy as bundling this file because it also contains argon2-demo-webpack.js which sets the parameters for generating the example argon2 hash. However the principle is very easy. If only the library is packed then it is sufficient to have an example html file like

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Argon2 Browser VanillaJS Demo</title>
    <script src="./argon2Library.js"></script>
</head>
<body>
    <h1>Argon2-Browser WebPack Demo</h1>
    <script src="run.js"></script>
    <pre>Output should appear here. If not, please check DevTools in your browser.</pre>
</body>
</html>

You don't need any Webserver or so. Firefox just executes it without any CORS errors in the developer console.

JsBergbau commented 3 years ago

For me it is also very confusing to download a release image and then to get it work having to download the actual code via npm. So a argon2 library in one js file would be really great.

antelle commented 3 years ago

I've added a bundled version in d71f437298c305501ce254fed7d09b3122601aa8, but it needs some more work because bintray is not anymore so publishing is now broken.

antelle commented 3 years ago

Done! v1.16.0 provides dist/argon2-bundled.min.js, here you can see it in action: https://jsfiddle.net/vqzrtupw/

JsBergbau commented 3 years ago

Thank you very much this helps a lot.