Compare commits

..

No commits in common. "master" and "v1.0.7" have entirely different histories.

13 changed files with 1053 additions and 2457 deletions

View File

@ -1,66 +0,0 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -1,124 +0,0 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

128
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,128 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
before_script:
- pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ====================
# security stage
# ====================
# ====================
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci command npm config set registry https://registry.npmjs.org
- npmci command pnpm audit --audit-level=high --prod
tags:
- lossless
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci command npm config set registry https://registry.npmjs.org
- npmci command pnpm audit --audit-level=high --dev
tags:
- lossless
- docker
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci node install stable
- npmci npm install
- npmci npm build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
stage: metadata
script:
- npmci node install stable
- npmci npm install
- npmci command npm run buildDocs
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

View File

@ -2,29 +2,17 @@
"gitzone": { "gitzone": {
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "code.foss.global", "githost": "gitlab.com",
"gitscope": "push.rocks", "gitscope": "pushrocks",
"gitrepo": "smartwhois", "gitrepo": "smartwhois",
"description": "A package for executing WHOIS requests and processing domain and IP information.", "description": "a package for dealing with whois requests",
"npmPackagename": "@push.rocks/smartwhois", "npmPackagename": "@pushrocks/smartwhois",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks", "projectDomain": "push.rocks"
"keywords": [
"WHOIS",
"domain information",
"IP lookup",
"TLD validation",
"DNSSEC status",
"HTTP status checker",
"TypeScript"
]
} }
}, },
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"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"
} }
} }

View File

@ -1,8 +1,8 @@
{ {
"name": "@push.rocks/smartwhois", "name": "@pushrocks/smartwhois",
"version": "1.0.16", "version": "1.0.7",
"private": false, "private": false,
"description": "A package for executing WHOIS requests and processing domain and IP information.", "description": "a package for dealing with whois requests",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module", "type": "module",
@ -11,20 +11,18 @@
"scripts": { "scripts": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web --allowimplicitany)", "build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc" "buildDocs": "(tsdoc)"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.1.65", "@gitzone/tsbuild": "^2.1.65",
"@git.zone/tsbundle": "^2.0.7", "@gitzone/tsbundle": "^2.0.7",
"@git.zone/tsrun": "^1.2.39", "@gitzone/tsdoc": "^1.1.12",
"@git.zone/tstest": "^1.0.74", "@gitzone/tsrun": "^1.2.39",
"@push.rocks/tapbundle": "^5.0.4", "@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.15.11" "@types/node": "^18.15.11"
}, },
"dependencies": { "dependencies": {
"@push.rocks/smartrequest": "^2.0.15",
"@push.rocks/smarturl": "^3.0.6",
"@tsclass/tsclass": "^4.0.38",
"tldts": "^6.0.3", "tldts": "^6.0.3",
"whoiser": "^1.16.0" "whoiser": "^1.16.0"
}, },
@ -42,19 +40,5 @@
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "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"
}
} }

2894
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@

132
readme.md
View File

@ -1,117 +1,37 @@
# @push.rocks/smartwhois # @pushrocks/smartwhois
a package for dealing with whois requests a package for dealing with whois requests
## Install ## Availabililty and Links
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: * [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartwhois)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartwhois)
* [github.com (source mirror)](https://github.com/pushrocks/smartwhois)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartwhois/)
```sh ## Status for master
npm install @push.rocks/smartwhois --save
```
or
```sh
yarn add @push.rocks/smartwhois
```
This will add `@push.rocks/smartwhois` to your project's dependencies. Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartwhois/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartwhois/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartwhois)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/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/@pushrocks/smartwhois)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartwhois)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartwhois)](https://lossless.cloud)
## Usage ## 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.
### Getting Started Use TypeScript for best in class intellisense
First, ensure that you import the necessary classes from the module. The primary class you will interact with is `SmartWhois`.
```typescript ## Contribution
import { SmartWhois } from '@push.rocks/smartwhois';
// Create an instance of 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). :)
const smartWhois = new SmartWhois();
```
### Fetching WHOIS Information for a Domain For further information read the linked docs at the top of this readme.
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.
```typescript ## Legal
async function getDomainWhois() { > MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
const domainInfo = await smartWhois.getWhoisForDomain('example.com'); | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
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.

View File

@ -1,4 +1,4 @@
import { expect, expectAsync, tap } from '@push.rocks/tapbundle'; import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
import * as smartwhois from '../ts/index.js'; import * as smartwhois from '../ts/index.js';
let testSmartWhois: smartwhois.SmartWhois; let testSmartWhois: smartwhois.SmartWhois;
@ -6,33 +6,12 @@ let testSmartWhois: smartwhois.SmartWhois;
tap.test('should create a valid instance of SmartWhois', async () => { tap.test('should create a valid instance of SmartWhois', async () => {
testSmartWhois = new smartwhois.SmartWhois(); testSmartWhois = new smartwhois.SmartWhois();
expect(testSmartWhois).toBeInstanceOf(smartwhois.SmartWhois); expect(testSmartWhois).toBeInstanceOf(smartwhois.SmartWhois);
}); })
tap.test('should get a parsed url result for whois', async () => {
const domainDelegation = await testSmartWhois.getDomainDelegation('https://coffee.link/understanding-gen-z/');
console.log(domainDelegation);
const parsedUrlResult2 = await testSmartWhois.getDomainDelegation('task.vc');
console.log(parsedUrlResult2);
});
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 () => { tap.test('should get whois info for domain', async () => {
const whoisInfo = await testSmartWhois.getWhoisForDomain('task.vc'); const whoisInfo = await testSmartWhois.getWhoisForDomain('task.vc');
console.log(whoisInfo); 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 () => { tap.test('should check for a valid tld', async () => {
const comIsValid = await testSmartWhois.isValidTld('.com'); const comIsValid = await testSmartWhois.isValidTld('.com');

View File

@ -2,7 +2,7 @@
* autocreated commitinfo by @pushrocks/commitinfo * autocreated commitinfo by @pushrocks/commitinfo
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartwhois', name: '@pushrocks/smartwhois',
version: '1.0.16', version: '1.0.7',
description: 'a package for dealing with whois requests' description: 'a package for dealing with whois requests'
} }

View File

@ -38,53 +38,7 @@ export interface IWhoisInfo {
} }
export class SmartWhois { export class SmartWhois {
/**
* can be used to prepare an input for the whois command
*/
public async getDomainDelegation(urlArg: string): Promise<plugins.tsclass.network.IDomainDelegation> {
if (!urlArg.includes('//')) {
urlArg = `https://${urlArg}`;
}
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,
domainWithoutSuffix: tldtsData.domainWithoutSuffix,
isIcann: tldtsData.isIcann,
}
}
public async getAdditionalWhoisDataForDomain(domainArg: string) {
if (domainArg.includes('//')) {
const parsedUrlResult = await this.getDomainDelegation(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> { public async getWhoisForDomain(domainArg: string): Promise<IWhoisInfo> {
if (domainArg.includes('//')) {
const parsedUrlResult = await this.getDomainDelegation(domainArg);
domainArg = parsedUrlResult.fullDomain;
}
const whoisInfo = await plugins.whoiser.domain(domainArg); const whoisInfo = await plugins.whoiser.domain(domainArg);
const whoisServers = Object.keys(whoisInfo); const whoisServers = Object.keys(whoisInfo);
const selectedWhoisInfo: any = whoisInfo[whoisServers[0]]; const selectedWhoisInfo: any = whoisInfo[whoisServers[0]];

View File

@ -1,19 +1,3 @@
// @tsclass scope
import * as tsclass from '@tsclass/tsclass';
export {
tsclass,
}
// pushrocks scope
import * as smarturl from '@push.rocks/smarturl';
import * as smartrequest from '@push.rocks/smartrequest';
export {
smarturl,
smartrequest,
}
// third party // third party
import * as whoiser from 'whoiser'; import * as whoiser from 'whoiser';
import tldts from 'tldts'; import tldts from 'tldts';

View File

@ -3,12 +3,8 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"useDefineForClassFields": false, "useDefineForClassFields": false,
"target": "ES2022", "target": "ES2022",
"module": "NodeNext", "module": "ES2022",
"moduleResolution": "NodeNext", "moduleResolution": "nodenext",
"esModuleInterop": true, "esModuleInterop": true
"verbatimModuleSyntax": true }
},
"exclude": [
"dist_*/**/*.d.ts"
]
} }