diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..1ceb529 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,17 @@ +{ "node": true +, "browser": true +, "jquery": true +, "globals": { "Promise": true } + +, "indent": 2 +, "onevar": true +, "laxcomma": true +, "laxbreak": true +, "curly": true +, "nonbsp": true + +, "eqeqeq": true +, "immed": true +, "undef": true +, "latedef": "nofunc" +} diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..7e5d770 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "bracketSpacing": true, + "printWidth": 80, + "singleQuote": true, + "tabWidth": 4, + "trailingComma": "none", + "useTabs": true +} 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 4070055..4dbd414 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,111 @@ -# acme-dns-01-dnsimple.js +# [acme-dns-01-dnsimple.js](https://git.rootprojects.org/root/acme-dns-01-dnsimple.js) | a [Root](https://rootprojects.org/) project -DNSimple + Let's Encrypt for Node.js - ACME dns-01 challenges w/ ACME.js and Greenlock.js \ No newline at end of file +DNSimple DNS + Let's Encrypt for Node.js - ACME dns-01 challenges w/ ACME.js and Greenlock.js + +Handles ACME dns-01 challenges. Compatible with ACME.js and Greenlock.js. Passes acme-dns-01-test. + +# Features + +- Compatible + - Let’s Encrypt v2.1 / ACME draft 18 (2019) + - DNSimple API + - ACME.js, Greenlock.js, and others +- Quality + - node v6 compatible VanillaJS + - < 150 lines of code + - Zero Dependencies + +# Install + +```js +npm install --save acme-dns-01-dnsimple +``` + +DNSimple Token: + +- Login to your account at: {{ Service URL }} +- {{ Instructions to generate token }} + +# Usage + +First you create an instance with your credentials: + +```js +var dns01 = require('acme-dns-01-dnsimple').create({ + baseUrl: '{{ api url }}', // default + token: 'xxxx' +}); +``` + +Then you can use it with any compatible ACME library, such as Greenlock.js or ACME.js. + +## Greenlock.js + +```js +var Greenlock = require('greenlock-express'); +var greenlock = Greenlock.create({ + challenges: { + 'dns-01': dns01 + // ... + } +}); +``` + +See [Greenlock Express](https://git.rootprojects.org/root/greenlock-express.js) and/or [Greenlock.js](https://git.rootprojects.org/root/greenlock.js) documentation for more details. + +## ACME.js + +```js +// TODO +``` + +See the [ACME.js](https://git.rootprojects.org/root/acme-v2.js) for more details. + +## Build your own + +There are only 5 methods: + +- `init(config)` +- `zones(opts)` +- `set(opts)` +- `get(opts)` +- `remove(opts)` + +```js +dns01 + .set({ + identifier: { value: 'foo.example.co.uk' }, + wildcard: false, + dnsZone: 'example.co.uk', + dnsPrefix: '_acme-challenge.foo', + 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 for more implementation details. + +# Tests + +```bash +# node ./test.js domain-zone username password +node ./test.js example.com johndoe xxxxxx +``` + +# Authors + +- AJ ONeal + +See AUTHORS for contact info. + +# Legal + +[acme-dns-01-dnsimple.js](https://git.coolaj86.com/coolaj86/acme-dns-01-dnsimple.js) | MPL-2.0 | [Terms of Use](https://therootcompany.com/legal/#terms) | [Privacy Policy](https://therootcompany.com/legal/#privacy) + +Copyright 2019 AJ ONeal +Copyright 2019 The Root Group LLC diff --git a/example.env b/example.env new file mode 100644 index 0000000..e053b84 --- /dev/null +++ b/example.env @@ -0,0 +1,3 @@ +ZONE=example.co.uk +USERNAME=johndoe +PASSWORD=xxxxxxxx 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.json b/package.json new file mode 100644 index 0000000..4b3e067 --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "acme-dns-01-dnsimple", + "version": "0.0.1", + "description": "DNSimple + 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-dnsimple.js.git" + }, + "keywords": [ + "dnsimple", + "dns", + "dns-01", + "letsencrypt", + "acme", + "greenlock" + ], + "author": "AJ ONeal (https://coolaj86.com/)", + "license": "MPL-2.0", + "devDependencies": { + "acme-challenge-test": "^3.3.2", + "dotenv": "^8.0.0" + }, + "dependencies": {} +} diff --git a/test.js b/test.js new file mode 100755 index 0000000..a459da9 --- /dev/null +++ b/test.js @@ -0,0 +1,25 @@ +#!/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 username xxxxxxxxx +var zone = process.argv[2] || process.env.ZONE; +var challenger = require('./index.js').create({ + username: process.argv[3] || process.env.USERNAME, + password: process.argv[4] || process.env.PASSWORD +}); + +// 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); + });