make calls to remove resolve before returning #30

Open
Ghost wants to merge 1 commits from (deleted):remove-logic into master
1 changed files with 25 additions and 43 deletions
Showing only changes of commit d8faeff64d - Show all commits

52
acme.js
View File

@ -774,50 +774,32 @@ ACME._postChallenge = function(me, options, kid, auth) {
// REMOVE DNS records as soon as the state is non-processing // REMOVE DNS records as soon as the state is non-processing
// (valid or invalid or other) // (valid or invalid or other)
try { var errmsg;
options.challenges[auth.type] return options.challenges[auth.type]
.remove({ challenge: auth }) .remove({ challenge: auth })
.catch(function(err) { .then((res) => {
err.action = 'challenge_remove'; if ("valid" === resp.body.status) {
err.altname = auth.altname;
err.type = auth.type;
ACME._notify(me, options, 'error', err);
});
} catch (e) {}
if ('valid' === resp.body.status) {
if (me.debug) { if (me.debug) {
console.debug('poll: valid'); console.debug("poll: valid");
} }
return resp.body; return resp.body;
} }
return Promise.reject("status not valid");
var errmsg; })
.catch(function (err) {
if (!resp.body.status) { if (!resp.body.status) {
errmsg = errmsg = "[ACME.js] (E_STATE_EMPTY) empty challenge state for '" + altname + "':" + JSON.stringify(resp.body);
"[ACME.js] (E_STATE_EMPTY) empty challenge state for '" + } else if ("invalid" === resp.body.status) {
altname + errmsg = "[ACME.js] (E_STATE_INVALID) challenge state for '" + altname + "': '" + JSON.stringify(resp.body) + "'";
"':" +
JSON.stringify(resp.body);
} else if ('invalid' === resp.body.status) {
errmsg =
"[ACME.js] (E_STATE_INVALID) challenge state for '" +
altname +
"': '" +
//resp.body.status +
JSON.stringify(resp.body) +
"'";
} else { } else {
errmsg = errmsg = "[ACME.js] (E_STATE_UKN) challenge state for '" + altname + "': '" + resp.body.status + "'";
"[ACME.js] (E_STATE_UKN) challenge state for '" +
altname +
"': '" +
resp.body.status +
"'";
} }
err.action = "challenge_remove";
err.altname = auth.altname;
err.type = auth.type;
ACME._notify(me, options, "error", err);
return Promise.reject(new Error(errmsg)); return Promise.reject(new Error(errmsg));
});
} }
function transformError(e) { function transformError(e) {