Replaced keypair with rsa-keypair module (#10758)

refs #10789 

Speed up Ghost boot time by replacing the JS-only RSA key generator
library with a native alternative.
This commit is contained in:
Daniel Lockyer 2019-06-21 16:51:44 +07:00 committed by Fabien O'Carroll
parent ede267e823
commit 64735693be
3 changed files with 10 additions and 11 deletions

View File

@ -2,7 +2,7 @@ const Promise = require('bluebird'),
_ = require('lodash'),
uuid = require('uuid'),
crypto = require('crypto'),
keypair = require('keypair'),
keypair = require('rsa-keypair'),
ghostBookshelf = require('./base'),
common = require('../lib/common'),
validation = require('../data/validation'),
@ -25,12 +25,10 @@ function parseDefaultSettings() {
theme_session_secret: crypto.randomBytes(32).toString('hex')
};
const membersKeypair = keypair({
bits: 1024
});
const membersKeypair = keypair.generate(1024);
dynamicDefault.members_public_key = membersKeypair.public;
dynamicDefault.members_private_key = membersKeypair.private;
dynamicDefault.members_public_key = membersKeypair.publicKey;
dynamicDefault.members_private_key = membersKeypair.privateKey;
_.each(defaultSettingsInCategories, function each(settings, categoryName) {
_.each(settings, function each(setting, settingName) {

View File

@ -89,7 +89,6 @@
"js-yaml": "3.12.1",
"jsonpath": "1.0.0",
"jsonwebtoken": "8.4.0",
"keypair": "1.0.1",
"knex": "0.14.6",
"knex-migrator": "3.2.5",
"lodash": "4.17.11",
@ -113,6 +112,7 @@
"passport-oauth2-client-password": "0.1.2",
"path-match": "1.2.4",
"probe-image-size": "4.0.0",
"rsa-keypair": "^2.0.2",
"rss": "1.2.2",
"sanitize-html": "1.20.0",
"semver": "5.6.0",

View File

@ -3901,10 +3901,6 @@ keygrip@~1.0.2, keygrip@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/keygrip/-/keygrip-1.0.3.tgz#399d709f0aed2bab0a059e0cdd3a5023a053e1dc"
keypair@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/keypair/-/keypair-1.0.1.tgz#7603719270afb6564ed38a22087a06fc9aa4ea1b"
keyv@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.0.0.tgz#44923ba39e68b12a7cec7df6c3268c031f2ef373"
@ -6208,6 +6204,11 @@ rimraf@~2.4.0:
dependencies:
glob "^6.0.1"
rsa-keypair@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/rsa-keypair/-/rsa-keypair-2.0.2.tgz#47ec7fa29486ceaefdd1af1f80f1db2284dba236"
integrity sha512-FmMjEQrH9oJrBy13wMbSQx1bomRbub7mzxwvVuXFvqJIeZ7NkWd9NJhFoeftd4lzQAeLP8/avm7HHmtEIGLHpQ==
rss@1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/rss/-/rss-1.2.2.tgz#50a1698876138133a74f9a05d2bdc8db8d27a921"