make Prettier
This commit is contained in:
parent
29e501d8b3
commit
c914536dff
|
@ -59,10 +59,10 @@ dns01
|
|||
dnsHost: '_acme-challenge.foo.example.com',
|
||||
dnsAuthorization: 'xxx_secret_xxx'
|
||||
})
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
console.log('TXT record set');
|
||||
})
|
||||
.catch(function() {
|
||||
.catch(function () {
|
||||
console.log('Failed to set TXT record');
|
||||
});
|
||||
```
|
||||
|
|
43
lib/index.js
43
lib/index.js
|
@ -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();
|
||||
|
|
4
test.js
4
test.js
|
@ -17,10 +17,10 @@ var challenger = require('./index.js').create({
|
|||
// but the integration tests require that you have control over the domain
|
||||
tester
|
||||
.testZone('dns-01', zone, challenger)
|
||||
.then(function() {
|
||||
.then(function () {
|
||||
console.info('PASS', zone);
|
||||
})
|
||||
.catch(function(e) {
|
||||
.catch(function (e) {
|
||||
console.error(e.message);
|
||||
console.error(e.stack);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue