rdapper 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +16 -2
- package/dist/index.js +17 -6
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { parse } from "tldts";
|
|
2
|
+
|
|
1
3
|
//#region src/types.d.ts
|
|
2
4
|
type LookupSource = "rdap" | "whois";
|
|
3
5
|
interface RegistrarInfo {
|
|
@@ -125,11 +127,23 @@ interface LookupResult {
|
|
|
125
127
|
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
126
128
|
//#endregion
|
|
127
129
|
//#region src/lib/domain.d.ts
|
|
130
|
+
type ParseOptions = Parameters<typeof parse>[1];
|
|
131
|
+
/**
|
|
132
|
+
* Parse a domain into its parts. Accepts options which are passed to tldts.parse().
|
|
133
|
+
* @see https://github.com/remusao/tldts/blob/master/packages/tldts-core/src/options.ts
|
|
134
|
+
*/
|
|
135
|
+
declare function getDomainParts(domain: string, opts?: ParseOptions): ReturnType<typeof parse>;
|
|
136
|
+
/** Get the TLD (ICANN-only public suffix) of a domain. */
|
|
137
|
+
declare function getDomainTld(domain: string, opts?: ParseOptions): string | null;
|
|
138
|
+
/**
|
|
139
|
+
* Basic domain validity check (hostname-like), not performing DNS or RDAP.
|
|
140
|
+
*/
|
|
141
|
+
declare function isLikelyDomain(value: string): boolean;
|
|
128
142
|
/**
|
|
129
143
|
* Normalize arbitrary input (domain or URL) to its registrable domain (eTLD+1).
|
|
130
144
|
* Returns null when the input is not a valid ICANN domain (e.g., invalid TLD, IPs).
|
|
131
145
|
*/
|
|
132
|
-
declare function toRegistrableDomain(input: string): string | null;
|
|
146
|
+
declare function toRegistrableDomain(input: string, opts?: ParseOptions): string | null;
|
|
133
147
|
//#endregion
|
|
134
148
|
//#region src/index.d.ts
|
|
135
149
|
/**
|
|
@@ -144,4 +158,4 @@ declare function isAvailable(domain: string, opts?: LookupOptions): Promise<bool
|
|
|
144
158
|
* Performs a lookup and resolves to a boolean. Rejects on lookup error. */
|
|
145
159
|
declare function isRegistered(domain: string, opts?: LookupOptions): Promise<boolean>;
|
|
146
160
|
//#endregion
|
|
147
|
-
export { Contact, DomainRecord, FetchLike, LookupOptions, LookupResult, LookupSource, Nameserver, RegistrarInfo, StatusEvent, isAvailable, isRegistered, lookupDomain, toRegistrableDomain };
|
|
161
|
+
export { Contact, DomainRecord, FetchLike, LookupOptions, LookupResult, LookupSource, Nameserver, RegistrarInfo, StatusEvent, getDomainParts, getDomainTld, isAvailable, isLikelyDomain, isRegistered, lookupDomain, toRegistrableDomain };
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,18 @@ import { parse } from "tldts";
|
|
|
2
2
|
|
|
3
3
|
//#region src/lib/domain.ts
|
|
4
4
|
/**
|
|
5
|
-
* Parse a domain into its parts.
|
|
5
|
+
* Parse a domain into its parts. Accepts options which are passed to tldts.parse().
|
|
6
|
+
* @see https://github.com/remusao/tldts/blob/master/packages/tldts-core/src/options.ts
|
|
6
7
|
*/
|
|
7
|
-
function getDomainParts(domain) {
|
|
8
|
-
return parse(domain);
|
|
8
|
+
function getDomainParts(domain, opts) {
|
|
9
|
+
return parse(domain, { ...opts });
|
|
10
|
+
}
|
|
11
|
+
/** Get the TLD (ICANN-only public suffix) of a domain. */
|
|
12
|
+
function getDomainTld(domain, opts) {
|
|
13
|
+
return getDomainParts(domain, {
|
|
14
|
+
allowPrivateDomains: false,
|
|
15
|
+
...opts
|
|
16
|
+
}).publicSuffix ?? null;
|
|
9
17
|
}
|
|
10
18
|
/**
|
|
11
19
|
* Basic domain validity check (hostname-like), not performing DNS or RDAP.
|
|
@@ -18,10 +26,13 @@ function isLikelyDomain(value) {
|
|
|
18
26
|
* Normalize arbitrary input (domain or URL) to its registrable domain (eTLD+1).
|
|
19
27
|
* Returns null when the input is not a valid ICANN domain (e.g., invalid TLD, IPs).
|
|
20
28
|
*/
|
|
21
|
-
function toRegistrableDomain(input) {
|
|
29
|
+
function toRegistrableDomain(input, opts) {
|
|
22
30
|
const raw = (input ?? "").trim();
|
|
23
31
|
if (raw === "") return null;
|
|
24
|
-
const result =
|
|
32
|
+
const result = getDomainParts(raw, {
|
|
33
|
+
allowPrivateDomains: false,
|
|
34
|
+
...opts
|
|
35
|
+
});
|
|
25
36
|
if (result.isIp) return null;
|
|
26
37
|
if (!result.isIcann) return null;
|
|
27
38
|
const domain = result.domain ?? "";
|
|
@@ -1056,4 +1067,4 @@ async function isRegistered(domain, opts) {
|
|
|
1056
1067
|
}
|
|
1057
1068
|
|
|
1058
1069
|
//#endregion
|
|
1059
|
-
export { isAvailable, isRegistered, lookupDomain, toRegistrableDomain };
|
|
1070
|
+
export { getDomainParts, getDomainTld, isAvailable, isLikelyDomain, isRegistered, lookupDomain, toRegistrableDomain };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rdapper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "🎩 RDAP/WHOIS fetcher, parser, and normalizer for Node",
|
|
6
6
|
"repository": {
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"tldts": "7.0.17"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@biomejs/biome": "2.2.
|
|
51
|
-
"@types/node": "24.
|
|
52
|
-
"tsdown": "0.15.
|
|
50
|
+
"@biomejs/biome": "2.2.6",
|
|
51
|
+
"@types/node": "24.8.1",
|
|
52
|
+
"tsdown": "0.15.7",
|
|
53
53
|
"typescript": "5.9.3",
|
|
54
54
|
"vitest": "^3.2.4"
|
|
55
55
|
},
|