@cleandns/whois-rdap 1.0.50 → 1.0.52
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 +50 -25
- package/package.json +1 -1
- package/src/index.ts +72 -12
package/dist/index.js
CHANGED
|
@@ -90,7 +90,7 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
|
|
|
90
90
|
const registrars = [];
|
|
91
91
|
const resellers = [];
|
|
92
92
|
async function extractRegistrarsAndResellers(response, url, isThick) {
|
|
93
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
93
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
94
94
|
for (const ent of [
|
|
95
95
|
...(response.entities || []),
|
|
96
96
|
response.entity ? { events: response.events, ...response.entity } : null,
|
|
@@ -113,64 +113,81 @@ export async function whois(origDomain, options = { fetch: fetch, thinOnly: fals
|
|
|
113
113
|
|| ((_e = pubIds.find((id) => id.type === "IANA Registrar ID")) === null || _e === void 0 ? void 0 : _e.identifier)
|
|
114
114
|
|| ((_f = pubIds.find((id) => id.type === "IANA RegistrarID")) === null || _f === void 0 ? void 0 : _f.Identifier)
|
|
115
115
|
|| ((_g = pubIds.find((id) => id.type === "IANA RegistrarID")) === null || _g === void 0 ? void 0 : _g.identifier)
|
|
116
|
+
|| ((_h = pubIds.find((id) => id.type === "Registry Identifier")) === null || _h === void 0 ? void 0 : _h.identifier)
|
|
116
117
|
|| pubIds.find((id) => id.type === "IANA Registrar ID");
|
|
117
118
|
if (reg) {
|
|
118
119
|
// console.log(ent.vcardArray);
|
|
119
120
|
const id = typeof reg === 'object' ? 0 : reg;
|
|
120
121
|
const name = (parseInt(id) == id
|
|
121
|
-
&& ((
|
|
122
|
+
&& ((_j = (await ianaIdToRegistrar(parseInt(id)))) === null || _j === void 0 ? void 0 : _j.name))
|
|
122
123
|
|| findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], reg);
|
|
123
|
-
const email = ((
|
|
124
|
+
const email = ((_k = [ent, ...(ent.entities || [])]
|
|
124
125
|
.filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
|
|
125
126
|
.map((e) => findInObject(e.vcardArray, (el) => Array.isArray(el) && el[0] === "email", (el) => el[3], ""))
|
|
126
|
-
.filter(Boolean)) === null ||
|
|
127
|
+
.filter(Boolean)) === null || _k === void 0 ? void 0 : _k[0]) || "";
|
|
128
|
+
const abuseEmail = ((_l = [ent, ...(ent.entities || [])]
|
|
129
|
+
.filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
|
|
130
|
+
.map((e) => findInObject(e.vcardArray, (el) => { var _a; return Array.isArray(el) && ((_a = e.roles) === null || _a === void 0 ? void 0 : _a.includes("abuse")) && el[0] === "email"; }, (el) => el[3], ""))
|
|
131
|
+
.filter(Boolean)) === null || _l === void 0 ? void 0 : _l[0]) || "";
|
|
127
132
|
const events = ent.events || response.events || ent.enents || response.enents;
|
|
128
|
-
registrars.push({ id, name, email, events });
|
|
133
|
+
registrars.push({ id, name, email, abuseEmail, events });
|
|
129
134
|
}
|
|
130
135
|
// handles .ca
|
|
131
|
-
else if (((
|
|
132
|
-
const email = ((
|
|
136
|
+
else if (((_p = (_o = (_m = ent.vcardArray) === null || _m === void 0 ? void 0 : _m[1]) === null || _o === void 0 ? void 0 : _o[3]) === null || _p === void 0 ? void 0 : _p[3]) === 'registrar') {
|
|
137
|
+
const email = ((_q = [ent, ...(ent.entities || [])]
|
|
133
138
|
.filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
|
|
134
139
|
.map((e) => findInObject(e.vcardArray, (el) => Array.isArray(el) && el[0] === "email", (el) => el[3], ""))
|
|
135
|
-
.filter(Boolean)) === null ||
|
|
136
|
-
|
|
140
|
+
.filter(Boolean)) === null || _q === void 0 ? void 0 : _q[0]) || "";
|
|
141
|
+
const abuseEmail = ((_r = [ent, ...(ent.entities || [])]
|
|
142
|
+
.filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
|
|
143
|
+
.map((e) => findInObject(e.vcardArray, (el) => { var _a; return Array.isArray(el) && ((_a = e.roles) === null || _a === void 0 ? void 0 : _a.includes("abuse")) && el[0] === "email"; }, (el) => el[3], ""))
|
|
144
|
+
.filter(Boolean)) === null || _r === void 0 ? void 0 : _r[0]) || "";
|
|
145
|
+
registrars.push({ id: 0, name: ent.vcardArray[1][1][3], email, abuseEmail, events: ent.events || response.events || ent.enents || response.enents });
|
|
137
146
|
}
|
|
138
147
|
// handles .si
|
|
139
148
|
else if (ent.vcardArray && ent.vcardArray[1] && ent.vcardArray[1].find((el) => el[0] === 'fn')) {
|
|
140
|
-
const email = ((
|
|
149
|
+
const email = ((_s = [ent, ...(ent.entities || [])]
|
|
141
150
|
.filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
|
|
142
151
|
.map((e) => findInObject(e.vcardArray, (el) => Array.isArray(el) && el[0] === "email", (el) => el[3], ""))
|
|
143
|
-
.filter(Boolean)) === null ||
|
|
152
|
+
.filter(Boolean)) === null || _s === void 0 ? void 0 : _s[0]) || "";
|
|
153
|
+
const abuseEmail = ((_t = [ent, ...(ent.entities || [])]
|
|
154
|
+
.filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
|
|
155
|
+
.map((e) => findInObject(e.vcardArray, (el) => { var _a; return Array.isArray(el) && ((_a = e.roles) === null || _a === void 0 ? void 0 : _a.includes("abuse")) && el[0] === "email"; }, (el) => el[3], ""))
|
|
156
|
+
.filter(Boolean)) === null || _t === void 0 ? void 0 : _t[0]) || "";
|
|
144
157
|
if (ent.handle && ent.handle.toString().match(/^\d+$/)) {
|
|
145
158
|
const id = ent.handle;
|
|
146
159
|
const name = (parseInt(id) == id
|
|
147
|
-
&& ((
|
|
160
|
+
&& ((_u = (await ianaIdToRegistrar(parseInt(id)))) === null || _u === void 0 ? void 0 : _u.name))
|
|
148
161
|
|| findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], id);
|
|
149
|
-
registrars.push({ id, name, email, events: ent.events || response.events || ent.enents || response.enents });
|
|
162
|
+
registrars.push({ id, name, email, abuseEmail, events: ent.events || response.events || ent.enents || response.enents });
|
|
150
163
|
}
|
|
151
164
|
else {
|
|
152
|
-
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 });
|
|
165
|
+
registrars.push({ id: ent.handle || 0, name: ent.vcardArray[1].find((el) => el[0] === 'fn')[3], email, abuseEmail, events: ent.events || response.events || ent.enents || response.enents });
|
|
153
166
|
}
|
|
154
167
|
}
|
|
155
168
|
// handles .ar
|
|
156
169
|
else if (ent.handle) {
|
|
157
|
-
registrars.push({ id: 0, name: ent.handle, email: '', events: ent.events || response.events || ent.enents || response.enents });
|
|
170
|
+
registrars.push({ id: 0, name: ent.handle, email: '', abuseEmail: '', events: ent.events || response.events || ent.enents || response.enents });
|
|
158
171
|
}
|
|
159
172
|
}
|
|
160
173
|
if (domain.endsWith(".is") &&
|
|
161
|
-
(((
|
|
174
|
+
(((_v = ent.roles) === null || _v === void 0 ? void 0 : _v.includes("technical")) || ent.role === "technical")) {
|
|
162
175
|
const id = ent.handle;
|
|
163
176
|
const name = (parseInt(id) == id
|
|
164
|
-
&& ((
|
|
177
|
+
&& ((_w = (await ianaIdToRegistrar(parseInt(id)))) === null || _w === void 0 ? void 0 : _w.name))
|
|
165
178
|
|| findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], id);
|
|
166
|
-
const email = ((
|
|
179
|
+
const email = ((_x = [ent, ...(ent.entities || [])]
|
|
167
180
|
.filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
|
|
168
181
|
.map((e) => findInObject(e.vcardArray, (el) => Array.isArray(el) && el[0] === "email", (el) => el[3], ""))
|
|
169
|
-
.filter(Boolean)) === null ||
|
|
182
|
+
.filter(Boolean)) === null || _x === void 0 ? void 0 : _x[0]) || "";
|
|
183
|
+
const abuseEmail = ((_y = [ent, ...(ent.entities || [])]
|
|
184
|
+
.filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
|
|
185
|
+
.map((e) => findInObject(e.vcardArray, (el) => { var _a; return Array.isArray(el) && ((_a = e.roles) === null || _a === void 0 ? void 0 : _a.includes("abuse")) && el[0] === "email"; }, (el) => el[3], ""))
|
|
186
|
+
.filter(Boolean)) === null || _y === void 0 ? void 0 : _y[0]) || "";
|
|
170
187
|
const events = ent.events || response.events || ent.enents || response.enents;
|
|
171
|
-
registrars.push({ id, name, email, events });
|
|
188
|
+
registrars.push({ id, name, email, abuseEmail, events });
|
|
172
189
|
}
|
|
173
|
-
if ((((
|
|
190
|
+
if ((((_z = ent.roles) === null || _z === void 0 ? void 0 : _z.includes("reseller")) || ent.role === "reseller") &&
|
|
174
191
|
ent.vcardArray) {
|
|
175
192
|
// vcard objects can be unexpectedly and arbitrarily nested
|
|
176
193
|
const name = findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], "");
|
|
@@ -262,10 +279,18 @@ function findTimestamps(values) {
|
|
|
262
279
|
events = Object.values(values);
|
|
263
280
|
}
|
|
264
281
|
for (const [event, field] of eventMap) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
282
|
+
events.find((ev) => {
|
|
283
|
+
var _a;
|
|
284
|
+
const isMatch = ((_a = ev === null || ev === void 0 ? void 0 : ev.eventAction) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === event && ev.eventDate;
|
|
285
|
+
if (isMatch) {
|
|
286
|
+
const d = new Date(ev.eventDate.toString().replace(/\+0000Z$/, "Z"));
|
|
287
|
+
// console.log(field, ev.eventDate, d);
|
|
288
|
+
if (!isNaN(d.valueOf())) {
|
|
289
|
+
ts[field] = d;
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
});
|
|
269
294
|
}
|
|
270
295
|
return ts;
|
|
271
296
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -70,7 +70,7 @@ export async function whois(
|
|
|
70
70
|
console.warn(`thin RDAP lookup failure: ${error.message}`);
|
|
71
71
|
return null;
|
|
72
72
|
});
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
if (thinResponse && !thinResponse.errorCode) {
|
|
75
75
|
} else if (!options.server) {
|
|
76
76
|
return response;
|
|
@@ -140,6 +140,7 @@ export async function whois(
|
|
|
140
140
|
|| pubIds.find((id: any) => id.type === "IANA Registrar ID")?.identifier
|
|
141
141
|
|| pubIds.find((id: any) => id.type === "IANA RegistrarID")?.Identifier
|
|
142
142
|
|| pubIds.find((id: any) => id.type === "IANA RegistrarID")?.identifier
|
|
143
|
+
|| pubIds.find((id: any) => id.type === "Registry Identifier")?.identifier
|
|
143
144
|
|| pubIds.find((id: any) => id.type === "IANA Registrar ID")
|
|
144
145
|
;
|
|
145
146
|
|
|
@@ -169,9 +170,22 @@ export async function whois(
|
|
|
169
170
|
)
|
|
170
171
|
.filter(Boolean)?.[0] || "";
|
|
171
172
|
|
|
173
|
+
const abuseEmail =
|
|
174
|
+
[ent, ...(ent.entities || [])]
|
|
175
|
+
.filter((e) => e?.vcardArray)
|
|
176
|
+
.map((e) =>
|
|
177
|
+
findInObject(
|
|
178
|
+
e.vcardArray,
|
|
179
|
+
(el: any) => Array.isArray(el) && e.roles?.includes("abuse") && el[0] === "email",
|
|
180
|
+
(el: any[]) => el[3],
|
|
181
|
+
""
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
.filter(Boolean)?.[0] || "";
|
|
185
|
+
|
|
172
186
|
const events =
|
|
173
187
|
ent.events || response.events || ent.enents || response.enents;
|
|
174
|
-
registrars.push({ id, name, email, events });
|
|
188
|
+
registrars.push({ id, name, email, abuseEmail, events });
|
|
175
189
|
}
|
|
176
190
|
// handles .ca
|
|
177
191
|
else if (ent.vcardArray?.[1]?.[3]?.[3] === 'registrar') {
|
|
@@ -188,7 +202,20 @@ export async function whois(
|
|
|
188
202
|
)
|
|
189
203
|
.filter(Boolean)?.[0] || "";
|
|
190
204
|
|
|
191
|
-
|
|
205
|
+
const abuseEmail =
|
|
206
|
+
[ent, ...(ent.entities || [])]
|
|
207
|
+
.filter((e) => e?.vcardArray)
|
|
208
|
+
.map((e) =>
|
|
209
|
+
findInObject(
|
|
210
|
+
e.vcardArray,
|
|
211
|
+
(el: any) => Array.isArray(el) && e.roles?.includes("abuse") && el[0] === "email",
|
|
212
|
+
(el: any[]) => el[3],
|
|
213
|
+
""
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
.filter(Boolean)?.[0] || "";
|
|
217
|
+
|
|
218
|
+
registrars.push({ id: 0, name: ent.vcardArray[1][1][3], email, abuseEmail, events: ent.events || response.events || ent.enents || response.enents });
|
|
192
219
|
}
|
|
193
220
|
// handles .si
|
|
194
221
|
else if (ent.vcardArray && ent.vcardArray[1] && ent.vcardArray[1].find((el: string[]) => el[0] === 'fn')) {
|
|
@@ -205,6 +232,19 @@ export async function whois(
|
|
|
205
232
|
)
|
|
206
233
|
.filter(Boolean)?.[0] || "";
|
|
207
234
|
|
|
235
|
+
const abuseEmail =
|
|
236
|
+
[ent, ...(ent.entities || [])]
|
|
237
|
+
.filter((e) => e?.vcardArray)
|
|
238
|
+
.map((e) =>
|
|
239
|
+
findInObject(
|
|
240
|
+
e.vcardArray,
|
|
241
|
+
(el: any) => Array.isArray(el) && e.roles?.includes("abuse") && el[0] === "email",
|
|
242
|
+
(el: any[]) => el[3],
|
|
243
|
+
""
|
|
244
|
+
)
|
|
245
|
+
)
|
|
246
|
+
.filter(Boolean)?.[0] || "";
|
|
247
|
+
|
|
208
248
|
if (ent.handle && ent.handle.toString().match(/^\d+$/)) {
|
|
209
249
|
const id = ent.handle;
|
|
210
250
|
const name =
|
|
@@ -217,15 +257,15 @@ export async function whois(
|
|
|
217
257
|
(el: any[]) => el[3],
|
|
218
258
|
id
|
|
219
259
|
);
|
|
220
|
-
registrars.push({ id, name, email, events: ent.events || response.events || ent.enents || response.enents });
|
|
260
|
+
registrars.push({ id, name, email, abuseEmail, events: ent.events || response.events || ent.enents || response.enents });
|
|
221
261
|
}
|
|
222
262
|
else {
|
|
223
|
-
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 });
|
|
263
|
+
registrars.push({ id: ent.handle || 0, name: ent.vcardArray[1].find((el: string[]) => el[0] === 'fn')[3], email, abuseEmail, events: ent.events || response.events || ent.enents || response.enents });
|
|
224
264
|
}
|
|
225
265
|
}
|
|
226
266
|
// handles .ar
|
|
227
267
|
else if (ent.handle) {
|
|
228
|
-
registrars.push({ id: 0, name: ent.handle, email: '', events: ent.events || response.events || ent.enents || response.enents });
|
|
268
|
+
registrars.push({ id: 0, name: ent.handle, email: '', abuseEmail: '', events: ent.events || response.events || ent.enents || response.enents });
|
|
229
269
|
}
|
|
230
270
|
|
|
231
271
|
}
|
|
@@ -258,9 +298,22 @@ export async function whois(
|
|
|
258
298
|
)
|
|
259
299
|
.filter(Boolean)?.[0] || "";
|
|
260
300
|
|
|
301
|
+
const abuseEmail =
|
|
302
|
+
[ent, ...(ent.entities || [])]
|
|
303
|
+
.filter((e) => e?.vcardArray)
|
|
304
|
+
.map((e) =>
|
|
305
|
+
findInObject(
|
|
306
|
+
e.vcardArray,
|
|
307
|
+
(el: any) => Array.isArray(el) && e.roles?.includes("abuse") && el[0] === "email",
|
|
308
|
+
(el: any[]) => el[3],
|
|
309
|
+
""
|
|
310
|
+
)
|
|
311
|
+
)
|
|
312
|
+
.filter(Boolean)?.[0] || "";
|
|
313
|
+
|
|
261
314
|
const events =
|
|
262
315
|
ent.events || response.events || ent.enents || response.enents;
|
|
263
|
-
registrars.push({ id, name, email, events });
|
|
316
|
+
registrars.push({ id, name, email, abuseEmail, events });
|
|
264
317
|
}
|
|
265
318
|
|
|
266
319
|
if (
|
|
@@ -385,12 +438,19 @@ function findTimestamps(values: any[]) {
|
|
|
385
438
|
}
|
|
386
439
|
|
|
387
440
|
for (const [event, field] of eventMap) {
|
|
388
|
-
|
|
389
|
-
(ev: any) =>
|
|
441
|
+
events.find(
|
|
442
|
+
(ev: any) => {
|
|
443
|
+
const isMatch = ev?.eventAction?.toLocaleLowerCase() === event && ev.eventDate;
|
|
444
|
+
if (isMatch) {
|
|
445
|
+
const d = new Date(ev.eventDate.toString().replace(/\+0000Z$/, "Z"));
|
|
446
|
+
// console.log(field, ev.eventDate, d);
|
|
447
|
+
if (!isNaN(d.valueOf())) {
|
|
448
|
+
ts[field] = d;
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
390
453
|
);
|
|
391
|
-
if (date?.eventDate) {
|
|
392
|
-
ts[field] = new Date(date.eventDate.toString().replace(/\+0000Z$/, "Z"));
|
|
393
|
-
}
|
|
394
454
|
}
|
|
395
455
|
|
|
396
456
|
return ts;
|