From e2ec6737c6011d76a5a6726392fbf01e037a2c35 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 28 Oct 2019 02:25:32 -0600 Subject: [PATCH] minor updates --- certificates.js | 10 ++-------- greenlock.js | 25 ++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/certificates.js b/certificates.js index 1c3da6c..573e67b 100644 --- a/certificates.js +++ b/certificates.js @@ -152,14 +152,8 @@ C._rawOrder = function(gnlck, mconf, db, acme, chs, acc, email, args) { return Enc.bufToUrlBase64(csrDer); }) .then(function(csr) { - function notify() { - gnlck._notify('challenge_status', { - options: args, - subject: args.subject, - altnames: args.altnames, - account: acc, - email: email - }); + function notify(ev, opts) { + gnlck._notify(ev, opts); } var certReq = { debug: args.debug || gnlck._defaults.debug, diff --git a/greenlock.js b/greenlock.js index bfb7ccc..78010e6 100644 --- a/greenlock.js +++ b/greenlock.js @@ -86,7 +86,6 @@ G.create = function(gconf) { }); return p; }; - greenlock._init(); // The goal here is to reduce boilerplate, such as error checking // and duration parsing, that a manager must implement @@ -256,8 +255,16 @@ G.create = function(gconf) { order.pems = pems; }) .catch(function(err) { - order.error = err; - greenlock._notify('order_error', order); + // For greenlock express serialization + err.toJSON = errorToJSON; + err.subject = site.subject; + if (args.servername) { + err.servername = args.servername; + } + // for debugging, but not to be relied on + err._order = order; + // TODO err.context = err.context || 'renew_certificate' + greenlock._notify('error', err); }) .then(function() { return next(); @@ -395,6 +402,10 @@ G._defaults = function(opts) { defaults[k] = opts[k]; }); + if ('function' === typeof opts.notify) { + defaults.notify = opts.notify; + } + if (!defaults._maintainerPackage) { defaults._maintainerPackage = pkg.name; defaults._maintainerPackageVersion = pkg.version; @@ -599,3 +610,11 @@ Greenlock._normalizeChallenge = function(name, ch) { return ch; }; + +function errorToJSON(e) { + var error = {}; + Object.getOwnPropertyNames(e).forEach(function(k) { + error[k] = e[k]; + }); + return error; +}