make Prettier
This commit is contained in:
parent
d2fca0eea7
commit
fa912800b4
157
README.md
157
README.md
|
@ -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 get the record via the DNS server's API
|
||||||
// Should NOT remove otherrecords for opts.dnsHost (wildcard shares dnsHost with non-wildcard)
|
get: function(opts) {
|
||||||
remove: function (opts) {
|
console.log('get opts:', opts);
|
||||||
console.log("remove opts:", opts);
|
throw new Error('get not implemented');
|
||||||
throw new Error("remove 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'
|
|
||||||
// , identifier: { type: 'dns', value: 'example.com' }
|
|
||||||
// , wildcard: false
|
|
||||||
// , token: 'xxxx'
|
|
||||||
// , keyAuthorization: 'xxxx.yyyy'
|
|
||||||
// , dnsHost: '_acme-challenge.example.com'
|
|
||||||
// , dnsAuthorization: 'zzzz' }
|
|
||||||
|
|
||||||
return API.set(...);
|
set: function(opts) {
|
||||||
}
|
var ch = opts.challenge;
|
||||||
, get: function (query) {
|
// { type: 'http-01' // or 'dns-01'
|
||||||
var ch = query.challenge;
|
// , identifier: { type: 'dns', value: 'example.com' }
|
||||||
// { type: 'http-01' // or 'dns-01', 'tls-alpn-01', etc
|
// , wildcard: false
|
||||||
// , identifier: { type: 'dns', value: 'example.com' }
|
// , token: 'xxxx'
|
||||||
// // http-01 only
|
// , keyAuthorization: 'xxxx.yyyy'
|
||||||
// , token: 'xxxx'
|
// , dnsHost: '_acme-challenge.example.com'
|
||||||
// , url: '...' // for testing and debugging
|
// , dnsAuthorization: 'zzzz' }
|
||||||
// // 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('POST', 'https://example.com/api/dns/txt', {
|
||||||
// http-01
|
host: ch.dnsHost,
|
||||||
return { keyAuthorization: secret };
|
record: ch.dnsAuthorization
|
||||||
// dns-01
|
});
|
||||||
//return { dnsAuthorization: secret };
|
},
|
||||||
|
|
||||||
|
get: function(query) {
|
||||||
|
var ch = query.challenge;
|
||||||
|
// { type: 'http-01' // or 'dns-01', 'tls-alpn-01', etc
|
||||||
|
// , identifier: { type: 'dns', value: 'example.com' }
|
||||||
|
// // http-01 only
|
||||||
|
// , token: 'xxxx'
|
||||||
|
// , url: '...' // for testing and debugging
|
||||||
|
// // dns-01 only, for testing / dubgging
|
||||||
|
// , altname: '...'
|
||||||
|
// , dnsHost: '...'
|
||||||
|
// , wildcard: false }
|
||||||
|
// Note: query.identifier.value is different for http-01 than for dns-01
|
||||||
|
|
||||||
|
return YourApi('GET', 'https://example.com/api/dns/txt', {
|
||||||
|
host: ch.dnsHost
|
||||||
|
}).then(function(secret) {
|
||||||
|
// http-01
|
||||||
|
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:
|
||||||
|
|
Loading…
Reference in New Issue