diff --git a/.gitignore b/.gitignore index 407a14c..1bb61b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.env *secret* node_modules diff --git a/README.md b/README.md index bdc435d..3ecf13b 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,12 @@ npm install --save acme-dns-01-vultr@3.x # Usage -First you create an instance with your credentials: +First you create an instance with your API token: ```js var dns01 = require('acme-dns-01-vultr').create({ baseUrl: 'https://api.vultr.com/v1/dns', // default - apiKey: 'xxxx' + token: 'xxxx' }); ``` @@ -52,18 +52,18 @@ See the [ACME.js](https://git.rootprojects.org/root/acme-v2.js) for more details ```js dns01 - .set({ - identifier: { value: 'foo.example.com' }, - wildcard: false, - dnsHost: '_acme-challenge.foo.example.com', - dnsAuthorization: 'xxx_secret_xxx' - }) - .then(function () { - console.log("TXT record set"); - }) - .catch(function () { - console.log("Failed to set TXT record"); - }); + .set({ + identifier: { value: 'foo.example.com' }, + wildcard: false, + dnsHost: '_acme-challenge.foo.example.com', + dnsAuthorization: 'xxx_secret_xxx' + }) + .then(function() { + console.log('TXT record set'); + }) + .catch(function() { + console.log('Failed to set TXT record'); + }); ``` See [acme-dns-01-test](https://git.rootprojects.org/root/acme-dns-01-test.js) diff --git a/example.env b/example.env new file mode 100644 index 0000000..48ceb39 --- /dev/null +++ b/example.env @@ -0,0 +1,2 @@ +ZONE=example.co.uk +TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx diff --git a/lib/index.js b/lib/index.js index 3dbe6ca..2c84e13 100644 --- a/lib/index.js +++ b/lib/index.js @@ -9,7 +9,9 @@ var defaults = { module.exports.create = function(config) { var baseUrl = (config.baseUrl || defaults.baseUrl).replace(/\/$/, ''); - var apiKey = config.apiKey; + // In all of the other modules the API token is called token, + // but here we support both. + var apiKey = config.token || config.apiKey; function api(method, path, form) { return request({ diff --git a/package-lock.json b/package-lock.json index 529ab68..09b0fad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "acme-dns-01-vultr", - "version": "3.0.0", + "version": "3.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -23,6 +23,12 @@ "requires": { "acme-challenge-test": "^3.2.0" } + }, + "dotenv": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.0.0.tgz", + "integrity": "sha512-30xVGqjLjiUOArT4+M5q9sYdvuR4riM6yK9wMcas9Vbp6zZa+ocC9dp6QoftuhTPhFAiLK/0C5Ni2nou/Bk8lg==", + "dev": true } } } diff --git a/package.json b/package.json index 1431d08..839d8ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "acme-dns-01-vultr", - "version": "3.0.1", + "version": "3.0.2", "description": "Vultr DNS for Let's Encrypt / ACME dns-01 challenges with ACME.js and Greenlock.js", "main": "index.js", "scripts": { @@ -24,6 +24,7 @@ "@root/request": "^1.3.11" }, "devDependencies": { - "acme-dns-01-test": "^3.2.1" + "acme-dns-01-test": "^3.2.1", + "dotenv": "^8.0.0" } } diff --git a/test.js b/test.js old mode 100644 new mode 100755 index ca6de26..d8b9412 --- a/test.js +++ b/test.js @@ -1,13 +1,14 @@ #!/usr/bin/env node 'use strict'; -// https://git.rootprojects.org/root/acme-dns-01-test.js -var tester = require('acme-dns-01-test'); +// See https://git.coolaj86.com/coolaj86/acme-challenge-test.js +var tester = require('acme-challenge-test'); +require('dotenv').config(); // Usage: node ./test.js example.com xxxxxxxxx -var zone = process.argv[2]; +var zone = process.argv[2] || process.env.ZONE; var challenger = require('./index.js').create({ - apiKey: process.argv[3] + token: process.argv[3] || process.env.TOKEN }); // The dry-run tests can pass on, literally, 'example.com' @@ -18,7 +19,6 @@ tester console.info('PASS', zone); }) .catch(function(e) { - console.info('FAIL', zone); console.error(e.message); console.error(e.stack); });