browserclaw 0.2.5 → 0.2.7
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/README.md +5 -3
- package/dist/index.cjs +75 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +75 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -399,7 +399,8 @@ async function launchChrome(opts = {}) {
|
|
|
399
399
|
args.push("--no-sandbox", "--disable-setuid-sandbox");
|
|
400
400
|
}
|
|
401
401
|
if (process.platform === "linux") args.push("--disable-dev-shm-usage");
|
|
402
|
-
|
|
402
|
+
const extraArgs = Array.isArray(opts.chromeArgs) ? opts.chromeArgs.filter((a) => typeof a === "string" && a.trim().length > 0) : [];
|
|
403
|
+
if (extraArgs.length) args.push(...extraArgs);
|
|
403
404
|
args.push("about:blank");
|
|
404
405
|
return spawn(exe.path, args, {
|
|
405
406
|
stdio: "pipe",
|
|
@@ -1396,7 +1397,76 @@ function assertSafeOutputPath(path2, allowedRoots) {
|
|
|
1396
1397
|
}
|
|
1397
1398
|
}
|
|
1398
1399
|
}
|
|
1400
|
+
function expandIPv6(ip) {
|
|
1401
|
+
let normalized = ip;
|
|
1402
|
+
const v4Match = normalized.match(/^(.+:)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
|
|
1403
|
+
if (v4Match) {
|
|
1404
|
+
const octets = v4Match[2].split(".").map(Number);
|
|
1405
|
+
if (octets.some((o) => o > 255)) return null;
|
|
1406
|
+
const hexHi = (octets[0] << 8 | octets[1]).toString(16).padStart(4, "0");
|
|
1407
|
+
const hexLo = (octets[2] << 8 | octets[3]).toString(16).padStart(4, "0");
|
|
1408
|
+
normalized = v4Match[1] + hexHi + ":" + hexLo;
|
|
1409
|
+
}
|
|
1410
|
+
const halves = normalized.split("::");
|
|
1411
|
+
if (halves.length > 2) return null;
|
|
1412
|
+
if (halves.length === 2) {
|
|
1413
|
+
const left = halves[0] !== "" ? halves[0].split(":") : [];
|
|
1414
|
+
const right = halves[1] !== "" ? halves[1].split(":") : [];
|
|
1415
|
+
const needed = 8 - left.length - right.length;
|
|
1416
|
+
if (needed < 0) return null;
|
|
1417
|
+
const groups2 = [...left, ...Array(needed).fill("0"), ...right];
|
|
1418
|
+
if (groups2.length !== 8) return null;
|
|
1419
|
+
return groups2.map((g) => g.padStart(4, "0")).join(":");
|
|
1420
|
+
}
|
|
1421
|
+
const groups = normalized.split(":");
|
|
1422
|
+
if (groups.length !== 8) return null;
|
|
1423
|
+
return groups.map((g) => g.padStart(4, "0")).join(":");
|
|
1424
|
+
}
|
|
1425
|
+
function hexToIPv4(hiHex, loHex) {
|
|
1426
|
+
const hi = parseInt(hiHex, 16);
|
|
1427
|
+
const lo = parseInt(loHex, 16);
|
|
1428
|
+
return `${hi >> 8 & 255}.${hi & 255}.${lo >> 8 & 255}.${lo & 255}`;
|
|
1429
|
+
}
|
|
1430
|
+
function extractEmbeddedIPv4(lower) {
|
|
1431
|
+
if (lower.startsWith("::ffff:")) {
|
|
1432
|
+
return lower.slice(7);
|
|
1433
|
+
}
|
|
1434
|
+
const expanded = expandIPv6(lower);
|
|
1435
|
+
if (expanded === null) return "";
|
|
1436
|
+
const groups = expanded.split(":");
|
|
1437
|
+
if (groups.length !== 8) return "";
|
|
1438
|
+
if (groups[0] === "0064" && groups[1] === "ff9b" && groups[2] === "0000" && groups[3] === "0000" && groups[4] === "0000" && groups[5] === "0000") {
|
|
1439
|
+
return hexToIPv4(groups[6], groups[7]);
|
|
1440
|
+
}
|
|
1441
|
+
if (groups[0] === "0064" && groups[1] === "ff9b" && groups[2] === "0001") {
|
|
1442
|
+
return hexToIPv4(groups[6], groups[7]);
|
|
1443
|
+
}
|
|
1444
|
+
if (groups[0] === "2002") {
|
|
1445
|
+
return hexToIPv4(groups[1], groups[2]);
|
|
1446
|
+
}
|
|
1447
|
+
if (groups[0] === "2001" && groups[1] === "0000") {
|
|
1448
|
+
const hiXored = (parseInt(groups[6], 16) ^ 65535).toString(16).padStart(4, "0");
|
|
1449
|
+
const loXored = (parseInt(groups[7], 16) ^ 65535).toString(16).padStart(4, "0");
|
|
1450
|
+
return hexToIPv4(hiXored, loXored);
|
|
1451
|
+
}
|
|
1452
|
+
return null;
|
|
1453
|
+
}
|
|
1454
|
+
function isStrictDecimalOctet(part) {
|
|
1455
|
+
if (!/^[0-9]+$/.test(part)) return false;
|
|
1456
|
+
const n = parseInt(part, 10);
|
|
1457
|
+
if (n < 0 || n > 255) return false;
|
|
1458
|
+
if (String(n) !== part) return false;
|
|
1459
|
+
return true;
|
|
1460
|
+
}
|
|
1461
|
+
function isUnsupportedIPv4Literal(ip) {
|
|
1462
|
+
if (/^[0-9]+$/.test(ip)) return true;
|
|
1463
|
+
const parts = ip.split(".");
|
|
1464
|
+
if (parts.length !== 4) return true;
|
|
1465
|
+
if (!parts.every(isStrictDecimalOctet)) return true;
|
|
1466
|
+
return false;
|
|
1467
|
+
}
|
|
1399
1468
|
function isInternalIP(ip) {
|
|
1469
|
+
if (!ip.includes(":") && isUnsupportedIPv4Literal(ip)) return true;
|
|
1400
1470
|
if (/^127\./.test(ip)) return true;
|
|
1401
1471
|
if (/^10\./.test(ip)) return true;
|
|
1402
1472
|
if (/^172\.(1[6-9]|2\d|3[01])\./.test(ip)) return true;
|
|
@@ -1408,9 +1478,10 @@ function isInternalIP(ip) {
|
|
|
1408
1478
|
if (lower === "::1") return true;
|
|
1409
1479
|
if (lower.startsWith("fe80:")) return true;
|
|
1410
1480
|
if (lower.startsWith("fc") || lower.startsWith("fd")) return true;
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1481
|
+
const embedded = extractEmbeddedIPv4(lower);
|
|
1482
|
+
if (embedded !== null) {
|
|
1483
|
+
if (embedded === "") return true;
|
|
1484
|
+
return isInternalIP(embedded);
|
|
1414
1485
|
}
|
|
1415
1486
|
return false;
|
|
1416
1487
|
}
|