@cleandns/whois-rdap 1.0.27 → 1.0.29

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
@@ -66,8 +66,8 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
66
66
  }
67
67
  const registrars = [];
68
68
  const resellers = [];
69
- async function extractRegistrarsAndResellers(response, url) {
70
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
69
+ async function extractRegistrarsAndResellers(response, url, isThick) {
70
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
71
71
  for (const ent of [
72
72
  ...(response.entities || []),
73
73
  response.entity ? { events: response.events, ...response.entity } : null,
@@ -84,11 +84,11 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
84
84
  ? ent.publicIDs
85
85
  : [[ent.publicIDs]]));
86
86
  }
87
- const reg = ((_b = pubIds.find((id) => id.type === "PANDI Registrar ID")) === null || _b === void 0 ? void 0 : _b.Identifier) ||
88
- ((_c = pubIds.find((id) => id.type === "PANDI Registrar ID")) === null || _c === void 0 ? void 0 : _c.identifier) ||
89
- ((_d = pubIds.find((id) => id.type === "IANA Registrar ID")) === null || _d === void 0 ? void 0 : _d.Identifier) ||
90
- ((_e = pubIds.find((id) => id.type === "IANA Registrar ID")) === null || _e === void 0 ? void 0 : _e.identifier) ||
91
- pubIds.find((id) => id.type === "IANA Registrar ID");
87
+ const reg = ((_b = pubIds.find((id) => id.type === "PANDI Registrar ID")) === null || _b === void 0 ? void 0 : _b.Identifier)
88
+ || ((_c = pubIds.find((id) => id.type === "PANDI Registrar ID")) === null || _c === void 0 ? void 0 : _c.identifier)
89
+ || ((_d = pubIds.find((id) => id.type === "IANA Registrar ID")) === null || _d === void 0 ? void 0 : _d.Identifier)
90
+ || ((_e = pubIds.find((id) => id.type === "IANA Registrar ID")) === null || _e === void 0 ? void 0 : _e.identifier)
91
+ || pubIds.find((id) => id.type === "IANA Registrar ID");
92
92
  if (reg) {
93
93
  // console.log(ent.vcardArray);
94
94
  const id = typeof reg === 'object' ? 0 : reg;
@@ -116,7 +116,16 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
116
116
  .filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
117
117
  .map((e) => findInObject(e.vcardArray, (el) => Array.isArray(el) && el[0] === "email", (el) => el[3], ""))
118
118
  .filter(Boolean)) === null || _o === void 0 ? void 0 : _o[0]) || "";
119
- registrars.push({ id: 0, name: ent.vcardArray[1].find((el) => el[0] === 'fn')[3], email, events: ent.events || response.events || ent.enents || response.enents });
119
+ if (ent.handle && ent.handle.toString().match(/^\d+$/)) {
120
+ const id = ent.handle;
121
+ const name = (parseInt(id) == id
122
+ && ((_p = (await ianaIdToRegistrar(parseInt(id)))) === null || _p === void 0 ? void 0 : _p.name))
123
+ || findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], id);
124
+ registrars.push({ id, name, email, events: ent.events || response.events || ent.enents || response.enents });
125
+ }
126
+ else {
127
+ registrars.push({ id: ent.handle || 0, name: ent.vcardArray[1].find((el) => el[0] === 'fn')[3], email, events: ent.events || response.events || ent.enents || response.enents });
128
+ }
120
129
  }
121
130
  // handles .ar
122
131
  else if (ent.handle) {
@@ -124,19 +133,19 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
124
133
  }
125
134
  }
126
135
  if (domain.endsWith(".is") &&
127
- (((_p = ent.roles) === null || _p === void 0 ? void 0 : _p.includes("technical")) || ent.role === "technical")) {
136
+ (((_q = ent.roles) === null || _q === void 0 ? void 0 : _q.includes("technical")) || ent.role === "technical")) {
128
137
  const id = ent.handle;
129
138
  const name = (parseInt(id) == id
130
- && ((_q = (await ianaIdToRegistrar(parseInt(id)))) === null || _q === void 0 ? void 0 : _q.name))
139
+ && ((_r = (await ianaIdToRegistrar(parseInt(id)))) === null || _r === void 0 ? void 0 : _r.name))
131
140
  || findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], id);
132
- const email = ((_r = [ent, ...(ent.entities || [])]
141
+ const email = ((_s = [ent, ...(ent.entities || [])]
133
142
  .filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
134
143
  .map((e) => findInObject(e.vcardArray, (el) => Array.isArray(el) && el[0] === "email", (el) => el[3], ""))
135
- .filter(Boolean)) === null || _r === void 0 ? void 0 : _r[0]) || "";
144
+ .filter(Boolean)) === null || _s === void 0 ? void 0 : _s[0]) || "";
136
145
  const events = ent.events || response.events || ent.enents || response.enents;
137
146
  registrars.push({ id, name, email, events });
138
147
  }
139
- if ((((_s = ent.roles) === null || _s === void 0 ? void 0 : _s.includes("reseller")) || ent.role === "reseller") &&
148
+ if ((((_t = ent.roles) === null || _t === void 0 ? void 0 : _t.includes("reseller")) || ent.role === "reseller") &&
140
149
  ent.vcardArray) {
141
150
  // vcard objects can be unexpectedly and arbitrarily nested
142
151
  const name = findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], "");
@@ -145,10 +154,10 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
145
154
  }
146
155
  }
147
156
  if (thickResponse && !thickResponse.errorCode) {
148
- await extractRegistrarsAndResellers(thickResponse, thickRdap);
157
+ await extractRegistrarsAndResellers(thickResponse, thickRdap, true);
149
158
  }
150
159
  if (thinResponse && !thinResponse.errorCode) {
151
- await extractRegistrarsAndResellers(thinResponse, thinRdap);
160
+ await extractRegistrarsAndResellers(thinResponse, thinRdap, false);
152
161
  }
153
162
  response.found = true;
154
163
  // registrar
package/dist/port43.js CHANGED
@@ -68,7 +68,7 @@ export async function port43(actor) {
68
68
  if (!response.found) {
69
69
  return response;
70
70
  }
71
- console.log(port43response);
71
+ // console.log(port43response);
72
72
  if (port43response.match(/^%*\s+(NOT FOUND|No match|NO OBJECT FOUND|No entries found|No Data Found|Domain is available for registration|No information available|Status: free)\b/im)) {
73
73
  response.found = false;
74
74
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleandns/whois-rdap",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -87,7 +87,7 @@ export async function whois(
87
87
  const registrars: any[] = [];
88
88
  const resellers: any[] = [];
89
89
 
90
- async function extractRegistrarsAndResellers(response: any, url: string) {
90
+ async function extractRegistrarsAndResellers(response: any, url: string, isThick?: boolean) {
91
91
  for (const ent of [
92
92
  ...(response.entities || []),
93
93
  response.entity ? { events: response.events, ...response.entity } : null,
@@ -109,11 +109,12 @@ export async function whois(
109
109
  );
110
110
  }
111
111
  const reg =
112
- pubIds.find((id: any) => id.type === "PANDI Registrar ID")?.Identifier ||
113
- pubIds.find((id: any) => id.type === "PANDI Registrar ID")?.identifier ||
114
- pubIds.find((id: any) => id.type === "IANA Registrar ID")?.Identifier ||
115
- pubIds.find((id: any) => id.type === "IANA Registrar ID")?.identifier ||
116
- pubIds.find((id: any) => id.type === "IANA Registrar ID");
112
+ pubIds.find((id: any) => id.type === "PANDI Registrar ID")?.Identifier
113
+ || pubIds.find((id: any) => id.type === "PANDI Registrar ID")?.identifier
114
+ || pubIds.find((id: any) => id.type === "IANA Registrar ID")?.Identifier
115
+ || pubIds.find((id: any) => id.type === "IANA Registrar ID")?.identifier
116
+ || pubIds.find((id: any) => id.type === "IANA Registrar ID")
117
+ ;
117
118
 
118
119
  if (reg) {
119
120
  // console.log(ent.vcardArray);
@@ -148,36 +149,52 @@ export async function whois(
148
149
  // handles .ca
149
150
  else if (ent.vcardArray?.[1]?.[3]?.[3] === 'registrar') {
150
151
  const email =
151
- [ent, ...(ent.entities || [])]
152
- .filter((e) => e?.vcardArray)
153
- .map((e) =>
154
- findInObject(
155
- e.vcardArray,
156
- (el: any) => Array.isArray(el) && el[0] === "email",
157
- (el: any[]) => el[3],
158
- ""
152
+ [ent, ...(ent.entities || [])]
153
+ .filter((e) => e?.vcardArray)
154
+ .map((e) =>
155
+ findInObject(
156
+ e.vcardArray,
157
+ (el: any) => Array.isArray(el) && el[0] === "email",
158
+ (el: any[]) => el[3],
159
+ ""
160
+ )
159
161
  )
160
- )
161
- .filter(Boolean)?.[0] || "";
162
+ .filter(Boolean)?.[0] || "";
162
163
 
163
164
  registrars.push({ id: 0, name: ent.vcardArray[1][1][3], email, events: ent.events || response.events || ent.enents || response.enents });
164
165
  }
165
166
  // handles .si
166
167
  else if (ent.vcardArray?.[1].find((el: string[]) => el[0] === 'fn')) {
167
168
  const email =
168
- [ent, ...(ent.entities || [])]
169
- .filter((e) => e?.vcardArray)
170
- .map((e) =>
171
- findInObject(
172
- e.vcardArray,
173
- (el: any) => Array.isArray(el) && el[0] === "email",
174
- (el: any[]) => el[3],
175
- ""
169
+ [ent, ...(ent.entities || [])]
170
+ .filter((e) => e?.vcardArray)
171
+ .map((e) =>
172
+ findInObject(
173
+ e.vcardArray,
174
+ (el: any) => Array.isArray(el) && el[0] === "email",
175
+ (el: any[]) => el[3],
176
+ ""
177
+ )
176
178
  )
177
- )
178
- .filter(Boolean)?.[0] || "";
179
+ .filter(Boolean)?.[0] || "";
179
180
 
180
- registrars.push({ id: 0, name: ent.vcardArray[1].find((el: string[]) => el[0] === 'fn')[3], email, events: ent.events || response.events || ent.enents || response.enents });
181
+ if (ent.handle && ent.handle.toString().match(/^\d+$/)) {
182
+ const id = ent.handle;
183
+ const name =
184
+ (parseInt(id) == id
185
+ && (await ianaIdToRegistrar(parseInt(id)))?.name)
186
+ || findInObject(
187
+ ent.vcardArray,
188
+ (el: any) =>
189
+ Array.isArray(el) && (el[0] === "fn" || el[0] === "org"),
190
+ (el: any[]) => el[3],
191
+ id
192
+ );
193
+ registrars.push({ id, name, email, events: ent.events || response.events || ent.enents || response.enents });
194
+ }
195
+ else {
196
+ registrars.push({ id: ent.handle || 0, name: ent.vcardArray[1].find((el: string[]) => el[0] === 'fn')[3], email, events: ent.events || response.events || ent.enents || response.enents });
197
+ }
181
198
  }
182
199
  // handles .ar
183
200
  else if (ent.handle) {
@@ -236,10 +253,10 @@ export async function whois(
236
253
  }
237
254
 
238
255
  if (thickResponse && !thickResponse.errorCode) {
239
- await extractRegistrarsAndResellers(thickResponse, thickRdap);
256
+ await extractRegistrarsAndResellers(thickResponse, thickRdap, true);
240
257
  }
241
258
  if (thinResponse && !thinResponse.errorCode) {
242
- await extractRegistrarsAndResellers(thinResponse, thinRdap);
259
+ await extractRegistrarsAndResellers(thinResponse, thinRdap, false);
243
260
  }
244
261
 
245
262
  response.found = true;
package/src/port43.ts CHANGED
@@ -79,7 +79,7 @@ export async function port43(actor: string): Promise<WhoisResponse> {
79
79
  return response;
80
80
  }
81
81
 
82
- console.log(port43response);
82
+ // console.log(port43response);
83
83
 
84
84
  if (
85
85
  port43response.match(