From c914536dff0f67aeb0e40d95448333a205e46da4 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 4 Apr 2021 10:51:43 -0600 Subject: [PATCH] make Prettier --- README.md | 4 ++-- lib/index.js | 43 ++++++++++++++++++++----------------------- test.js | 4 ++-- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index e4b8eeb..43abc3c 100644 --- a/README.md +++ b/README.md @@ -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'); }); ``` diff --git a/lib/index.js b/lib/index.js index be16860..706c3de 100644 --- a/lib/index.js +++ b/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(); diff --git a/test.js b/test.js index a3e108b..7ff47eb 100755 --- a/test.js +++ b/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); });