diff --git a/lib/index.js b/lib/index.js index bb051a8..8d45741 100644 --- a/lib/index.js +++ b/lib/index.js @@ -114,20 +114,19 @@ module.exports.create = function(config) { }, remove: function(data) { var ch = data.challenge; - var zone = ch.identifier.value; - var dnsPrefix = ch.dnsHost.replace(new RegExp('.' + zone + '$'), ''); - var txt = ch.dnsAuthorization; - var url = baseUrl + '/v2/domains/' + zone + '/records'; - + var domainRecord = ch.identifier.value; + // Digital ocean provides the api to remove records by ID. So we first get the recordId and use it to remove the domain record return helpers.getDomain(domainRecord).then(function(zone) { var dnsPrefix = ch.dnsHost.replace(new RegExp('.' + zone + '$'), ''); + console.info('Removing TXT', data); var payload = { dnsPrefix: dnsPrefix, zone: zone, - txt: data.dnsAuthorization + txt: ch.dnsAuthorization }; + return helpers.getTXTRecord(payload).then(function(txtRecord) { if (txtRecord) { var url =