@forge/egress 1.1.2 → 1.2.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 +12 -0
- package/out/egress/egress-filtering-service.d.ts +3 -3
- package/out/egress/egress-filtering-service.d.ts.map +1 -1
- package/out/egress/egress-filtering-service.js +10 -17
- package/out/egress/url-parser.d.ts +3 -0
- package/out/egress/url-parser.d.ts.map +1 -0
- package/out/egress/url-parser.js +10 -0
- package/out/egress/utils.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @forge/egress
|
|
2
2
|
|
|
3
|
+
## 1.2.0-next.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3bdedf0: Fix URL-constructor in Firefox browsers
|
|
8
|
+
|
|
9
|
+
## 1.1.3-next.0
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0da2b48: Removed support for the CLI running on node 14
|
|
14
|
+
|
|
3
15
|
## 1.1.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -2,10 +2,10 @@ export declare class EgressFilteringService {
|
|
|
2
2
|
private readonly URLs;
|
|
3
3
|
private readonly wildcardDomains;
|
|
4
4
|
private readonly allowsEverything;
|
|
5
|
+
private readonly DEFAULT_PROTOCOL;
|
|
5
6
|
constructor(allowList: string[]);
|
|
6
|
-
private
|
|
7
|
+
private parseUrl;
|
|
7
8
|
isValidUrl(url: string): boolean;
|
|
8
|
-
private
|
|
9
|
-
private domainIsAllowed;
|
|
9
|
+
private allowedDomain;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=egress-filtering-service.d.ts.map
|
|
@@ -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,
|
|
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,CAAY;IACjC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAY;IAC5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAU;IAC3C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAc;gBAEnC,SAAS,EAAE,MAAM,EAAE;IAU/B,OAAO,CAAC,QAAQ;IAQT,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IASvC,OAAO,CAAC,aAAa;CAKtB"}
|
|
@@ -3,40 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EgressFilteringService = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const minimatch_1 = tslib_1.__importDefault(require("minimatch"));
|
|
6
|
-
const
|
|
6
|
+
const url_parser_1 = require("./url-parser");
|
|
7
7
|
class EgressFilteringService {
|
|
8
8
|
constructor(allowList) {
|
|
9
|
-
this.
|
|
9
|
+
this.DEFAULT_PROTOCOL = 'https://';
|
|
10
|
+
this.URLs = allowList.filter((domainOrURL) => !domainOrURL.startsWith('*')).map((url) => this.parseUrl(url));
|
|
10
11
|
this.wildcardDomains = allowList
|
|
11
12
|
.filter((domainOrURL) => domainOrURL !== '*')
|
|
12
|
-
.map((url) => this.
|
|
13
|
+
.map((url) => this.parseUrl(url))
|
|
13
14
|
.filter((url) => decodeURIComponent(url.hostname).startsWith('*'));
|
|
14
15
|
this.allowsEverything = allowList.includes('*');
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
parseUrl(url) {
|
|
17
18
|
const protocolRegex = /^(.*:\/\/)/;
|
|
18
|
-
const
|
|
19
|
-
return
|
|
19
|
+
const urlWithProtocol = protocolRegex.test(url) ? url : `${this.DEFAULT_PROTOCOL}${url}`;
|
|
20
|
+
return (0, url_parser_1.parseUrl)(urlWithProtocol);
|
|
20
21
|
}
|
|
21
22
|
isValidUrl(url) {
|
|
22
23
|
if (this.allowsEverything) {
|
|
23
24
|
return true;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
const parsedUrl = this.parseUrl(url);
|
|
27
|
+
return this.allowedDomain(parsedUrl, this.URLs) || this.allowedDomain(parsedUrl, this.wildcardDomains);
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
allowedDomain(domain, allowList) {
|
|
28
30
|
return allowList
|
|
29
31
|
.filter((allowed) => allowed.protocol === domain.protocol)
|
|
30
32
|
.some((url) => (0, minimatch_1.default)(domain.hostname, decodeURIComponent(url.hostname)));
|
|
31
33
|
}
|
|
32
|
-
domainIsAllowed(domain) {
|
|
33
|
-
if (this.domainCheck(domain, this.URLs)) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
if (this.domainCheck(domain, this.wildcardDomains)) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
34
|
}
|
|
42
35
|
exports.EgressFilteringService = EgressFilteringService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-parser.d.ts","sourceRoot":"","sources":["../../src/egress/url-parser.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC;AAKzD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAK7C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseUrl = void 0;
|
|
4
|
+
function parseUrl(url) {
|
|
5
|
+
var _a, _b;
|
|
6
|
+
const protocol = (_b = (_a = url.match(/^(.*:\/\/)/)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 'https://';
|
|
7
|
+
const hostname = url.replace(protocol, '').split(/[\/?]/)[0];
|
|
8
|
+
return { protocol, hostname };
|
|
9
|
+
}
|
|
10
|
+
exports.parseUrl = parseUrl;
|
package/out/egress/utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sortAndGroupEgressPermissionsByDomain = void 0;
|
|
4
4
|
const minimatch_1 = require("minimatch");
|
|
5
|
-
const
|
|
5
|
+
const url_parser_1 = require("./url-parser");
|
|
6
6
|
const sortAndGroupEgressPermissionsByDomain = (egressAddresses) => {
|
|
7
7
|
if ((egressAddresses === null || egressAddresses === void 0 ? void 0 : egressAddresses.length) === 0) {
|
|
8
8
|
return [];
|
|
@@ -12,7 +12,7 @@ const sortAndGroupEgressPermissionsByDomain = (egressAddresses) => {
|
|
|
12
12
|
const wildcardDomains = [];
|
|
13
13
|
egressAddresses.forEach((item) => {
|
|
14
14
|
const itemWithProtocol = protocolRegex.test(item) ? item : `https://${item}`;
|
|
15
|
-
const url =
|
|
15
|
+
const url = (0, url_parser_1.parseUrl)(itemWithProtocol);
|
|
16
16
|
if (url.hostname.startsWith('*')) {
|
|
17
17
|
domains.add(url.hostname.substring(2));
|
|
18
18
|
wildcardDomains.push((0, minimatch_1.makeRe)(url.hostname));
|