From c2199e8140470d5633be70b629a4277190f89ce9 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 22 Jul 2019 23:31:48 -0600 Subject: [PATCH] acme dns-01 library template --- AUTHORS | 1 + README.md | 4 ++-- example.env | 2 ++ index.js | 3 +++ lib/index.js | 29 +++++++++++++++++++++++++++++ package-lock.json | 36 ++++++++++++++++++++++++++++++++++++ package.json | 31 +++++++++++++++++++++++++++++++ test.js | 24 ++++++++++++++++++++++++ 8 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 AUTHORS create mode 100644 example.env create mode 100644 index.js create mode 100644 lib/index.js create mode 100644 package-lock.json create mode 100644 package.json create mode 100755 test.js diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..f2496e6 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +AJ ONeal (https://coolaj86.com/) diff --git a/README.md b/README.md index 7d4dd29..e05f988 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# acme-dns-01-template.js +# acme-dns-01-{{servicename}}.js -{{ Service }} DNS + Let's Encrypt for Node.js - ACME dns-01 challenges w/ ACME.js and Greenlock.js \ No newline at end of file +{{ Service Title }} DNS + Let's Encrypt for Node.js - ACME dns-01 challenges w/ ACME.js and Greenlock.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/index.js b/index.js new file mode 100644 index 0000000..647221a --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('./lib/index.js'); diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..e25856a --- /dev/null +++ b/lib/index.js @@ -0,0 +1,29 @@ +'use strict'; + +var request; +var defaults = {}; + +module.exports.create = function(config) { + return { + init: function(opts) { + request = opts.request; + return null; + }, + zones: function(data) { + //console.info('List Zones', data); + throw Error('listing zones not implemented'); + }, + set: function(data) { + // console.info('Add TXT', data); + throw Error('setting TXT not implemented'); + }, + remove: function(data) { + // console.info('Remove TXT', data); + throw Error('removing TXT not implemented'); + }, + get: function(data) { + // console.info('List TXT', data); + throw Error('listing TXTs not implemented'); + } + }; +}; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..63db48c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,36 @@ +{ + "name": "acme-dns-01-{{servicename}}", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@root/request": { + "version": "1.3.11", + "resolved": "https://registry.npmjs.org/@root/request/-/request-1.3.11.tgz", + "integrity": "sha512-3a4Eeghcjsfe6zh7EJ+ni1l8OK9Fz2wL1OjP4UCa0YdvtH39kdXB9RGWuzyNv7dZi0+Ffkc83KfH0WbPMiuJFw==" + }, + "acme-challenge-test": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/acme-challenge-test/-/acme-challenge-test-3.3.2.tgz", + "integrity": "sha512-0AbMcaON20wpI5vzFDAqwcv2VerY4xIlNCqX0w1xEJUIu/EQtQNmkje+rKNuy2TUl2KBMdIaR6YBbJUdaEiC4w==", + "requires": { + "@root/request": "^1.3.11" + } + }, + "acme-dns-01-test": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/acme-dns-01-test/-/acme-dns-01-test-3.3.1.tgz", + "integrity": "sha512-di2/n19FDLc/pe4CDxd/FpxuuCZG7CHEQVjWr96vvtxe5XNNgdHi2eJqVP0z9WBf9s61zxslyRPrAWzTN8ZVWw==", + "dev": true, + "requires": { + "acme-challenge-test": "^3.3.1" + } + }, + "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 new file mode 100644 index 0000000..4448be2 --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "acme-dns-01-{{servicename}}", + "version": "0.0.1", + "description": "{{ Service Title }} + Let's Encrypt for Node.js - ACME dns-01 challenges w/ ACME.js and Greenlock.js", + "main": "index.js", + "files": [ + "lib", + "test.js" + ], + "scripts": { + "test": "node test.js" + }, + "repository": { + "type": "git", + "url": "https://git.coolaj86.com/coolaj86/acme-dns-01-{{servicename}}.js.git" + }, + "keywords": [ + "{{servicename}}", + "dns", + "dns-01", + "letsencrypt", + "acme", + "greenlock" + ], + "author": "AJ ONeal (https://coolaj86.com/)", + "license": "MPL-2.0", + "devDependencies": { + "acme-dns-01-test": "^3.3.1", + "dotenv": "^8.0.0" + } +} diff --git a/test.js b/test.js new file mode 100755 index 0000000..d8b9412 --- /dev/null +++ b/test.js @@ -0,0 +1,24 @@ +#!/usr/bin/env node +'use strict'; + +// 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] || process.env.ZONE; +var challenger = require('./index.js').create({ + token: process.argv[3] || process.env.TOKEN +}); + +// The dry-run tests can pass on, literally, 'example.com' +// but the integration tests require that you have control over the domain +tester + .testZone('dns-01', zone, challenger) + .then(function() { + console.info('PASS', zone); + }) + .catch(function(e) { + console.error(e.message); + console.error(e.stack); + });