@stacksjs/whois 0.67.0 → 0.68.0
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/constants.d.ts +1 -1
- package/dist/index.d.ts +63 -82
- package/dist/index.js +28 -28
- package/dist/types.d.ts +20 -89
- package/dist/utils.d.ts +1 -7
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,88 +1,69 @@
|
|
|
1
|
-
import type { ProxyData, WhoIsOptions
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @returns WhoIs server which hosts the information for the domains of the TLD
|
|
8
|
-
*/
|
|
1
|
+
import type { ProxyData, WhoIsOptions } from './types';
|
|
2
|
+
import type { SocksClientOptions } from 'socks';
|
|
3
|
+
import { SocksClient } from 'socks';
|
|
4
|
+
|
|
5
|
+
export { SocksClient } from 'socks'
|
|
6
|
+
export type { SocksClientOptions } from 'socks';
|
|
9
7
|
export declare function findWhoIsServer(tld: string): Promise<string>;
|
|
10
|
-
/**
|
|
11
|
-
* Get whois server of the tld from servers list
|
|
12
|
-
*
|
|
13
|
-
* @param tld TLD of the domain
|
|
14
|
-
* @returns WhoIs server which hosts the information for the domains of the TLD
|
|
15
|
-
*/
|
|
16
8
|
export declare function getWhoIsServer(tld: keyof typeof SERVERS): string | undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Extract TLD from domain name.
|
|
19
|
-
* If the TLD is in whois-servers.json file, then the TLD is returned.
|
|
20
|
-
* If TLD is not found within the file, then determined by taking the last element after splitting the domain name from '.'
|
|
21
|
-
*
|
|
22
|
-
* @param domain Domain name
|
|
23
|
-
* @returns TLD
|
|
24
|
-
*/
|
|
25
9
|
export declare function getTLD(domain: string): keyof typeof SERVERS;
|
|
26
10
|
export declare function getParameters(server: string): string | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Parse collected raw WhoIs data
|
|
29
|
-
*
|
|
30
|
-
* @class
|
|
31
|
-
*/
|
|
32
11
|
export declare class WhoIsParser {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
12
|
+
private static iterParse(rawData: string, outputData: any) {
|
|
13
|
+
let lastStr = ''
|
|
14
|
+
let lastField: string | null = null
|
|
15
|
+
let lastLetter = ''
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < rawData.length; i++) {
|
|
18
|
+
const letter = rawData[i]
|
|
19
|
+
if (letter === '\n' || (lastLetter === ':' && letter === ' ')) {
|
|
20
|
+
if (lastStr.trim() in outputData) {
|
|
21
|
+
lastField = lastStr.trim()
|
|
22
|
+
}
|
|
23
|
+
else if (lastField !== null) {
|
|
24
|
+
const x = lastStr.trim()
|
|
25
|
+
if (x !== '') {
|
|
26
|
+
const obj = outputData[lastField]
|
|
27
|
+
if (Array.isArray(obj))
|
|
28
|
+
obj.push(x)
|
|
29
|
+
else outputData[lastField] = x
|
|
30
|
+
|
|
31
|
+
lastField = null
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
lastStr = ''
|
|
35
|
+
}
|
|
36
|
+
else if (letter !== ':') {
|
|
37
|
+
lastStr = lastStr + letter
|
|
38
|
+
}
|
|
39
|
+
lastLetter = letter as string
|
|
40
|
+
if (lastStr === 'Record maintained by' || lastStr === '>>>')
|
|
41
|
+
break
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return outputData
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public static parseData(rawData: string, outputData: any | null): any {
|
|
48
|
+
if (!outputData) {
|
|
49
|
+
outputData = {
|
|
50
|
+
'Domain Name': '',
|
|
51
|
+
'Creation Date': '',
|
|
52
|
+
'Updated Date': '',
|
|
53
|
+
'Registry Expiry Date': '',
|
|
54
|
+
'Domain Status': [],
|
|
55
|
+
'Registrar': '',
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
outputData = WhoIsParser.iterParse(rawData, outputData)
|
|
60
|
+
|
|
61
|
+
return outputData
|
|
62
|
+
}
|
|
49
63
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @param port WhoIs server port
|
|
57
|
-
* @param encoding Encoding used by the WhoIs server
|
|
58
|
-
* @param proxy {@link ProxyData}
|
|
59
|
-
* @returns The {string} WhoIs response for the query. Empty string is returned for errors
|
|
60
|
-
*/
|
|
61
|
-
export declare function tcpWhois(domain: string, queryOptions: string, server: string, port: number, encoding: string, proxy: ProxyData | null): Promise<string>;
|
|
62
|
-
/**
|
|
63
|
-
* Collect WhoIs data for the mentioned {@link domain}. Parse the received response if {@link parse} is true, accordingly.
|
|
64
|
-
*
|
|
65
|
-
* @param domain Domain name
|
|
66
|
-
* @param parse Whether the raw text needs to be parsed/formatted or not
|
|
67
|
-
* @param options {@link WhoIsOptions}
|
|
68
|
-
* @returns {@link WhoIsResponse} Returns a {@link WhoIsResponse} object which contains the raw text and parsed data (if parse is true)
|
|
69
|
-
*/
|
|
70
|
-
export declare function whois(domain: string, parse?: boolean, options?: WhoIsOptions | null): Promise<WhoIsResponse>;
|
|
71
|
-
export declare function lookup(domain: string, options?: WhoIsOptions | null): Promise<WhoIsResponse>;
|
|
72
|
-
/**
|
|
73
|
-
* Collects (and parse/format if set to be true) for the provided {@link domains}. If {@link parallel} is set to be true, multiple threads will be used to batch process the domains according to {@link threads} mentioned.
|
|
74
|
-
* If <i>options.parsedData</i> is mentioned, then it will be used to parse <b>all</b> the responses.
|
|
75
|
-
* If a proxy is mentioned in {@link options}, then the proxy will be used to collect <b>all</b> the WhoIs data.
|
|
76
|
-
*
|
|
77
|
-
* @param domains Domains Names
|
|
78
|
-
* @param parallel Whether data should be collected parallally or not
|
|
79
|
-
* @param threads Batch size (for parallel processing)
|
|
80
|
-
* @param parse Whether the raw text needs to be parsed/formatted or not
|
|
81
|
-
* @param options {@link WhoIsOptions}
|
|
82
|
-
* @returns Array of {@link WhoIsResponse} for all the domains. Order is not guaranteed
|
|
83
|
-
*/
|
|
84
|
-
export declare function batchWhois(domains: string[], parallel?: boolean, threads?: number, parse?: boolean, options?: WhoIsOptions | null): Promise<WhoIsResponse[]>;
|
|
85
|
-
export * from "./constants";
|
|
86
|
-
export * from "./types";
|
|
87
|
-
export { SocksClient } from "socks";
|
|
88
|
-
export type { SocksClientOptions } from "socks";
|
|
64
|
+
export declare function tcpWhois(domain: string, queryOptions: string, server: string, port: number, encoding: string, proxy: ProxyData | null,): Promise<string>;
|
|
65
|
+
export declare function whois(domain: string, parse = false, options: WhoIsOptions | null = null,): Promise<WhoIsResponse>;
|
|
66
|
+
export declare function lookup(domain: string, options: WhoIsOptions | null = null): Promise<WhoIsResponse>;
|
|
67
|
+
export declare function batchWhois(domains: string[], parallel = false, threads = 1, parse = false, options: WhoIsOptions | null = null,): Promise<WhoIsResponse[]>;
|
|
68
|
+
export * from './constants'
|
|
69
|
+
export * from './types'
|