From ae4bc64fa0a44e25aa402c42d88a5a288a9c706e Mon Sep 17 00:00:00 2001 From: Anson Tsao Date: Thu, 22 Oct 2020 14:25:38 -0700 Subject: [PATCH] Fixed api response, added propagation delay Previous implementation did not work as api was not returning the response --- README.md | 2 +- lib/index.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5dbe457..e4b8eeb 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ First you create an instance with your API token: ```js var dns01 = require('acme-dns-01-godaddy').create({ - baseUrl: 'https://api.godaddy.com', // default + baseUrl: 'https://api.godaddy.com/v1', // default key: 'xxxx', secret: 'xxxx' }); diff --git a/lib/index.js b/lib/index.js index 3f45af4..3a3721a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -19,9 +19,11 @@ module.exports.create = function(config) { var redacted = 'sso-key ' + apiKey + ':[redacted]'; return { + propagationDelay: 30*1000, + init: function(deps) { request = deps.request; - return null; + return new Promise(resolve => resolve()); }, zones: function(data) { @@ -53,9 +55,9 @@ module.exports.create = function(config) { return api('PATCH', '/domains/' + ch.dnsZone + '/records', records).then( function(resp) { - return null; + return null } - ); + ) }, remove: function(data) { var ch = data.challenge; @@ -66,6 +68,7 @@ module.exports.create = function(config) { '/domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix ) .then(function(resp) { + // keep all TXT records that we don't need to remove return resp.body.filter(function(el) { return el.data !== ch.dnsAuthorization; @@ -93,6 +96,7 @@ module.exports.create = function(config) { '/domains/' + ch.dnsZone + '/records/TXT', records ).then(function(resp) { + return null; }); }); @@ -103,6 +107,7 @@ module.exports.create = function(config) { 'GET', '/domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix ).then(function(resp) { + var entry = (resp.body || []).filter(function(x) { return x.data === ch.dnsAuthorization; })[0]; @@ -148,6 +153,7 @@ module.exports.create = function(config) { '. Check subdomain, api key, etc' ); } + return resp; }); } };