From 6922fb2e9747e88d498f87cb604446ef301addaa Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 7 Apr 2019 11:39:49 -0600 Subject: [PATCH] v3.0.2: clarify with comments and docs --- index.js | 21 ++++++++------------- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 492193f..1335824 100644 --- a/index.js +++ b/index.js @@ -69,12 +69,10 @@ module.exports.create = function (opts) { var id = opts.account.id || opts.email || 'default'; var keypair = opts.keypair; - saveKeypair(id, JSON.stringify({ + return saveKeypair(id, JSON.stringify({ privateKeyPem: keypair.privateKeyPem , privateKeyJwk: keypair.privateKeyJwk - })); - - return null; // or Promise.resolve(null); + })); // Must return or Promise `null` instead of `undefined` }; @@ -121,14 +119,13 @@ module.exports.create = function (opts) { var id = opts.certificate.kid || opts.certificate.id || opts.subject; var keypair = opts.keypair; - saveKeypair(id, JSON.stringify({ + return saveKeypair(id, JSON.stringify({ privateKeyPem: keypair.privateKeyPem , privateKeyJwk: keypair.privateKeyJwk - })); - // Note: you can use the "keypairs" package to convert between - // public and private for jwk and pem, as well as convert JWK <-> PEM + })); // Must return or Promise `null` instead of `undefined` - return null; + // Side Note: you can use the "keypairs" package to convert between + // public and private for jwk and pem, as well as convert JWK <-> PEM }; @@ -155,16 +152,14 @@ module.exports.create = function (opts) { var id = opts.certificate.id || opts.subject; var pems = opts.pems; - saveCertificate(id, JSON.stringify({ + return saveCertificate(id, JSON.stringify({ cert: pems.cert , chain: pems.chain , subject: pems.subject , altnames: pems.altnames , issuedAt: pems.issuedAt // a.k.a. NotBefore , expiresAt: pems.expiresAt // a.k.a. NotAfter - })); - - return null; + })); // Must return or Promise `null` instead of `undefined` }; diff --git a/package-lock.json b/package-lock.json index a2c609a..6b9c711 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { "name": "greenlock-store-memory", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 1 } diff --git a/package.json b/package.json index 7450ff7..010de14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "greenlock-store-memory", - "version": "3.0.1", + "version": "3.0.2", "description": "An in-memory reference implementation for account, certificate, and keypair storage strategies in Greenlock", "homepage": "https://git.coolaj86.com/coolaj86/greenlock-store-memory.js", "main": "index.js",