@cleandns/whois-rdap 1.0.14 → 1.0.16
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.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/port43.js +20 -12
- package/dist/port43servers.js +4 -1
- package/dist/utils/tldToRdap.js +4 -3
- package/dist/wwwservers.d.ts +1 -0
- package/dist/wwwservers.js +3 -0
- package/package.json +1 -1
- package/src/index.ts +4 -2
- package/src/port43.ts +16 -8
- package/src/port43servers.ts +6 -1
- package/src/utils/tldToRdap.ts +11 -8
- package/whois.d.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { WhoisOptions, WhoisResponse } from "../whois.js";
|
|
2
|
-
export declare function whois(
|
|
2
|
+
export declare function whois(origDomain: string, options?: WhoisOptions): Promise<WhoisResponse>;
|
package/dist/index.js
CHANGED
|
@@ -10,11 +10,12 @@ const eventMap = new Map([
|
|
|
10
10
|
["expiration", "expires"],
|
|
11
11
|
["expiration date", "expires"],
|
|
12
12
|
]);
|
|
13
|
-
export async function whois(
|
|
13
|
+
export async function whois(origDomain, options = { fetch: fetch }) {
|
|
14
14
|
var _a, _b, _c, _d, _e, _f;
|
|
15
15
|
const fetch = options.fetch;
|
|
16
|
+
let domain = origDomain;
|
|
16
17
|
let url = null;
|
|
17
|
-
[domain, url] = await tldToRdap(
|
|
18
|
+
[domain, url] = await tldToRdap(origDomain);
|
|
18
19
|
const response = {
|
|
19
20
|
found: false,
|
|
20
21
|
registrar: { id: 0, name: null },
|
package/dist/port43.js
CHANGED
|
@@ -21,9 +21,10 @@ export function determinePort43Domain(actor) {
|
|
|
21
21
|
return [actor, "", null];
|
|
22
22
|
}
|
|
23
23
|
export async function port43(actor) {
|
|
24
|
-
var _a, _b, _c;
|
|
24
|
+
var _a, _b, _c, _d;
|
|
25
25
|
const [domain, tld, whoisServer] = determinePort43Domain(actor);
|
|
26
26
|
const opts = whoisServer;
|
|
27
|
+
const isWwww = opts === null || opts === void 0 ? void 0 : opts.url;
|
|
27
28
|
const server = (opts === null || opts === void 0 ? void 0 : opts.host) || opts || null;
|
|
28
29
|
const query = (opts === null || opts === void 0 ? void 0 : opts.query)
|
|
29
30
|
? opts.query.replace("$addr", domain)
|
|
@@ -43,14 +44,21 @@ export async function port43(actor) {
|
|
|
43
44
|
}
|
|
44
45
|
let port43response = "";
|
|
45
46
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
.
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
if (isWwww) {
|
|
48
|
+
port43response = (await fetch(opts.url.replace('%%domain%%', domain)).then(r => r.text())).toString().replace(/^[ \t]+/gm, "");
|
|
49
|
+
response.server = (_a = opts.url.match('//(.*?)/')) === null || _a === void 0 ? void 0 : _a[1];
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
response.server = server;
|
|
53
|
+
const promiseSocket = new PromiseSocket(new Socket());
|
|
54
|
+
promiseSocket.setTimeout(5 * 1000);
|
|
55
|
+
await promiseSocket.connect(port, server);
|
|
56
|
+
await promiseSocket.write(query);
|
|
57
|
+
port43response = (await promiseSocket.readAll())
|
|
58
|
+
.toString()
|
|
59
|
+
.replace(/^[ \t]+/gm, "");
|
|
60
|
+
await promiseSocket.end();
|
|
61
|
+
}
|
|
54
62
|
}
|
|
55
63
|
catch (error) {
|
|
56
64
|
response.found = false;
|
|
@@ -63,7 +71,7 @@ export async function port43(actor) {
|
|
|
63
71
|
return response;
|
|
64
72
|
}
|
|
65
73
|
let m;
|
|
66
|
-
const parser = port43parsers[tld] || ((
|
|
74
|
+
const parser = port43parsers[tld] || ((_b = Object.entries(port43parsers).find(([t]) => tld.endsWith('.' + t))) === null || _b === void 0 ? void 0 : _b[1]);
|
|
67
75
|
if (parser) {
|
|
68
76
|
await parser(port43response, response);
|
|
69
77
|
}
|
|
@@ -85,12 +93,12 @@ export async function port43(actor) {
|
|
|
85
93
|
!response.ts.expires &&
|
|
86
94
|
(m = port43response.match(/^(?:(?:Registry )?Expiry Date):[ \t]*(\S.+)/m)) &&
|
|
87
95
|
(response.ts.expires = new Date(m[1]) || null);
|
|
88
|
-
!((
|
|
96
|
+
!((_c = response.status) === null || _c === void 0 ? void 0 : _c.length) && (m = port43response.match(/^(?:Status|Domain Status|status):.*/gm)) &&
|
|
89
97
|
m.forEach((s) => {
|
|
90
98
|
let m;
|
|
91
99
|
(m = s.match(/^(?:Status|Domain Status|status):[ \t]*(?:<a[^>]*>)?(\S+)/m)) && response.status.push(normalizeWhoisStatus(m[1]));
|
|
92
100
|
});
|
|
93
|
-
!((
|
|
101
|
+
!((_d = response.nameservers) === null || _d === void 0 ? void 0 : _d.length) && (m = port43response.match(/^(?:Name Server|ns_name_\d+|namserver|nserver):.*/gm)) &&
|
|
94
102
|
m.forEach((s) => {
|
|
95
103
|
let m;
|
|
96
104
|
(m = s.match(/^(?:Name Server|ns_name_\d+|namserver|nserver):[ \t]*(\S+)/m)) && response.nameservers.push(m[1].toLowerCase());
|
package/dist/port43servers.js
CHANGED
|
@@ -147,6 +147,9 @@ export const port43servers = {
|
|
|
147
147
|
"uy.com": "whois.centralnic.net",
|
|
148
148
|
"web.com": "whois.centralnic.net",
|
|
149
149
|
"za.com": "whois.centralnic.net",
|
|
150
|
+
"it.com": {
|
|
151
|
+
url: `https://engine.itcomdomains.com/api/v1/domain/%%domain%%/whois_info`,
|
|
152
|
+
},
|
|
150
153
|
com: {
|
|
151
154
|
host: "whois.verisign-grs.com",
|
|
152
155
|
query: "DOMAIN $addr\r\n",
|
|
@@ -743,7 +746,7 @@ export const port43servers = {
|
|
|
743
746
|
mv: null,
|
|
744
747
|
mw: "whois.nic.mw",
|
|
745
748
|
mx: "whois.mx",
|
|
746
|
-
my: "whois.
|
|
749
|
+
my: "whois.mynic.my",
|
|
747
750
|
mz: "whois.nic.mz",
|
|
748
751
|
na: "whois.na-nic.com.na",
|
|
749
752
|
nc: "whois.nc",
|
package/dist/utils/tldToRdap.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ParseResultType, parseDomain } from "parse-domain";
|
|
2
2
|
const tldCache = new Map([]);
|
|
3
3
|
const tldCachePresets = [
|
|
4
|
+
["it.com", null],
|
|
4
5
|
["br.com", "https://rdap.centralnic.com/br.com"],
|
|
5
6
|
["cn.com", "https://rdap.centralnic.com/cn.com"],
|
|
6
7
|
["de.com", "https://rdap.centralnic.com/de.com"],
|
|
@@ -33,7 +34,7 @@ export async function tldToRdap(domain) {
|
|
|
33
34
|
const response = await fetch(`https://data.iana.org/rdap/dns.json`).then((r) => r.json());
|
|
34
35
|
for (const [tlds, urls] of response.services) {
|
|
35
36
|
for (const tld of tlds) {
|
|
36
|
-
tldCache.set(tld, urls[0].replace(/\/$/,
|
|
37
|
+
tldCache.set(tld, urls[0].replace(/\/$/, ""));
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -41,11 +42,11 @@ export async function tldToRdap(domain) {
|
|
|
41
42
|
if (parsed.type === ParseResultType.Listed) {
|
|
42
43
|
let tld = parsed.topLevelDomains.join(".");
|
|
43
44
|
if (tldCache.has(tld)) {
|
|
44
|
-
return [parsed.domain +
|
|
45
|
+
return [parsed.domain + "." + tld, tldCache.get(tld)];
|
|
45
46
|
}
|
|
46
47
|
tld = parsed.icann.topLevelDomains.join(".");
|
|
47
48
|
if (tldCache.has(tld)) {
|
|
48
|
-
return [parsed.icann.domain +
|
|
49
|
+
return [parsed.icann.domain + "." + tld, tldCache.get(tld)];
|
|
49
50
|
}
|
|
50
51
|
// const tlds = [
|
|
51
52
|
// parsed.topLevelDomains.join("."),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const loadWWWServers: Record<string, string>;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -14,13 +14,15 @@ const eventMap = new Map<string, WhoisTimestampFields>([
|
|
|
14
14
|
]);
|
|
15
15
|
|
|
16
16
|
export async function whois(
|
|
17
|
-
|
|
17
|
+
origDomain: string,
|
|
18
18
|
options: WhoisOptions = { fetch: fetch }
|
|
19
19
|
): Promise<WhoisResponse> {
|
|
20
20
|
const fetch = options.fetch!;
|
|
21
21
|
|
|
22
|
+
let domain = origDomain;
|
|
22
23
|
let url: string | null = null;
|
|
23
|
-
|
|
24
|
+
|
|
25
|
+
[domain, url] = await tldToRdap(origDomain);
|
|
24
26
|
|
|
25
27
|
const response: WhoisResponse = {
|
|
26
28
|
found: false,
|
package/src/port43.ts
CHANGED
|
@@ -29,6 +29,7 @@ export function determinePort43Domain(actor: string) {
|
|
|
29
29
|
export async function port43(actor: string): Promise<WhoisResponse> {
|
|
30
30
|
const [domain, tld, whoisServer] = determinePort43Domain(actor);
|
|
31
31
|
const opts = whoisServer;
|
|
32
|
+
const isWwww = opts?.url;
|
|
32
33
|
const server = opts?.host || opts || null;
|
|
33
34
|
const query = opts?.query
|
|
34
35
|
? opts.query.replace("$addr", domain)
|
|
@@ -53,14 +54,21 @@ export async function port43(actor: string): Promise<WhoisResponse> {
|
|
|
53
54
|
let port43response = "";
|
|
54
55
|
|
|
55
56
|
try {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
if (isWwww) {
|
|
58
|
+
port43response = (await fetch(opts.url.replace('%%domain%%', domain)).then(r => r.text())).toString().replace(/^[ \t]+/gm, "");
|
|
59
|
+
response.server = opts.url.match('//(.*?)/')?.[1];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
response.server = server;
|
|
63
|
+
const promiseSocket = new PromiseSocket(new Socket());
|
|
64
|
+
promiseSocket.setTimeout(5 * 1000);
|
|
65
|
+
await promiseSocket.connect(port, server);
|
|
66
|
+
await promiseSocket.write(query);
|
|
67
|
+
port43response = (await promiseSocket.readAll())!
|
|
68
|
+
.toString()
|
|
69
|
+
.replace(/^[ \t]+/gm, "");
|
|
70
|
+
await promiseSocket.end();
|
|
71
|
+
}
|
|
64
72
|
} catch (error) {
|
|
65
73
|
response.found = false;
|
|
66
74
|
}
|
package/src/port43servers.ts
CHANGED
|
@@ -187,6 +187,11 @@ export const port43servers: Record<string, any> = {
|
|
|
187
187
|
"uy.com": "whois.centralnic.net",
|
|
188
188
|
"web.com": "whois.centralnic.net",
|
|
189
189
|
"za.com": "whois.centralnic.net",
|
|
190
|
+
|
|
191
|
+
"it.com": {
|
|
192
|
+
url: `https://engine.itcomdomains.com/api/v1/domain/%%domain%%/whois_info`,
|
|
193
|
+
},
|
|
194
|
+
|
|
190
195
|
com: {
|
|
191
196
|
host: "whois.verisign-grs.com",
|
|
192
197
|
query: "DOMAIN $addr\r\n",
|
|
@@ -790,7 +795,7 @@ export const port43servers: Record<string, any> = {
|
|
|
790
795
|
mv: null,
|
|
791
796
|
mw: "whois.nic.mw",
|
|
792
797
|
mx: "whois.mx",
|
|
793
|
-
my: "whois.
|
|
798
|
+
my: "whois.mynic.my",
|
|
794
799
|
mz: "whois.nic.mz",
|
|
795
800
|
na: "whois.na-nic.com.na",
|
|
796
801
|
nc: "whois.nc",
|
package/src/utils/tldToRdap.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ParseResultType, parseDomain } from "parse-domain";
|
|
2
2
|
|
|
3
3
|
type TldToRdap = [string[], string[]];
|
|
4
|
-
const tldCache = new Map<string, string>([]);
|
|
5
|
-
const tldCachePresets = [
|
|
4
|
+
const tldCache = new Map<string, string | null>([]);
|
|
5
|
+
const tldCachePresets: [string, string | null][] = [
|
|
6
|
+
["it.com", null],
|
|
6
7
|
["br.com", "https://rdap.centralnic.com/br.com"],
|
|
7
8
|
["cn.com", "https://rdap.centralnic.com/cn.com"],
|
|
8
9
|
["de.com", "https://rdap.centralnic.com/de.com"],
|
|
@@ -27,20 +28,22 @@ const tldCachePresets = [
|
|
|
27
28
|
["za.com", "https://rdap.centralnic.com/za.com"],
|
|
28
29
|
];
|
|
29
30
|
|
|
30
|
-
export async function tldToRdap(
|
|
31
|
+
export async function tldToRdap(
|
|
32
|
+
domain: string
|
|
33
|
+
): Promise<[string, string | null]> {
|
|
31
34
|
if (tldCache.size === 0) {
|
|
32
35
|
for (const [tld, url] of tldCachePresets) {
|
|
33
36
|
tldCache.set(tld, url);
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
// console.warn(`fetching tld-to-rdap`);
|
|
37
|
-
const response: { services: TldToRdap[]
|
|
40
|
+
const response: { services: TldToRdap[] } = await fetch(
|
|
38
41
|
`https://data.iana.org/rdap/dns.json`
|
|
39
42
|
).then((r) => r.json() as any);
|
|
40
43
|
|
|
41
44
|
for (const [tlds, urls] of response.services) {
|
|
42
45
|
for (const tld of tlds) {
|
|
43
|
-
tldCache.set(tld, urls[0].replace(/\/$/,
|
|
46
|
+
tldCache.set(tld, urls[0].replace(/\/$/, ""));
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
}
|
|
@@ -50,11 +53,11 @@ export async function tldToRdap(domain: string): Promise<[ string, string | null
|
|
|
50
53
|
if (parsed.type === ParseResultType.Listed) {
|
|
51
54
|
let tld = parsed.topLevelDomains.join(".");
|
|
52
55
|
if (tldCache.has(tld)) {
|
|
53
|
-
return [
|
|
56
|
+
return [parsed.domain + "." + tld, tldCache.get(tld)!];
|
|
54
57
|
}
|
|
55
58
|
tld = parsed.icann.topLevelDomains.join(".");
|
|
56
59
|
if (tldCache.has(tld)) {
|
|
57
|
-
return [
|
|
60
|
+
return [parsed.icann.domain + "." + tld, tldCache.get(tld)!];
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
// const tlds = [
|
|
@@ -69,5 +72,5 @@ export async function tldToRdap(domain: string): Promise<[ string, string | null
|
|
|
69
72
|
// }
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
return [
|
|
75
|
+
return [domain, null];
|
|
73
76
|
}
|