@econ-v1/domain 7.6.146 → 7.6.148
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.
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export function isPublicIpOrigin(origin: string): boolean;
|
|
8
8
|
/**
|
|
9
|
+
* The node moved only when the page's IP is one it no longer uses. The match is
|
|
10
|
+
* by IP, not origin: a router port-forward (`https://203.0.113.7:1024`) reaches
|
|
11
|
+
* the same address the node advertises without the external port it cannot see.
|
|
9
12
|
* Inputs may use equivalent scheme/host casing, a trailing slash or default :443.
|
|
10
13
|
* Returns normalised origins.
|
|
11
14
|
* @param {{ pageOrigin: string, wanOrigins?: readonly string[], wanOrigin?: string, onDirectToPage: boolean }} input
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-move.d.ts","sourceRoot":"","sources":["../../src/network/address-move.js"],"names":[],"mappings":"AAuDA;;;;;GAKG;AACH,yCAHW,MAAM,GACJ,OAAO,CAUnB;AAED
|
|
1
|
+
{"version":3,"file":"address-move.d.ts","sourceRoot":"","sources":["../../src/network/address-move.js"],"names":[],"mappings":"AAuDA;;;;;GAKG;AACH,yCAHW,MAAM,GACJ,OAAO,CAUnB;AAED;;;;;;;;GAQG;AACH,0FAHW;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAE,GACjG,SAAS,MAAM,EAAE,CAU7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@econ-v1/domain",
|
|
3
|
-
"version": "7.6.
|
|
3
|
+
"version": "7.6.148",
|
|
4
4
|
"description": "Platform-neutral domain contracts and errors for Node clients",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "Node contributors",
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@econ-v1/ports": "7.6.
|
|
60
|
+
"@econ-v1/ports": "7.6.148"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -70,6 +70,9 @@ export function isPublicIpOrigin(origin) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
+
* The node moved only when the page's IP is one it no longer uses. The match is
|
|
74
|
+
* by IP, not origin: a router port-forward (`https://203.0.113.7:1024`) reaches
|
|
75
|
+
* the same address the node advertises without the external port it cannot see.
|
|
73
76
|
* Inputs may use equivalent scheme/host casing, a trailing slash or default :443.
|
|
74
77
|
* Returns normalised origins.
|
|
75
78
|
* @param {{ pageOrigin: string, wanOrigins?: readonly string[], wanOrigin?: string, onDirectToPage: boolean }} input
|
|
@@ -79,11 +82,19 @@ export function addressMoveTargets({ pageOrigin, wanOrigins, wanOrigin, onDirect
|
|
|
79
82
|
pageOrigin = normalizeOrigin(pageOrigin);
|
|
80
83
|
if (!isPublicIpOrigin(pageOrigin) || onDirectToPage) return [];
|
|
81
84
|
const advertised = wanOrigins !== undefined && wanOrigins.length > 0 ? wanOrigins : wanOrigin ? [wanOrigin] : [];
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
const origins = [...new Set(advertised.map(normalizeOrigin))];
|
|
86
|
+
const pageHost = originHost(pageOrigin);
|
|
87
|
+
if (origins.some((origin) => originHost(origin) === pageHost)) return [];
|
|
88
|
+
return origins.sort((a, b) => Number(b.startsWith("https://[")) - Number(a.startsWith("https://[")));
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
/** @param {string} origin @returns {string} */
|
|
87
92
|
function normalizeOrigin(origin) {
|
|
88
93
|
return origin.toLowerCase().replace(/\/$/u, "").replace(/:443$/u, "");
|
|
89
94
|
}
|
|
95
|
+
|
|
96
|
+
/** Host of a normalised origin, without its port; IPv6 stays bracketed.
|
|
97
|
+
* @param {string} origin @returns {string} */
|
|
98
|
+
function originHost(origin) {
|
|
99
|
+
return origin.replace(/^https:\/\//u, "").replace(/:\d{1,5}$/u, "");
|
|
100
|
+
}
|