@cleandns/whois-rdap 1.0.48 → 1.0.49
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 +15 -3
- package/dist/port43.js +11 -2
- package/package.json +1 -1
- package/src/index.ts +16 -4
- package/src/port43.ts +13 -4
- package/whois.d.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -20,6 +20,8 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
|
|
|
20
20
|
[domain, url] = await tldToRdap(origDomain);
|
|
21
21
|
const response = {
|
|
22
22
|
found: false,
|
|
23
|
+
statusCode: 0,
|
|
24
|
+
error: '',
|
|
23
25
|
registrar: { id: 0, name: null },
|
|
24
26
|
reseller: null,
|
|
25
27
|
status: [],
|
|
@@ -43,10 +45,20 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
|
|
|
43
45
|
const type = domain.match(/[^\d.]/) ? "domain" : "ip";
|
|
44
46
|
let thinResponse = null;
|
|
45
47
|
const thinRdap = `${url}/${type}/${domain}`;
|
|
46
|
-
// console.log(`fetching thin RDAP: ${thinRdap}`);
|
|
47
48
|
thinResponse = await _fetch(thinRdap)
|
|
48
|
-
.then((r) =>
|
|
49
|
-
.
|
|
49
|
+
.then((r) => {
|
|
50
|
+
response.statusCode = r.status;
|
|
51
|
+
// console.log({ ok: r.ok, status: r.status, statusText: r.statusText });
|
|
52
|
+
if (r.status >= 200 && r.status < 400) {
|
|
53
|
+
return r.json();
|
|
54
|
+
}
|
|
55
|
+
response.error = r.statusText;
|
|
56
|
+
return null;
|
|
57
|
+
})
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
console.warn(`thin RDAP lookup failure: ${error.message}`);
|
|
60
|
+
return null;
|
|
61
|
+
});
|
|
50
62
|
if (thinResponse && !thinResponse.errorCode) {
|
|
51
63
|
}
|
|
52
64
|
else if (!options.server) {
|
package/dist/port43.js
CHANGED
|
@@ -33,6 +33,8 @@ export async function port43(actor, _fetch) {
|
|
|
33
33
|
// console.log(`looking up ${domain} on ${server}`);
|
|
34
34
|
const response = {
|
|
35
35
|
found: true,
|
|
36
|
+
statusCode: 200,
|
|
37
|
+
error: '',
|
|
36
38
|
registrar: { id: 0, name: null },
|
|
37
39
|
reseller: null,
|
|
38
40
|
status: [],
|
|
@@ -40,6 +42,9 @@ export async function port43(actor, _fetch) {
|
|
|
40
42
|
ts: { created: null, updated: null, expires: null },
|
|
41
43
|
};
|
|
42
44
|
if (!server) {
|
|
45
|
+
response.found = false;
|
|
46
|
+
response.statusCode = 405;
|
|
47
|
+
response.error = "No server specified for port 43 lookup";
|
|
43
48
|
return response;
|
|
44
49
|
}
|
|
45
50
|
let port43response = "";
|
|
@@ -70,17 +75,21 @@ export async function port43(actor, _fetch) {
|
|
|
70
75
|
catch (error) {
|
|
71
76
|
console.warn({ port, server, query, error: error.message });
|
|
72
77
|
response.found = false;
|
|
78
|
+
response.statusCode = 500;
|
|
79
|
+
response.error = error.message || "Unknown error during port 43 lookup";
|
|
73
80
|
}
|
|
74
81
|
if (!response.found) {
|
|
75
82
|
return response;
|
|
76
83
|
}
|
|
77
84
|
port43response = port43response.replace(/^[ \t]+/gm, "");
|
|
78
85
|
// console.log(port43response);
|
|
79
|
-
|
|
86
|
+
let m;
|
|
87
|
+
if (m = port43response.match(/^%*\s*(NOT FOUND|No match|NO OBJECT FOUND|No entries found|No Data Found|Domain is available for registration|No information available|Status: free)\b/im)) {
|
|
80
88
|
response.found = false;
|
|
89
|
+
response.statusCode = 404;
|
|
90
|
+
response.error = m[1].trim();
|
|
81
91
|
return response;
|
|
82
92
|
}
|
|
83
|
-
let m;
|
|
84
93
|
const parser = port43parsers[tld] || ((_b = Object.entries(port43parsers).find(([t]) => tld.endsWith('.' + t))) === null || _b === void 0 ? void 0 : _b[1]);
|
|
85
94
|
if (parser) {
|
|
86
95
|
await parser(port43response, response);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -28,6 +28,8 @@ export async function whois(
|
|
|
28
28
|
|
|
29
29
|
const response: WhoisResponse = {
|
|
30
30
|
found: false,
|
|
31
|
+
statusCode: 0,
|
|
32
|
+
error: '',
|
|
31
33
|
registrar: { id: 0, name: null },
|
|
32
34
|
reseller: null,
|
|
33
35
|
status: [],
|
|
@@ -54,11 +56,21 @@ export async function whois(
|
|
|
54
56
|
let thinResponse: any = null;
|
|
55
57
|
const thinRdap = `${url}/${type}/${domain}`;
|
|
56
58
|
|
|
57
|
-
// console.log(`fetching thin RDAP: ${thinRdap}`);
|
|
58
|
-
|
|
59
59
|
thinResponse = await _fetch(thinRdap)
|
|
60
|
-
.then((r) =>
|
|
61
|
-
|
|
60
|
+
.then((r) => {
|
|
61
|
+
response.statusCode = r.status;
|
|
62
|
+
// console.log({ ok: r.ok, status: r.status, statusText: r.statusText });
|
|
63
|
+
if (r.status >= 200 && r.status < 400) {
|
|
64
|
+
return r.json() as any;
|
|
65
|
+
}
|
|
66
|
+
response.error = r.statusText;
|
|
67
|
+
return null;
|
|
68
|
+
})
|
|
69
|
+
.catch((error: Error) => {
|
|
70
|
+
console.warn(`thin RDAP lookup failure: ${error.message}`);
|
|
71
|
+
return null;
|
|
72
|
+
});
|
|
73
|
+
|
|
62
74
|
if (thinResponse && !thinResponse.errorCode) {
|
|
63
75
|
} else if (!options.server) {
|
|
64
76
|
return response;
|
package/src/port43.ts
CHANGED
|
@@ -40,6 +40,8 @@ export async function port43(actor: string, _fetch: typeof fetch): Promise<Whois
|
|
|
40
40
|
|
|
41
41
|
const response: WhoisResponse = {
|
|
42
42
|
found: true,
|
|
43
|
+
statusCode: 200,
|
|
44
|
+
error: '',
|
|
43
45
|
registrar: { id: 0, name: null },
|
|
44
46
|
reseller: null,
|
|
45
47
|
status: [],
|
|
@@ -48,6 +50,9 @@ export async function port43(actor: string, _fetch: typeof fetch): Promise<Whois
|
|
|
48
50
|
};
|
|
49
51
|
|
|
50
52
|
if (!server) {
|
|
53
|
+
response.found = false;
|
|
54
|
+
response.statusCode = 405;
|
|
55
|
+
response.error = "No server specified for port 43 lookup";
|
|
51
56
|
return response;
|
|
52
57
|
}
|
|
53
58
|
|
|
@@ -79,6 +84,8 @@ export async function port43(actor: string, _fetch: typeof fetch): Promise<Whois
|
|
|
79
84
|
} catch (error: any) {
|
|
80
85
|
console.warn({ port, server, query, error: error.message });
|
|
81
86
|
response.found = false;
|
|
87
|
+
response.statusCode = 500;
|
|
88
|
+
response.error = error.message || "Unknown error during port 43 lookup";
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
if (!response.found) {
|
|
@@ -88,17 +95,19 @@ export async function port43(actor: string, _fetch: typeof fetch): Promise<Whois
|
|
|
88
95
|
port43response = port43response.replace(/^[ \t]+/gm, "");
|
|
89
96
|
// console.log(port43response);
|
|
90
97
|
|
|
98
|
+
let m;
|
|
99
|
+
|
|
91
100
|
if (
|
|
92
|
-
port43response.match(
|
|
93
|
-
/^%*\s
|
|
101
|
+
m = port43response.match(
|
|
102
|
+
/^%*\s*(NOT FOUND|No match|NO OBJECT FOUND|No entries found|No Data Found|Domain is available for registration|No information available|Status: free)\b/im
|
|
94
103
|
)
|
|
95
104
|
) {
|
|
96
105
|
response.found = false;
|
|
106
|
+
response.statusCode = 404;
|
|
107
|
+
response.error = m[1].trim();
|
|
97
108
|
return response;
|
|
98
109
|
}
|
|
99
110
|
|
|
100
|
-
let m;
|
|
101
|
-
|
|
102
111
|
const parser = port43parsers[tld] || Object.entries(port43parsers).find(([t]) => tld.endsWith('.' + t))?.[1];
|
|
103
112
|
|
|
104
113
|
if (parser) {
|