8 Commits

Author SHA1 Message Date
jkunz 4be4df03bc v1.0.17 2026-05-01 16:20:47 +00:00
jkunz c7d2b13c8b fix(whois): improve type safety and harden WHOIS parsing for missing fields 2026-05-01 16:20:47 +00:00
jkunz dc3288cc51 update 2025-07-29 00:27:48 +00:00
philkunz 86cc1a138b update description 2024-05-29 14:17:14 +02:00
philkunz 37a00db7c8 update tsconfig 2024-04-14 18:34:24 +02:00
philkunz 65a9b7f504 update tsconfig 2024-04-01 21:42:17 +02:00
philkunz e9fa022159 update npmextra.json: githost 2024-04-01 20:00:06 +02:00
philkunz b2b3ae34bd update npmextra.json: githost 2024-03-30 21:49:06 +01:00
13 changed files with 7880 additions and 4988 deletions
+37
View File
@@ -0,0 +1,37 @@
{
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartwhois",
"shortDescription": "execute WHOIS requests",
"npmPackagename": "@push.rocks/smartwhois",
"license": "MIT",
"description": "A package for executing WHOIS requests and processing domain and IP information.",
"keywords": [
"WHOIS",
"domain information",
"IP lookup",
"TLD validation",
"DNSSEC status",
"HTTP status checker",
"TypeScript"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
},
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
}
}
+51
View File
@@ -0,0 +1,51 @@
# Changelog
## 2026-05-01 - 1.0.17 - fix(whois)
improve type safety and harden WHOIS parsing for missing fields
- add explicit additional WHOIS data interface and return types
- default parsed domain and WHOIS fields to safe fallback values to avoid undefined access
- normalize Domain Status handling for both string and array responses
- update test entrypoint to test.node.ts and align tooling and build scripts with newer dependencies
## 2025-07-29 - 1.0.16 - maintenance
Routine maintenance updates for v1.0.16 after the initial release.
- Updated project description
- Updated TypeScript configuration
- Updated `npmextra.json` git host settings
- Included a general maintenance update
## 2023-10-06 - 1.0.16 - release
Released v1.0.16.
- Published version 1.0.16
- Included a core update carried forward from the previous patch cycle
## 2023-10-06 - 1.0.15 - core
Applied a core fix update.
- Updated core behavior in v1.0.15
## 2023-04-19 - 1.0.14 - core
Patch releases from v1.0.8 through v1.0.14 consisted primarily of repeated core maintenance updates.
- Released versions 1.0.8 through 1.0.14
- Applied recurring `fix(core): update` changes across the patch range
## 2023-04-18 - 1.0.8 - release
Released v1.0.8.
- Published version 1.0.8
## 2023-04-10 - 1.0.7 - core
Patch releases from v1.0.4 through v1.0.7 focused on small core fixes.
- Released versions 1.0.4 through 1.0.7
- Applied recurring `fix(core): update` changes across the patch range
## 2023-04-03 - 1.0.4 - core
Initial patch series from v1.0.1 through v1.0.3 contained minor core fixes.
- Released versions 1.0.1 through 1.0.3
- Applied recurring `fix(core): update` changes across the patch range
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2026 Task Venture Capital GmbH <hello@task.vc>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+25 -6
View File
@@ -1,18 +1,37 @@
{
"gitzone": {
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartwhois",
"description": "a package for dealing with whois requests",
"shortDescription": "execute WHOIS requests",
"npmPackagename": "@push.rocks/smartwhois",
"license": "MIT",
"projectDomain": "push.rocks"
"description": "A package for executing WHOIS requests and processing domain and IP information.",
"keywords": [
"WHOIS",
"domain information",
"IP lookup",
"TLD validation",
"DNSSEC status",
"HTTP status checker",
"TypeScript"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"npmci": {
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
},
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
"npmRegistryUrl": "registry.npmjs.org"
}
}
+34 -16
View File
@@ -1,32 +1,33 @@
{
"name": "@push.rocks/smartwhois",
"version": "1.0.16",
"version": "1.0.17",
"private": false,
"description": "a package for dealing with whois requests",
"description": "A package for executing WHOIS requests and processing domain and IP information.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Task Venture Capital GmbH",
"author": "Task Venture Capital GmbH <hello@task.vc>",
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web --allowimplicitany)",
"test": "tstest test/ --verbose",
"format": "gitzone format",
"build": "tsbuild --web",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.65",
"@git.zone/tsbundle": "^2.0.7",
"@git.zone/tsrun": "^1.2.39",
"@git.zone/tstest": "^1.0.74",
"@push.rocks/tapbundle": "^5.0.4",
"@types/node": "^18.15.11"
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsbundle": "^2.10.1",
"@git.zone/tsrun": "^2.0.3",
"@git.zone/tstest": "^3.6.3",
"@types/node": "^25.6.0",
"why-is-node-running": "^3.2.2"
},
"dependencies": {
"@push.rocks/smartrequest": "^2.0.15",
"@push.rocks/smartrequest": "^5.0.1",
"@push.rocks/smarturl": "^3.0.6",
"@tsclass/tsclass": "^4.0.38",
"tldts": "^6.0.3",
"whoiser": "^1.16.0"
"@tsclass/tsclass": "^9.5.1",
"tldts": "^7.0.29",
"whoiser": "^1.18.0"
},
"browserslist": [
"last 1 chrome versions"
@@ -40,7 +41,24 @@
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
".smartconfig.json",
"license",
"npmextra.json",
"readme.md"
]
],
"keywords": [
"WHOIS",
"domain information",
"IP lookup",
"TLD validation",
"DNSSEC status",
"HTTP status checker",
"TypeScript"
],
"homepage": "https://code.foss.global/push.rocks/smartwhois",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartwhois.git"
},
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
}
+7537 -4903
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
+105 -25
View File
@@ -1,37 +1,117 @@
# @push.rocks/smartwhois
a package for dealing with whois requests
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartwhois)
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartwhois)
* [github.com (source mirror)](https://github.com/push.rocks/smartwhois)
* [docs (typedoc)](https://push.rocks.gitlab.io/smartwhois/)
## Install
To install `@push.rocks/smartwhois`, you can use npm or yarn. First, open your terminal, then execute one of the following commands in your project directory:
## Status for master
```sh
npm install @push.rocks/smartwhois --save
```
or
```sh
yarn add @push.rocks/smartwhois
```
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartwhois/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartwhois/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartwhois)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartwhois)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartwhois)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartwhois)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartwhois)](https://lossless.cloud)
This will add `@push.rocks/smartwhois` to your project's dependencies.
## Usage
The `@push.rocks/smartwhois` module provides an intuitive TypeScript interface for dealing with WHOIS requests. It allows you to gather WHOIS information for domains, including registration details, registrar information, and more. For using this module, it is highly recommended to be familiar with TypeScript and async/await patterns for promise handling.
Use TypeScript for best in class intellisense
### Getting Started
First, ensure that you import the necessary classes from the module. The primary class you will interact with is `SmartWhois`.
## Contribution
```typescript
import { SmartWhois } from '@push.rocks/smartwhois';
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
// Create an instance of SmartWhois
const smartWhois = new SmartWhois();
```
For further information read the linked docs at the top of this readme.
### Fetching WHOIS Information for a Domain
The most common operation is to fetch WHOIS information for a given domain. This can easily be done using the `getWhoisForDomain` method, which returns detailed WHOIS information.
## Legal
> MIT licensed | **&copy;** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
```typescript
async function getDomainWhois() {
const domainInfo = await smartWhois.getWhoisForDomain('example.com');
console.log(domainInfo);
}
getDomainWhois();
```
### Determining Domain Delegation
To understand the structure of a domain or URL, you can use `getDomainDelegation`. This method provides insights into various components of a domain or URL, such as its TLD, domain name, etc.
```typescript
async function checkDomainDelegation() {
const delegationInfo = await smartWhois.getDomainDelegation('https://www.example.com/path');
console.log(delegationInfo);
}
checkDomainDelegation();
```
### Additional WHOIS Data
For some domains, additional WHOIS data beyond the basics might be useful. This includes HTTPS status, headers, and more. Retrieving additional data is straightforward:
```typescript
async function fetchAdditionalData() {
const additionalData = await smartWhois.getAdditionalWhoisDataForDomain('example.com');
console.log(additionalData);
}
fetchAdditionalData();
```
### Validating TLDs
When working with various top-level domains (TLDs), you might want to verify if a given TLD is valid. The `isValidTld` method helps check the validity of a TLD:
```typescript
async function isTldValid() {
const isValid = await smartWhois.isValidTld('.com');
console.log(`Is .com a valid TLD? ${isValid}`);
}
isTldValid();
```
### Handling Errors
When making requests, there is always a possibility of running into errors due to network issues, invalid domains, or other reasons. It's crucial to properly handle these cases:
```typescript
async function safelyGetWhois() {
try {
const whoisInfo = await smartWhois.getWhoisForDomain('nonexistentdomain.xyz');
console.log(whoisInfo);
} catch (error) {
console.error('Failed to fetch WHOIS info:', error);
}
}
safelyGetWhois();
```
### Integration with Other Systems
The retrieved WHOIS data can be easily integrated into other parts of your application or system. For instance, you could store the data in a database, use it to monitor domain registration changes, or create alerts for domain expiry dates.
### Advanced Usage
While the above examples cover the basics, `@push.rocks/smartwhois` offers much more. Explore the source code and TypeScript definitions to uncover additional functionality, such as parsing complex WHOIS server responses, handling internationalized domain names (IDNs), and more.
### Summary
`@push.rocks/smartwhois` is a powerful tool for querying WHOIS information, designed with modern development practices in mind. By leveraging TypeScript, it offers a robust and type-safe way to integrate WHOIS data into your applications, enriching your projects with valuable domain-related insights.
For further information and the latest updates, refer to the official documentation and GitHub repository.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
+5 -3
View File
@@ -1,4 +1,4 @@
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartwhois from '../ts/index.js';
let testSmartWhois: smartwhois.SmartWhois;
@@ -38,6 +38,8 @@ tap.test('should check for a valid tld', async () => {
const comIsValid = await testSmartWhois.isValidTld('.com');
console.log(comIsValid);
expect(comIsValid).toBeTrue();
})
});
tap.start();
export default tap.start({
throwOnError: true
});
+3 -3
View File
@@ -1,8 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartwhois',
version: '1.0.16',
description: 'a package for dealing with whois requests'
version: '1.0.17',
description: 'A package for executing WHOIS requests and processing domain and IP information.'
}
+51 -24
View File
@@ -37,6 +37,13 @@ export interface IWhoisInfo {
expiryDate: string;
}
export interface IAdditionalWhoisData {
httpStatus: number;
httpsStatus: number;
httpHeaders: unknown;
httpsHeaders: unknown;
}
export class SmartWhois {
/**
* can be used to prepare an input for the whois command
@@ -50,36 +57,38 @@ export class SmartWhois {
return {
fullUrl: smarturlInstance.toString(),
fullDomain: smarturlInstance.hostname,
domain: tldtsData.domain,
publicSuffix: tldtsData.publicSuffix,
subdomain: tldtsData.subdomain,
domainWithoutSuffix: tldtsData.domainWithoutSuffix,
isIcann: tldtsData.isIcann,
}
domain: tldtsData.domain ?? '',
publicSuffix: tldtsData.publicSuffix ?? '',
subdomain: tldtsData.subdomain ?? '',
domainWithoutSuffix: tldtsData.domainWithoutSuffix ?? '',
isIcann: tldtsData.isIcann ?? undefined,
};
}
public async getAdditionalWhoisDataForDomain(domainArg: string) {
public async getAdditionalWhoisDataForDomain(domainArg: string): Promise<IAdditionalWhoisData> {
if (domainArg.includes('//')) {
const parsedUrlResult = await this.getDomainDelegation(domainArg);
domainArg = parsedUrlResult.fullDomain;
}
// lets test http response
const httpResult = await plugins.smartrequest.safeGet(`http://${domainArg}/`);
const httpResult = await plugins.smartrequest.SmartRequest.create()
.url(`http://${domainArg}/`)
.get();
// lets test https response
const httpsResult = await plugins.smartrequest.safeGet(`https://${domainArg}/`);
const httpsResult = await plugins.smartrequest.SmartRequest.create()
.url(`https://${domainArg}/`)
.get();
return {
httpStatus: httpResult.statusCode,
httpsStatus: httpsResult.statusCode,
httpStatus: httpResult.status,
httpsStatus: httpsResult.status,
httpHeaders: httpResult.headers,
httpsHeaders: httpsResult.headers,
}
};
}
public async getWhoisForDomain(domainArg: string): Promise<IWhoisInfo> {
if (domainArg.includes('//')) {
const parsedUrlResult = await this.getDomainDelegation(domainArg);
@@ -87,21 +96,39 @@ export class SmartWhois {
}
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'];
const selectedWhoisInfo = whoisInfo[whoisServers[0]] as Record<string, unknown>;
const getStringField = (fieldName: string): string => {
const fieldValue = selectedWhoisInfo[fieldName];
return typeof fieldValue === 'string' ? fieldValue : '';
};
const registrar = getStringField('Registrar');
const registrarUrl = getStringField('Registrar URL');
const createdDate = getStringField('Created Date');
const updatedDate = getStringField('Updated Date');
const expiryDate = getStringField('Expiry Date');
const domainStatusRaw = selectedWhoisInfo['Domain Status'];
const domainStatusSource = Array.isArray(domainStatusRaw)
? domainStatusRaw
: typeof domainStatusRaw === 'string'
? [domainStatusRaw]
: [];
const domainStatus = domainStatusSource.map((statusArg) => String(statusArg).split(' ')[0]) as IWhoisInfo['domainStatus'];
const tldtsData = plugins.tldts.parse(domainArg);
return {
...tldtsData,
domain: tldtsData.domain ?? '',
domainWithoutSuffix: tldtsData.domainWithoutSuffix ?? '',
hostname: tldtsData.hostname ?? '',
isIcann: tldtsData.isIcann ?? false,
isIp: tldtsData.isIp ?? false,
isPrivate: tldtsData.isPrivate ?? false,
publicSuffix: tldtsData.publicSuffix ?? '',
subdomain: tldtsData.subdomain ?? '',
isRegistered: true,
domainStatus: selectedWhoisInfo['Domain Status'].map((statusArg: string) => statusArg.split(' ')[0]),
dnsSec: selectedWhoisInfo['DNSSEC'],
originalWhoisInfo: whoisInfo,
domainStatus,
dnsSec: getStringField('DNSSEC') as IWhoisInfo['dnsSec'],
originalWhoisInfo: whoisInfo as Record<string, unknown>,
whoisServers,
registrar,
registrarUrl,
+3 -3
View File
@@ -3,7 +3,7 @@ import * as tsclass from '@tsclass/tsclass';
export {
tsclass,
}
};
// pushrocks scope
import * as smarturl from '@push.rocks/smarturl';
@@ -12,7 +12,7 @@ import * as smartrequest from '@push.rocks/smartrequest';
export {
smarturl,
smartrequest,
}
};
// third party
import * as whoiser from 'whoiser';
@@ -21,4 +21,4 @@ import tldts from 'tldts';
export {
whoiser,
tldts,
}
};
+8 -4
View File
@@ -3,8 +3,12 @@
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": ["dist_*/**/*.d.ts"]
}