@abtnode/router-provider 1.17.8-beta-20260121-102603-f9d0176f → 1.17.8-beta-20260125-093329-64b43854

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 (2) hide show
  1. package/lib/util.js +38 -4
  2. package/package.json +8 -8
package/lib/util.js CHANGED
@@ -23,10 +23,44 @@ const decideHttpPort = (port) => port || process.env.ABT_NODE_HTTP_PORT || DEFAU
23
23
  const decideHttpsPort = (port) => port || process.env.ABT_NODE_HTTPS_PORT || DEFAULT_HTTPS_PORT;
24
24
 
25
25
  const findCertificate = (certs, domain) => {
26
- const results = certs
27
- .filter((cert) => [cert.domain, ...(cert.sans || [])].some((d) => checkDomainMatch(d, domain)))
28
- .sort((d1) => (d1.domain[0] === '*' ? 1 : -1)); // will first match a.b.com, then *.b.com
29
- return results[0];
26
+ const lowerDomain = domain.toLowerCase();
27
+
28
+ // First try exact match (highest priority)
29
+ // Note: Domain matching should be case-insensitive per DNS standards
30
+ for (const cert of certs) {
31
+ const certDomains = [cert.domain, ...(cert.sans || [])].map((d) => d.toLowerCase());
32
+ if (certDomains.includes(lowerDomain)) {
33
+ return cert;
34
+ }
35
+ }
36
+
37
+ // Then try wildcard match
38
+ // Note: wildcard cert *.example.com should match foo.example.com
39
+ // but should NOT match example.com itself (per SSL/TLS standards)
40
+ const domainParts = domain.split('.');
41
+
42
+ for (const cert of certs) {
43
+ const certDomains = [cert.domain, ...(cert.sans || [])];
44
+
45
+ for (const certDomain of certDomains) {
46
+ // Skip wildcard certs that would incorrectly match the base domain
47
+ // e.g., *.staging.myvibe.so should not match staging.myvibe.so
48
+ if (certDomain.startsWith('*.')) {
49
+ const certBaseParts = certDomain.substring(2).split('.');
50
+ // If domain has same or fewer parts than cert base, it's the base domain or shorter
51
+ // Wildcard should only match domains with more parts (subdomains)
52
+ if (domainParts.length <= certBaseParts.length) {
53
+ continue; // eslint-disable-line no-continue
54
+ }
55
+ }
56
+
57
+ if (checkDomainMatch(certDomain, domain)) {
58
+ return cert;
59
+ }
60
+ }
61
+ }
62
+
63
+ return undefined;
30
64
  };
31
65
 
32
66
  const trimEndSlash = (str) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/router-provider",
3
- "version": "1.17.8-beta-20260121-102603-f9d0176f",
3
+ "version": "1.17.8-beta-20260125-093329-64b43854",
4
4
  "description": "Routing engine implementations for abt node",
5
5
  "author": "polunzh <polunzh@gmail.com>",
6
6
  "homepage": "https://github.com/ArcBlock/blocklet-server#readme",
@@ -30,14 +30,14 @@
30
30
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@abtnode/constant": "1.17.8-beta-20260121-102603-f9d0176f",
34
- "@abtnode/db-cache": "1.17.8-beta-20260121-102603-f9d0176f",
35
- "@abtnode/logger": "1.17.8-beta-20260121-102603-f9d0176f",
36
- "@abtnode/router-templates": "1.17.8-beta-20260121-102603-f9d0176f",
37
- "@abtnode/util": "1.17.8-beta-20260121-102603-f9d0176f",
33
+ "@abtnode/constant": "1.17.8-beta-20260125-093329-64b43854",
34
+ "@abtnode/db-cache": "1.17.8-beta-20260125-093329-64b43854",
35
+ "@abtnode/logger": "1.17.8-beta-20260125-093329-64b43854",
36
+ "@abtnode/router-templates": "1.17.8-beta-20260125-093329-64b43854",
37
+ "@abtnode/util": "1.17.8-beta-20260125-093329-64b43854",
38
38
  "@arcblock/http-proxy": "^1.19.1",
39
39
  "@arcblock/is-valid-domain": "^1.0.5",
40
- "@ocap/util": "^1.28.5",
40
+ "@ocap/util": "^1.28.6",
41
41
  "axios": "^1.7.9",
42
42
  "debug": "^4.4.1",
43
43
  "fast-glob": "^3.3.2",
@@ -60,5 +60,5 @@
60
60
  "bluebird": "^3.7.2",
61
61
  "fs-extra": "^11.2.0"
62
62
  },
63
- "gitHead": "7ae816f51ed511037e5b7ac0008012ebf4afc987"
63
+ "gitHead": "241254785bda907be2296228869b4fc9c1679a6b"
64
64
  }