@poe-platform/safe-bash 0.1.236 → 0.1.238
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/dist/safe-bash/browser.js +11 -1
- package/dist/safe-bash/browser.js.map +4 -4
- package/dist/safe-bash/commands/network/authorizer.d.ts.map +1 -1
- package/dist/safe-bash/commands/network/authorizer.js +7 -41
- package/dist/safe-bash/commands/network/authorizer.js.map +1 -1
- package/dist/safe-bash/commands/network/curl.js +9 -2
- package/dist/safe-bash/commands/network/curl.js.map +1 -1
- package/dist/safe-bash/commands/network/fetch-transport.d.ts.map +1 -1
- package/dist/safe-bash/commands/network/fetch-transport.js +2 -0
- package/dist/safe-bash/commands/network/fetch-transport.js.map +1 -1
- package/dist/safe-bash/commands/network/private-address.d.ts +2 -0
- package/dist/safe-bash/commands/network/private-address.d.ts.map +1 -0
- package/dist/safe-bash/commands/network/private-address.js +38 -0
- package/dist/safe-bash/commands/network/private-address.js.map +1 -0
- package/dist/safe-bash/commands/network/transport.d.ts +4 -0
- package/dist/safe-bash/commands/network/transport.d.ts.map +1 -1
- package/dist/safe-bash/commands/network/transport.js +71 -17
- package/dist/safe-bash/commands/network/transport.js.map +1 -1
- package/dist/safe-bash/commands/network/types.d.ts +5 -1
- package/dist/safe-bash/commands/network/types.d.ts.map +1 -1
- package/dist/safe-bash/commands/network/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -17776,6 +17776,7 @@ function createFetchTransport(options3 = {}) {
|
|
|
17776
17776
|
input3.signal.throwIfAborted();
|
|
17777
17777
|
const url = new URL(input3.url);
|
|
17778
17778
|
if (url.protocol !== "http:" && url.protocol !== "https:") throw new CurlError(1, "Unsupported protocol");
|
|
17779
|
+
if (input3.denyPrivateNetworks === true) throw new CurlError(7, "Fetch transport cannot enforce private-network denial");
|
|
17779
17780
|
const stopped = new AbortController();
|
|
17780
17781
|
const signal = AbortSignal.any([input3.signal, stopped.signal]);
|
|
17781
17782
|
const body = requestBody(input3.body, signal);
|
|
@@ -17823,6 +17824,9 @@ function createFetchTransport(options3 = {}) {
|
|
|
17823
17824
|
|
|
17824
17825
|
// packages/safe-bash/src/commands/network/authorizer.ts
|
|
17825
17826
|
init_platform();
|
|
17827
|
+
|
|
17828
|
+
// packages/safe-bash/src/commands/network/private-address.ts
|
|
17829
|
+
init_platform();
|
|
17826
17830
|
function privateIPv4(first, second) {
|
|
17827
17831
|
return first === 10 || first === 127 || first === 0 || first === 169 && second === 254 || first === 192 && second === 168 || first === 172 && second >= 16 && second <= 31;
|
|
17828
17832
|
}
|
|
@@ -17852,7 +17856,10 @@ function privateHostname(input3) {
|
|
|
17852
17856
|
const [first, second] = octets;
|
|
17853
17857
|
return privateIPv4(first, second);
|
|
17854
17858
|
}
|
|
17859
|
+
|
|
17860
|
+
// packages/safe-bash/src/commands/network/authorizer.ts
|
|
17855
17861
|
function createOriginAuthorizer(allowlist = "*", options3 = {}) {
|
|
17862
|
+
const denyPrivateNetworks = options3.denyPrivateNetworks === true;
|
|
17856
17863
|
const origins = /* @__PURE__ */ new Set();
|
|
17857
17864
|
const hosts = /* @__PURE__ */ new Set();
|
|
17858
17865
|
for (const entry of allowlist === "*" ? [] : allowlist) {
|
|
@@ -17872,7 +17879,10 @@ function createOriginAuthorizer(allowlist = "*", options3 = {}) {
|
|
|
17872
17879
|
return (request) => {
|
|
17873
17880
|
const url = new URL(request.url);
|
|
17874
17881
|
const hostname = url.hostname.toLowerCase().replace(/\.$/u, "");
|
|
17875
|
-
if (
|
|
17882
|
+
if (denyPrivateNetworks) {
|
|
17883
|
+
request.requirePrivateNetworkDeny?.();
|
|
17884
|
+
if (privateHostname(hostname)) return false;
|
|
17885
|
+
}
|
|
17876
17886
|
return allowlist === "*" || origins.has(url.origin) || hosts.has(hostname);
|
|
17877
17887
|
};
|
|
17878
17888
|
}
|