@cleandns/whois-rdap 1.0.18 → 1.0.20

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.js CHANGED
@@ -10,9 +10,9 @@ const eventMap = new Map([
10
10
  ["expiration", "expires"],
11
11
  ["expiration date", "expires"],
12
12
  ]);
13
- export async function whois(origDomain, options = { fetch: fetch }) {
13
+ export async function whois(origDomain, options = { fetch: fetch, thinOnly: false }) {
14
14
  var _a, _b, _c, _d, _e, _f;
15
- const fetch = options.fetch;
15
+ const _fetch = options.fetch || fetch;
16
16
  let domain = origDomain;
17
17
  let url = null;
18
18
  [domain, url] = await tldToRdap(origDomain);
@@ -32,7 +32,7 @@ export async function whois(origDomain, options = { fetch: fetch }) {
32
32
  }
33
33
  const thinRdap = `${url}/domain/${domain}`;
34
34
  // console.log(`fetching thin RDAP: ${thinRdap}`);
35
- let thinResponse = await fetch(thinRdap)
35
+ let thinResponse = await _fetch(thinRdap)
36
36
  .then((r) => r.json())
37
37
  .catch(() => null);
38
38
  if (thinResponse && !thinResponse.errorCode) {
@@ -48,9 +48,9 @@ export async function whois(origDomain, options = { fetch: fetch }) {
48
48
  link.rel === "related" &&
49
49
  link.type === "application/rdap+json")) === null || _d === void 0 ? void 0 : _d.href.replace("/domain/domain/", "/domain/");
50
50
  let thickResponse = null;
51
- if (thickRdap) {
51
+ if (!options.thinOnly && thickRdap) {
52
52
  // console.log(`fetching thick RDAP: ${thickRdap}`);
53
- thickResponse = await fetch(thickRdap)
53
+ thickResponse = await _fetch(thickRdap)
54
54
  .then((r) => r.json())
55
55
  .catch(() => null);
56
56
  if (thickResponse && !thickResponse.errorCode && !thickResponse.error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleandns/whois-rdap",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -15,9 +15,9 @@ const eventMap = new Map<string, WhoisTimestampFields>([
15
15
 
16
16
  export async function whois(
17
17
  origDomain: string,
18
- options: WhoisOptions = { fetch: fetch }
18
+ options: WhoisOptions = { fetch: fetch, thinOnly: false }
19
19
  ): Promise<WhoisResponse> {
20
- const fetch = options.fetch!;
20
+ const _fetch = options.fetch || fetch;
21
21
 
22
22
  let domain = origDomain;
23
23
  let url: string | null = null;
@@ -43,7 +43,7 @@ export async function whois(
43
43
  const thinRdap = `${url}/domain/${domain}`;
44
44
  // console.log(`fetching thin RDAP: ${thinRdap}`);
45
45
 
46
- let thinResponse = await fetch(thinRdap)
46
+ let thinResponse = await _fetch(thinRdap)
47
47
  .then((r) => r.json() as any)
48
48
  .catch(() => null);
49
49
  if (thinResponse && !thinResponse.errorCode) {
@@ -67,9 +67,9 @@ export async function whois(
67
67
 
68
68
  let thickResponse: any = null;
69
69
 
70
- if (thickRdap) {
70
+ if (!options.thinOnly && thickRdap) {
71
71
  // console.log(`fetching thick RDAP: ${thickRdap}`);
72
- thickResponse = await fetch(thickRdap)
72
+ thickResponse = await _fetch(thickRdap)
73
73
  .then((r) => r.json() as any)
74
74
  .catch(() => null);
75
75
  if (thickResponse && !thickResponse.errorCode && !thickResponse.error) {
package/whois.d.ts CHANGED
@@ -2,6 +2,7 @@ export type WhoisTimestampFields = "created" | "updated" | "expires";
2
2
 
3
3
  export type WhoisOptions = Partial<{
4
4
  fetch: typeof fetch;
5
+ thinOnly: boolean;
5
6
  }>;
6
7
 
7
8
  export type WhoisResponse = {