@forge/egress
Advanced tools
Comparing version 1.1.0 to 1.1.1-next.0
# @forge/egress | ||
## 1.1.1-next.0 | ||
### Patch Changes | ||
- 63d168c: Fix browser compatibility | ||
## 1.1.0 | ||
@@ -4,0 +10,0 @@ |
@@ -5,3 +5,3 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const micromatch_1 = tslib_1.__importDefault(require("micromatch")); | ||
const minimatch_1 = tslib_1.__importDefault(require("minimatch")); | ||
const url_1 = require("url"); | ||
@@ -29,8 +29,5 @@ class EgressFilteringService { | ||
domainCheck(domain, allowList) { | ||
const hostnameMatchedProtocol = allowList | ||
return allowList | ||
.filter((allowed) => allowed.protocol === domain.protocol) | ||
.map((url) => decodeURIComponent(url.hostname)); | ||
return (micromatch_1.default([domain.hostname], hostnameMatchedProtocol, { | ||
dot: true | ||
}).length > 0); | ||
.some((url) => minimatch_1.default(domain.hostname, decodeURIComponent(url.hostname))); | ||
} | ||
@@ -37,0 +34,0 @@ domainIsAllowed(domain) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sortAndGroupEgressPermissionsByDomain = void 0; | ||
const tslib_1 = require("tslib"); | ||
const micromatch_1 = tslib_1.__importDefault(require("micromatch")); | ||
const minimatch_1 = require("minimatch"); | ||
const url_1 = require("url"); | ||
const sortAndGroupEgressPermissionsByDomain = (egressAddresses) => { | ||
const protocolRegex = /^(.*?:\/\/)/; | ||
const domainSet = new Set(); | ||
const groupSet = new Set(); | ||
const removeSet = new Set(); | ||
if ((egressAddresses === null || egressAddresses === void 0 ? void 0 : egressAddresses.length) === 0) { | ||
return []; | ||
} | ||
const protocolRegex = /^(.*?:\/\/)/; | ||
const domains = new Set(); | ||
const wildcardDomains = []; | ||
egressAddresses.forEach((item) => { | ||
@@ -19,14 +17,16 @@ const itemWithProtocol = protocolRegex.test(item) ? item : `https://${item}`; | ||
if (url.hostname.startsWith('*')) { | ||
groupSet.add(url.hostname.substring(2)); | ||
removeSet.add('!' + url.hostname); | ||
domains.add(url.hostname.substring(2)); | ||
wildcardDomains.push(minimatch_1.makeRe(url.hostname)); | ||
} | ||
else { | ||
domainSet.add(url.hostname); | ||
domains.add(url.hostname); | ||
} | ||
}); | ||
if (removeSet.size === 0) { | ||
return [...domainSet]; | ||
} | ||
return [...new Set(micromatch_1.default([...domainSet], [...removeSet]).concat([...groupSet]))].sort(); | ||
return [...domains].sort().reduce((grouped, domain) => { | ||
if (!wildcardDomains.some((wcd) => wcd.test(domain))) { | ||
grouped.push(domain); | ||
} | ||
return grouped; | ||
}, []); | ||
}; | ||
exports.sortAndGroupEgressPermissionsByDomain = sortAndGroupEgressPermissionsByDomain; |
{ | ||
"name": "@forge/egress", | ||
"version": "1.1.0", | ||
"version": "1.1.1-next.0", | ||
"description": "Helpers and utils for egress implementation in Forge apps", | ||
@@ -17,4 +17,4 @@ "main": "out/index.js", | ||
"dependencies": { | ||
"micromatch": "^4.0.2" | ||
"minimatch": "^5.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
5902
97
2
+ Addedminimatch@^5.1.0
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedminimatch@5.1.6(transitive)
- Removedmicromatch@^4.0.2
- Removedbraces@3.0.3(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedis-number@7.0.0(transitive)
- Removedmicromatch@4.0.8(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedto-regex-range@5.0.1(transitive)