You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

acme-dns-01-cloudflare

Package Overview
Dependencies
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acme-dns-01-cloudflare - npm Package Compare versions

Comparing version

to
1.1.1

5

CHANGELOG.md

@@ -9,3 +9,6 @@ # Changelog

## [1.1.0] - 2020-01
## [1.1.1] - 2020-02-04
- Simplify promise handlers
## [1.1.0] - 2020-01-15
- Bump `cloudflare` to 2.7.0

@@ -12,0 +15,0 @@ - Enable using an API token for Cloudflare instead of email + API Key

168

index.js

@@ -29,56 +29,52 @@ 'use strict';

async set(args){
return new Promise(async (resolve, reject) => {
if(!args.challenge){
return reject("You must be using Greenlock v2.7+ to use acme-dns-01-cloudflare");
if(!args.challenge){
return Promise.reject("You must be using Greenlock v2.7+ to use acme-dns-01-cloudflare");
}
try{
const fullRecordName = args.challenge.dnsPrefix + '.' + args.challenge.dnsZone;
const zone = await this.getZoneForDomain(args.challenge.dnsZone);
if(!zone){
return Promise.reject(`Could not find a zone for '${fullRecordName}'.`);
}
try{
const fullRecordName = args.challenge.dnsPrefix + '.' + args.challenge.dnsZone;
const zone = await this.getZoneForDomain(args.challenge.dnsZone);
if(!zone){
return reject(`Could not find a zone for '${fullRecordName}'.`);
}
// add record
await this.client.dnsRecords.add(zone.id, {
type: 'TXT',
name: fullRecordName,
content: args.challenge.dnsAuthorization,
ttl: 120
});
if(this.options.verifyPropagation){
await Challenge.verifyPropagation(args.challenge, this.options.waitFor, this.options.retries);
}
return resolve(null);
}catch(err){
return reject(err);
// add record
await this.client.dnsRecords.add(zone.id, {
type: 'TXT',
name: fullRecordName,
content: args.challenge.dnsAuthorization,
ttl: 120
});
if(this.options.verifyPropagation){
await Challenge.verifyPropagation(args.challenge, this.options.waitFor, this.options.retries);
}
});
return null;
}catch(err){
throw new Error(err);
}
}
async remove(args){
return new Promise(async (resolve, reject) => {
if(!args.challenge){
return reject("You must be using Greenlock v2.7+ to use acme-dns-01-cloudflare");
if(!args.challenge){
return Promise.reject("You must be using Greenlock v2.7+ to use acme-dns-01-cloudflare");
}
try{
const fullRecordName = args.challenge.dnsPrefix + '.' + args.challenge.dnsZone;
const zone = await this.getZoneForDomain(args.challenge.dnsZone);
if(!zone){
return Promise.reject(`Could not find a zone for '${fullRecordName}'.`);
}
try{
const fullRecordName = args.challenge.dnsPrefix + '.' + args.challenge.dnsZone;
const zone = await this.getZoneForDomain(args.challenge.dnsZone);
if(!zone){
return reject(`Could not find a zone for '${fullRecordName}'.`);
const records = await this.getTxtRecords(zone, fullRecordName);
if(!records.length){
return Promise.reject(`No TXT records found for ${fullRecordName}`);
}
for(const record of records){
if(record.name === fullRecordName && record.content === args.challenge.dnsAuthorization){
await this.client.dnsRecords.del(zone.id, record.id);
}
const records = await this.getTxtRecords(zone, fullRecordName);
if(!records.length){
return reject(`No TXT records found for ${fullRecordName}`);
}
for(const record of records){
if(record.name === fullRecordName && record.content === args.challenge.dnsAuthorization){
await this.client.dnsRecords.del(zone.id, record.id);
}
}
// allow time for deletion to propagate
await Challenge.verifyPropagation(Object.assign({}, args.challenge, {removed: true}));
return resolve(null);
}catch(err){
return reject(err);
}
});
// allow time for deletion to propagate
await Challenge.verifyPropagation(Object.assign({}, args.challenge, {removed: true}));
return null;
}catch(err){
throw new Error(err);
}
}

@@ -88,51 +84,47 @@

async get(args){
return new Promise(async (resolve, reject) => {
if(!args.challenge){
return reject("You must be using Greenlock v2.7+ to use acme-dns-01-cloudflare");
if(!args.challenge){
return Promise.reject("You must be using Greenlock v2.7+ to use acme-dns-01-cloudflare");
}
try{
const fullRecordName = args.challenge.dnsPrefix + '.' + args.challenge.dnsZone;
const zone = await this.getZoneForDomain(fullRecordName);
if(!zone){
return Promise.reject(`Could not find a zone for '${fullRecordName}'.`);
}
try{
const fullRecordName = args.challenge.dnsPrefix + '.' + args.challenge.dnsZone;
const zone = await this.getZoneForDomain(fullRecordName);
if(!zone){
return reject(`Could not find a zone for '${fullRecordName}'.`);
const records = await this.getTxtRecords(zone, fullRecordName);
if(!records.length){
return null;
}
// find the applicable record if multiple
let foundRecord = null;
for(const record of records){
if(record.name === fullRecordName && record.content === args.challenge.dnsAuthorization){
foundRecord = record;
}
const records = await this.getTxtRecords(zone, fullRecordName);
if(!records.length){
return resolve(null);
}
// find the applicable record if multiple
let foundRecord = null;
for(const record of records){
if(record.name === fullRecordName && record.content === args.challenge.dnsAuthorization){
foundRecord = record;
}
}
if(!foundRecord){
return resolve(null);
}
return resolve({
dnsAuthorization: foundRecord.content
});
}
if(!foundRecord){
return null;
}
return {
dnsAuthorization: foundRecord.content
};
}catch(err){
// could not get record
return resolve(null);
}
});
}catch(err){
// could not get record
return null;
}
}
async zones(args){ // eslint-disable-line no-unused-vars
return new Promise(async (resolve, reject) => {
try{
const zones = [];
for await(const zone of consumePages(pagination =>
this.client.zones.browse(pagination)
)){
zones.push(zone.name);
}
return resolve(zones);
}catch(err){
return reject(err);
try{
const zones = [];
for await(const zone of consumePages(pagination =>
this.client.zones.browse(pagination)
)){
zones.push(zone.name);
}
});
return zones;
}catch(err){
throw new Error(err);
}
}

@@ -139,0 +131,0 @@

{
"name": "acme-dns-01-cloudflare",
"version": "1.1.0",
"version": "1.1.1",
"description": "Cloudflare DNS for Let's Encrypt / ACME dns-01 challenges with Greenlock.js and ACME.js",

@@ -5,0 +5,0 @@ "keywords": [

@@ -47,3 +47,3 @@ acme-dns-01-cloudflare

#### Greenlock.js v4
### Greenlock.js v4

@@ -68,7 +68,3 @@ See the [Greenlock.js documentation](https://www.npmjs.com/package/greenlock) for more information.

challenges: {
"dns-01": {
module: "acme-dns-01-cloudflare",
token: "xxxxxx",
verifyPropagation: true
}
"dns-01": cloudflareDns01
}

@@ -75,0 +71,0 @@ });