From 64735693beda5800bc81fdcd610d71a84ca36896 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Fri, 21 Jun 2019 16:51:44 +0700 Subject: [PATCH] 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. --- core/server/models/settings.js | 10 ++++------ package.json | 2 +- yarn.lock | 9 +++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/server/models/settings.js b/core/server/models/settings.js index da69f853f8..2f7371dde2 100644 --- a/core/server/models/settings.js +++ b/core/server/models/settings.js @@ -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) { diff --git a/package.json b/package.json index caa0566aa4..e8466fbbec 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 881e1ed899..34862d7f3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"