@abtnode/core 1.8.9 → 1.8.12

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.
@@ -1284,12 +1284,6 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
1284
1284
  });
1285
1285
  };
1286
1286
 
1287
- const checkDomain = async (domain) => {
1288
- const matchedCert = await routerManager.getMatchedCert(domain);
1289
-
1290
- return { domain, isHttps: !!matchedCert, matchedCert };
1291
- };
1292
-
1293
1287
  return {
1294
1288
  ensureDashboardRouting,
1295
1289
  ensureBlockletRouting,
@@ -1305,7 +1299,6 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
1305
1299
  getSnapshotSites,
1306
1300
  getSitesFromSnapshot,
1307
1301
  getCertificates,
1308
- checkDomain,
1309
1302
  ensureWildcardCerts,
1310
1303
  addWellknownSite,
1311
1304
  upsertSiteRule,
@@ -1,6 +1,7 @@
1
+ const https = require('https');
1
2
  const { EventEmitter } = require('events');
2
3
  const logger = require('@abtnode/logger')('@abtnode/domain-status');
3
- const { EVENTS } = require('@abtnode/constant');
4
+ const { EVENTS, WELLKNOWN_PING_PREFIX } = require('@abtnode/constant');
4
5
  const { checkDomainDNS } = require('./index');
5
6
 
6
7
  const dnsStatusStore = Object.create(null);
@@ -31,9 +32,51 @@ class DomainStatus extends EventEmitter {
31
32
  this.routerManager = routerManager;
32
33
  }
33
34
 
35
+ async getHttpsCert(domain) {
36
+ const matchedCert = await this.routerManager.getMatchedCert(domain);
37
+
38
+ if (matchedCert) {
39
+ return matchedCert;
40
+ }
41
+
42
+ return new Promise((resolve) => {
43
+ const req = https.request(
44
+ {
45
+ host: domain,
46
+ path: WELLKNOWN_PING_PREFIX,
47
+ method: 'GET',
48
+ timeout: 1000 * 10,
49
+ },
50
+ (res) => {
51
+ try {
52
+ const data = res.socket.getPeerCertificate();
53
+ const cert = {
54
+ issuer: {
55
+ countryName: data.issuer.C,
56
+ organizationName: data.issuer.O,
57
+ commonName: data.issuer.CN,
58
+ },
59
+ validFrom: data.valid_from,
60
+ validTo: data.valid_to,
61
+ };
62
+ resolve(cert);
63
+ } catch {
64
+ resolve(null);
65
+ }
66
+ }
67
+ );
68
+
69
+ req.on('error', () => {
70
+ resolve(null);
71
+ });
72
+
73
+ req.end();
74
+ });
75
+ }
76
+
34
77
  checkDomainsStatus({ domains } = {}) {
35
78
  (domains || []).forEach((domain) => {
36
- Promise.all([this.routerManager.getMatchedCert(domain), checkDomainDnsWrapper(domain)])
79
+ Promise.all([this.getHttpsCert(domain), checkDomainDnsWrapper(domain)])
37
80
  .then((data) => {
38
81
  const [matchedCert, dns] = data;
39
82
  this.emit(EVENTS.DOMAIN_STATUS, { domain, matchedCert, isHttps: !!matchedCert, dns });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.9",
6
+ "version": "1.8.12",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,32 +19,32 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@abtnode/certificate-manager": "1.8.9",
23
- "@abtnode/constant": "1.8.9",
24
- "@abtnode/cron": "1.8.9",
25
- "@abtnode/db": "1.8.9",
26
- "@abtnode/logger": "1.8.9",
27
- "@abtnode/queue": "1.8.9",
28
- "@abtnode/rbac": "1.8.9",
29
- "@abtnode/router-provider": "1.8.9",
30
- "@abtnode/static-server": "1.8.9",
31
- "@abtnode/timemachine": "1.8.9",
32
- "@abtnode/util": "1.8.9",
33
- "@arcblock/did": "1.17.11",
22
+ "@abtnode/certificate-manager": "1.8.12",
23
+ "@abtnode/constant": "1.8.12",
24
+ "@abtnode/cron": "1.8.12",
25
+ "@abtnode/db": "1.8.12",
26
+ "@abtnode/logger": "1.8.12",
27
+ "@abtnode/queue": "1.8.12",
28
+ "@abtnode/rbac": "1.8.12",
29
+ "@abtnode/router-provider": "1.8.12",
30
+ "@abtnode/static-server": "1.8.12",
31
+ "@abtnode/timemachine": "1.8.12",
32
+ "@abtnode/util": "1.8.12",
33
+ "@arcblock/did": "1.17.12",
34
34
  "@arcblock/did-motif": "^1.1.10",
35
- "@arcblock/did-util": "1.17.11",
36
- "@arcblock/event-hub": "1.17.11",
37
- "@arcblock/jwt": "^1.17.11",
35
+ "@arcblock/did-util": "1.17.12",
36
+ "@arcblock/event-hub": "1.17.12",
37
+ "@arcblock/jwt": "^1.17.12",
38
38
  "@arcblock/pm2-events": "^0.0.5",
39
- "@arcblock/vc": "1.17.11",
40
- "@blocklet/meta": "1.8.9",
41
- "@blocklet/sdk": "1.8.9",
39
+ "@arcblock/vc": "1.17.12",
40
+ "@blocklet/meta": "1.8.12",
41
+ "@blocklet/sdk": "1.8.12",
42
42
  "@fidm/x509": "^1.2.1",
43
43
  "@nedb/core": "^1.3.4",
44
44
  "@nedb/multi": "^1.3.4",
45
- "@ocap/mcrypto": "1.17.11",
46
- "@ocap/util": "1.17.11",
47
- "@ocap/wallet": "1.17.11",
45
+ "@ocap/mcrypto": "1.17.12",
46
+ "@ocap/util": "1.17.12",
47
+ "@ocap/wallet": "1.17.12",
48
48
  "@slack/webhook": "^5.0.4",
49
49
  "axios": "^0.27.2",
50
50
  "axon": "^2.0.3",
@@ -82,5 +82,5 @@
82
82
  "express": "^4.18.1",
83
83
  "jest": "^27.5.1"
84
84
  },
85
- "gitHead": "1846a1f0bae2f870f3fe635b1f17ed06867d370d"
85
+ "gitHead": "f4cb25a77f7ee48333b3243918a0a9c81b94ab8c"
86
86
  }