Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "cf-doh", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Typed Cloudflare DNS Over HTTP Resolver", | ||
@@ -5,0 +5,0 @@ "main": "pkg/index.js", |
@@ -129,3 +129,3 @@ export declare enum DOHStatus { | ||
MAILA = 254,// mail agent RRs (OBSOLETE - see MX) [RFC1035] | ||
"*" = 255,// A request for some or all records the server has available [RFC1035][RFC6895][RFC8482] | ||
ANY = 255,// A request for some or all records the server has available [RFC1035][RFC6895][RFC8482] | ||
URI = 256,// URI [RFC7553] URI/uri-completed-template 2011-02-22 | ||
@@ -151,3 +151,3 @@ CAA = 257,// Certification Authority Restriction [RFC8659] CAA/caa-completed-template 2011-04-07 | ||
}[]; | ||
Answer: { | ||
Answer?: { | ||
name: string; | ||
@@ -154,0 +154,0 @@ type: DNSRecordType; |
@@ -182,3 +182,3 @@ "use strict"; | ||
DNSRecordType[DNSRecordType["MAILA"] = 254] = "MAILA"; | ||
DNSRecordType[DNSRecordType["*"] = 255] = "*"; | ||
DNSRecordType[DNSRecordType["ANY"] = 255] = "ANY"; | ||
DNSRecordType[DNSRecordType["URI"] = 256] = "URI"; | ||
@@ -198,5 +198,5 @@ DNSRecordType[DNSRecordType["CAA"] = 257] = "CAA"; | ||
var queryDNSRecords = function (hostname, recordType) { return __awaiter(void 0, void 0, void 0, function () { | ||
var r, _a, _b, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
var r, b, e_1, response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
@@ -210,10 +210,24 @@ if (!_fetchImpl) { | ||
case 1: | ||
r = _d.sent(); | ||
if (!!r.ok) return [3 /*break*/, 3]; | ||
_a = Error.bind; | ||
_c = (_b = "HoF request failed: [".concat(r.status, "] (")).concat; | ||
r = _a.sent(); | ||
if (!!r.ok) return [3 /*break*/, 6]; | ||
b = "[binary data]"; | ||
_a.label = 2; | ||
case 2: | ||
_a.trys.push([2, 4, , 5]); | ||
return [4 /*yield*/, r.text()]; | ||
case 2: throw new (_a.apply(Error, [void 0, _c.apply(_b, [_d.sent(), ")"])]))(); | ||
case 3: return [4 /*yield*/, r.json()]; | ||
case 4: return [2 /*return*/, (_d.sent())]; | ||
case 3: | ||
b = _a.sent(); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
b = "Failed parsing, ".concat(e_1); | ||
return [3 /*break*/, 5]; | ||
case 5: throw new Error("DoH request failed: [".concat(r.status, "] (").concat(b, ")")); | ||
case 6: return [4 /*yield*/, r.json()]; | ||
case 7: | ||
response = _a.sent(); | ||
if (typeof response.Status !== "number") { | ||
throw new Error("Cloudflare returned and unexpected DoH response: ".concat(JSON.stringify(response))); | ||
} | ||
return [2 /*return*/, response]; | ||
} | ||
@@ -233,11 +247,13 @@ }); | ||
} | ||
return [2 /*return*/, r.Answer.map(function (r) { | ||
try { | ||
// Text records are returned wrapped in quotes, parse them to strip the quotes | ||
return JSON.parse(r.data); | ||
} | ||
catch (e) { | ||
return r.data; | ||
} | ||
})]; | ||
return [2 /*return*/, r.Answer | ||
? r.Answer.map(function (r) { | ||
try { | ||
// Text records are returned wrapped in quotes, parse them to strip the quotes | ||
return JSON.parse(r.data); | ||
} | ||
catch (e) { | ||
return r.data; | ||
} | ||
}) | ||
: []]; | ||
} | ||
@@ -252,4 +268,7 @@ }); | ||
exports.setFetch = setFetch; | ||
if (self && self.fetch) { | ||
if (typeof fetch !== "undefined") { | ||
(0, exports.setFetch)(fetch); | ||
} | ||
else if (typeof self !== "undefined" && self.fetch) { | ||
(0, exports.setFetch)(fetch); | ||
} |
Sorry, the diff of this file is not supported yet
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
30039
441
3