@firstdorsal/powerdns-api
Advanced tools
Comparing version 1.4.2 to 1.5.0
112
index.js
'use strict'; | ||
const f = require("node-fetch") | ||
const r = require("request-promise"); | ||
/** | ||
@@ -149,17 +146,23 @@ * @typedef Cryptokey | ||
const zoneNameSan = dname.substr(0, dname.length - 1).match(/[A-Za-z0-9]*\.[A-Za-z0-9]*$/)[0]; | ||
return r(`${this.baseurl}/zones`, { | ||
method: 'post', | ||
return f(`${this.baseurl}/zones`, { | ||
method: 'POST', | ||
headers: { | ||
'X-Api-Key': this.apikey | ||
'X-Api-Key': this.apikey, | ||
"Content-Type": "application/json" | ||
}, | ||
body: { | ||
body: JSON.stringify({ | ||
name: zoneNameSan + '.', | ||
kind | ||
}, | ||
json: true | ||
}).then((res) => { | ||
if (!res.rrsets) return false; | ||
return res.rrsets[0] | ||
}) | ||
}).then(async (res) => { | ||
let j = await res.text().catch(); | ||
try { | ||
j = JSON.parse(j); | ||
} catch (err) { | ||
throw j; | ||
} | ||
if (!j.rrsets) return false; | ||
return j.rrsets[0] | ||
}).catch((err) => { | ||
throw new Error(err.error.error); | ||
throw new Error(err); | ||
}); | ||
@@ -222,3 +225,3 @@ } | ||
const zoneNameSan = dname.substr(0, dname.length - 1).match(/[A-Za-z0-9]*\.[A-Za-z0-9]*$/)[0]; | ||
return r(this.baseurl + '/zones/' + zoneNameSan, { | ||
return f(this.baseurl + '/zones/' + zoneNameSan, { | ||
method: 'DELETE', | ||
@@ -229,6 +232,15 @@ headers: { | ||
json: true | ||
}).then((res) => { | ||
if (res === undefined) return true; | ||
}).then(async (res) => { | ||
let j = await res.text().catch(); | ||
if (j) { | ||
try { | ||
j = JSON.parse(j); | ||
} catch (err) { | ||
throw j; | ||
} | ||
} | ||
if (j === undefined || j.length === 0) return true; | ||
return false; | ||
}).catch((err) => { | ||
throw new Error(err.error.error); | ||
throw err; | ||
}) | ||
@@ -274,3 +286,3 @@ } | ||
} | ||
return r(this.baseurl + '/zones/' + zoneName, { | ||
return f(this.baseurl + '/zones/' + zoneName, { | ||
method: 'PATCH', | ||
@@ -280,13 +292,19 @@ headers: { | ||
}, | ||
body: { | ||
body: JSON.stringify({ | ||
rrsets | ||
}, | ||
json: true | ||
}).then((res) => { | ||
if (res === undefined) return true; | ||
}) | ||
}).then(async (res) => { | ||
let j = await res.text().catch(); | ||
if (j) { | ||
try { | ||
j = JSON.parse(j); | ||
} catch (err) { | ||
throw j; | ||
} | ||
} | ||
if (j === undefined || j.length === 0) return true; | ||
return false; | ||
}).catch((err) => { | ||
console.error(err); | ||
return false; | ||
throw err; | ||
}); | ||
@@ -319,3 +337,3 @@ } | ||
return r(this.baseurl + '/zones/' + zoneName, { | ||
return f(this.baseurl + '/zones/' + zoneName, { | ||
method: 'PATCH', | ||
@@ -325,12 +343,18 @@ headers: { | ||
}, | ||
body: { | ||
body: JSON.stringify({ | ||
rrsets | ||
}, | ||
json: true | ||
}).then((res) => { | ||
if (res === undefined) return true; | ||
}) | ||
}).then(async (res) => { | ||
let j = await res.text().catch(); | ||
if (j) { | ||
try { | ||
j = JSON.parse(j); | ||
} catch (err) { | ||
throw j; | ||
} | ||
} | ||
if (j === undefined || j.length === 0) return true; | ||
return false; | ||
}).catch((err) => { | ||
console.error(err); | ||
return false; | ||
throw err; | ||
}); | ||
@@ -411,6 +435,5 @@ } | ||
const body = cryptokey; | ||
const dname = this.absoluteName(zoneName); | ||
const zoneNameSan = dname.substr(0, dname.length - 1).match(/[A-Za-z0-9]*\.[A-Za-z0-9]*$/)[0]; | ||
return r(`${this.baseurl}/zones/${zoneNameSan}/cryptokeys`, { | ||
return f(`${this.baseurl}/zones/${zoneNameSan}/cryptokeys`, { | ||
method: 'POST', | ||
@@ -420,8 +443,15 @@ headers: { | ||
}, | ||
body, | ||
json: true | ||
}).then((res) => { | ||
if (returnPrivateKey) return res; | ||
delete res.privatekey; | ||
return res; | ||
body: JSON.stringify(cryptokey) | ||
}).then(async (res) => { | ||
let j = await res.text().catch(); | ||
if (j) { | ||
try { | ||
j = JSON.parse(j); | ||
} catch (err) { | ||
throw j; | ||
} | ||
} | ||
if (returnPrivateKey) return j; | ||
delete j.privatekey; | ||
return j; | ||
}) | ||
@@ -428,0 +458,0 @@ } |
{ | ||
"name": "@firstdorsal/powerdns-api", | ||
"version": "1.4.2", | ||
"version": "1.5.0", | ||
"description": "Nodejs PowerDNS API.", | ||
@@ -9,5 +9,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"node-fetch": "^2.6.0", | ||
"request": "^2.88.2", | ||
"request-promise": "^4.2.6" | ||
"node-fetch": "^2.6.0" | ||
}, | ||
@@ -14,0 +12,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41167
1
577
- Removedrequest@^2.88.2
- Removedrequest-promise@^4.2.6
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.10.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrequest-promise@4.2.6(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)