@stacksjs/whois 0.64.6 → 0.66.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.
@@ -0,0 +1,3 @@
1
+ export declare const IANA_CHK_URL: string;
2
+ export declare const PARAMETERS: Record<string, string>;
3
+ export declare const SERVERS: Record<string, string>;
@@ -0,0 +1,88 @@
1
+ import type { ProxyData, WhoIsOptions, WhoIsResponse } from "./types";
2
+ import { SERVERS } from "./constants";
3
+ /**
4
+ * Find the WhoIs server for the TLD from IANA WhoIs service. The TLD is be searched and the HTML response is parsed to extract the WhoIs server
5
+ *
6
+ * @param tld TLD of the domain
7
+ * @returns WhoIs server which hosts the information for the domains of the TLD
8
+ */
9
+ 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
+ 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
+ export declare function getTLD(domain: string): keyof typeof SERVERS;
26
+ export declare function getParameters(server: string): string | undefined;
27
+ /**
28
+ * Parse collected raw WhoIs data
29
+ *
30
+ * @class
31
+ */
32
+ export declare class WhoIsParser {
33
+ /**
34
+ * Iterated through the complete text and returns extracted values
35
+ *
36
+ * @param rawData raw text from WhoIs server
37
+ * @param outputData Data which needs to be extracted from the raw text (key/value pairs). Keys are used to extract from raw text and values are filled.
38
+ * @returns Filled {@link outputData}
39
+ */
40
+ private static iterParse;
41
+ /**
42
+ * Parse the raw WhoIs text and returns extracted values
43
+ *
44
+ * @param rawData raw text from WhoIs server
45
+ * @param outputData Data which needs to be extracted from the raw text (key/value pairs). Keys are used to extract from raw text and values are filled.
46
+ * @returns Filled {@link outputData}
47
+ */
48
+ static parseData(rawData: string, outputData: any | null): any;
49
+ }
50
+ /**
51
+ * Connects to the provided {@link server}:{@link port} through TCP (through a proxy if a proxy is given), run the WhoIs query and returns the response
52
+ *
53
+ * @param domain Domain name
54
+ * @param queryOptions Query options which can be used with the specific WhoIs server to get the complete response
55
+ * @param server WhoIs server
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";