diff --git a/README.md b/README.md index 18cdb7c..81c93bc 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Get WHOIS info for domains. - `timeout` - WHOIS server request timeout in ms. Default: 1500 - `follow` - How many WHOIS server to query. 1 = registry server (faster), 2 = registry + registrar (more domain details). Default: 2 - `raw` - Return the raw WHOIS result in response. Added to `__raw` + - `ignorePrivacy` - Show or hide the WHOIS protected data from response, accepts boolean. Default: true ```js const whoiser = require('whoiser'); diff --git a/index.d.ts b/index.d.ts index 182fbf7..1a52004 100644 --- a/index.d.ts +++ b/index.d.ts @@ -37,6 +37,13 @@ declare module 'whoiser' { * @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 diff --git a/src/parsers.js b/src/parsers.js index c0ff679..016a7f1 100644 --- a/src/parsers.js +++ b/src/parsers.js @@ -109,7 +109,7 @@ const parseSimpleWhois = (whois) => { return data } -const parseDomainWhois = (domain, whois) => { +const parseDomainWhois = (domain, whois, ignorePrivacy) => { // Text saying there's no useful data in a field const noData = [ '-', @@ -325,7 +325,7 @@ const parseDomainWhois = (domain, whois) => { } // remove redacted data - if (noData.includes(value.toLowerCase())) { + if (ignorePrivacy && noData.includes(value.toLowerCase())) { value = '' } diff --git a/src/whoiser.js b/src/whoiser.js index 9033b1c..bf703d3 100644 --- a/src/whoiser.js +++ b/src/whoiser.js @@ -120,7 +120,7 @@ const whoisTld = async (query, { timeout = 15000, raw = false, domainTld = '' } return data } -const whoisDomain = async (rawDomain, { host = null, timeout = 15000, follow = 2, raw = false } = {}) => { +const whoisDomain = async (rawDomain, { host = null, timeout = 15000, follow = 2, raw = false, ignorePrivacy = true } = {}) => { domain = punycode.toASCII(rawDomain) const [domainName, domainTld] = splitStringBy(domain.toLowerCase(), domain.lastIndexOf('.')) let results = {} @@ -157,7 +157,7 @@ const whoisDomain = async (rawDomain, { host = null, timeout = 15000, follow = 2 try { resultRaw = await whoisQuery({ host, query, timeout }) - result = parseDomainWhois(domain, resultRaw) + result = parseDomainWhois(domain, resultRaw, ignorePrivacy) } catch (err) { result = { error: err.message } }