@cleandns/whois-rdap 1.0.40 → 1.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -6
- package/dist/test.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +11 -7
- package/src/test.ts +1 -1
- package/whois.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -41,23 +41,24 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
|
|
|
41
41
|
url = "https://rdap.org";
|
|
42
42
|
}
|
|
43
43
|
const type = domain.match(/[^\d.]/) ? "domain" : "ip";
|
|
44
|
+
let thinResponse = null;
|
|
44
45
|
const thinRdap = `${url}/${type}/${domain}`;
|
|
45
46
|
// console.log(`fetching thin RDAP: ${thinRdap}`);
|
|
46
|
-
|
|
47
|
+
thinResponse = await _fetch(thinRdap)
|
|
47
48
|
.then((r) => r.json())
|
|
48
49
|
.catch(() => null);
|
|
49
50
|
if (thinResponse && !thinResponse.errorCode) {
|
|
50
51
|
}
|
|
51
|
-
else {
|
|
52
|
+
else if (!options.server) {
|
|
52
53
|
return response;
|
|
53
54
|
}
|
|
54
55
|
if ((_a = thinResponse === null || thinResponse === void 0 ? void 0 : thinResponse.rdapConformance) === null || _a === void 0 ? void 0 : _a["0"]) {
|
|
55
56
|
thinResponse = fixArrays(thinResponse);
|
|
56
57
|
}
|
|
57
|
-
const selfRdap = (_b = thinResponse.links) === null || _b === void 0 ? void 0 : _b.find((link) => link.rel === "self");
|
|
58
|
-
const thickRdap = (_d = (_c = thinResponse.links) === null || _c === void 0 ? void 0 : _c.find((link) => link.href !== (selfRdap === null || selfRdap === void 0 ? void 0 : selfRdap.href) &&
|
|
58
|
+
const selfRdap = (_b = thinResponse === null || thinResponse === void 0 ? void 0 : thinResponse.links) === null || _b === void 0 ? void 0 : _b.find((link) => link.rel === "self");
|
|
59
|
+
const thickRdap = ((_d = (_c = thinResponse.links) === null || _c === void 0 ? void 0 : _c.find((link) => link.href !== (selfRdap === null || selfRdap === void 0 ? void 0 : selfRdap.href) &&
|
|
59
60
|
link.rel === "related" &&
|
|
60
|
-
link.type === "application/rdap+json")) === null || _d === void 0 ? void 0 : _d.href.replace("/domain/domain/", "/domain/")
|
|
61
|
+
link.type === "application/rdap+json")) === null || _d === void 0 ? void 0 : _d.href.replace("/domain/domain/", "/domain/")) || `${options.server}/domain/${domain}`;
|
|
61
62
|
let thickResponse = null;
|
|
62
63
|
if (!options.thinOnly && thickRdap) {
|
|
63
64
|
// console.log(`fetching thick RDAP: ${thickRdap}`);
|
|
@@ -216,7 +217,9 @@ function findStatus(statuses, domain) {
|
|
|
216
217
|
? statuses
|
|
217
218
|
: statuses && typeof statuses === "object"
|
|
218
219
|
? Object.keys(statuses)
|
|
219
|
-
:
|
|
220
|
+
: typeof statuses === "string"
|
|
221
|
+
? statuses.trim().split(/\s*,\s*/)
|
|
222
|
+
: []).map((status) => normalizeWhoisStatus(status));
|
|
220
223
|
}
|
|
221
224
|
function findNameservers(values) {
|
|
222
225
|
let nameservers = [];
|
package/dist/test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { whois } from "./index.js";
|
|
2
|
-
whois(process.argv[2], { thinOnly: Boolean(process.argv[3]) }).then((r) => console.log(JSON.stringify(r, undefined, 2)));
|
|
2
|
+
whois(process.argv[2], { thinOnly: Boolean(process.argv[3]), server: process.argv[4] }).then((r) => console.log(JSON.stringify(r, undefined, 2)));
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -40,7 +40,7 @@ export async function whois(
|
|
|
40
40
|
const host = new URL(url).host;
|
|
41
41
|
/* check for A record via DNS lookup */
|
|
42
42
|
const isLive = await resolve4(host).then((r) => Boolean(r?.length)).catch(() => false);
|
|
43
|
-
if (!
|
|
43
|
+
if (!isLive) url = null;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
if (url === null) {
|
|
@@ -51,15 +51,16 @@ export async function whois(
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const type = domain.match(/[^\d.]/) ? "domain" : "ip";
|
|
54
|
-
|
|
54
|
+
let thinResponse: any = null;
|
|
55
55
|
const thinRdap = `${url}/${type}/${domain}`;
|
|
56
|
+
|
|
56
57
|
// console.log(`fetching thin RDAP: ${thinRdap}`);
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
thinResponse = await _fetch(thinRdap)
|
|
59
60
|
.then((r) => r.json() as any)
|
|
60
61
|
.catch(() => null);
|
|
61
62
|
if (thinResponse && !thinResponse.errorCode) {
|
|
62
|
-
} else {
|
|
63
|
+
} else if (!options.server) {
|
|
63
64
|
return response;
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -67,7 +68,8 @@ export async function whois(
|
|
|
67
68
|
thinResponse = fixArrays(thinResponse);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
const selfRdap = thinResponse
|
|
71
|
+
const selfRdap = thinResponse?.links?.find((link: any) => link.rel === "self");
|
|
72
|
+
|
|
71
73
|
const thickRdap = thinResponse.links
|
|
72
74
|
?.find(
|
|
73
75
|
(link: any) =>
|
|
@@ -75,7 +77,7 @@ export async function whois(
|
|
|
75
77
|
link.rel === "related" &&
|
|
76
78
|
link.type === "application/rdap+json"
|
|
77
79
|
)
|
|
78
|
-
?.href.replace("/domain/domain/", "/domain/")
|
|
80
|
+
?.href.replace("/domain/domain/", "/domain/") || `${options.server}/domain/${domain}`;
|
|
79
81
|
|
|
80
82
|
let thickResponse: any = null;
|
|
81
83
|
|
|
@@ -333,7 +335,9 @@ function findStatus(statuses: string | string[], domain: string): string[] {
|
|
|
333
335
|
? statuses
|
|
334
336
|
: statuses && typeof statuses === "object"
|
|
335
337
|
? Object.keys(statuses)
|
|
336
|
-
:
|
|
338
|
+
: typeof statuses === "string"
|
|
339
|
+
? statuses.trim().split(/\s*,\s*/)
|
|
340
|
+
: []
|
|
337
341
|
).map((status) => normalizeWhoisStatus(status));
|
|
338
342
|
}
|
|
339
343
|
|
package/src/test.ts
CHANGED