@cleandns/whois-rdap 1.0.31 → 1.0.33
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 +5 -1
- package/dist/ip.d.ts +2 -0
- package/dist/ip.js +23 -0
- package/dist/port43.js +15 -9
- package/dist/utils/tldToRdap.js +3 -0
- package/package.json +1 -1
- package/src/index.ts +6 -1
- package/src/ip.ts +28 -0
- package/src/port43.ts +15 -9
- package/src/utils/tldToRdap.ts +3 -0
- package/whois.d.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseIpResponse } from "./ip.js";
|
|
1
2
|
import { determinePort43Domain, port43 } from "./port43.js";
|
|
2
3
|
import { findInObject } from "./utils/findInObject.js";
|
|
3
4
|
import { fixArrays } from "./utils/fixArrays.js";
|
|
@@ -31,7 +32,8 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
|
|
|
31
32
|
}
|
|
32
33
|
url = "https://rdap.org";
|
|
33
34
|
}
|
|
34
|
-
const
|
|
35
|
+
const type = domain.match(/[^\d.]/) ? "domain" : "ip";
|
|
36
|
+
const thinRdap = `${url}/${type}/${domain}`;
|
|
35
37
|
// console.log(`fetching thin RDAP: ${thinRdap}`);
|
|
36
38
|
let thinResponse = await _fetch(thinRdap)
|
|
37
39
|
.then((r) => r.json())
|
|
@@ -194,6 +196,8 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
|
|
|
194
196
|
...((thickResponse === null || thickResponse === void 0 ? void 0 : thickResponse.events) || []),
|
|
195
197
|
...((thinResponse === null || thinResponse === void 0 ? void 0 : thinResponse.events) || []),
|
|
196
198
|
]);
|
|
199
|
+
if (type === 'ip')
|
|
200
|
+
parseIpResponse(domain, thinResponse, response);
|
|
197
201
|
return response;
|
|
198
202
|
}
|
|
199
203
|
function findStatus(statuses, domain) {
|
package/dist/ip.d.ts
ADDED
package/dist/ip.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function parseIpResponse(ip, rdap, response) {
|
|
2
|
+
var _a, _b, _c;
|
|
3
|
+
response.found = Boolean(rdap.handle);
|
|
4
|
+
const registry = rdap.port43 ? rdap.port43.match(/\.(\w+)\./)[1].toUpperCase() : '';
|
|
5
|
+
const realRdapServer = (_c = (_b = (_a = rdap.links) === null || _a === void 0 ? void 0 : _a.find(({ rel }) => rel === 'self')) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.replace(/\/ip\/.*/, '/ip/');
|
|
6
|
+
response.server = realRdapServer || 'https://rdap.org/ip/';
|
|
7
|
+
response.identity = {
|
|
8
|
+
handle: rdap.handle,
|
|
9
|
+
ipRange: {
|
|
10
|
+
start: rdap.startAddress,
|
|
11
|
+
endAddress: rdap.endAddress
|
|
12
|
+
},
|
|
13
|
+
cidr: (rdap.cidr0_cidrs || []).map((cidr) => cidr.v4prefix + '/' + cidr.length),
|
|
14
|
+
name: rdap.name,
|
|
15
|
+
type: rdap.type,
|
|
16
|
+
parent: rdap.parentHandle,
|
|
17
|
+
ip,
|
|
18
|
+
};
|
|
19
|
+
response.registrar = {
|
|
20
|
+
id: 0,
|
|
21
|
+
name: registry,
|
|
22
|
+
};
|
|
23
|
+
}
|
package/dist/port43.js
CHANGED
|
@@ -50,15 +50,21 @@ export async function port43(actor) {
|
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
response.server = server;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
port43response
|
|
58
|
-
|
|
59
|
-
.
|
|
60
|
-
.
|
|
61
|
-
|
|
53
|
+
port43response = await fetch(`https://www.whois.com/whois/${domain}`).then(r => r.text()).then((r) => {
|
|
54
|
+
var _a;
|
|
55
|
+
return ((_a = r.match(/<pre class="df-raw" id="registryData">(.*?)<\/pre>/s)) === null || _a === void 0 ? void 0 : _a[1]) || "";
|
|
56
|
+
});
|
|
57
|
+
if (port43response === '') {
|
|
58
|
+
const promiseSocket = new PromiseSocket(new Socket());
|
|
59
|
+
promiseSocket.setTimeout(5 * 1000);
|
|
60
|
+
await promiseSocket.connect(port, server);
|
|
61
|
+
await promiseSocket.write(query);
|
|
62
|
+
port43response = (await promiseSocket.readAll())
|
|
63
|
+
.toString()
|
|
64
|
+
.replace(/\r/g, "")
|
|
65
|
+
.replace(/^[ \t]+/gm, "");
|
|
66
|
+
await promiseSocket.end();
|
|
67
|
+
}
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
catch (error) {
|
package/dist/utils/tldToRdap.js
CHANGED
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WhoisOptions, WhoisResponse, WhoisTimestampFields } from "../whois.js";
|
|
2
|
+
import { parseIpResponse } from "./ip.js";
|
|
2
3
|
import { determinePort43Domain, port43 } from "./port43.js";
|
|
3
4
|
import { findInObject } from "./utils/findInObject.js";
|
|
4
5
|
import { fixArrays } from "./utils/fixArrays.js";
|
|
@@ -41,7 +42,9 @@ export async function whois(
|
|
|
41
42
|
url = "https://rdap.org";
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
+
const type = domain.match(/[^\d.]/) ? "domain" : "ip";
|
|
46
|
+
|
|
47
|
+
const thinRdap = `${url}/${type}/${domain}`;
|
|
45
48
|
// console.log(`fetching thin RDAP: ${thinRdap}`);
|
|
46
49
|
|
|
47
50
|
let thinResponse = await _fetch(thinRdap)
|
|
@@ -308,6 +311,8 @@ export async function whois(
|
|
|
308
311
|
...(thinResponse?.events || []),
|
|
309
312
|
]);
|
|
310
313
|
|
|
314
|
+
if (type === 'ip') parseIpResponse(domain, thinResponse, response);
|
|
315
|
+
|
|
311
316
|
return response;
|
|
312
317
|
}
|
|
313
318
|
|
package/src/ip.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WhoisResponse } from "../whois.js";
|
|
2
|
+
|
|
3
|
+
export function parseIpResponse(ip: string, rdap: any, response: WhoisResponse) {
|
|
4
|
+
response.found = Boolean(rdap.handle);
|
|
5
|
+
|
|
6
|
+
const registry = rdap.port43 ? rdap.port43.match(/\.(\w+)\./)[1].toUpperCase() : '';
|
|
7
|
+
const realRdapServer = rdap.links?.find(({ rel }: { rel: string }) => rel === 'self')?.value?.replace(/\/ip\/.*/, '/ip/');
|
|
8
|
+
|
|
9
|
+
response.server = realRdapServer || 'https://rdap.org/ip/';
|
|
10
|
+
|
|
11
|
+
response.identity = {
|
|
12
|
+
handle: rdap.handle,
|
|
13
|
+
ipRange: {
|
|
14
|
+
start: rdap.startAddress,
|
|
15
|
+
endAddress: rdap.endAddress
|
|
16
|
+
},
|
|
17
|
+
cidr: (rdap.cidr0_cidrs || []).map((cidr: any) => cidr.v4prefix + '/' + cidr.length),
|
|
18
|
+
name: rdap.name,
|
|
19
|
+
type: rdap.type,
|
|
20
|
+
parent: rdap.parentHandle,
|
|
21
|
+
ip,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
response.registrar = {
|
|
25
|
+
id: 0,
|
|
26
|
+
name: registry,
|
|
27
|
+
};
|
|
28
|
+
}
|
package/src/port43.ts
CHANGED
|
@@ -60,15 +60,21 @@ export async function port43(actor: string): Promise<WhoisResponse> {
|
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
62
|
response.server = server;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
port43response
|
|
68
|
-
|
|
69
|
-
.
|
|
70
|
-
.
|
|
71
|
-
|
|
63
|
+
port43response = await fetch(`https://www.whois.com/whois/${domain}`).then(r => r.text()).then((r) => {
|
|
64
|
+
return r.match(/<pre class="df-raw" id="registryData">(.*?)<\/pre>/s)?.[1] || "";
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (port43response === '') {
|
|
68
|
+
const promiseSocket = new PromiseSocket(new Socket());
|
|
69
|
+
promiseSocket.setTimeout(5 * 1000);
|
|
70
|
+
await promiseSocket.connect(port, server);
|
|
71
|
+
await promiseSocket.write(query);
|
|
72
|
+
port43response = (await promiseSocket.readAll())!
|
|
73
|
+
.toString()
|
|
74
|
+
.replace(/\r/g, "")
|
|
75
|
+
.replace(/^[ \t]+/gm, "");
|
|
76
|
+
await promiseSocket.end();
|
|
77
|
+
}
|
|
72
78
|
}
|
|
73
79
|
} catch (error: any) {
|
|
74
80
|
console.warn(port, server, query);
|
package/src/utils/tldToRdap.ts
CHANGED
package/whois.d.ts
CHANGED
|
@@ -21,4 +21,16 @@ export type WhoisResponse = {
|
|
|
21
21
|
updated: Date | null;
|
|
22
22
|
expires: Date | null;
|
|
23
23
|
};
|
|
24
|
+
identity?: {
|
|
25
|
+
handle: string;
|
|
26
|
+
ipRange: {
|
|
27
|
+
start: string;
|
|
28
|
+
endAddress: string;
|
|
29
|
+
};
|
|
30
|
+
cidr: string[];
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
parent: string | null;
|
|
34
|
+
ip: string;
|
|
35
|
+
}
|
|
24
36
|
};
|