From 8a0c1bc5f22b213fc4386212a036c2ccb2006524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Fr=C3=B6hle?= Date: Wed, 12 Sep 2018 00:47:46 +0200 Subject: [PATCH] feat(package): add promisify methods pem.promisify.FUNCTIONNAME MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Josef Fröhle --- lib/pem.js | 22 ++++++++++++++++++++++ package-lock.json | 21 ++++++++++++++------- package.json | 1 + 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/lib/pem.js b/lib/pem.js index c85f0baa..260099f9 100644 --- a/lib/pem.js +++ b/lib/pem.js @@ -6,6 +6,7 @@ * @module pem */ +const {promisify} = require("es6-promisify"); var net = require('net') var helper = require('./helper.js') var openssl = require('./openssl.js') @@ -26,6 +27,27 @@ module.exports.verifySigningChain = verifySigningChain module.exports.checkCertificate = checkCertificate module.exports.checkPkcs12 = checkPkcs12 module.exports.config = config + +// promisify not tested yet +const promisifyObj = { + createPrivateKey: promisify(createPrivateKey), + createDhparam: promisify(createDhparam), + createEcparam: promisify(createEcparam), + createCSR: promisify(createCSR), + createCertificate: promisify(createCertificate), + readCertificateInfo: promisify(readCertificateInfo), + getPublicKey: promisify(getPublicKey), + getFingerprint: promisify(getFingerprint), + getModulus: promisify(getModulus), + getDhparamInfo: promisify(getDhparamInfo), + createPkcs12: promisify(createPkcs12), + readPkcs12: promisify(readPkcs12), + verifySigningChain: promisify(verifySigningChain), + checkCertificate: promisify(checkCertificate), + checkPkcs12: promisify(checkPkcs12) +} +module.exports.promisified = promisifyObj + /** * quick access the convert module * @type {module:convert} diff --git a/package-lock.json b/package-lock.json index bd50e003..88e02c82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1321,6 +1321,17 @@ "dev": true, "requires": { "es6-promisify": "^5.0.0" + }, + "dependencies": { + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", + "dev": true, + "requires": { + "es6-promise": "^4.0.3" + } + } } }, "aggregate-error": { @@ -2779,13 +2790,9 @@ "dev": true }, "es6-promisify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", - "dev": true, - "requires": { - "es6-promise": "^4.0.3" - } + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-6.0.0.tgz", + "integrity": "sha512-8Tbqjrb8lC85dd81haajYwuRmiU2rkqNAFnlvQOJeeKqdUloIlI+JcUqeJruV4rCm5Y7oNU7jfs2FbmxhRR/2g==" }, "escape-string-regexp": { "version": "1.0.5", diff --git a/package.json b/package.json index 4b953182..c14f4f21 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ ] }, "dependencies": { + "es6-promisify": "^6.0.0", "md5": "^2.2.1", "os-tmpdir": "^1.0.1", "which": "^1.3.1"