Files
meteor/packages/npm-bcrypt/wrapper.js
Ben Newman a1c3516053 Use pure-JavaScript implementation for npm-bcrypt package. (#7595)
According to the README, this implementation is approximately 2.7 times
slower than native: https://www.npmjs.com/package/bcryptjs

Apps that wish to continue using the native bcrypt package should run
`meteor npm install --save bcrypt` in the root application directory, and
the npm-bcrypt package will prefer that implementation.
2016-08-09 16:42:41 -04:00

39 lines
1.2 KiB
JavaScript

var assert = require("assert");
// The bcryptjs package has a slightly larger API than the native bcrypt
// package, so we stick to the smaller API for consistency.
var methods = {
compare: true,
compareSync: true,
genSalt: true,
genSaltSync: true,
getRounds: true,
hash: true,
hashSync: true
};
try {
// If you really need the native `bcrypt` package, then you should
// `meteor npm install --save bcrypt` into the node_modules directory in
// the root of your application.
var bcrypt = require("bcrypt");
} catch (e) {
bcrypt = require("bcryptjs");
console.warn([
"Note: you are using a pure-JavaScript implementation of bcrypt.",
"While this implementation will work correctly, it is known to be",
"approximately three times slower than the native implementation.",
"In order to use the native implementation instead, run",
"",
" meteor npm install --save bcrypt",
"",
"in the root directory of your application."
].join("\n"));
}
exports.NpmModuleBcrypt = {};
Object.keys(methods).forEach(function (key) {
assert.strictEqual(typeof bcrypt[key], "function");
exports.NpmModuleBcrypt[key] = bcrypt[key];
});