|
|
@ -10,7 +10,7 @@ var defaults = { |
|
|
|
baseUrl: PRODUCTION_ENVIRONMENT |
|
|
|
}; |
|
|
|
|
|
|
|
module.exports.create = function(config) { |
|
|
|
module.exports.create = function (config) { |
|
|
|
var baseUrl = (config.baseUrl || defaults.baseUrl).replace(/\/$/, ''); |
|
|
|
var apiKey = config.key || config.apiKey; |
|
|
|
var apiSecret = config.secret || config.apiSecret; |
|
|
@ -19,21 +19,21 @@ module.exports.create = function(config) { |
|
|
|
var redacted = 'sso-key ' + apiKey + ':[redacted]'; |
|
|
|
|
|
|
|
return { |
|
|
|
propagationDelay: 30*1000, |
|
|
|
propagationDelay: 30 * 1000, |
|
|
|
|
|
|
|
init: function(deps) { |
|
|
|
init: function (deps) { |
|
|
|
request = deps.request; |
|
|
|
return new Promise(resolve => resolve()); |
|
|
|
return new Promise((resolve) => resolve()); |
|
|
|
}, |
|
|
|
|
|
|
|
zones: function(data) { |
|
|
|
return api('GET', '/domains?statuses=ACTIVE').then(function(resp) { |
|
|
|
return resp.body.map(function(x) { |
|
|
|
zones: function (data) { |
|
|
|
return api('GET', '/domains?statuses=ACTIVE').then(function (resp) { |
|
|
|
return resp.body.map(function (x) { |
|
|
|
return x.domain; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
set: function(data) { |
|
|
|
set: function (data) { |
|
|
|
var ch = data.challenge; |
|
|
|
var txt = ch.dnsAuthorization; |
|
|
|
// If the domain to be verified is
|
|
|
@ -54,12 +54,12 @@ module.exports.create = function(config) { |
|
|
|
]; |
|
|
|
|
|
|
|
return api('PATCH', '/domains/' + ch.dnsZone + '/records', records).then( |
|
|
|
function(resp) { |
|
|
|
return null |
|
|
|
function (resp) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
) |
|
|
|
); |
|
|
|
}, |
|
|
|
remove: function(data) { |
|
|
|
remove: function (data) { |
|
|
|
var ch = data.challenge; |
|
|
|
|
|
|
|
// get all domain records of type or name
|
|
|
@ -67,14 +67,13 @@ module.exports.create = function(config) { |
|
|
|
'GET', |
|
|
|
'/domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix |
|
|
|
) |
|
|
|
.then(function(resp) { |
|
|
|
|
|
|
|
.then(function (resp) { |
|
|
|
// keep all TXT records that we don't need to remove
|
|
|
|
return resp.body.filter(function(el) { |
|
|
|
return resp.body.filter(function (el) { |
|
|
|
return el.data !== ch.dnsAuthorization; |
|
|
|
}); |
|
|
|
}) |
|
|
|
.then(function(records) { |
|
|
|
.then(function (records) { |
|
|
|
// godaddy doesn't provide an endpoint for a single record removal
|
|
|
|
// but provides this endpoint to replace all records of a given type
|
|
|
|
// https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceType
|
|
|
@ -95,20 +94,18 @@ module.exports.create = function(config) { |
|
|
|
'PUT', |
|
|
|
'/domains/' + ch.dnsZone + '/records/TXT', |
|
|
|
records |
|
|
|
).then(function(resp) { |
|
|
|
|
|
|
|
).then(function (resp) { |
|
|
|
return null; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
get: function(data) { |
|
|
|
get: function (data) { |
|
|
|
var ch = data.challenge; |
|
|
|
return api( |
|
|
|
'GET', |
|
|
|
'/domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix |
|
|
|
).then(function(resp) { |
|
|
|
|
|
|
|
var entry = (resp.body || []).filter(function(x) { |
|
|
|
).then(function (resp) { |
|
|
|
var entry = (resp.body || []).filter(function (x) { |
|
|
|
return x.data === ch.dnsAuthorization; |
|
|
|
})[0]; |
|
|
|
|
|
|
@ -129,7 +126,7 @@ module.exports.create = function(config) { |
|
|
|
json: data || true |
|
|
|
}; |
|
|
|
|
|
|
|
return request(req).then(function(resp) { |
|
|
|
return request(req).then(function (resp) { |
|
|
|
if (resp.statusCode < 200 || resp.statusCode >= 300) { |
|
|
|
req.headers.Authorization = redacted; |
|
|
|
console.error(); |
|
|
|