browserclaw 0.2.6 → 0.2.8
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/index.cjs +24 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1387,6 +1387,12 @@ async function pressKeyViaPlaywright(opts) {
|
|
|
1387
1387
|
ensurePageState(page);
|
|
1388
1388
|
await page.keyboard.press(key, { delay: Math.max(0, Math.floor(opts.delayMs ?? 0)) });
|
|
1389
1389
|
}
|
|
1390
|
+
var InvalidBrowserNavigationUrlError = class extends Error {
|
|
1391
|
+
constructor(message) {
|
|
1392
|
+
super(message);
|
|
1393
|
+
this.name = "InvalidBrowserNavigationUrlError";
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1390
1396
|
function assertSafeOutputPath(path2, allowedRoots) {
|
|
1391
1397
|
if (!path2 || typeof path2 !== "string") {
|
|
1392
1398
|
throw new Error("Output path is required.");
|
|
@@ -1460,7 +1466,22 @@ function extractEmbeddedIPv4(lower) {
|
|
|
1460
1466
|
}
|
|
1461
1467
|
return null;
|
|
1462
1468
|
}
|
|
1469
|
+
function isStrictDecimalOctet(part) {
|
|
1470
|
+
if (!/^[0-9]+$/.test(part)) return false;
|
|
1471
|
+
const n = parseInt(part, 10);
|
|
1472
|
+
if (n < 0 || n > 255) return false;
|
|
1473
|
+
if (String(n) !== part) return false;
|
|
1474
|
+
return true;
|
|
1475
|
+
}
|
|
1476
|
+
function isUnsupportedIPv4Literal(ip) {
|
|
1477
|
+
if (/^[0-9]+$/.test(ip)) return true;
|
|
1478
|
+
const parts = ip.split(".");
|
|
1479
|
+
if (parts.length !== 4) return true;
|
|
1480
|
+
if (!parts.every(isStrictDecimalOctet)) return true;
|
|
1481
|
+
return false;
|
|
1482
|
+
}
|
|
1463
1483
|
function isInternalIP(ip) {
|
|
1484
|
+
if (!ip.includes(":") && isUnsupportedIPv4Literal(ip)) return true;
|
|
1464
1485
|
if (/^127\./.test(ip)) return true;
|
|
1465
1486
|
if (/^10\./.test(ip)) return true;
|
|
1466
1487
|
if (/^172\.(1[6-9]|2\d|3[01])\./.test(ip)) return true;
|
|
@@ -1516,7 +1537,7 @@ async function navigateViaPlaywright(opts) {
|
|
|
1516
1537
|
const url = String(opts.url ?? "").trim();
|
|
1517
1538
|
if (!url) throw new Error("url is required");
|
|
1518
1539
|
if (!opts.allowInternal && await isInternalUrlResolved(url)) {
|
|
1519
|
-
throw new
|
|
1540
|
+
throw new InvalidBrowserNavigationUrlError(`Navigation to internal/loopback address blocked: "${url}". Set allowInternal: true if this is intentional.`);
|
|
1520
1541
|
}
|
|
1521
1542
|
const page = await getPageForTargetId({ cdpUrl: opts.cdpUrl, targetId: opts.targetId });
|
|
1522
1543
|
ensurePageState(page);
|
|
@@ -1541,7 +1562,7 @@ async function listPagesViaPlaywright(opts) {
|
|
|
1541
1562
|
async function createPageViaPlaywright(opts) {
|
|
1542
1563
|
const targetUrl = (opts.url ?? "").trim() || "about:blank";
|
|
1543
1564
|
if (targetUrl !== "about:blank" && !opts.allowInternal && await isInternalUrlResolved(targetUrl)) {
|
|
1544
|
-
throw new
|
|
1565
|
+
throw new InvalidBrowserNavigationUrlError(`Navigation to internal/loopback address blocked: "${targetUrl}". Set allowInternal: true if this is intentional.`);
|
|
1545
1566
|
}
|
|
1546
1567
|
const { browser } = await connectBrowser(opts.cdpUrl);
|
|
1547
1568
|
const context = browser.contexts()[0] ?? await browser.newContext();
|
|
@@ -3059,5 +3080,6 @@ var BrowserClaw = class _BrowserClaw {
|
|
|
3059
3080
|
|
|
3060
3081
|
exports.BrowserClaw = BrowserClaw;
|
|
3061
3082
|
exports.CrawlPage = CrawlPage;
|
|
3083
|
+
exports.InvalidBrowserNavigationUrlError = InvalidBrowserNavigationUrlError;
|
|
3062
3084
|
//# sourceMappingURL=index.cjs.map
|
|
3063
3085
|
//# sourceMappingURL=index.cjs.map
|