domain-alive 0.1.9 → 0.1.11

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.
Files changed (3) hide show
  1. package/dist/index.js +13 -18
  2. package/dist/index.mjs +13 -18
  3. package/package.json +10 -12
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  var tldts = require('tldts');
4
4
  var dns2 = require('dns2');
5
- var _ = require('punycode/');
6
5
  var asyncRetry = require('foxts/async-retry');
7
6
  var net = require('node:net');
8
7
  var retrie = require('foxts/retrie');
9
8
  var extractErrorMessage = require('foxts/extract-error-message');
10
9
  var debug = require('debug');
11
10
  var shuffleArray = require('foxts/shuffle-array');
11
+ var url = require('url');
12
12
 
13
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
14
 
@@ -1139,7 +1139,8 @@ const whoiserNoWhoisSymbol = Symbol('"whoiser" library returns "No WHOIS data fo
1139
1139
  *
1140
1140
  * We expect this function to only be called within `isRegisterableDomainAlive`. If you are trying
1141
1141
  * to do this yourself, please implement the necessary extraction first, we recommend using both
1142
- * `punycode` & `tldts` library, which we also use in the `isRegisterableDomainAlive` function.
1142
+ * `require('node:url').domainToASCII` API & `tldts` library, which we also use in the
1143
+ * `isRegisterableDomainAlive` function.
1143
1144
  */ async function domainHasBeenRegistered(registerableDomain, options = {}) {
1144
1145
  const tld = tldts.getPublicSuffix(registerableDomain, getIcannTldOptions);
1145
1146
  if (!tld) {
@@ -1180,7 +1181,8 @@ const whoiserNoWhoisSymbol = Symbol('"whoiser" library returns "No WHOIS data fo
1180
1181
  throw error;
1181
1182
  }), retryOption);
1182
1183
  } catch (e) {
1183
- errorLog$1('[whois] %s %O', registerableDomain, e);
1184
+ const errorMessage = extractErrorMessage.extractErrorMessage(e, true, false) || 'unknown error';
1185
+ errorLog$1('[whois] %s %s', registerableDomain, errorMessage);
1184
1186
  return whoisErrorCountAsAlive;
1185
1187
  }
1186
1188
  if (whois === whoiserTLDNotSupportedSymbol) {
@@ -1319,7 +1321,7 @@ const sharedNullResponse = Object.freeze({
1319
1321
  };
1320
1322
  const mutex = createAsyncMutex();
1321
1323
  return async function isRegisterableDomainAlive(domain) {
1322
- domain = _.toASCII(domain);
1324
+ domain = url.domainToASCII(domain);
1323
1325
  return mutex(domain, ()=>cacheApply(registerableDomainResultCache, domain, async ()=>{
1324
1326
  // Step 0: we normalize the domain and find the registerable part
1325
1327
  const registerableDomain = tldts.getDomain(domain, getRegisterableDomainTldtsOption);
@@ -1369,7 +1371,8 @@ tencentcloud.com. 86400 IN SOA ns-tel1.qq.com. webmaster.qq.com. 165111089
1369
1371
  confirmations++;
1370
1372
  }
1371
1373
  } catch (e) {
1372
- errorNsLog('[NS] %s error (%s) %O', domain, resolve.server, e);
1374
+ const errorMessage = extractErrorMessage.extractErrorMessage(e, true, false) || 'unknown error';
1375
+ errorNsLog('[NS] %s error (%s) %s', domain, resolve.server, errorMessage);
1373
1376
  } finally{
1374
1377
  attempts++;
1375
1378
  log$1('[NS] %s %d %d/%d', domain, confirmations, attempts, maxAttempts);
@@ -1423,7 +1426,7 @@ function createDomainAliveChecker(options = {}) {
1423
1426
  };
1424
1427
  const mutex = createAsyncMutex();
1425
1428
  return async function isDomainAlive(domain) {
1426
- domain = _.toASCII(domain);
1429
+ domain = url.domainToASCII(domain);
1427
1430
  const registerableDomainAliveResult = await isRegisterableDomainAlive(domain);
1428
1431
  if (registerableDomainAliveResult.registerableDomain === null) {
1429
1432
  return sharedNullishResult;
@@ -1469,12 +1472,8 @@ function createDomainAliveChecker(options = {}) {
1469
1472
  confirmations++;
1470
1473
  }
1471
1474
  } catch (e) {
1472
- if (typeof e === 'object' && e !== null) {
1473
- Object.assign(e, {
1474
- dns: resolve.server
1475
- });
1476
- }
1477
- errorLog('[A] %s error %O', domain, e);
1475
+ const errorMessage = extractErrorMessage.extractErrorMessage(e, true, false) || 'unknown error';
1476
+ errorLog('[A] %s error (%s) %s', domain, resolve.server, errorMessage);
1478
1477
  } finally{
1479
1478
  attempts++;
1480
1479
  log('[A] %s %d %d/%d', domain, confirmations, attempts, maxAttempts);
@@ -1502,12 +1501,8 @@ function createDomainAliveChecker(options = {}) {
1502
1501
  confirmations++;
1503
1502
  }
1504
1503
  } catch (e) {
1505
- if (typeof e === 'object' && e !== null) {
1506
- Object.assign(e, {
1507
- dns: resolve.server
1508
- });
1509
- }
1510
- errorLog('[AAAA] %s error %O', domain, e);
1504
+ const errorMessage = extractErrorMessage.extractErrorMessage(e, true, false) || 'unknown error';
1505
+ errorLog('[AAAA] %s error (%s) %s', domain, resolve.server, errorMessage);
1511
1506
  } finally{
1512
1507
  attempts++;
1513
1508
  log('[AAAA] %s %d %d/%d', domain, confirmations, attempts, maxAttempts);
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { getPublicSuffix, getDomain } from 'tldts';
2
2
  import { UDPClient, TCPClient, DOHClient } from 'dns2';
3
- import { toASCII as toASCII$1 } from 'punycode/';
4
3
  import { asyncRetry } from 'foxts/async-retry';
5
4
  import net from 'node:net';
6
5
  import { createRetrieKeywordFilter } from 'foxts/retrie';
7
6
  import { extractErrorMessage } from 'foxts/extract-error-message';
8
7
  import debug from 'debug';
9
8
  import { shuffleArray } from 'foxts/shuffle-array';
9
+ import { domainToASCII } from 'url';
10
10
 
11
11
  const defaultDnsServers = [
12
12
  'https://1.1.1.1',
@@ -1132,7 +1132,8 @@ const whoiserNoWhoisSymbol = Symbol('"whoiser" library returns "No WHOIS data fo
1132
1132
  *
1133
1133
  * We expect this function to only be called within `isRegisterableDomainAlive`. If you are trying
1134
1134
  * to do this yourself, please implement the necessary extraction first, we recommend using both
1135
- * `punycode` & `tldts` library, which we also use in the `isRegisterableDomainAlive` function.
1135
+ * `require('node:url').domainToASCII` API & `tldts` library, which we also use in the
1136
+ * `isRegisterableDomainAlive` function.
1136
1137
  */ async function domainHasBeenRegistered(registerableDomain, options = {}) {
1137
1138
  const tld = getPublicSuffix(registerableDomain, getIcannTldOptions);
1138
1139
  if (!tld) {
@@ -1173,7 +1174,8 @@ const whoiserNoWhoisSymbol = Symbol('"whoiser" library returns "No WHOIS data fo
1173
1174
  throw error;
1174
1175
  }), retryOption);
1175
1176
  } catch (e) {
1176
- errorLog$1('[whois] %s %O', registerableDomain, e);
1177
+ const errorMessage = extractErrorMessage(e, true, false) || 'unknown error';
1178
+ errorLog$1('[whois] %s %s', registerableDomain, errorMessage);
1177
1179
  return whoisErrorCountAsAlive;
1178
1180
  }
1179
1181
  if (whois === whoiserTLDNotSupportedSymbol) {
@@ -1312,7 +1314,7 @@ const sharedNullResponse = Object.freeze({
1312
1314
  };
1313
1315
  const mutex = createAsyncMutex();
1314
1316
  return async function isRegisterableDomainAlive(domain) {
1315
- domain = toASCII$1(domain);
1317
+ domain = domainToASCII(domain);
1316
1318
  return mutex(domain, ()=>cacheApply(registerableDomainResultCache, domain, async ()=>{
1317
1319
  // Step 0: we normalize the domain and find the registerable part
1318
1320
  const registerableDomain = getDomain(domain, getRegisterableDomainTldtsOption);
@@ -1362,7 +1364,8 @@ tencentcloud.com. 86400 IN SOA ns-tel1.qq.com. webmaster.qq.com. 165111089
1362
1364
  confirmations++;
1363
1365
  }
1364
1366
  } catch (e) {
1365
- errorNsLog('[NS] %s error (%s) %O', domain, resolve.server, e);
1367
+ const errorMessage = extractErrorMessage(e, true, false) || 'unknown error';
1368
+ errorNsLog('[NS] %s error (%s) %s', domain, resolve.server, errorMessage);
1366
1369
  } finally{
1367
1370
  attempts++;
1368
1371
  log$1('[NS] %s %d %d/%d', domain, confirmations, attempts, maxAttempts);
@@ -1416,7 +1419,7 @@ function createDomainAliveChecker(options = {}) {
1416
1419
  };
1417
1420
  const mutex = createAsyncMutex();
1418
1421
  return async function isDomainAlive(domain) {
1419
- domain = toASCII$1(domain);
1422
+ domain = domainToASCII(domain);
1420
1423
  const registerableDomainAliveResult = await isRegisterableDomainAlive(domain);
1421
1424
  if (registerableDomainAliveResult.registerableDomain === null) {
1422
1425
  return sharedNullishResult;
@@ -1462,12 +1465,8 @@ function createDomainAliveChecker(options = {}) {
1462
1465
  confirmations++;
1463
1466
  }
1464
1467
  } catch (e) {
1465
- if (typeof e === 'object' && e !== null) {
1466
- Object.assign(e, {
1467
- dns: resolve.server
1468
- });
1469
- }
1470
- errorLog('[A] %s error %O', domain, e);
1468
+ const errorMessage = extractErrorMessage(e, true, false) || 'unknown error';
1469
+ errorLog('[A] %s error (%s) %s', domain, resolve.server, errorMessage);
1471
1470
  } finally{
1472
1471
  attempts++;
1473
1472
  log('[A] %s %d %d/%d', domain, confirmations, attempts, maxAttempts);
@@ -1495,12 +1494,8 @@ function createDomainAliveChecker(options = {}) {
1495
1494
  confirmations++;
1496
1495
  }
1497
1496
  } catch (e) {
1498
- if (typeof e === 'object' && e !== null) {
1499
- Object.assign(e, {
1500
- dns: resolve.server
1501
- });
1502
- }
1503
- errorLog('[AAAA] %s error %O', domain, e);
1497
+ const errorMessage = extractErrorMessage(e, true, false) || 'unknown error';
1498
+ errorLog('[AAAA] %s error (%s) %s', domain, resolve.server, errorMessage);
1504
1499
  } finally{
1505
1500
  attempts++;
1506
1501
  log('[AAAA] %s %d %d/%d', domain, confirmations, attempts, maxAttempts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domain-alive",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "A Node.js library for checking if an FQDN (Fully Qualified Domain Name) is alive or not, uses a combination techniques of `NS` records, WHOIS/RDAP lookups, `A/AAAA` records",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,22 +32,20 @@
32
32
  "dependencies": {
33
33
  "debug": "4.4.1",
34
34
  "dns2": "github:lsongdev/node-dns#3adb7e91b3101c0e4f43ebaca3a568269ea04d11",
35
- "foxts": "^4.1.0",
36
- "punycode": "^2.3.1",
37
- "tldts": "^7.0.16"
35
+ "foxts": "^5.0.0",
36
+ "tldts": "^7.0.17"
38
37
  },
39
38
  "devDependencies": {
40
- "@eslint-sukka/node": "^7.2.1",
39
+ "@eslint-sukka/node": "^8.0.2",
41
40
  "@swc-node/register": "^1.11.1",
42
41
  "@types/debug": "^4.1.12",
43
42
  "@types/dns2": "^2.0.10",
44
- "@types/node": "^24.6.2",
45
- "@types/punycode": "^2.1.4",
46
- "bumpp": "^10.2.3",
47
- "bunchee": "^6.6.0",
48
- "eslint": "^9.37.0",
49
- "eslint-config-sukka": "^7.2.1",
50
- "eslint-formatter-sukka": "^7.2.1",
43
+ "@types/node": "^24.10.0",
44
+ "bumpp": "^10.3.1",
45
+ "bunchee": "^6.6.2",
46
+ "eslint": "^9.39.1",
47
+ "eslint-config-sukka": "^8.0.2",
48
+ "eslint-formatter-sukka": "^8.0.2",
51
49
  "typescript": "^5.9.3",
52
50
  "whoiser": "2.0.0-beta.8"
53
51
  },