node-identity-server
Version:
A package that allows you to verify & create identity server 2/3/4 hashes in nodeJS
80 lines (64 loc) • 2.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.verifyPassword = exports.hashPassword = undefined;
/**
* Given a password hashes it using the identity 3/4 server implementation.
* @param password
* @returns {Promise<*>}
*/
var hashPassword = exports.hashPassword = function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(password) {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return newHasher.hashPassword(password);
case 2:
return _context.abrupt('return', _context.sent);
case 3:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
return function hashPassword(_x) {
return _ref.apply(this, arguments);
};
}();
/**
* Given a password and a hash verify's if they match using the identity server 3/4 implementation.
* @param plainTextPassword
* @param hash
* @returns {Promise<boolean|*>}
*/
var verifyPassword = exports.verifyPassword = function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(plainTextPassword, hash) {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return newHasher.verifyPassword(plainTextPassword, hash);
case 2:
return _context2.abrupt('return', _context2.sent);
case 3:
case 'end':
return _context2.stop();
}
}
}, _callee2, this);
}));
return function verifyPassword(_x2, _x3) {
return _ref2.apply(this, arguments);
};
}();
var _HashPasswordv = require('./IdentityServer3/HashPasswordv3');
var _HashPasswordv2 = _interopRequireDefault(_HashPasswordv);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
var newHasher = new _HashPasswordv2.default();
//# sourceMappingURL=index.js.map