make Prettier

This commit is contained in:
AJ ONeal 2019-06-06 06:49:46 +00:00
parent d2fca0eea7
commit fa912800b4
1 changed files with 95 additions and 62 deletions

157
README.md
View File

@ -55,36 +55,37 @@ See `example.js` (it works).
Here's what you could start with. Here's what you could start with.
```js ```js
var tester = require("acme-challenge-test"); var tester = require('acme-challenge-test');
// The dry-run tests can pass on, literally, 'example.com' // The dry-run tests can pass on, literally, 'example.com'
// but the integration tests require that you have control over the domain // but the integration tests require that you have control over the domain
var domain = "example.com"; var domain = 'example.com';
tester.test("http-01", domain, { tester
.test('http-01', domain, {
// Should set a TXT record for dnsHost with dnsAuthorization and ttl || 300
set: function(opts) {
console.log('set opts:', opts);
throw new Error('set not implemented');
},
// Should set a TXT record for opts.dnsHost with opts.dnsAuthorization for opts.ttl || 300 // Should remove the *one* TXT record for dnsHost with dnsAuthorization
set: function (opts) { // Should NOT remove otherrecords for dnsHost (wildcard shares dnsHost with
console.log("set opts:", opts); // non-wildcard)
throw new Error("set not implemented"); remove: function(opts) {
}, console.log('remove opts:', opts);
throw new Error('remove not implemented');
// Should remove the *one* TXT record for opts.dnsHost with opts.dnsAuthorization },
// Should NOT remove otherrecords for opts.dnsHost (wildcard shares dnsHost with non-wildcard)
remove: function (opts) {
console.log("remove opts:", opts);
throw new Error("remove not implemented");
},
// Should get the record via the DNS server's API
get: function (opts) {
console.log("get opts:", opts);
throw new Error("get not implemented");
}
}).then(function() { // Should get the record via the DNS server's API
console.info("PASS"); get: function(opts) {
}); console.log('get opts:', opts);
throw new Error('get not implemented');
}
})
.then(function() {
console.info('PASS');
});
``` ```
## dns-01 vs http-01 ## dns-01 vs http-01
@ -105,48 +106,80 @@ For `type` dns-01:
Here's a quick pseudo stub-out of what a test-passing plugin object might look like: Here's a quick pseudo stub-out of what a test-passing plugin object might look like:
```js ```js
tester.test('http-01', 'example.com', { tester
set: function (opts) { .test('http-01', 'example.com', {
var ch = opts.challenge;
// { type: 'http-01' // or 'dns-01' set: function(opts) {
// , identifier: { type: 'dns', value: 'example.com' } var ch = opts.challenge;
// , wildcard: false // { type: 'http-01' // or 'dns-01'
// , token: 'xxxx' // , identifier: { type: 'dns', value: 'example.com' }
// , keyAuthorization: 'xxxx.yyyy' // , wildcard: false
// , dnsHost: '_acme-challenge.example.com' // , token: 'xxxx'
// , dnsAuthorization: 'zzzz' } // , keyAuthorization: 'xxxx.yyyy'
// , dnsHost: '_acme-challenge.example.com'
// , dnsAuthorization: 'zzzz' }
return API.set(...); return YourApi('POST', 'https://example.com/api/dns/txt', {
} host: ch.dnsHost,
, get: function (query) { record: ch.dnsAuthorization
var ch = query.challenge; });
// { type: 'http-01' // or 'dns-01', 'tls-alpn-01', etc },
// , identifier: { type: 'dns', value: 'example.com' }
// // http-01 only get: function(query) {
// , token: 'xxxx' var ch = query.challenge;
// , url: '...' // for testing and debugging // { type: 'http-01' // or 'dns-01', 'tls-alpn-01', etc
// // dns-01 only, for testing / dubgging // , identifier: { type: 'dns', value: 'example.com' }
// , altname: '...' // // http-01 only
// , dnsHost: '...' // , token: 'xxxx'
// , wildcard: false } // , url: '...' // for testing and debugging
// Note: query.identifier.value is different for http-01 than for dns-01 // // dns-01 only, for testing / dubgging
// , altname: '...'
// , dnsHost: '...'
// , wildcard: false }
// Note: query.identifier.value is different for http-01 than for dns-01
return API.get(...).then(function (secret) { return YourApi('GET', 'https://example.com/api/dns/txt', {
// http-01 host: ch.dnsHost
return { keyAuthorization: secret }; }).then(function(secret) {
// dns-01 // http-01
//return { dnsAuthorization: secret }; return { keyAuthorization: secret };
// dns-01
//return { dnsAuthorization: secret };
});
},
remove: function(opts) {
var ch = opts.challenge;
// same options as in `set()` (which are not the same as `get()`
return YourApi('DELETE', 'https://example.com/api/dns/txt/' + ch.dnsHost);
}
})
.then(function() {
console.info('PASS');
});
```
Where `YourApi` might look something like this:
```js
var YourApi = function createApi(config) {
var request = require('@root/request');
request = require('util').promisify(request);
return function (method, url, body) {
return request({
method: method,
url: url,
json: body || true,
headers: {
Authorization: 'Bearer ' + config.apiToken
}
}).then(function(resp) {
return resp.body;
}); });
} }
, remove: function (opts) { }
var ch = opts.challenge;
// same options as in `set()` (which are not the same as `get()`
return API.remove(...);
}
}).then(function () {
console.info("PASS");
});
``` ```
### Two notes: ### Two notes: