fix: check more whois data
Deploy / Build (push) Successful in 9m32s
Lint / ESLint (push) Successful in 6m40s
Lint / Oxlint (push) Successful in 5m0s
Lint / TypeScript (push) Successful in 5m24s
Deploy / Deploy to Stapler (push) Successful in 5m52s

This commit is contained in:
2026-06-16 11:42:00 +02:00
parent 98e3ecd76e
commit 98f937e9de
2 changed files with 63 additions and 7 deletions
+30 -7
View File
@@ -1,15 +1,38 @@
import type {
WhoIsResponse,
WhoIsData,
WhoIsEvent,
WhoIsIpAddresses,
} from "@/types";
function checkEvents(events: WhoIsEvent[]): boolean {
for (const event of events) {
if (event.eventAction === "registration" && event.eventDate === "") {
return true;
}
}
return false;
}
function checkIpAddresses(ipAddresses: WhoIsIpAddresses): boolean {
return ipAddresses.v4.length === 0 && ipAddresses.v6.length === 0;
}
function checkWhoIsData(data: WhoIsData): boolean {
return (
checkEvents(data.events) &&
checkIpAddresses(data.ipAddresses) &&
data.nameservers.length === 0
);
}
export async function isDomainAvailable(domain: string): Promise<boolean> { export async function isDomainAvailable(domain: string): Promise<boolean> {
try { try {
const response = await fetch( const response = await fetch(
`https://whois.klemek.fr/api/lookup/${domain}`, `https://whois.klemek.fr/api/lookup/${domain}`,
); );
const content = await response.json(); const content: WhoIsResponse = await response.json();
for (const event of content?.data?.events ?? []) { return checkWhoIsData(content.data);
if (event?.eventAction === "registration" && event?.eventDate === "") {
return true;
}
}
return false;
} catch { } catch {
return false; return false;
} }
+33
View File
@@ -0,0 +1,33 @@
export interface WhoIsResponse {
type: string;
data: WhoIsData;
}
export interface WhoIsData {
ldhName: string;
handle: string;
status: string[];
ipAddresses: WhoIsIpAddresses;
events: WhoIsEvent[];
nameservers: WhoIsNameserver[];
entities: WhoIsEntity[];
}
export interface WhoIsIpAddresses {
v4: string[];
v6: string[];
}
export interface WhoIsEvent {
eventAction: string;
eventDate: string;
}
export interface WhoIsNameserver {
ldhName: string;
}
export interface WhoIsEntity {
roles: string[];
vcardArray: [string, [string, object, string, string][]];
}