@forge/egress
Advanced tools
Comparing version 1.1.2 to 1.1.3-next.0
# @forge/egress | ||
## 1.1.3-next.0 | ||
### Patch Changes | ||
- 0da2b48: Removed support for the CLI running on node 14 | ||
## 1.1.2 | ||
@@ -4,0 +10,0 @@ |
@@ -5,8 +5,8 @@ export declare class EgressFilteringService { | ||
private readonly allowsEverything; | ||
private readonly DEFAULT_PROTOCOL; | ||
constructor(allowList: string[]); | ||
private safeURL; | ||
private parseUrl; | ||
isValidUrl(url: string): boolean; | ||
private domainCheck; | ||
private domainIsAllowed; | ||
private allowedDomain; | ||
} | ||
//# sourceMappingURL=egress-filtering-service.d.ts.map |
@@ -9,13 +9,14 @@ "use strict"; | ||
constructor(allowList) { | ||
this.URLs = allowList.filter((domainOrURL) => !domainOrURL.startsWith('*')).map((url) => this.safeURL(url)); | ||
this.DEFAULT_PROTOCOL = 'https://'; | ||
this.URLs = allowList.filter((domainOrURL) => !domainOrURL.startsWith('*')).map((url) => this.parseUrl(url)); | ||
this.wildcardDomains = allowList | ||
.filter((domainOrURL) => domainOrURL !== '*') | ||
.map((url) => this.safeURL(url)) | ||
.map((url) => this.parseUrl(url)) | ||
.filter((url) => decodeURIComponent(url.hostname).startsWith('*')); | ||
this.allowsEverything = allowList.includes('*'); | ||
} | ||
safeURL(url, defaultProtocol = 'https://') { | ||
parseUrl(url) { | ||
const protocolRegex = /^(.*:\/\/)/; | ||
const urlParser = url_1.URL !== null && url_1.URL !== void 0 ? url_1.URL : window.URL; | ||
return new urlParser(protocolRegex.test(url) ? url : `${defaultProtocol}${url}`); | ||
return new urlParser(protocolRegex.test(url) ? url : `${this.DEFAULT_PROTOCOL}${url}`); | ||
} | ||
@@ -26,5 +27,6 @@ isValidUrl(url) { | ||
} | ||
return this.domainIsAllowed(this.safeURL(url)); | ||
const parsedUrl = this.parseUrl(url); | ||
return this.allowedDomain(parsedUrl, this.URLs) || this.allowedDomain(parsedUrl, this.wildcardDomains); | ||
} | ||
domainCheck(domain, allowList) { | ||
allowedDomain(domain, allowList) { | ||
return allowList | ||
@@ -34,12 +36,3 @@ .filter((allowed) => allowed.protocol === domain.protocol) | ||
} | ||
domainIsAllowed(domain) { | ||
if (this.domainCheck(domain, this.URLs)) { | ||
return true; | ||
} | ||
if (this.domainCheck(domain, this.wildcardDomains)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
exports.EgressFilteringService = EgressFilteringService; |
{ | ||
"name": "@forge/egress", | ||
"version": "1.1.2", | ||
"version": "1.1.3-next.0", | ||
"description": "Helpers and utils for egress implementation in Forge apps", | ||
@@ -5,0 +5,0 @@ "main": "out/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6201
90
2