New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

credential-plus-argon2

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

credential-plus-argon2 - npm Package Compare versions

Comparing version

to
2.0.0

38

index.js

@@ -9,2 +9,3 @@ 'use strict';

* Default configurations used to generate a new hash.
* @private
* @type {Object}

@@ -29,13 +30,9 @@ */

/**
* Generates an unique hash.
* Generates an unique hash and the data needed to verify it.
* @public
* @param {string} password The password to hash.
* @param {object} configs Configurations related to the hashing function.
* @param {generateCallback} callback Called after the hash has been generated.
* @param {object} configs Configurations related to the hashing function.
* @returns {Promise<string>} A promise that contains the generated hash string.
*/
/**
* @callback generateCallback
* @param {object} err Possible error thrown.
* @param {string} hash Generated hash string.
*/
function hashFunc(password, configs, callback) {
function hashFunc(password, configs) {
const cfgs = _.extend(defaultConfigs, configs);

@@ -45,5 +42,3 @@

argon2.hash(password, cfgs)
.then(hash => callback(null, hash))
.catch(callback);
return argon2.hash(password, cfgs);
}

@@ -53,15 +48,10 @@

* Determines whether or not the user's input matches the stored password.
* @param {object} hash Previously hashed password.
* @param {password} password User's password input.
* @param {hashCallback} callback Called after the hash has been computed.
* @public
* @param {string} hash Stringified hash object generated from this package.
* @param {string} input User's password input.
* @returns {Promise<boolean>} A promise that contains a boolean that is true if
* if the hash computed for the input matches.
*/
/**
* @callback hashCallback
* @param {object} err Possible error thrown.
* @param {string} match True if the hash computed for the input matches.
*/
function verifyFunc(hash, password, callback) {
argon2.verify(hash, password)
.then(match => callback(null, match))
.catch(callback);
function verifyFunc(hash, password) {
return argon2.verify(hash, password);
}

@@ -68,0 +58,0 @@

{
"name": "credential-plus-argon2",
"version": "1.0.2",
"version": "2.0.0",
"description": "argon2 hash function implementation for credential-plus",

@@ -14,5 +14,4 @@ "main": "index.js",

"nyc": "^11.0.3",
"pify": "^3.0.0",
"xo": "*",
"credential-plus": "*"
"credential-plus": "2.x"
},

@@ -19,0 +18,0 @@ "engines": {

@@ -1,9 +0,24 @@

# credential-plus-argon2
[![Travis CI](https://travis-ci.org/simonepri/credential-plus-argon2.svg?branch=master)](https://travis-ci.org/simonepri/credential-plus-argon2) [![Codecov](https://img.shields.io/codecov/c/github/simonepri/credential-plus-argon2/master.svg)](https://codecov.io/gh/simonepri/credential-plus-argon2) [![npm](https://img.shields.io/npm/dm/credential-plus-argon2.svg)](https://www.npmjs.com/package/credential-plus-argon2) [![npm version](https://img.shields.io/npm/v/credential-plus-argon2.svg)](https://www.npmjs.com/package/credential-plus-argon2) [![npm dependencies](https://david-dm.org/simonepri/credential-plus-argon2.svg)](https://david-dm.org/simonepri/credential-plus-argon2) [![npm dev dependencies](https://david-dm.org/simonepri/credential-plus-argon2/dev-status.svg)](https://david-dm.org/simonepri/credential-plus-argon2#info=devDependencies)
> 🛡 argon2 plugin for credential-plus
<h1 align="center">
<img src="https://github.com/simonepri/credential-plus/blob/master/media/credential-plus.png?raw=true" alt="credential-plus-argon2" />
</h1>
<div align="center">
<a href="https://travis-ci.org/simonepri/credential-plus-argon2"> <img src="https://travis-ci.org/simonepri/credential-plus-argon2.svg?branch=master" alt="build status"></a>
<a href="https://codecov.io/gh/simonepri/credential-plus-argon2"><img src="https://img.shields.io/codecov/c/github/simonepri/credential-plus-argon2/master.svg" alt="code coverage" /></a>
<a href="https://github.com/sindresorhus/xo"><img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg" alt="code style" /></a>
<a href="https://www.npmjs.com/package/credential-plus-argon2"><img src="https://img.shields.io/npm/v/credential-plus-argon2.svg" alt="npm version" /></a>
<a href="https://www.npmjs.com/package/credential-plus-argon2"><img src="https://img.shields.io/npm/dm/credential-plus-argon2.svg" alt="npm downloads" /></a>
<a href="https://david-dm.org/simonepri/credential-plus-argon2"><img src="https://david-dm.org/simonepri/credential-plus-argon2.svg" alt="dependencies" /></a>
<a href="https://david-dm.org/simonepri/credential-plus-argon2#info=devDependencies"><img src="https://david-dm.org/simonepri/credential-plus-argon2/dev-status.svg" alt="dev dependencies" /></a>
<a href="LICENSE"><img src="https://img.shields.io/github/license/simonepri/credential-plus-argon2.svg" alt="license" /></a>
</div>
<br />
<div align="center">
🛡 Argon2 password hashing function for [credential-plus](https://github.com/simonepri/credential-plus).
</div>
<div align="center">
<sub>
If you find a security flaw in this code, PLEASE [report it](issues/new).
</sub>
</div>
This package is thought to be used in conjunction with [credential-plus](https://github.com/simonepri/credential-plus)
If you find a security flaw in this code, please [report it](issues/new).
## Install

@@ -21,119 +36,17 @@

// Hash and verify with argon2 and default configs
credential.hash('We are all unicorns', {func: 'argon2'}, (err, hash) => {
console.log(hash);
//=> {"hash":"$argon2d$v=19$m=4096,t=3,p=1$i5VhaDYfYqSWWoG1uKVBbw$QHpzhFRYJZwIcogtSciXh0hbc8f91PyGBdtWSNocuiE","func":"argon2"}
credential.verify(hash, 'We are all unicorns', (match) =>{
console.log(match);
//=> true
})
});
```
credential.hash('We are all unicorns', {func: 'argon2'})
.then(hash) => {
## API
console.log(hash);
//=> {"hash":"$argon2d$v=19$m=4096,t=3,p=1$i5VhaDYfYqSWWoG1uKVBbw$QHpzhFRYJZwIcogtSciXh0hbc8f91PyGBdtWSNocuiE","func":"argon2"}
### hash(password, options, callback)
credential.verify(hash, 'We are all unicorns')
.then(match) => {
console.log(match);
//=> true
});
Creates a new 'unique' hash from a password.
});
```
#### password
Type: `string`
The password to hash.
#### options
Type: `object`
Configurations for the hash function.
#### type
Type: `number`<br>
Default: 0
The type option is flexible and accepts.
`0`, `1` or `2` for `Argon2d`, `Argon2i` and `Argon2id` respectively.
#### timeCost
Type: `number`<br>
Default: 3
The amount of computation realized and therefore the execution time,
given in number of iterations.
#### memoryCost
Type: `number`<br>
Default: 12
The memory usage, given in kibibytes.
#### parallelism
Type: `number`<br>
Default: 1
The number of parallel threads.
#### hashLength
Type: `number`<br>
Default: 32
The length of the generated hash.
#### callback(err, hash)
Type: `function`
Called after the hash has been computed.
#### err
Type: `object`
Possible error thrown.
#### hash
Type: `object`
The generated hash.
### verify(hash, input, callback)
Determines whether or not the user's input matches the stored password.
#### hash
Type: `string`
An hash generated from this package.
#### input
Type: `string`
User's input input.
#### callback(err, valid)
Type: `string`
Called after the verification process has been computed.
#### err
Type: `object`
Possible error thrown.
##### valid
Type: `boolean`
True if the hash computed for the input matches.
## Authors

@@ -140,0 +53,0 @@ * **Simone Primarosa** - [simonepri](https://github.com/simonepri)