argon2-pass
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -5,2 +5,7 @@ # Changelog | ||
## 0.1.0 - 2018-09-06 | ||
### Fixed | ||
- Fixed missing export SecurePassError. | ||
## 0.1.0 - 2018-09-06 | ||
### Added | ||
@@ -7,0 +12,0 @@ |
@@ -145,3 +145,3 @@ "use strict"; | ||
describe('callback hashPassword()', () => { | ||
test('Should return a string if given a valid password buffer.', () => { | ||
test('Should return a string if given a valid password buffer.', done => { | ||
const sp = new __1.SecurePass(); | ||
@@ -152,5 +152,6 @@ const password = Buffer.from('SecurePass'); | ||
expect(hash).toBeDefined(); | ||
done(); | ||
}); | ||
}); | ||
test('Should return an error if given a blank password buffer.', () => { | ||
test('Should return an error if given a blank password buffer.', done => { | ||
const sp = new __1.SecurePass(); | ||
@@ -162,2 +163,3 @@ const password = Buffer.from(''); | ||
expect(hash).toBeUndefined(); | ||
done(); | ||
}); | ||
@@ -175,3 +177,3 @@ }); | ||
})); | ||
test('Should correctly rehash weak passwords.', () => __awaiter(this, void 0, void 0, function* () { | ||
test('Should correctly rehash passwords.', () => __awaiter(this, void 0, void 0, function* () { | ||
const wsp = new __1.SecurePass({ | ||
@@ -205,3 +207,3 @@ memLimit: __1.SecurePass.MemLimitDefault, | ||
const hash = Buffer.alloc(__1.SecurePass.HashBytes); | ||
const result = sp.verifyHash(password, hash); | ||
const result = yield sp.verifyHash(password, hash); | ||
} | ||
@@ -218,3 +220,3 @@ catch (e) { | ||
const hash = Buffer.from(''); | ||
const result = sp.verifyHash(password, hash); | ||
const result = yield sp.verifyHash(password, hash); | ||
} | ||
@@ -228,11 +230,19 @@ catch (e) { | ||
describe('callback verifyHash()', () => { | ||
test('Should correctly verify a valid hashed password.', () => __awaiter(this, void 0, void 0, function* () { | ||
test('Should correctly verify a valid hashed password.', done => { | ||
const sp = new __1.SecurePass(); | ||
const password = Buffer.from('SecurePass'); | ||
const hash = yield sp.hashPassword(password); | ||
const result = yield sp.verifyHash(password, hash); | ||
expect(result).toBeDefined(); | ||
expect(result).toEqual(__1.VerificationResult.Valid); | ||
})); | ||
test('Should correctly rehash weak passwords.', () => __awaiter(this, void 0, void 0, function* () { | ||
sp.hashPassword(password, (err, hash) => { | ||
if (hash == undefined) { | ||
expect(hash).toBeDefined(); | ||
return; | ||
} | ||
const passwordHash = hash; | ||
sp.verifyHash(password, passwordHash, (verifyError, result) => { | ||
expect(verifyError).toBeNull(); | ||
expect(result).toEqual(__1.VerificationResult.Valid); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
test('Should correctly rehash passwords.', done => { | ||
const wsp = new __1.SecurePass({ | ||
@@ -242,9 +252,2 @@ memLimit: __1.SecurePass.MemLimitDefault, | ||
}); | ||
const userPassword = Buffer.from('SecurePass'); | ||
const wrongPassword = Buffer.from('SecurePass2'); | ||
const weakHash = yield wsp.hashPassword(userPassword); | ||
const weakValid = yield wsp.verifyHash(userPassword, weakHash); | ||
expect(weakValid).toEqual(__1.VerificationResult.Valid); | ||
const weakInvalid = yield wsp.verifyHash(wrongPassword, weakHash); | ||
expect(weakInvalid).toEqual(__1.VerificationResult.Invalid); | ||
const bsp = new __1.SecurePass({ | ||
@@ -254,36 +257,82 @@ memLimit: __1.SecurePass.MemLimitDefault + 1024, | ||
}); | ||
const rehashValid = yield bsp.verifyHash(userPassword, weakHash); | ||
expect(rehashValid).toEqual(__1.VerificationResult.ValidNeedsRehash); | ||
const betterHash = yield bsp.hashPassword(userPassword); | ||
const betterValid = yield bsp.verifyHash(userPassword, betterHash); | ||
expect(betterValid).toEqual(__1.VerificationResult.Valid); | ||
const betterInvalid = yield bsp.verifyHash(wrongPassword, betterHash); | ||
expect(betterInvalid).toEqual(__1.VerificationResult.Invalid); | ||
})); | ||
test('Should return an error if given a blank password buffer.', () => __awaiter(this, void 0, void 0, function* () { | ||
const userPassword = Buffer.from('SecurePass'); | ||
const wrongPassword = Buffer.from('SecurePass2'); | ||
wsp.hashPassword(userPassword, (err1, weakHash) => { | ||
if (weakHash == undefined) { | ||
expect(weakHash).toBeDefined(); | ||
return; | ||
} | ||
expect(err1).toBeNull(); | ||
wsp.verifyHash(userPassword, weakHash, (err2, weakValid) => { | ||
if (weakValid == undefined) { | ||
expect(weakValid).toBeDefined(); | ||
return; | ||
} | ||
expect(err2).toBeNull(); | ||
expect(weakValid).toEqual(__1.VerificationResult.Valid); | ||
wsp.verifyHash(wrongPassword, weakHash, (err3, weakInvalid) => { | ||
if (weakInvalid == undefined) { | ||
expect(weakInvalid).toBeDefined(); | ||
return; | ||
} | ||
expect(err3).toBeNull(); | ||
expect(weakInvalid).toEqual(__1.VerificationResult.Invalid); | ||
bsp.verifyHash(userPassword, weakHash, (err4, rehashValid) => { | ||
if (rehashValid == undefined) { | ||
expect(rehashValid).toBeDefined(); | ||
return; | ||
} | ||
expect(err4).toBeNull(); | ||
expect(rehashValid).toEqual(__1.VerificationResult.ValidNeedsRehash); | ||
bsp.hashPassword(userPassword, (err5, betterHash) => { | ||
if (betterHash == undefined) { | ||
expect(betterHash).toBeDefined(); | ||
return; | ||
} | ||
expect(err5).toBeNull(); | ||
bsp.verifyHash(userPassword, betterHash, (err6, betterValid) => { | ||
if (betterValid == undefined) { | ||
expect(betterHash).toBeDefined(); | ||
return; | ||
} | ||
expect(err6).toBeNull(); | ||
expect(betterValid).toEqual(__1.VerificationResult.Valid); | ||
bsp.verifyHash(wrongPassword, betterHash, (err7, betterInvalid) => { | ||
if (betterInvalid == undefined) { | ||
expect(betterInvalid).toBeDefined(); | ||
return; | ||
} | ||
expect(err7).toBeNull(); | ||
expect(betterInvalid).toEqual(__1.VerificationResult.Invalid); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
test('Should return an error if given a blank password buffer.', done => { | ||
const sp = new __1.SecurePass(); | ||
try { | ||
const password = Buffer.from(''); | ||
const hash = Buffer.alloc(__1.SecurePass.HashBytes); | ||
const result = sp.verifyHash(password, hash); | ||
} | ||
catch (e) { | ||
expect(e).toBeDefined(); | ||
expect(e instanceof __1.SecurePassError).toBeTruthy(); | ||
} | ||
})); | ||
test('Should return an error if given a blank hash buffer.', () => __awaiter(this, void 0, void 0, function* () { | ||
const password = Buffer.from(''); | ||
const hash = Buffer.alloc(__1.SecurePass.HashBytes); | ||
sp.verifyHash(password, hash, (err, result) => { | ||
expect(err).toBeDefined(); | ||
expect(err instanceof __1.SecurePassError).toBeTruthy(); | ||
done(); | ||
}); | ||
}); | ||
test('Should return an error if given a blank hash buffer.', done => { | ||
const sp = new __1.SecurePass(); | ||
try { | ||
const password = Buffer.from('SecurePass'); | ||
const hash = Buffer.from(''); | ||
const result = sp.verifyHash(password, hash); | ||
} | ||
catch (e) { | ||
expect(e).toBeDefined(); | ||
expect(e instanceof __1.SecurePassError).toBeTruthy(); | ||
} | ||
})); | ||
const password = Buffer.from('SecurePass'); | ||
const hash = Buffer.from(''); | ||
sp.verifyHash(password, hash, (err, result) => { | ||
expect(err).toBeDefined(); | ||
expect(err instanceof __1.SecurePassError).toBeTruthy(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "argon2-pass", | ||
"version": "0.1.0", | ||
"version": "v0.1.1", | ||
"description": "State of the art password hashing and one time password reset token generation module written in TypeScript for nodejs.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -1,2 +0,2 @@ | ||
<p align="center"><img width=60% src="https://github.com/DrBarnabus/secure-pass/blob/master/media/logo_transparent_background.png"></p> | ||
<p align="center"><img width="60%" src="https://github.com/DrBarnabus/secure-pass/blob/master/media/logo_transparent_background.png"></p> | ||
@@ -12,3 +12,3 @@ [![NPM Version][npm-badge]][npm-url] | ||
SecurePass is a module for the creation of hashes from passwords, allowing you to store passwords securely. The module also provides a facility for the generation and verification of one time use password reset tokens for use in your own password reset flows. This module is a wrapper for [libsodium]'s implementation of the [Argon2ID] password hashing algorithm. | ||
SecurePass (argon2-pass) is a module for the creation of hashes from passwords, allowing you to store passwords securely. The module also provides a facility for the generation and verification of one time use password reset tokens for use in your own password reset flows. This module is a wrapper for [libsodium]'s implementation of the [Argon2ID] password hashing algorithm. | ||
@@ -30,4 +30,4 @@ # Features | ||
``` | ||
yarn add secure-pass | ||
npm install secure-pass | ||
yarn add argon2-pass | ||
npm install argon2-pass | ||
``` | ||
@@ -64,14 +64,14 @@ | ||
<!-- Badges --> | ||
[npm-badge]: https://img.shields.io/npm/v/secure-pass.svg?style=flat-square | ||
[npm-url]: https://www.npmjs.com/package/secure-pass | ||
[npmd-badge]: https://img.shields.io/npm/dw/secure-pass.svg?style=flat-square | ||
[npm-badge]: https://img.shields.io/npm/v/argon2-pass.svg?style=flat-square | ||
[npm-url]: https://www.npmjs.com/package/argon2-pass | ||
[npmd-badge]: https://img.shields.io/npm/dw/argon2-pass.svg?style=flat-square | ||
[travis-badge]: https://img.shields.io/travis/DrBarnabus/secure-pass/master.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/DrBarnabus/secure-pass | ||
[dependencies-badge]: https://david-dm.org/drbarnabus/secure-pass.svg?style=flat-square | ||
[dependencies-badge]: https://david-dm.org/drbarnabus/argon2-pass.svg?style=flat-square | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/DrBarnabus/secure-pass/master.svg?style=flat-square | ||
[codecov-url]: https://codecov.io/gh/DrBarnabus/secure-pass | ||
[dependencies-url]: https://david-dm.org/drbarnabus/secure-pass | ||
[devDependencies-badge]: https://david-dm.org/drbarnabus/secure-pass/dev-status.svg?style=flat-square | ||
[devDependencies-url]: https://david-dm.org/drbarnabus/secure-pass?type=dev | ||
[dependencies-url]: https://david-dm.org/drbarnabus/argon2-pass | ||
[devDependencies-badge]: https://david-dm.org/drbarnabus/argon2-pass/dev-status.svg?style=flat-square | ||
[devDependencies-url]: https://david-dm.org/drbarnabus/argon2-pass?type=dev | ||
[snyk-badge]: https://snyk.io/test/github/DrBarnabus/secure-pass/badge.svg?targetFile=package.json&style=flat-square | ||
[snyk-url]: https://snyk.io/test/github/DrBarnabus/secure-pass?targetFile=package.json |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
82052
1361
1