From 37375b8b5555d82e6e6241fbd053f2f6b8d670d1 Mon Sep 17 00:00:00 2001 From: saintedlama Date: Wed, 15 Aug 2018 11:52:10 +0200 Subject: [PATCH] fix: use Buffer.from instead of new Buffer new Buffer is deprecated in node 10 --- index.js | 2 +- lib/authenticate.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f5967df..acf7c51 100644 --- a/index.js +++ b/index.js @@ -101,7 +101,7 @@ module.exports = function(schema, options) { }) .then(salt => pbkdf2Promisified(password, salt, options)) .then(hashRaw => { - this.set(options.hashField, new Buffer(hashRaw, 'binary').toString(options.encoding)); + this.set(options.hashField, Buffer.from(hashRaw, 'binary').toString(options.encoding)); }) .then(() => this); diff --git a/lib/authenticate.js b/lib/authenticate.js index 37ae72b..afd7d94 100644 --- a/lib/authenticate.js +++ b/lib/authenticate.js @@ -44,7 +44,7 @@ function authenticate(user, password, options, cb) { return cb(err); } - if (scmp(hashBuffer, new Buffer(user.get(options.hashField), options.encoding))) { + if (scmp(hashBuffer, Buffer.from(user.get(options.hashField), options.encoding))) { if (options.limitAttempts) { user.set(options.lastLoginField, Date.now()); user.set(options.attemptsField, 0);