@poe-platform/safe-bash 0.1.80 → 0.1.81

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.
@@ -16368,19 +16368,31 @@ function createFetchTransport(options3 = {}) {
16368
16368
 
16369
16369
  // packages/safe-bash/src/commands/network/authorizer.ts
16370
16370
  init_platform();
16371
+ function privateIPv4(first, second) {
16372
+ return first === 10 || first === 127 || first === 0 || first === 169 && second === 254 || first === 192 && second === 168 || first === 172 && second >= 16 && second <= 31;
16373
+ }
16371
16374
  function privateHostname(input3) {
16372
16375
  const hostname = input3.toLowerCase().replace(/\.$/u, "").replace(/^\[|\]$/gu, "");
16373
16376
  if (hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "::1") return true;
16374
16377
  if (hostname.includes(":")) {
16375
- const first2 = hostname.split(":", 1)[0] ?? "";
16376
- return first2.startsWith("fc") || first2.startsWith("fd") || ["fe8", "fe9", "fea", "feb"].some((prefix2) => first2.startsWith(prefix2));
16378
+ const [prefix2, suffix2] = hostname.split("::");
16379
+ const leading = prefix2 ? prefix2.split(":") : [];
16380
+ const trailing = suffix2 ? suffix2.split(":") : [];
16381
+ const hextets = new Array(8).fill(0);
16382
+ for (let index = 0; index < leading.length; index++) hextets[index] = Number.parseInt(leading[index], 16);
16383
+ for (let index = 0; index < trailing.length; index++) hextets[8 - trailing.length + index] = Number.parseInt(trailing[index], 16);
16384
+ if (hextets.every((value2) => value2 === 0)) return true;
16385
+ if (hextets.slice(0, 5).every((value2) => value2 === 0) && hextets[5] === 65535) {
16386
+ return privateIPv4(hextets[6] >>> 8, hextets[6] & 255);
16387
+ }
16388
+ return (hextets[0] & 65024) === 64512 || (hextets[0] & 65472) === 65152;
16377
16389
  }
16378
16390
  const parts = hostname.split(".");
16379
16391
  if (parts.length !== 4 || parts.some((part) => !part || Array.from(part).some((character) => character < "0" || character > "9"))) return false;
16380
16392
  const octets = parts.map(Number);
16381
16393
  if (octets.some((value2) => value2 < 0 || value2 > 255)) return false;
16382
16394
  const [first, second] = octets;
16383
- return first === 10 || first === 127 || first === 0 || first === 169 && second === 254 || first === 192 && second === 168 || first === 172 && second >= 16 && second <= 31;
16395
+ return privateIPv4(first, second);
16384
16396
  }
16385
16397
  function createOriginAuthorizer(allowlist = "*", options3 = {}) {
16386
16398
  const origins = /* @__PURE__ */ new Set();