rdapper 0.5.0 → 0.7.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/README.md CHANGED
@@ -53,6 +53,29 @@ toRegistrableDomain("192.168.0.1"); // => null
53
53
  - `isRegistered(domain, options?) => Promise<boolean>`
54
54
  - `isAvailable(domain, options?) => Promise<boolean>`
55
55
 
56
+ ### CLI
57
+
58
+ For quick checks, a minimal CLI is included:
59
+
60
+ ```bash
61
+ npx rdapper example.com
62
+ echo "example.com" | npx rdapper
63
+ ```
64
+
65
+ ### Edge runtimes (e.g., Vercel Edge)
66
+
67
+ WHOIS requires a raw TCP connection over port 43 via `node:net`, which is not available on edge runtimes. This package lazily loads `node:net` only when the WHOIS code path runs. To use rdapper safely on edge:
68
+
69
+ - Prefer RDAP only:
70
+
71
+ ```ts
72
+ import { lookupDomain } from "rdapper";
73
+
74
+ const res = await lookupDomain("example.com", { rdapOnly: true });
75
+ ```
76
+
77
+ - If `rdapOnly` is omitted and the code path reaches WHOIS on edge, rdapper throws a clear runtime error indicating WHOIS is unsupported on edge and to run in Node or set `rdapOnly: true`.
78
+
56
79
  ### Options
57
80
 
58
81
  - `timeoutMs?: number` – Total timeout budget per network operation (default `15000`).
@@ -182,7 +205,7 @@ Project layout:
182
205
  - `src/whois/` – WHOIS TCP client, discovery/referral, normalization, exceptions
183
206
  - `src/lib/` – utilities for dates, text parsing, domain processing, async
184
207
  - `src/types.ts` – public types; `src/index.ts` re‑exports API and types
185
- - `cli.mjs` – local CLI helper for quick testing
208
+ - `bin/cli.js` – simple CLI for quick checks
186
209
 
187
210
  ## Caveats
188
211
 
package/bin/cli.js ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Quick informal command-line interface for rdapper
4
+ // Usage:
5
+ // npx rdapper example.com
6
+ // echo "example.com" | npx rdapper
7
+
8
+ import { createInterface } from "node:readline";
9
+ import { lookupDomain } from "../dist/index.js";
10
+
11
+ async function main() {
12
+ if (process.argv.length > 2) {
13
+ // URL(s) specified in the command arguments
14
+ console.log(
15
+ JSON.stringify(
16
+ await lookupDomain(process.argv[process.argv.length - 1]),
17
+ null,
18
+ 2,
19
+ ),
20
+ );
21
+ } else {
22
+ // No domain passed as argument, read from each line of stdin
23
+ const rlInterface = createInterface({
24
+ input: process.stdin,
25
+ });
26
+ rlInterface.on("line", async (line) => {
27
+ console.log(JSON.stringify(await lookupDomain(line), null, 2));
28
+ });
29
+ }
30
+ }
31
+
32
+ main();
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { parse } from "tldts";
2
- import { createConnection } from "node:net";
3
2
 
4
3
  //#region src/lib/domain.ts
5
4
  /**
@@ -562,9 +561,16 @@ async function whoisQuery(server, query, options) {
562
561
  text
563
562
  };
564
563
  }
565
- function queryTcp(host, port, query, options) {
564
+ async function queryTcp(host, port, query, options) {
565
+ let net;
566
+ try {
567
+ net = await import("net");
568
+ } catch {
569
+ net = null;
570
+ }
571
+ if (!net?.createConnection) throw new Error("WHOIS client is only available in Node.js runtimes; try setting `rdapOnly: true`.");
566
572
  return new Promise((resolve, reject) => {
567
- const socket = createConnection({
573
+ const socket = net.createConnection({
568
574
  host,
569
575
  port
570
576
  });
@@ -960,7 +966,11 @@ async function followWhoisReferrals(initialServer, domain, opts) {
960
966
  if (visited.has(normalized)) break;
961
967
  visited.add(normalized);
962
968
  try {
963
- current = await whoisQuery(next, domain, opts);
969
+ const res = await whoisQuery(next, domain, opts);
970
+ const registeredBefore = !isWhoisAvailable(current.text);
971
+ const registeredAfter = !isWhoisAvailable(res.text);
972
+ if (registeredBefore && !registeredAfter) break;
973
+ current = res;
964
974
  } catch {
965
975
  break;
966
976
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rdapper",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "description": "🎩 RDAP/WHOIS fetcher, parser, and normalizer for Node",
6
6
  "repository": {
@@ -15,15 +15,19 @@
15
15
  "email": "jake@jarv.is",
16
16
  "url": "https://jarv.is"
17
17
  },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
18
21
  "type": "module",
19
22
  "main": "./dist/index.js",
20
23
  "module": "./dist/index.js",
21
24
  "types": "./dist/index.d.ts",
25
+ "bin": "./bin/cli.js",
22
26
  "exports": {
23
27
  ".": {
24
- "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js",
25
29
  "import": "./dist/index.js",
26
- "default": "./dist/index.js"
30
+ "types": "./dist/index.d.ts"
27
31
  }
28
32
  },
29
33
  "files": [
@@ -32,6 +36,7 @@
32
36
  "scripts": {
33
37
  "build": "tsdown",
34
38
  "dev": "tsdown --watch",
39
+ "cli": "node bin/cli.js",
35
40
  "typecheck": "tsc --noEmit",
36
41
  "test": "vitest",
37
42
  "test:run": "vitest run",
@@ -43,7 +48,7 @@
43
48
  },
44
49
  "devDependencies": {
45
50
  "@biomejs/biome": "2.2.5",
46
- "@types/node": "24.7.1",
51
+ "@types/node": "24.7.2",
47
52
  "tsdown": "0.15.6",
48
53
  "typescript": "5.9.3",
49
54
  "vitest": "^3.2.4"