From b38c666e95fac064609f0d8cfd26d891d8e6635d Mon Sep 17 00:00:00 2001 From: Mikunj Date: Tue, 31 Mar 2020 12:32:52 +1100 Subject: [PATCH] Remove js-sha512 --- app/password_util.js | 9 ++++++++- package.json | 1 - yarn.lock | 5 ----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/password_util.js b/app/password_util.js index 944769c60..d2bf73c20 100644 --- a/app/password_util.js +++ b/app/password_util.js @@ -1,4 +1,4 @@ -const { sha512 } = require('js-sha512'); +const crypto = require('crypto'); const ERRORS = { TYPE: 'Password must be a string', @@ -6,6 +6,12 @@ const ERRORS = { CHARACTER: 'Password must only contain letters, numbers and symbols', }; +const sha512 = text => { + const hash = crypto.createHash('sha512'); + hash.update(text.trim()); + return hash.digest('hex'); +}; + const generateHash = phrase => phrase && sha512(phrase.trim()); const matchesHash = (phrase, hash) => phrase && sha512(phrase.trim()) === hash.trim(); @@ -29,6 +35,7 @@ const validatePassword = (phrase, i18n) => { return null; }; + module.exports = { generateHash, matchesHash, diff --git a/package.json b/package.json index f35fafb8d..8a1d8193e 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,6 @@ "glob": "7.1.2", "he": "1.2.0", "jquery": "3.3.1", - "js-sha512": "0.8.0", "js-yaml": "3.13.0", "jsbn": "1.1.0", "linkify-it": "2.0.3", diff --git a/yarn.lock b/yarn.lock index abb2c1f7c..07431b7b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5558,11 +5558,6 @@ js-base64@^2.1.8, js-base64@^2.1.9: resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.5.2.tgz#313b6274dda718f714d00b3330bbae6e38e90209" integrity sha512-Vg8czh0Q7sFBSUMWWArX/miJeBWYBPpdU/3M/DKSaekLMqrqVPaedp+5mZhie/r0lgrcaYBfwXatEew6gwgiQQ== -js-sha512@0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/js-sha512/-/js-sha512-0.8.0.tgz#dd22db8d02756faccf19f218e3ed61ec8249f7d4" - integrity sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ== - "js-tokens@^3.0.0 || ^4.0.0": version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"