@forge/egress 1.0.1-next.0 → 1.1.0-next.1
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/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"egress-filtering-service.d.ts","sourceRoot":"","sources":["../../src/egress/egress-filtering-service.ts"],"names":[],"mappings":"AAGA,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;gBAE/B,SAAS,EAAE,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"egress-filtering-service.d.ts","sourceRoot":"","sources":["../../src/egress/egress-filtering-service.ts"],"names":[],"mappings":"AAGA,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;gBAE/B,SAAS,EAAE,MAAM,EAAE;IAU/B,OAAO,CAAC,OAAO;IAQR,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAQvC,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,eAAe;CAWxB"}
|
|
@@ -6,18 +6,17 @@ const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
|
|
|
6
6
|
const url_1 = require("url");
|
|
7
7
|
class EgressFilteringService {
|
|
8
8
|
constructor(allowList) {
|
|
9
|
-
this.URLs = allowList
|
|
10
|
-
.filter((domainOrURL) => !domainOrURL.startsWith('*'))
|
|
11
|
-
.map((url) => this.safeURL(url));
|
|
9
|
+
this.URLs = allowList.filter((domainOrURL) => !domainOrURL.startsWith('*')).map((url) => this.safeURL(url));
|
|
12
10
|
this.wildcardDomains = allowList
|
|
13
11
|
.filter((domainOrURL) => domainOrURL !== '*')
|
|
14
12
|
.map((url) => this.safeURL(url))
|
|
15
|
-
.filter((url) => url.hostname.startsWith('*'));
|
|
13
|
+
.filter((url) => decodeURIComponent(url.hostname).startsWith('*'));
|
|
16
14
|
this.allowsEverything = allowList.includes('*');
|
|
17
15
|
}
|
|
18
16
|
safeURL(url, defaultProtocol = 'https://') {
|
|
19
17
|
const protocolRegex = /^(.*:\/\/)/;
|
|
20
|
-
|
|
18
|
+
const urlParser = url_1.URL !== null && url_1.URL !== void 0 ? url_1.URL : window.URL;
|
|
19
|
+
return new urlParser(protocolRegex.test(url) ? url : `${defaultProtocol}${url}`);
|
|
21
20
|
}
|
|
22
21
|
isValidUrl(url) {
|
|
23
22
|
if (this.allowsEverything) {
|
|
@@ -28,7 +27,7 @@ class EgressFilteringService {
|
|
|
28
27
|
domainCheck(domain, allowList) {
|
|
29
28
|
const hostnameMatchedProtocol = allowList
|
|
30
29
|
.filter((allowed) => allowed.protocol === domain.protocol)
|
|
31
|
-
.map((url) => url.hostname);
|
|
30
|
+
.map((url) => decodeURIComponent(url.hostname));
|
|
32
31
|
return (micromatch_1.default([domain.hostname], hostnameMatchedProtocol, {
|
|
33
32
|
dot: true
|
|
34
33
|
}).length > 0);
|