make Prettier
This commit is contained in:
parent
29e501d8b3
commit
c914536dff
|
@ -59,10 +59,10 @@ dns01
|
||||||
dnsHost: '_acme-challenge.foo.example.com',
|
dnsHost: '_acme-challenge.foo.example.com',
|
||||||
dnsAuthorization: 'xxx_secret_xxx'
|
dnsAuthorization: 'xxx_secret_xxx'
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function () {
|
||||||
console.log('TXT record set');
|
console.log('TXT record set');
|
||||||
})
|
})
|
||||||
.catch(function() {
|
.catch(function () {
|
||||||
console.log('Failed to set TXT record');
|
console.log('Failed to set TXT record');
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
43
lib/index.js
43
lib/index.js
|
@ -10,7 +10,7 @@ var defaults = {
|
||||||
baseUrl: PRODUCTION_ENVIRONMENT
|
baseUrl: PRODUCTION_ENVIRONMENT
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.create = function(config) {
|
module.exports.create = function (config) {
|
||||||
var baseUrl = (config.baseUrl || defaults.baseUrl).replace(/\/$/, '');
|
var baseUrl = (config.baseUrl || defaults.baseUrl).replace(/\/$/, '');
|
||||||
var apiKey = config.key || config.apiKey;
|
var apiKey = config.key || config.apiKey;
|
||||||
var apiSecret = config.secret || config.apiSecret;
|
var apiSecret = config.secret || config.apiSecret;
|
||||||
|
@ -19,21 +19,21 @@ module.exports.create = function(config) {
|
||||||
var redacted = 'sso-key ' + apiKey + ':[redacted]';
|
var redacted = 'sso-key ' + apiKey + ':[redacted]';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
propagationDelay: 30*1000,
|
propagationDelay: 30 * 1000,
|
||||||
|
|
||||||
init: function(deps) {
|
init: function (deps) {
|
||||||
request = deps.request;
|
request = deps.request;
|
||||||
return new Promise(resolve => resolve());
|
return new Promise((resolve) => resolve());
|
||||||
},
|
},
|
||||||
|
|
||||||
zones: function(data) {
|
zones: function (data) {
|
||||||
return api('GET', '/domains?statuses=ACTIVE').then(function(resp) {
|
return api('GET', '/domains?statuses=ACTIVE').then(function (resp) {
|
||||||
return resp.body.map(function(x) {
|
return resp.body.map(function (x) {
|
||||||
return x.domain;
|
return x.domain;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
set: function(data) {
|
set: function (data) {
|
||||||
var ch = data.challenge;
|
var ch = data.challenge;
|
||||||
var txt = ch.dnsAuthorization;
|
var txt = ch.dnsAuthorization;
|
||||||
// If the domain to be verified is
|
// 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(
|
return api('PATCH', '/domains/' + ch.dnsZone + '/records', records).then(
|
||||||
function(resp) {
|
function (resp) {
|
||||||
return null
|
return null;
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
},
|
},
|
||||||
remove: function(data) {
|
remove: function (data) {
|
||||||
var ch = data.challenge;
|
var ch = data.challenge;
|
||||||
|
|
||||||
// get all domain records of type or name
|
// get all domain records of type or name
|
||||||
|
@ -67,14 +67,13 @@ module.exports.create = function(config) {
|
||||||
'GET',
|
'GET',
|
||||||
'/domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix
|
'/domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix
|
||||||
)
|
)
|
||||||
.then(function(resp) {
|
.then(function (resp) {
|
||||||
|
|
||||||
// keep all TXT records that we don't need to remove
|
// 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;
|
return el.data !== ch.dnsAuthorization;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(function(records) {
|
.then(function (records) {
|
||||||
// godaddy doesn't provide an endpoint for a single record removal
|
// godaddy doesn't provide an endpoint for a single record removal
|
||||||
// but provides this endpoint to replace all records of a given type
|
// but provides this endpoint to replace all records of a given type
|
||||||
// https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceType
|
// https://developer.godaddy.com/doc/endpoint/domains#/v1/recordReplaceType
|
||||||
|
@ -95,20 +94,18 @@ module.exports.create = function(config) {
|
||||||
'PUT',
|
'PUT',
|
||||||
'/domains/' + ch.dnsZone + '/records/TXT',
|
'/domains/' + ch.dnsZone + '/records/TXT',
|
||||||
records
|
records
|
||||||
).then(function(resp) {
|
).then(function (resp) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
get: function(data) {
|
get: function (data) {
|
||||||
var ch = data.challenge;
|
var ch = data.challenge;
|
||||||
return api(
|
return api(
|
||||||
'GET',
|
'GET',
|
||||||
'/domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix
|
'/domains/' + ch.dnsZone + '/records/TXT/' + ch.dnsPrefix
|
||||||
).then(function(resp) {
|
).then(function (resp) {
|
||||||
|
var entry = (resp.body || []).filter(function (x) {
|
||||||
var entry = (resp.body || []).filter(function(x) {
|
|
||||||
return x.data === ch.dnsAuthorization;
|
return x.data === ch.dnsAuthorization;
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
|
@ -129,7 +126,7 @@ module.exports.create = function(config) {
|
||||||
json: data || true
|
json: data || true
|
||||||
};
|
};
|
||||||
|
|
||||||
return request(req).then(function(resp) {
|
return request(req).then(function (resp) {
|
||||||
if (resp.statusCode < 200 || resp.statusCode >= 300) {
|
if (resp.statusCode < 200 || resp.statusCode >= 300) {
|
||||||
req.headers.Authorization = redacted;
|
req.headers.Authorization = redacted;
|
||||||
console.error();
|
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
|
// but the integration tests require that you have control over the domain
|
||||||
tester
|
tester
|
||||||
.testZone('dns-01', zone, challenger)
|
.testZone('dns-01', zone, challenger)
|
||||||
.then(function() {
|
.then(function () {
|
||||||
console.info('PASS', zone);
|
console.info('PASS', zone);
|
||||||
})
|
})
|
||||||
.catch(function(e) {
|
.catch(function (e) {
|
||||||
console.error(e.message);
|
console.error(e.message);
|
||||||
console.error(e.stack);
|
console.error(e.stack);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue