Fixed GET and REMOVE functions

This commit is contained in:
Aneem 2019-06-11 21:16:59 +05:45
parent 4072ae0565
commit 4dfaa01fed
1 changed files with 10 additions and 13 deletions

View File

@ -39,7 +39,7 @@ module.exports.create = function(config) {
}
}
throw new Error('Domain not found for: ' + identifier);
})
});
},
getTXTRecord: function(data) {
// data:{dnsPrefix:"_88-acme-challenge-0e.foo",zone:"example.com",txt:"_cdZWaclIbkP1qYpMkZIURTK--ydQIK6d9axFmftWz0"}
@ -60,7 +60,6 @@ module.exports.create = function(config) {
}
}).then(function(resp) {
resp = resp.body;
var entries =
resp &&
resp.domain_records &&
@ -88,7 +87,7 @@ module.exports.create = function(config) {
var txt = ch.dnsAuthorization;
var url = baseUrl + '/v2/domains/' + zone + '/records';
console.info('Adding TXT', data);
// console.info('Adding TXT', data);
return request({
method: 'POST',
url: url,
@ -120,7 +119,7 @@ module.exports.create = function(config) {
return helpers.getDomain(domainRecord).then(function(zone) {
var dnsPrefix = ch.dnsHost.replace(new RegExp('.' + zone + '$'), '');
console.info('Removing TXT', data);
// console.info('Removing TXT', data);
var payload = {
dnsPrefix: dnsPrefix,
zone: zone,
@ -141,7 +140,6 @@ module.exports.create = function(config) {
}
}).then(function(resp) {
resp = resp.body;
console.log(resp);
return true;
});
} else {
@ -152,21 +150,20 @@ module.exports.create = function(config) {
},
get: function(data) {
var ch = data.challenge;
var domainRecord = data.challenge.altname;
console.log('DATA:xx', data);
var domainRecord = ch.identifier.value;
return helpers.getDomain(domainRecord).then(function(zone) {
var dnsPrefix = ch.dnsHost.replace(new RegExp('.' + zone + '$'), '');
var dnsPrefix = domainRecord.replace(new RegExp('.' + zone + '$'), '');
console.info('Fetching TXT', data);
// console.info('Fetching TXT', data);
var payload = {
dnsPrefix: dnsPrefix,
zone: zone,
txt: data.dnsAuthorization
txt: ch.dnsAuthorization
};
return helpers.getTXTRecord(payload).then(function(txtRecord) {
if (txtRecord) {
return { dnsAuthorization: entry.data };
return { dnsAuthorization: txtRecord.data };
} else {
return null;
}