Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
4093d091f4 | |||
7a8086b58c | |||
a45e41889d | |||
c33ee3f52c | |||
1732a2ab3e | |||
43ebd17ae6 | |||
18f09a5109 | |||
bec73de6d5 | |||
deba684093 | |||
1625f507d8 | |||
32f8315493 | |||
ffbf56625e | |||
d928a62b5e | |||
b5c5b18f35 | |||
3e3b61cc73 | |||
ecb009dedb | |||
6e8beac2dd | |||
9160a1bd56 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartwhois",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.11",
|
||||
"private": false,
|
||||
"description": "a package for dealing with whois requests",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -23,6 +23,9 @@
|
||||
"@types/node": "^18.15.11"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartrequest": "^2.0.15",
|
||||
"@pushrocks/smarturl": "^3.0.6",
|
||||
"tldts": "^6.0.3",
|
||||
"whoiser": "^1.16.0"
|
||||
},
|
||||
"browserslist": [
|
||||
|
55
pnpm-lock.yaml
generated
55
pnpm-lock.yaml
generated
@ -1,6 +1,15 @@
|
||||
lockfileVersion: '6.0'
|
||||
|
||||
dependencies:
|
||||
'@pushrocks/smartrequest':
|
||||
specifier: ^2.0.15
|
||||
version: 2.0.15
|
||||
'@pushrocks/smarturl':
|
||||
specifier: ^3.0.6
|
||||
version: 3.0.6
|
||||
tldts:
|
||||
specifier: ^6.0.3
|
||||
version: 6.0.3
|
||||
whoiser:
|
||||
specifier: ^1.16.0
|
||||
version: 1.16.0
|
||||
@ -71,7 +80,7 @@ packages:
|
||||
'@pushrocks/smartjson': 5.0.5
|
||||
'@pushrocks/smartsocket': 2.0.19
|
||||
'@pushrocks/smartstring': 4.0.5
|
||||
'@pushrocks/smarturl': 3.0.5
|
||||
'@pushrocks/smarturl': 3.0.6
|
||||
transitivePeerDependencies:
|
||||
- bufferutil
|
||||
- supports-color
|
||||
@ -470,7 +479,7 @@ packages:
|
||||
'@pushrocks/smartmime': 1.0.5
|
||||
'@pushrocks/smartpath': 5.0.5
|
||||
'@pushrocks/smartpromise': 3.1.7
|
||||
'@pushrocks/smartrequest': 2.0.11
|
||||
'@pushrocks/smartrequest': 2.0.15
|
||||
'@pushrocks/smartsitemap': 2.0.1
|
||||
'@pushrocks/smarttime': 4.0.1
|
||||
'@tsclass/tsclass': 4.0.34
|
||||
@ -511,7 +520,7 @@ packages:
|
||||
'@pushrocks/smartmime': 1.0.5
|
||||
'@pushrocks/smartpath': 5.0.5
|
||||
'@pushrocks/smartpromise': 3.1.7
|
||||
'@pushrocks/smartrequest': 2.0.11
|
||||
'@pushrocks/smartrequest': 2.0.15
|
||||
'@pushrocks/smartstream': 2.0.3
|
||||
'@pushrocks/streamfunction': 4.0.4
|
||||
'@types/fs-extra': 11.0.1
|
||||
@ -670,6 +679,9 @@ packages:
|
||||
resolution: {integrity: sha512-2gLQCeviEJwZ+cHHtK2Ks98brZatGC6dPXKIs1tVgJsiNgRFjnp90fESuJ1Pmoe7RrS+7J3mO4NtsFHAJJ/y5w==}
|
||||
dev: true
|
||||
|
||||
/@pushrocks/smartpromise@4.0.2:
|
||||
resolution: {integrity: sha512-bqorOaGXPOuiOSV81luTKrTghg4O4NBRD0zyv7TIqmrMGf4a0uoozaUMp1X8vQdZW+y0gTzUJP9wkzAE6Cci0g==}
|
||||
|
||||
/@pushrocks/smartpuppeteer@2.0.2:
|
||||
resolution: {integrity: sha512-l3tqnD6Evseofq1avHsMy2FXXEmCd4Z+nm3xmMWS7nWvP9qTbJIn0XguOBaUIAhR8zE53UKPXs5/qBqXVNZDDQ==}
|
||||
dependencies:
|
||||
@ -684,16 +696,15 @@ packages:
|
||||
- utf-8-validate
|
||||
dev: true
|
||||
|
||||
/@pushrocks/smartrequest@2.0.11:
|
||||
resolution: {integrity: sha512-fqS5D+o4fzhen4qlhT8DJiSSUVno1q+hSXcq5VJFGTQVtvaZ5lZeK1odqMJsCOHZ3mD2LykrufIPViktwgnyVg==}
|
||||
/@pushrocks/smartrequest@2.0.15:
|
||||
resolution: {integrity: sha512-QDXXKhOwAIp+TNFrDglApBpbCTClHrf8pUM3w81q5+VtrMbqUrLINHhInXt3ZUSgTS7RD9HtJSIVSqAukcJo5A==}
|
||||
dependencies:
|
||||
'@pushrocks/smartpromise': 3.1.7
|
||||
'@pushrocks/smarturl': 3.0.5
|
||||
'@pushrocks/smartpromise': 4.0.2
|
||||
'@pushrocks/smarturl': 3.0.6
|
||||
agentkeepalive: 4.3.0
|
||||
form-data: 4.0.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@pushrocks/smartrx@2.0.27:
|
||||
resolution: {integrity: sha512-aFRpGxDZgHH1mpmkRBTFwuIVqFiDxk22n2vX2gW4hntV0nJGlt9M9dixMFFXGUjabwX9hHW7y60QPJm2rKaypA==}
|
||||
@ -827,9 +838,8 @@ packages:
|
||||
uuid: 7.0.3
|
||||
dev: true
|
||||
|
||||
/@pushrocks/smarturl@3.0.5:
|
||||
resolution: {integrity: sha512-XKS+GpIOvMhxr855PmO39SOvv/hdhBbLZ45dkAA6uGL3XdW036jAp61nu7qeB3c6FPShCyhJzo2z5x51wW7OwQ==}
|
||||
dev: true
|
||||
/@pushrocks/smarturl@3.0.6:
|
||||
resolution: {integrity: sha512-YHWnYE1mm8WIJk1usSXg+kNM7s7ByM+PKApO9cgl0T/oGybjzAJiO3clGNDro4ysP0TD+WuvJuiVue02bErEBQ==}
|
||||
|
||||
/@pushrocks/smartxml@1.0.6:
|
||||
resolution: {integrity: sha512-Cy//pxzdpplqE64h9/sAwvAkUBv9t3Nw9v6k2c+erXH779iOtuyGiiyWqgbRTX1wo2CRhMJqWGJx6xd2Ljq5kw==}
|
||||
@ -1418,7 +1428,6 @@ packages:
|
||||
humanize-ms: 1.2.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/aggregate-error@4.0.1:
|
||||
resolution: {integrity: sha512-0poP0T7el6Vq3rstR8Mn4V/IQrpBLO6POkUSrN7RhyY+GF/InCFShQzsQ39T25gkHhLgSLByyAz+Kjb+c2L98w==}
|
||||
@ -1501,7 +1510,6 @@ packages:
|
||||
|
||||
/asynckit@0.4.0:
|
||||
resolution: {integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k=}
|
||||
dev: true
|
||||
|
||||
/axe-core@4.6.3:
|
||||
resolution: {integrity: sha512-/BQzOX780JhsxDnPpH4ZiyrJAzcd8AfzFPkv+89veFSr1rcMjuq2JDCwypKaPeB6ljHp9KjXhPpjgCvQlWYuqg==}
|
||||
@ -1776,7 +1784,6 @@ packages:
|
||||
engines: {node: '>= 0.8'}
|
||||
dependencies:
|
||||
delayed-stream: 1.0.0
|
||||
dev: true
|
||||
|
||||
/commander@2.20.3:
|
||||
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
|
||||
@ -1913,7 +1920,6 @@ packages:
|
||||
optional: true
|
||||
dependencies:
|
||||
ms: 2.1.2
|
||||
dev: true
|
||||
|
||||
/decompress-response@6.0.0:
|
||||
resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==}
|
||||
@ -1947,7 +1953,6 @@ packages:
|
||||
/delayed-stream@1.0.0:
|
||||
resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=}
|
||||
engines: {node: '>=0.4.0'}
|
||||
dev: true
|
||||
|
||||
/delegates@1.0.0:
|
||||
resolution: {integrity: sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=}
|
||||
@ -1961,7 +1966,6 @@ packages:
|
||||
/depd@2.0.0:
|
||||
resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==}
|
||||
engines: {node: '>= 0.8'}
|
||||
dev: true
|
||||
|
||||
/dependency-graph@0.11.0:
|
||||
resolution: {integrity: sha512-JeMq7fEshyepOWDfcfHK06N3MhyPhz++vtqWhMT5O9A3K42rdsEDpfdVqjaqaAhsw6a+ZqeDvQVtD0hFHQWrzg==}
|
||||
@ -2512,7 +2516,6 @@ packages:
|
||||
asynckit: 0.4.0
|
||||
combined-stream: 1.0.8
|
||||
mime-types: 2.1.35
|
||||
dev: true
|
||||
|
||||
/forwarded@0.2.0:
|
||||
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
|
||||
@ -2766,7 +2769,6 @@ packages:
|
||||
resolution: {integrity: sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=}
|
||||
dependencies:
|
||||
ms: 2.1.3
|
||||
dev: true
|
||||
|
||||
/iconv-lite@0.4.24:
|
||||
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
|
||||
@ -3288,14 +3290,12 @@ packages:
|
||||
/mime-db@1.52.0:
|
||||
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
dev: true
|
||||
|
||||
/mime-types@2.1.35:
|
||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
dependencies:
|
||||
mime-db: 1.52.0
|
||||
dev: true
|
||||
|
||||
/mime@1.6.0:
|
||||
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
|
||||
@ -3359,11 +3359,9 @@ packages:
|
||||
|
||||
/ms@2.1.2:
|
||||
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
|
||||
dev: true
|
||||
|
||||
/ms@2.1.3:
|
||||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||
dev: true
|
||||
|
||||
/nanocolors@0.2.13:
|
||||
resolution: {integrity: sha512-0n3mSAQLPpGLV9ORXT5+C/D4mwew7Ebws69Hx4E2sgz2ZA5+32Q80B9tL8PbL7XHnRDiAxH/pnrUJ9a4fkTNTA==}
|
||||
@ -4177,6 +4175,17 @@ packages:
|
||||
esm: 3.2.25
|
||||
dev: true
|
||||
|
||||
/tldts-core@6.0.3:
|
||||
resolution: {integrity: sha512-PLiEM2aCkfGifyr8npbd93eWIW4isFRB44vTiup5DRie6e2Qy3+9quwHb252v12JyoM+RmF1cxtDgwD2PVBOjA==}
|
||||
dev: false
|
||||
|
||||
/tldts@6.0.3:
|
||||
resolution: {integrity: sha512-rcdUIwrcGuMWe5+fg5FFBrmWTYdbfpHwkk1AjBKoSDbpsdAsYqJYKoZOVOHn8MQCYatADKGAx/SU+jpSKxSYNw==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
tldts-core: 6.0.3
|
||||
dev: false
|
||||
|
||||
/to-regex-range@5.0.1:
|
||||
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
|
||||
engines: {node: '>=8.0'}
|
||||
|
27
test/test.ts
27
test/test.ts
@ -6,11 +6,36 @@ let testSmartWhois: smartwhois.SmartWhois;
|
||||
tap.test('should create a valid instance of SmartWhois', async () => {
|
||||
testSmartWhois = new smartwhois.SmartWhois();
|
||||
expect(testSmartWhois).toBeInstanceOf(smartwhois.SmartWhois);
|
||||
})
|
||||
});
|
||||
|
||||
tap.test('should get a parsed url result for whois', async () => {
|
||||
const parsedUrlResult = await testSmartWhois.getParsedUrlResultForWhois('https://coffee.link/understanding-gen-z/');
|
||||
console.log(parsedUrlResult);
|
||||
});
|
||||
|
||||
tap.test('should get additional data', async () => {
|
||||
const parsedUrlResult = await testSmartWhois.getAdditionalWhoisDataForDomain('https://coffee.link/understanding-gen-z/');
|
||||
console.log(parsedUrlResult);
|
||||
});
|
||||
|
||||
tap.test('should get whois info for domain', async () => {
|
||||
const whoisInfo = await testSmartWhois.getWhoisForDomain('task.vc');
|
||||
console.log(whoisInfo);
|
||||
});
|
||||
tap.test('should get whois info for domain', async () => {
|
||||
const whoisInfo = await testSmartWhois.getWhoisForDomain('https://lossless.com');
|
||||
console.log(whoisInfo);
|
||||
});
|
||||
|
||||
tap.test('should get whois info for domain', async () => {
|
||||
const whoisInfo = await testSmartWhois.getWhoisForDomain('https://coffee.link/understanding-gen-z/');
|
||||
console.log(whoisInfo);
|
||||
});
|
||||
|
||||
tap.test('should check for a valid tld', async () => {
|
||||
const comIsValid = await testSmartWhois.isValidTld('.com');
|
||||
console.log(comIsValid);
|
||||
expect(comIsValid).toBeTrue();
|
||||
})
|
||||
|
||||
tap.start();
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartwhois',
|
||||
version: '1.0.2',
|
||||
version: '1.0.11',
|
||||
description: 'a package for dealing with whois requests'
|
||||
}
|
||||
|
97
ts/index.ts
97
ts/index.ts
@ -1,7 +1,85 @@
|
||||
import * as plugins from './smartwhois.plugins.js';
|
||||
|
||||
export interface IWhoisInfo {
|
||||
domain: string;
|
||||
isRegistered: boolean;
|
||||
domainStatus: Array<
|
||||
| 'clientTransferProhibited'
|
||||
| 'clientUpdateProhibited'
|
||||
| 'clientDeleteProhibited'
|
||||
| 'clientHold'
|
||||
| 'serverTransferProhibited'
|
||||
| 'serverUpdateProhibited'
|
||||
| 'serverDeleteProhibited'
|
||||
| 'serverHold'
|
||||
| 'inactive'
|
||||
| 'pendingDelete'
|
||||
| 'pendingRenew'
|
||||
| 'pendingTransfer'
|
||||
| 'pendingUpdate'
|
||||
| 'ok'>;
|
||||
domainWithoutSuffix: string;
|
||||
hostname: string;
|
||||
isIcann: boolean;
|
||||
isIp: boolean;
|
||||
isPrivate: boolean;
|
||||
publicSuffix: string;
|
||||
subdomain: string;
|
||||
dnsSec: 'signedDelegation' | 'unsigned';
|
||||
originalWhoisInfo: {
|
||||
[key: string]: any;
|
||||
};
|
||||
whoisServers: string[];
|
||||
registrar: string;
|
||||
registrarUrl: string;
|
||||
createdDate: string;
|
||||
updatedDate: string;
|
||||
expiryDate: string;
|
||||
}
|
||||
|
||||
export class SmartWhois {
|
||||
public async getWhoisForDomain(domainArg: string) {
|
||||
/**
|
||||
* can be used to prepare an input for the whois command
|
||||
*/
|
||||
public async getParsedUrlResultForWhois(urlArg: string) {
|
||||
const smarturlInstance = plugins.smarturl.Smarturl.createFromUrl(urlArg);
|
||||
const tldtsData = plugins.tldts.parse(urlArg);
|
||||
return {
|
||||
fullUrl: smarturlInstance.toString(),
|
||||
fullDomain: smarturlInstance.hostname,
|
||||
domain: tldtsData.domain,
|
||||
publicSuffix: tldtsData.publicSuffix,
|
||||
subdomain: tldtsData.subdomain,
|
||||
}
|
||||
}
|
||||
|
||||
public async getAdditionalWhoisDataForDomain(domainArg: string) {
|
||||
if (domainArg.includes('//')) {
|
||||
const parsedUrlResult = await this.getParsedUrlResultForWhois(domainArg);
|
||||
domainArg = parsedUrlResult.fullDomain;
|
||||
}
|
||||
|
||||
// lets test http response
|
||||
const httpResult = await plugins.smartrequest.safeGet(`http://${domainArg}/`);
|
||||
|
||||
// lets test https response
|
||||
const httpsResult = await plugins.smartrequest.safeGet(`https://${domainArg}/`);
|
||||
|
||||
return {
|
||||
httpStatus: httpResult.statusCode,
|
||||
httpsStatus: httpsResult.statusCode,
|
||||
httpHeaders: httpResult.headers,
|
||||
httpsHeaders: httpsResult.headers,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public async getWhoisForDomain(domainArg: string): Promise<IWhoisInfo> {
|
||||
if (domainArg.includes('//')) {
|
||||
const parsedUrlResult = await this.getParsedUrlResultForWhois(domainArg);
|
||||
domainArg = parsedUrlResult.fullDomain;
|
||||
}
|
||||
const whoisInfo = await plugins.whoiser.domain(domainArg);
|
||||
const whoisServers = Object.keys(whoisInfo);
|
||||
const selectedWhoisInfo: any = whoisInfo[whoisServers[0]];
|
||||
@ -10,7 +88,14 @@ export class SmartWhois {
|
||||
const createdDate = selectedWhoisInfo['Created Date'];
|
||||
const updatedDate = selectedWhoisInfo['Updated Date'];
|
||||
const expiryDate = selectedWhoisInfo['Expiry Date'];
|
||||
|
||||
const tldtsData = plugins.tldts.parse(domainArg);
|
||||
|
||||
return {
|
||||
...tldtsData,
|
||||
isRegistered: true,
|
||||
domainStatus: selectedWhoisInfo['Domain Status'].map((statusArg: string) => statusArg.split(' ')[0]),
|
||||
dnsSec: selectedWhoisInfo['DNSSEC'],
|
||||
originalWhoisInfo: whoisInfo,
|
||||
whoisServers,
|
||||
registrar,
|
||||
@ -21,5 +106,13 @@ export class SmartWhois {
|
||||
};
|
||||
}
|
||||
|
||||
public async isValidTld(tldArg: string): Promise<boolean> {
|
||||
const allTlds = await plugins.whoiser.allTlds();
|
||||
const sanatizedTld = tldArg.startsWith('.')
|
||||
? tldArg.replace('.', '').toUpperCase()
|
||||
: tldArg.toUpperCase();
|
||||
return allTlds.includes(sanatizedTld);
|
||||
}
|
||||
|
||||
public async getWhoisForIp(ipArg: string) {}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,17 @@
|
||||
// third party
|
||||
import * as whoiser from 'whoiser';
|
||||
// pushrocks scope
|
||||
import * as smarturl from '@pushrocks/smarturl';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
|
||||
export {
|
||||
whoiser
|
||||
smarturl,
|
||||
smartrequest,
|
||||
}
|
||||
|
||||
// third party
|
||||
import * as whoiser from 'whoiser';
|
||||
import tldts from 'tldts';
|
||||
|
||||
export {
|
||||
whoiser,
|
||||
tldts,
|
||||
}
|
||||
|
Reference in New Issue
Block a user