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
// (valid or invalid or other)
try {
options.challenges[auth.type]
var errmsg;
return options.challenges[auth.type]
.remove({ challenge: auth })
.catch(function(err) {
err.action = 'challenge_remove';
err.altname = auth.altname;
err.type = auth.type;
ACME._notify(me, options, 'error', err);
});
} catch (e) {}
if ('valid' === resp.body.status) {
.then((res) => {
if ("valid" === resp.body.status) {
if (me.debug) {
console.debug('poll: valid');
console.debug("poll: valid");
}
return resp.body;
}
var errmsg;
return Promise.reject("status not valid");
})
.catch(function (err) {
if (!resp.body.status) {
errmsg =
"[ACME.js] (E_STATE_EMPTY) empty challenge state for '" +
altname +
"':" +
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) +
"'";
errmsg = "[ACME.js] (E_STATE_EMPTY) empty challenge state for '" + altname + "':" + JSON.stringify(resp.body);
} else if ("invalid" === resp.body.status) {
errmsg = "[ACME.js] (E_STATE_INVALID) challenge state for '" + altname + "': '" + JSON.stringify(resp.body) + "'";
} else {
errmsg =
"[ACME.js] (E_STATE_UKN) challenge state for '" +
altname +
"': '" +
resp.body.status +
"'";
errmsg = "[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));
});
}
function transformError(e) {