forked from LayeredStudio/whoiser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
122 lines (105 loc) · 2.95 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
declare module 'whoiser' {
export interface Options {
/**
* WHOIS server to query.
*/
host?: string
port?: number
/**
* WHOIS server request timeout in ms.
*
* @default: 1500
*/
timeout?: number
/**
* How many WHOIS server to query.
* 1 = registry server (faster),
* 2 = registry + registrar (more domain details).
*
* @default: 2
*/
follow?: number
/**
* Return the raw WHOIS result in response.
* Added to `__raw`
*/
raw?: boolean
query?: string
/**
* Low level end of query suffix.
*
* @default '\r\n'
*/
querySuffix?: string
/**
* Ignore the protected WHOIS data from response
* and eplace them with empty values
* @default true
*/
ignorePrivacy?: boolean
}
export type OptionsIp = Pick<Options, 'host' | 'timeout' | 'raw'>
export type OptionsAsn = OptionsIp
export type OptionsQuery = Omit<Options, 'raw' | 'follow'>
export type OptionsTld = Pick<Options, 'timeout' | 'raw'>
export type OptionsDomain = Omit<Options, 'querySuffix' | 'query' | 'port'>
export type OptionsGeneric = OptionsIp | OptionsTld | OptionsDomain
export interface WhoisSearchResult {
[key: string]: string | Array<string> | WhoisSearchResult
}
/**
* Returns a list of all TLDs,
* [downloaded from IANA](https://www.iana.org/domains/root/db)
*
* @returns {Promise<string[]>}
*/
export function allTlds(): Promise<string[]>
/**
* Get WHOIS data for an AS number
*
* @param {string|number} asn
* @param {OptionsAsn} options
* @returns {Promise<WhoisSearchResult>} Parsed WHOIS server response
*/
export function asn(asn: string | number, options?: OptionsAsn): Promise<WhoisSearchResult>
/**
* Get parsed WHOIS data for a domain
*
* @param {string} domain
* @param {OptionsDomain} options
* @returns {Promise<WhoisSearchResult>} Parsed WHOIS server response
*/
export function domain(domain: string, options?: OptionsDomain): Promise<WhoisSearchResult>
/**
* Get WHOIS data for a IP
*
* @param {string} ip
* @param {OptionsIp} options
* @returns {Promise<WhoisSearchResult>} Parsed WHOIS server response
*/
export function ip(ip: string, options?: OptionsIp): Promise<WhoisSearchResult>
/**
* Query a WHOIS server for data
*
* @param {OptionsQuery} options
* @returns {Promise<string>} Raw WHOIS server response
*/
export function query(options: OptionsQuery): Promise<string>
/**
* Get WHOIS data for a TLD
*
* @param {string} tld Ex. `.net`
* @param {OptionsTld} options
* @returns {Promise<WhoisSearchResult>} Parsed WHOIS server response
*/
export function tld(tld: string, options?: OptionsTld): Promise<WhoisSearchResult>
/**
* Tries to guess query type and get WHOIS data
*
* @param {string} query
* @param {Options} options
* @returns {Promise<WhoisSearchResult>} Parsed WHOIS server response
*/
export function whoiser(query: string, options?: OptionsGeneric): Promise<WhoisSearchResult>
export default whoiser
}