@xyz/whois
Version:
A powerful TypeScript/JavaScript tool for comprehensive domain analysis, featuring detailed WHOIS data with registration dates, registrars, and domain status. Offers SSL certificate extraction (with PEM support), DNS records, and server details. Includes
72 lines (71 loc) ⢠3.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("../index");
/**
* Example demonstrating subdomain support in the domain-info-fetcher package
*/
async function main() {
try {
// You can replace these with your preferred domains
const domains = [
'www.github.com', // Subdomain that is typically stripped by formatDomain
'blog.github.com', // Regular subdomain
'github.com', // Root domain for comparison
];
console.log('Demonstrating subdomain support:\n');
for (const domain of domains) {
console.log(`\n${'-'.repeat(50)}`);
console.log(`Analyzing domain: ${domain}`);
// Demonstrate subdomain extraction functions
const subdomain = (0, index_1.extractSubdomain)(domain);
const rootDomain = (0, index_1.getRootDomain)(domain);
console.log(`Subdomain: ${subdomain || 'None'}`);
console.log(`Root domain: ${rootDomain}`);
// Fetch domain info
console.log(`\nFetching information for ${domain}...`);
const domainInfo = await (0, index_1.fetchDomainInfo)(domain);
if (!domainInfo) {
console.error(`No domain information returned for ${domain}`);
continue;
}
// SSL Certificate Information
console.log('\nš SSL Certificate:');
console.log(` - Issued to: ${JSON.stringify(domainInfo.sslData.subject)}`);
console.log(` - Valid: ${domainInfo.sslData.valid ? 'ā
Yes' : 'ā No'}`);
console.log(` - Valid until: ${new Date(domainInfo.sslData.validTo).toLocaleDateString()}`);
// DNS Information - Focus on subdomain handling
if (domainInfo.dnsData) {
console.log('\nš DNS Records:');
console.log(` - A Records: ${domainInfo.dnsData.A.join(', ')}`);
console.log(` - CNAME: ${domainInfo.dnsData.CNAME || 'None'}`);
// For subdomains, MX, TXT, NS records are typically from the root domain
if (subdomain) {
console.log(`\n Root domain (${rootDomain}) records:`);
}
if (domainInfo.dnsData.MX.length) {
console.log(` - MX Records: ${domainInfo.dnsData.MX.length} records found`);
}
if (domainInfo.dnsData.NS.length) {
console.log(` - NS Records: ${domainInfo.dnsData.NS.length} records found`);
}
if (domainInfo.dnsData.TXT.length) {
console.log(` - TXT Records: ${domainInfo.dnsData.TXT.length} records found`);
}
}
else {
console.log('\nš DNS Records: Not available');
}
}
}
catch (error) {
console.error('ā Error in example:');
if (error instanceof Error) {
console.error(` ${error.message}`);
}
else {
console.error(` ${String(error)}`);
}
}
}
// Run the example
main().catch(console.error);