@cleandns/whois-rdap 1.0.13 → 1.0.14

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
@@ -65,7 +65,7 @@ export async function whois(domain, options = { fetch: fetch }) {
65
65
  const registrars = [];
66
66
  const resellers = [];
67
67
  async function extractRegistrarsAndResellers(response, url) {
68
- var _a, _b, _c, _d, _e, _f, _g;
68
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
69
69
  for (const ent of [
70
70
  ...(response.entities || []),
71
71
  response.entity ? { events: response.events, ...response.entity } : null,
@@ -91,11 +91,28 @@ export async function whois(domain, options = { fetch: fetch }) {
91
91
  const name = parseInt(id) == id
92
92
  ? (_f = (await ianaIdToRegistrar(parseInt(id)))) === null || _f === void 0 ? void 0 : _f.name
93
93
  : findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], reg);
94
+ const email = ((_g = [ent, ...(ent.entities || [])]
95
+ .filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
96
+ .map((e) => findInObject(e.vcardArray, (el) => Array.isArray(el) && el[0] === "email", (el) => el[3], ""))
97
+ .filter(Boolean)) === null || _g === void 0 ? void 0 : _g[0]) || "";
94
98
  const events = ent.events || response.events || ent.enents || response.enents;
95
- registrars.push({ id, name, events });
99
+ registrars.push({ id, name, email, events });
96
100
  }
97
101
  }
98
- if ((((_g = ent.roles) === null || _g === void 0 ? void 0 : _g.includes("reseller")) || ent.role === "reseller") &&
102
+ if (domain.endsWith(".is") &&
103
+ (((_h = ent.roles) === null || _h === void 0 ? void 0 : _h.includes("technical")) || ent.role === "technical")) {
104
+ const id = ent.handle;
105
+ const name = parseInt(id) == id
106
+ ? (_j = (await ianaIdToRegistrar(parseInt(id)))) === null || _j === void 0 ? void 0 : _j.name
107
+ : findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], id);
108
+ const email = ((_k = [ent, ...(ent.entities || [])]
109
+ .filter((e) => e === null || e === void 0 ? void 0 : e.vcardArray)
110
+ .map((e) => findInObject(e.vcardArray, (el) => Array.isArray(el) && el[0] === "email", (el) => el[3], ""))
111
+ .filter(Boolean)) === null || _k === void 0 ? void 0 : _k[0]) || "";
112
+ const events = ent.events || response.events || ent.enents || response.enents;
113
+ registrars.push({ id, name, email, events });
114
+ }
115
+ if ((((_l = ent.roles) === null || _l === void 0 ? void 0 : _l.includes("reseller")) || ent.role === "reseller") &&
99
116
  ent.vcardArray) {
100
117
  // vcard objects can be unexpectedly and arbitrarily nested
101
118
  const name = findInObject(ent.vcardArray, (el) => Array.isArray(el) && (el[0] === "fn" || el[0] === "org"), (el) => el[3], "");
@@ -113,8 +130,12 @@ export async function whois(domain, options = { fetch: fetch }) {
113
130
  // registrar
114
131
  const { events, ...registrar } = registrars.sort((a, b) => {
115
132
  var _a, _b;
116
- const aDate = (((_a = a.events.find((ev) => ev.eventAction === "registration")) === null || _a === void 0 ? void 0 : _a.eventDate) || 0).toString().replace(/\+0000Z$/, 'Z');
117
- const bDate = (((_b = b.events.find((ev) => ev.eventAction === "registration")) === null || _b === void 0 ? void 0 : _b.eventDate) || 0).toString().replace(/\+0000Z$/, 'Z');
133
+ const aDate = (((_a = a.events.find((ev) => ev.eventAction === "registration")) === null || _a === void 0 ? void 0 : _a.eventDate) || 0)
134
+ .toString()
135
+ .replace(/\+0000Z$/, "Z");
136
+ const bDate = (((_b = b.events.find((ev) => ev.eventAction === "registration")) === null || _b === void 0 ? void 0 : _b.eventDate) || 0)
137
+ .toString()
138
+ .replace(/\+0000Z$/, "Z");
118
139
  return new Date(bDate).valueOf() - new Date(aDate).valueOf();
119
140
  })[0] || { id: 0, name: "" };
120
141
  response.registrar = registrar;
@@ -126,7 +147,10 @@ export async function whois(domain, options = { fetch: fetch }) {
126
147
  // nameservers
127
148
  response.nameservers = findNameservers((thickResponse === null || thickResponse === void 0 ? void 0 : thickResponse.nameservers) || (thinResponse === null || thinResponse === void 0 ? void 0 : thinResponse.nameservers) || []);
128
149
  // ts
129
- response.ts = findTimestamps([...((thickResponse === null || thickResponse === void 0 ? void 0 : thickResponse.events) || []), ...((thinResponse === null || thinResponse === void 0 ? void 0 : thinResponse.events) || [])]);
150
+ response.ts = findTimestamps([
151
+ ...((thickResponse === null || thickResponse === void 0 ? void 0 : thickResponse.events) || []),
152
+ ...((thinResponse === null || thinResponse === void 0 ? void 0 : thinResponse.events) || []),
153
+ ]);
130
154
  return response;
131
155
  }
132
156
  function findStatus(statuses, domain) {
@@ -168,7 +192,7 @@ function findTimestamps(values) {
168
192
  for (const [event, field] of eventMap) {
169
193
  const date = events.find((ev) => { var _a; return ((_a = ev === null || ev === void 0 ? void 0 : ev.eventAction) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === event; });
170
194
  if (date === null || date === void 0 ? void 0 : date.eventDate) {
171
- ts[field] = new Date(date.eventDate.toString().replace(/\+0000Z$/, 'Z'));
195
+ ts[field] = new Date(date.eventDate.toString().replace(/\+0000Z$/, "Z"));
172
196
  }
173
197
  }
174
198
  return ts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleandns/whois-rdap",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -13,7 +13,10 @@ const eventMap = new Map<string, WhoisTimestampFields>([
13
13
  ["expiration date", "expires"],
14
14
  ]);
15
15
 
16
- export async function whois(domain: string, options: WhoisOptions = { fetch: fetch }): Promise<WhoisResponse> {
16
+ export async function whois(
17
+ domain: string,
18
+ options: WhoisOptions = { fetch: fetch }
19
+ ): Promise<WhoisResponse> {
17
20
  const fetch = options.fetch!;
18
21
 
19
22
  let url: string | null = null;
@@ -123,12 +126,58 @@ export async function whois(domain: string, options: WhoisOptions = { fetch: fet
123
126
  (el: any[]) => el[3],
124
127
  reg
125
128
  );
129
+ const email =
130
+ [ent, ...(ent.entities || [])]
131
+ .filter((e) => e?.vcardArray)
132
+ .map((e) =>
133
+ findInObject(
134
+ e.vcardArray,
135
+ (el: any) => Array.isArray(el) && el[0] === "email",
136
+ (el: any[]) => el[3],
137
+ ""
138
+ )
139
+ )
140
+ .filter(Boolean)?.[0] || "";
141
+
126
142
  const events =
127
143
  ent.events || response.events || ent.enents || response.enents;
128
- registrars.push({ id, name, events });
144
+ registrars.push({ id, name, email, events });
129
145
  }
130
146
  }
131
147
 
148
+ if (
149
+ domain.endsWith(".is") &&
150
+ (ent.roles?.includes("technical") || ent.role === "technical")
151
+ ) {
152
+ const id = ent.handle;
153
+ const name =
154
+ parseInt(id) == id
155
+ ? (await ianaIdToRegistrar(parseInt(id)))?.name
156
+ : findInObject(
157
+ ent.vcardArray,
158
+ (el: any) =>
159
+ Array.isArray(el) && (el[0] === "fn" || el[0] === "org"),
160
+ (el: any[]) => el[3],
161
+ id
162
+ );
163
+ const email =
164
+ [ent, ...(ent.entities || [])]
165
+ .filter((e) => e?.vcardArray)
166
+ .map((e) =>
167
+ findInObject(
168
+ e.vcardArray,
169
+ (el: any) => Array.isArray(el) && el[0] === "email",
170
+ (el: any[]) => el[3],
171
+ ""
172
+ )
173
+ )
174
+ .filter(Boolean)?.[0] || "";
175
+
176
+ const events =
177
+ ent.events || response.events || ent.enents || response.enents;
178
+ registrars.push({ id, name, email, events });
179
+ }
180
+
132
181
  if (
133
182
  (ent.roles?.includes("reseller") || ent.role === "reseller") &&
134
183
  ent.vcardArray
@@ -156,12 +205,18 @@ export async function whois(domain: string, options: WhoisOptions = { fetch: fet
156
205
 
157
206
  // registrar
158
207
  const { events, ...registrar } = registrars.sort((a: any, b: any) => {
159
- const aDate =
160
- (a.events.find((ev: any) => ev.eventAction === "registration")
161
- ?.eventDate || 0).toString().replace(/\+0000Z$/, 'Z');
162
- const bDate =
163
- (b.events.find((ev: any) => ev.eventAction === "registration")
164
- ?.eventDate || 0).toString().replace(/\+0000Z$/, 'Z');
208
+ const aDate = (
209
+ a.events.find((ev: any) => ev.eventAction === "registration")
210
+ ?.eventDate || 0
211
+ )
212
+ .toString()
213
+ .replace(/\+0000Z$/, "Z");
214
+ const bDate = (
215
+ b.events.find((ev: any) => ev.eventAction === "registration")
216
+ ?.eventDate || 0
217
+ )
218
+ .toString()
219
+ .replace(/\+0000Z$/, "Z");
165
220
  return new Date(bDate).valueOf() - new Date(aDate).valueOf();
166
221
  })[0] || { id: 0, name: "" };
167
222
  response.registrar = registrar;
@@ -182,9 +237,10 @@ export async function whois(domain: string, options: WhoisOptions = { fetch: fet
182
237
  );
183
238
 
184
239
  // ts
185
- response.ts = findTimestamps(
186
- [ ...(thickResponse?.events || []), ...(thinResponse?.events || []) ]
187
- );
240
+ response.ts = findTimestamps([
241
+ ...(thickResponse?.events || []),
242
+ ...(thinResponse?.events || []),
243
+ ]);
188
244
 
189
245
  return response;
190
246
  }
@@ -232,9 +288,11 @@ function findTimestamps(values: any[]) {
232
288
  }
233
289
 
234
290
  for (const [event, field] of eventMap) {
235
- const date = events.find((ev: any) => ev?.eventAction?.toLocaleLowerCase() === event);
291
+ const date = events.find(
292
+ (ev: any) => ev?.eventAction?.toLocaleLowerCase() === event
293
+ );
236
294
  if (date?.eventDate) {
237
- ts[field] = new Date(date.eventDate.toString().replace(/\+0000Z$/, 'Z'));
295
+ ts[field] = new Date(date.eventDate.toString().replace(/\+0000Z$/, "Z"));
238
296
  }
239
297
  }
240
298