Comparing version 0.9.0 to 0.10.0
17
index.js
@@ -37,7 +37,6 @@ const bindings = require('bindings')('argon2'); | ||
// TODO: replace var with const https://github.com/tapjs/node-tap/issues/236 | ||
for (var key of Object.keys(limits)) { | ||
var max = limits[key].max; | ||
var min = limits[key].min; | ||
var value = options[key]; | ||
for (const key of Object.keys(limits)) { | ||
const max = limits[key].max; | ||
const min = limits[key].min; | ||
const value = options[key]; | ||
if (!Number.isInteger(value) || value > max || value < min) { | ||
@@ -115,2 +114,6 @@ fail(`Invalid ${key}, must be an integer between ${min} and ${max}.`, reject); | ||
if (!Buffer.isBuffer(hash)) { | ||
hash = new Buffer(hash); | ||
} | ||
if (!Buffer.isBuffer(plain)) { | ||
@@ -128,2 +131,6 @@ plain = new Buffer(plain); | ||
if (!Buffer.isBuffer(hash)) { | ||
hash = new Buffer(hash); | ||
} | ||
if (!Buffer.isBuffer(plain)) { | ||
@@ -130,0 +137,0 @@ plain = new Buffer(plain); |
{ | ||
"name": "argon2", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "An Argon2 library for Node", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"clean": "node-gyp clean", | ||
"test": "xo && tap test.spec.js --reporter=list" | ||
"test": "xo && babel-tap *.spec.js" | ||
}, | ||
@@ -36,4 +36,4 @@ "repository": { | ||
"async-benchmark": "^1.0.1", | ||
"tap": "^5.7.0", | ||
"xo": "^0.12.1" | ||
"babel-tap": "^4.0.0", | ||
"xo": "^0.13.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "engines": { |
@@ -6,5 +6,33 @@ # node-argon2 [![NPM package][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Coverage status][coverage-image]][coverage-url] [![Code Quality][codequality-image]][codequality-url] [![Dependencies][david-dm-image]][david-dm-url] | ||
### Before installing | ||
You **MUST** have a **node-gyp** global install before proceeding with install. | ||
**node-argon2** works only and is tested against >=4.0.0 . | ||
You **MUST** have a **node-gyp** global install before proceeding with install, | ||
along with GCC >= 4.8 / Clang >= 3.3. On Windows, you must compile under Visual | ||
Studio 2015 or newer. | ||
**node-argon2** works only and is tested against Node >=4.0.0. | ||
#### OSX | ||
To install GCC >= 4.8 on OSX, use [homebrew](http://brew.sh/): | ||
```console | ||
$ brew install gcc | ||
``` | ||
Once you've got GCC installed and ready to run, you then need to install | ||
node-gyp, you must do this globally: | ||
```console | ||
$ npm install -g node-gyp | ||
``` | ||
Finally, once node-gyp is installed and ready to go, you can install this | ||
library, specifying the GCC or Clang binary to use: | ||
```console | ||
$ CXX=g++-5 npm install argon2 | ||
``` | ||
**NOTE**: If your GCC or Clang binary is named something different than `g++-5`, | ||
you'll need to specify that in the command. | ||
### Usage | ||
@@ -34,3 +62,3 @@ It's possible to hash a password using both Argon2i (default) and Argon2d, sync | ||
// ES6 | ||
// ES7 | ||
@@ -62,3 +90,3 @@ try { | ||
// ES6 | ||
// ES7 | ||
@@ -87,3 +115,3 @@ try { | ||
// ES6 | ||
// ES7 | ||
@@ -103,3 +131,3 @@ const salt = await argon2.generateSalt(); | ||
// ES6 | ||
// ES7 | ||
@@ -130,3 +158,3 @@ const salt = await argon2.generateSalt(32); | ||
// ES6 | ||
// ES7 | ||
@@ -158,3 +186,3 @@ var hash = await argon2.hash('password', await argon2.generateSalt(), options); | ||
// ES6 | ||
// ES7 | ||
@@ -161,0 +189,0 @@ try { |
@@ -10,5 +10,3 @@ const argon2 = require('./index'); | ||
// trailing '=' characters for a more compact representation. | ||
const truncatedBase64 = (buffer) => { | ||
return buffer.toString('base64').replace(/\=*$/, ''); | ||
}; | ||
const truncatedBase64 = buffer => buffer.toString('base64').replace(/\=*$/, ''); | ||
@@ -559,5 +557,9 @@ // hashes for argon2i and argon2d with default options | ||
t.plan(1); | ||
return argon2.generateSalt().then(salt => { | ||
return argon2.hash(password, salt).then(hash => { | ||
return argon2.verify(hash, password).then(t.pass); | ||
return argon2.verify(hash, password).then(result => { | ||
t.true(result); | ||
}); | ||
}); | ||
@@ -570,5 +572,9 @@ }); | ||
t.plan(1); | ||
return argon2.generateSalt().then(salt => { | ||
return argon2.hash(password, salt).then(hash => { | ||
return argon2.verify(hash, 'passworld').catch(t.pass); | ||
return argon2.verify(hash, 'passworld').then(result => { | ||
t.false(result); | ||
}); | ||
}); | ||
@@ -581,5 +587,9 @@ }); | ||
t.plan(1); | ||
return argon2.generateSalt().then(salt => { | ||
return argon2.hash('pass\0word', salt).then(hash => { | ||
return argon2.verify(hash, 'pass\0word').then(t.pass); | ||
return argon2.verify(hash, 'pass\0word').then(result => { | ||
t.true(result); | ||
}); | ||
}); | ||
@@ -592,2 +602,4 @@ }); | ||
t.plan(1); | ||
return argon2.generateSalt().then(salt => { | ||
@@ -597,3 +609,5 @@ return argon2.hash(password, salt, { | ||
}).then(hash => { | ||
return argon2.verify(hash, password).then(t.pass); | ||
return argon2.verify(hash, password).then(result => { | ||
t.true(result); | ||
}); | ||
}); | ||
@@ -606,2 +620,4 @@ }); | ||
t.plan(1); | ||
return argon2.generateSalt().then(salt => { | ||
@@ -611,3 +627,5 @@ return argon2.hash(password, salt, { | ||
}).then(hash => { | ||
return argon2.verify(hash, 'passwolrd').catch(t.pass); | ||
return argon2.verify(hash, 'passwolrd').then(result => { | ||
t.false(result); | ||
}); | ||
}); | ||
@@ -614,0 +632,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
170243
29
818
207
1