"use strict"; // Tools for encrypting and decrypting passwords. // Basically promise-friendly wrappers for bcrypt. var bcrypt = require('bcryptjs'); try { const _bcrypt = require('@node-rs/bcrypt'); bcrypt = { hash: _bcrypt.hash, compare: _bcrypt.verify }; } catch (e) { /* */ } // Returns a promise for a hashed password string. function hash(password) { return bcrypt.hash(password, 10); } // Returns a promise for whether this password compares to equal this // hashed password. function compare(password, hashedPassword) { // Cannot bcrypt compare when one is undefined if (!password || !hashedPassword) { return Promise.resolve(false); } return bcrypt.compare(password, hashedPassword); } module.exports = { hash: hash, compare: compare }; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJiY3J5cHQiLCJyZXF1aXJlIiwiX2JjcnlwdCIsImhhc2giLCJjb21wYXJlIiwidmVyaWZ5IiwiZSIsInBhc3N3b3JkIiwiaGFzaGVkUGFzc3dvcmQiLCJQcm9taXNlIiwicmVzb2x2ZSIsIm1vZHVsZSIsImV4cG9ydHMiXSwic291cmNlcyI6WyIuLi9zcmMvcGFzc3dvcmQuanMiXSwic291cmNlc0NvbnRlbnQiOlsiLy8gVG9vbHMgZm9yIGVuY3J5cHRpbmcgYW5kIGRlY3J5cHRpbmcgcGFzc3dvcmRzLlxuLy8gQmFzaWNhbGx5IHByb21pc2UtZnJpZW5kbHkgd3JhcHBlcnMgZm9yIGJjcnlwdC5cbnZhciBiY3J5cHQgPSByZXF1aXJlKCdiY3J5cHRqcycpO1xuXG50cnkge1xuICBjb25zdCBfYmNyeXB0ID0gcmVxdWlyZSgnQG5vZGUtcnMvYmNyeXB0Jyk7XG4gIGJjcnlwdCA9IHtcbiAgICBoYXNoOiBfYmNyeXB0Lmhhc2gsXG4gICAgY29tcGFyZTogX2JjcnlwdC52ZXJpZnksXG4gIH07XG59IGNhdGNoIChlKSB7XG4gIC8qICovXG59XG5cbi8vIFJldHVybnMgYSBwcm9taXNlIGZvciBhIGhhc2hlZCBwYXNzd29yZCBzdHJpbmcuXG5mdW5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