ranisalt / node-argon2

Node.js bindings for Argon2 hashing algorithm
https://www.npmjs.com/package/argon2
MIT License
1.89k stars 93 forks source link

Enhancement: Promises #44

Closed DSchougaard closed 8 years ago

DSchougaard commented 8 years ago

I was just wondering if it would be a possibility to add an option for using Bluebird promises? Currently, the native promises are causing me headaches when in combination with Bluebird's filtered catches.

I tried to fork the library, and simply make my own changes, but I could not for the life of me get it to compile. It just kept giving me node-gyp errors.

ranisalt commented 8 years ago

Gonna have a look.

ranisalt commented 8 years ago

Please checkout the bluebird branch, I fixed it so you can change the Promise property of the exported object to use a custom promise.

See an example on bluebird.spec.js, it's really a one-liner.

If it works for you, please open a pull request for that branch.

DSchougaard commented 8 years ago

As far as I can tell, it works. My code once again catches the right errors, at the right places.

However, I cant for the life of me get npm to actually fetch and install it properly, by the github reference. But cloning, init'ing, and building with node-gyp manually, makes it work perfectly! :+1:

ranisalt commented 8 years ago

Yeah, npm makes it pretty hard to sync to branches.

Did you feel any improvements from using Bluebird? It plays nice with basic, default hash but it doesn't scale time and memory cost very well to me.

DSchougaard commented 8 years ago

Do you have any advice for how something like this could easily be handled? Currently I have an install-argon.sh script being executed during install, after having run npm-install on the project.

The improvements I felt, was actual compatibility with my own codebase. I've been relying pretty heavily on the Bluebird's filtered catches, in order to create what I feel is more readable code. I was using a BCrypt library previously, which was "promisified" using Bluebird.

But everything involved with hashing and verification unfortunately completely broke, after plugging in your Argon2 library (which supposedly is superior). So unfortunately, that is the only aspect I can even argue improvements -- which is horribly un-scientific.