bugfixes and metadata updates
This commit is contained in:
parent
e0548806cf
commit
138e2ecfae
|
@ -100,7 +100,7 @@ node ./test.js example.com johndoe xxxxxx
|
||||||
# Authors
|
# Authors
|
||||||
|
|
||||||
- AJ ONeal
|
- AJ ONeal
|
||||||
- Hitesh Walia
|
- Hitesh Walia
|
||||||
|
|
||||||
See AUTHORS for contact info.
|
See AUTHORS for contact info.
|
||||||
|
|
||||||
|
@ -108,5 +108,6 @@ See AUTHORS for contact info.
|
||||||
|
|
||||||
[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)
|
[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 Hitesh Walia
|
||||||
Copyright 2019 AJ ONeal
|
Copyright 2019 AJ ONeal
|
||||||
Copyright 2019 The Root Group LLC
|
Copyright 2019 The Root Group LLC
|
||||||
|
|
75
lib/index.js
75
lib/index.js
|
@ -46,6 +46,7 @@ module.exports.create = function(config) {
|
||||||
},
|
},
|
||||||
zones: function(data) {
|
zones: function(data) {
|
||||||
// console.info('List Zones', data);
|
// console.info('List Zones', data);
|
||||||
|
|
||||||
return api('GET', '/' + account + '/zones').then(function(resp) {
|
return api('GET', '/' + account + '/zones').then(function(resp) {
|
||||||
return resp['body']['data'].map(function(elem) {
|
return resp['body']['data'].map(function(elem) {
|
||||||
//console.log('DEBUG >>> elem.name: ' + elem.name);
|
//console.log('DEBUG >>> elem.name: ' + elem.name);
|
||||||
|
@ -54,19 +55,19 @@ module.exports.create = function(config) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
set: function(data) {
|
set: function(data) {
|
||||||
|
// console.info('Add TXT', data);
|
||||||
var ch = data.challenge;
|
var ch = data.challenge;
|
||||||
|
|
||||||
if (!ch.dnsZone) {
|
if (!ch.dnsZone) {
|
||||||
throw new Error('No matching zone for ' + ch.dnsHost);
|
throw new Error('No matching zone for ' + ch.dnsHost);
|
||||||
}
|
}
|
||||||
// console.info('Add TXT', data);
|
|
||||||
var ch = data.challenge;
|
|
||||||
var txt = ch.dnsAuthorization;
|
var txt = ch.dnsAuthorization;
|
||||||
|
|
||||||
return api(
|
return api(
|
||||||
'POST',
|
'POST',
|
||||||
'/' + account + '/zones/' + ch.dnsZone + '/records',
|
'/' + account + '/zones/' + ch.dnsZone + '/records',
|
||||||
{
|
{
|
||||||
name: '',
|
name: ch.dnsPrefix,
|
||||||
type: 'TXT',
|
type: 'TXT',
|
||||||
content: txt
|
content: txt
|
||||||
}
|
}
|
||||||
|
@ -81,44 +82,58 @@ module.exports.create = function(config) {
|
||||||
},
|
},
|
||||||
get: function(data) {
|
get: function(data) {
|
||||||
// console.info('List TXT', data);
|
// console.info('List TXT', data);
|
||||||
|
var ch = data.challenge;
|
||||||
|
|
||||||
|
// TODO use :name_like
|
||||||
|
// https://developer.dnsimple.com/v2/zones/records/
|
||||||
return api(
|
return api(
|
||||||
'GET',
|
'GET',
|
||||||
'/' + account + '/zones/' + data.challenge.dnsZone + '/records'
|
'/' + account + '/zones/' + data.challenge.dnsZone + '/records'
|
||||||
).then(function(resp) {
|
).then(function(resp) {
|
||||||
var record = resp.body.data.filter(function(record) {
|
var record = resp.body.data.filter(function(record) {
|
||||||
return data.challenge.dnsAuthorization === record.content;
|
return (
|
||||||
})[0];
|
ch.dnsPrefix === record.name &&
|
||||||
|
ch.dnsAuthorization === record.content
|
||||||
if (record) return { dnsAuthorization: record.content };
|
);
|
||||||
else return null;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
remove: function(data) {
|
|
||||||
return api(
|
|
||||||
'GET',
|
|
||||||
'/' + account + '/zones/' + data.challenge.dnsZone + '/records'
|
|
||||||
).then(function(resp) {
|
|
||||||
var record = resp.body.data.filter(function(record) {
|
|
||||||
return data.challenge.dnsAuthorization === record.content;
|
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
if (record) {
|
if (record) {
|
||||||
return api(
|
return { dnsAuthorization: record.content };
|
||||||
'DELETE',
|
}
|
||||||
'/' +
|
|
||||||
account +
|
return null;
|
||||||
'/zones/' +
|
});
|
||||||
data.challenge.dnsZone +
|
},
|
||||||
'/records/' +
|
remove: function(data) {
|
||||||
record.id
|
// console.info('Remove TXT', data);
|
||||||
).then(function(resp) {
|
var ch = data.challenge;
|
||||||
// console.info('DEBUG >>> resp: ', JSON.stringify(resp, null, 2));
|
|
||||||
return true;
|
return api(
|
||||||
});
|
'GET',
|
||||||
} else {
|
'/' + account + '/zones/' + data.challenge.dnsZone + '/records'
|
||||||
|
).then(function(resp) {
|
||||||
|
var record = resp.body.data.filter(function(record) {
|
||||||
|
return (
|
||||||
|
ch.dnsPrefix === record.name &&
|
||||||
|
ch.dnsAuthorization === record.content
|
||||||
|
);
|
||||||
|
})[0];
|
||||||
|
|
||||||
|
if (!record) {
|
||||||
throw new Error('Txt Record not found for removal');
|
throw new Error('Txt Record not found for removal');
|
||||||
}
|
}
|
||||||
|
return api(
|
||||||
|
'DELETE',
|
||||||
|
'/' +
|
||||||
|
account +
|
||||||
|
'/zones/' +
|
||||||
|
ch.dnsZone +
|
||||||
|
'/records/' +
|
||||||
|
record.id
|
||||||
|
).then(function(resp) {
|
||||||
|
// console.info('DEBUG >>> resp: ', JSON.stringify(resp, null, 2));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "acme-dns-01-dnsimple",
|
"name": "acme-dns-01-dnsimple",
|
||||||
"version": "0.0.1",
|
"version": "3.0.0",
|
||||||
"description": "DNSimple + Let's Encrypt for Node.js - ACME dns-01 challenges w/ ACME.js and Greenlock.js",
|
"description": "DNSimple + Let's Encrypt for Node.js - ACME dns-01 challenges w/ ACME.js and Greenlock.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.coolaj86.com/coolaj86/acme-dns-01-dnsimple.js.git"
|
"url": "https://git.rootprojects.org/root/acme-dns-01-dnsimple.js.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"dnsimple",
|
"dnsimple",
|
||||||
|
@ -22,7 +22,10 @@
|
||||||
"acme",
|
"acme",
|
||||||
"greenlock"
|
"greenlock"
|
||||||
],
|
],
|
||||||
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/), Hitesh Walia <hiteshwar.walia@gmail.com",
|
"author": "Hitesh Walia <hiteshwar.walia@gmail.com",
|
||||||
|
"contributors": [
|
||||||
|
"AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)"
|
||||||
|
],
|
||||||
"license": "MPL-2.0",
|
"license": "MPL-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"acme-challenge-test": "^3.3.2",
|
"acme-challenge-test": "^3.3.2",
|
||||||
|
|
Loading…
Reference in New Issue