From 25d820d448f82ea05c1c848f2ba4df5ae73ce7a2 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 18 Sep 2018 16:27:41 +0100 Subject: [PATCH] fix: coerce key gen size to number (#1582) Keychain params are now validated properly and has caused these test to fail https://github.com/libp2p/js-libp2p-keychain/pull/26 License: MIT Signed-off-by: Alan Shaw --- src/cli/commands/key/gen.js | 3 ++- src/http/api/resources/key.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cli/commands/key/gen.js b/src/cli/commands/key/gen.js index a3f108eeaa..811fbe2a1e 100644 --- a/src/cli/commands/key/gen.js +++ b/src/cli/commands/key/gen.js @@ -16,7 +16,8 @@ module.exports = { size: { alias: 's', describe: 'size of the key to generate.', - default: '2048' + default: 2048, + type: 'number' } }, diff --git a/src/http/api/resources/key.js b/src/http/api/resources/key.js index 15de675c8e..0e5e1545fc 100644 --- a/src/http/api/resources/key.js +++ b/src/http/api/resources/key.js @@ -64,7 +64,7 @@ exports.gen = (request, reply) => { const ipfs = request.server.app.ipfs const name = request.query.arg const type = request.query.type - const size = request.query.size + const size = parseInt(request.query.size) ipfs._keychain.createKey(name, type, size, (err, key) => { if (err) { return applyError(reply, err)