smartwhois/ts/index.ts

34 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-04-03 14:48:14 +00:00
import * as plugins from './smartwhois.plugins.js';
export class SmartWhois {
public async getWhoisForDomain(domainArg: string) {
const whoisInfo = await plugins.whoiser.domain(domainArg);
const whoisServers = Object.keys(whoisInfo);
const selectedWhoisInfo: any = whoisInfo[whoisServers[0]];
const registrar = selectedWhoisInfo.Registrar;
const registrarUrl = selectedWhoisInfo['Registrar URL'];
const createdDate = selectedWhoisInfo['Created Date'];
const updatedDate = selectedWhoisInfo['Updated Date'];
const expiryDate = selectedWhoisInfo['Expiry Date'];
return {
originalWhoisInfo: whoisInfo,
whoisServers,
registrar,
registrarUrl,
createdDate,
updatedDate,
expiryDate,
};
}
2023-04-03 15:50:55 +00:00
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);
}
2023-04-03 14:48:14 +00:00
public async getWhoisForIp(ipArg: string) {}
2023-04-03 15:50:55 +00:00
}