@cleandns/whois-rdap 1.0.4 → 1.0.6

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
@@ -112,10 +112,9 @@ export async function whois(domain, options = { fetch: fetch }) {
112
112
  // registrar
113
113
  const { events, ...registrar } = registrars.sort((a, b) => {
114
114
  var _a, _b;
115
- const aDate = ((_a = a.events.find((ev) => ev.eventAction === "registration")) === null || _a === void 0 ? void 0 : _a.eventDate) || 0;
116
- const bDate = ((_b = b.events.find((ev) => ev.eventAction === "registration")) === null || _b === void 0 ? void 0 : _b.eventDate) || 0;
117
- console.log({ aDate, bDate });
118
- return new Date(bDate.replace(/\+0000Z$/, 'Z')).valueOf() - new Date(aDate.replace(/\+0000Z$/, 'Z')).valueOf();
115
+ const aDate = (((_a = a.events.find((ev) => ev.eventAction === "registration")) === null || _a === void 0 ? void 0 : _a.eventDate) || 0).toString().replace(/\+0000Z$/, 'Z');
116
+ const bDate = (((_b = b.events.find((ev) => ev.eventAction === "registration")) === null || _b === void 0 ? void 0 : _b.eventDate) || 0).toString().replace(/\+0000Z$/, 'Z');
117
+ return new Date(bDate).valueOf() - new Date(aDate).valueOf();
119
118
  })[0] || { id: 0, name: "" };
120
119
  response.registrar = registrar;
121
120
  // reseller
@@ -168,9 +167,11 @@ function findTimestamps(values) {
168
167
  for (const [event, field] of eventMap) {
169
168
  const date = events.find((ev) => ev.eventAction === event);
170
169
  if (date === null || date === void 0 ? void 0 : date.eventDate) {
171
- ts[field] = new Date(date.eventDate.replace(/\+0000Z$/, 'Z'));
170
+ ts[field] = new Date(date.eventDate.toString().replace(/\+0000Z$/, 'Z'));
172
171
  }
173
172
  }
174
173
  return ts;
175
174
  }
176
- await whois(process.argv[2]).then((r) => console.log(JSON.stringify(r, null, 2)));
175
+ // await whois(process.argv[2]).then((r) =>
176
+ // console.log(JSON.stringify(r, null, 2))
177
+ // );
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@cleandns/whois-rdap",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
8
- "build": "tsc"
8
+ "build": "tsc",
9
+ "publish": "npm run build && npm version patch && npm publish"
9
10
  },
10
11
  "repository": {
11
12
  "type": "git",
package/src/index.ts CHANGED
@@ -156,12 +156,12 @@ export async function whois(domain: string, options: WhoisOptions = { fetch: fet
156
156
  // registrar
157
157
  const { events, ...registrar } = registrars.sort((a: any, b: any) => {
158
158
  const aDate =
159
- a.events.find((ev: any) => ev.eventAction === "registration")
160
- ?.eventDate || 0;
159
+ (a.events.find((ev: any) => ev.eventAction === "registration")
160
+ ?.eventDate || 0).toString().replace(/\+0000Z$/, 'Z');
161
161
  const bDate =
162
- b.events.find((ev: any) => ev.eventAction === "registration")
163
- ?.eventDate || 0;
164
- return new Date(bDate.replace(/\+0000Z$/, 'Z')).valueOf() - new Date(aDate.replace(/\+0000Z$/, 'Z')).valueOf();
162
+ (b.events.find((ev: any) => ev.eventAction === "registration")
163
+ ?.eventDate || 0).toString().replace(/\+0000Z$/, 'Z');
164
+ return new Date(bDate).valueOf() - new Date(aDate).valueOf();
165
165
  })[0] || { id: 0, name: "" };
166
166
  response.registrar = registrar;
167
167
 
@@ -233,7 +233,7 @@ function findTimestamps(values: any[]) {
233
233
  for (const [event, field] of eventMap) {
234
234
  const date = events.find((ev: any) => ev.eventAction === event);
235
235
  if (date?.eventDate) {
236
- ts[field] = new Date(date.eventDate.replace(/\+0000Z$/, 'Z'));
236
+ ts[field] = new Date(date.eventDate.toString().replace(/\+0000Z$/, 'Z'));
237
237
  }
238
238
  }
239
239