@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,6 +1,13 @@
1
1
  # @forge/egress
2
2
 
3
+ ## 1.1.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 174deac: Add support for browser environments
8
+
3
9
  ## 1.0.1-next.0
10
+
4
11
  ### Patch Changes
5
12
 
6
13
  - 3c0ac54: Move egress related services out of @forge/csp into new @forge/egress package
@@ -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;IAY/B,OAAO,CAAC,OAAO;IAOR,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAQvC,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,eAAe;CAWxB"}
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
- return new url_1.URL(protocolRegex.test(url) ? url : `${defaultProtocol}${url}`);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/egress",
3
- "version": "1.0.1-next.0",
3
+ "version": "1.1.0-next.1",
4
4
  "description": "Helpers and utils for egress implementation in Forge apps",
5
5
  "main": "out/index.js",
6
6
  "author": "Atlassian",