Compare commits

..

No commits in common. "master" and "v3.0.0" have entirely different histories.

4 changed files with 123 additions and 162 deletions

View File

@ -1,17 +0,0 @@
{ "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"
}

View File

@ -1,17 +0,0 @@
{ "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"
}

View File

@ -1,16 +1,14 @@
"use strict";
'use strict';
var request;
var defaults = {
baseUrl: "https://api.name.com/v4/",
wait: 15 * 1000
baseUrl: 'https://api.name.com/v4/'
};
module.exports.create = function(config) {
var baseUrl = (config.baseUrl || defaults.baseUrl).replace(/\/$/, "");
var baseUrl = (config.baseUrl || defaults.baseUrl).replace(/\/$/, '');
var token = config.token;
var username = config.username;
var wait = config.wait || defaults.wait;
var plugin = {
init: function(opts) {
@ -21,7 +19,7 @@ module.exports.create = function(config) {
// We must list all zones (domains) in the account
zones: function(data) {
return api({
url: baseUrl + "/domains"
url: baseUrl + '/domains'
}).then(function(resp) {
return resp.body.domains.map(function(d) {
//#console.log("Domain Name:", d.domainName);
@ -36,28 +34,24 @@ module.exports.create = function(config) {
var ch = data.challenge;
if (!ch.dnsZone) {
throw new Error(
"[Name.com Plugin] Unknown domain: ",
'[Name.com Plugin] Unknown domain: ',
data.domain || data.dnsHost
);
}
return api({
method: "POST",
url: baseUrl + "/domains/" + ch.dnsZone + "/records",
method: 'POST',
url: baseUrl + '/domains/' + ch.dnsZone + '/records',
json: {
host: ch.dnsPrefix,
type: "TXT",
type: 'TXT',
answer: ch.dnsAuthorization,
ttl: 300 // minimum allowed value
}
}).then(function(resp) {
if (!resp.body.id) {
throw Error("[Name.com API] [set] " + resp.body);
throw Error('[Name.com API] [set] ' + resp.body);
}
// The api returns success long before the record is actually set.
// Therefore we wait a bit to make sure the server propagate the response.
return new Promise(function(resolve) {
setTimeout(resolve, wait, null);
});
return null;
});
},
@ -67,17 +61,17 @@ module.exports.create = function(config) {
var ch = data.challenge;
if (!ch.dnsZone) {
throw new Error(
"[Name.com Plugin] Unknown domain: ",
'[Name.com Plugin] Unknown domain: ',
data.domain || data.dnsHost
);
}
return api({
url: baseUrl + "/domains/" + ch.dnsZone + "/records"
url: baseUrl + '/domains/' + ch.dnsZone + '/records'
}).then(function(resp) {
var value = resp.body.records.filter(function(r) {
return (
r.host === ch.dnsPrefix &&
"TXT" === r.type &&
'TXT' === r.type &&
ch.dnsAuthorization === r.answer
);
})[0];
@ -96,12 +90,13 @@ module.exports.create = function(config) {
return plugin.get(data).then(function(r) {
if (!r.id) {
throw new Error(
"[Name.com Plugin] [del] Did not find TXT record for " + ch.dnsHost
'[Name.com Plugin] [del] Did not find TXT record for ' +
ch.dnsHost
);
}
return api({
method: "DELETE",
url: baseUrl + "/domains/" + ch.dnsZone + "/records/" + r.id
method: 'DELETE',
url: baseUrl + '/domains/' + ch.dnsZone + '/records/' + r.id
}).then(function(resp) {
return null;
});
@ -124,15 +119,15 @@ module.exports.create = function(config) {
return resp;
}
console.error(opts.method + " " + opts.url);
console.error(opts.method + ' ' + opts.url);
console.error(resp.headers);
console.error(resp.body);
throw new Error(
"[Name.com API] " +
(opts.method || "GET") +
" " +
'[Name.com API] ' +
(opts.method || 'GET') +
' ' +
opts.url +
" : " +
' : ' +
resp.body.message
);
});

View File

@ -1,6 +1,6 @@
{
"name": "acme-dns-01-namedotcom",
"version": "3.0.1",
"version": "3.0.0",
"description": "Name.com + Let's Encrypt for Node.js - ACME dns-01 challenges w/ ACME.js and Greenlock.js",
"main": "index.js",
"files": [