browserclaw 0.3.4 → 0.3.5

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.d.cts CHANGED
@@ -9,10 +9,19 @@ interface FrameEvalResult {
9
9
 
10
10
  /**
11
11
  * Policy for controlling which URLs browser navigation is allowed to reach.
12
- * By default all private/internal addresses are blocked to prevent SSRF attacks.
12
+ * Defaults to trusted-network mode (private/internal addresses allowed).
13
+ * Set `dangerouslyAllowPrivateNetwork: false` to enforce strict public-only checks.
13
14
  */
14
15
  interface SsrfPolicy {
15
- /** Allow navigation to private/internal network addresses. Default: `false` */
16
+ /**
17
+ * Allow navigation to private/internal network addresses.
18
+ * Default: `true` (trusted-network mode). Set to `false` for strict public-only enforcement.
19
+ */
20
+ dangerouslyAllowPrivateNetwork?: boolean;
21
+ /**
22
+ * Allow navigation to private/internal network addresses.
23
+ * @deprecated Use `dangerouslyAllowPrivateNetwork` instead.
24
+ */
16
25
  allowPrivateNetwork?: boolean;
17
26
  /** Hostnames explicitly allowed even if they resolve to private addresses */
18
27
  allowedHostnames?: string[];
@@ -48,12 +57,13 @@ interface LaunchOptions {
48
57
  chromeArgs?: string[];
49
58
  /**
50
59
  * SSRF policy controlling which URLs navigation is allowed to reach.
51
- * By default all private/internal addresses are blocked.
60
+ * Defaults to trusted-network mode (private/internal addresses allowed).
61
+ * Set `dangerouslyAllowPrivateNetwork: false` to enforce strict public-only checks.
52
62
  */
53
63
  ssrfPolicy?: SsrfPolicy;
54
64
  /**
55
65
  * Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
56
- * @deprecated Use `ssrfPolicy: { allowPrivateNetwork: true }` instead.
66
+ * @deprecated Use `ssrfPolicy: { dangerouslyAllowPrivateNetwork: true }` instead.
57
67
  */
58
68
  allowInternal?: boolean;
59
69
  }
@@ -61,12 +71,13 @@ interface LaunchOptions {
61
71
  interface ConnectOptions {
62
72
  /**
63
73
  * SSRF policy controlling which URLs navigation is allowed to reach.
64
- * By default all private/internal addresses are blocked.
74
+ * Defaults to trusted-network mode (private/internal addresses allowed).
75
+ * Set `dangerouslyAllowPrivateNetwork: false` to enforce strict public-only checks.
65
76
  */
66
77
  ssrfPolicy?: SsrfPolicy;
67
78
  /**
68
79
  * Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
69
- * @deprecated Use `ssrfPolicy: { allowPrivateNetwork: true }` instead.
80
+ * @deprecated Use `ssrfPolicy: { dangerouslyAllowPrivateNetwork: true }` instead.
70
81
  */
71
82
  allowInternal?: boolean;
72
83
  /**
package/dist/index.d.ts CHANGED
@@ -9,10 +9,19 @@ interface FrameEvalResult {
9
9
 
10
10
  /**
11
11
  * Policy for controlling which URLs browser navigation is allowed to reach.
12
- * By default all private/internal addresses are blocked to prevent SSRF attacks.
12
+ * Defaults to trusted-network mode (private/internal addresses allowed).
13
+ * Set `dangerouslyAllowPrivateNetwork: false` to enforce strict public-only checks.
13
14
  */
14
15
  interface SsrfPolicy {
15
- /** Allow navigation to private/internal network addresses. Default: `false` */
16
+ /**
17
+ * Allow navigation to private/internal network addresses.
18
+ * Default: `true` (trusted-network mode). Set to `false` for strict public-only enforcement.
19
+ */
20
+ dangerouslyAllowPrivateNetwork?: boolean;
21
+ /**
22
+ * Allow navigation to private/internal network addresses.
23
+ * @deprecated Use `dangerouslyAllowPrivateNetwork` instead.
24
+ */
16
25
  allowPrivateNetwork?: boolean;
17
26
  /** Hostnames explicitly allowed even if they resolve to private addresses */
18
27
  allowedHostnames?: string[];
@@ -48,12 +57,13 @@ interface LaunchOptions {
48
57
  chromeArgs?: string[];
49
58
  /**
50
59
  * SSRF policy controlling which URLs navigation is allowed to reach.
51
- * By default all private/internal addresses are blocked.
60
+ * Defaults to trusted-network mode (private/internal addresses allowed).
61
+ * Set `dangerouslyAllowPrivateNetwork: false` to enforce strict public-only checks.
52
62
  */
53
63
  ssrfPolicy?: SsrfPolicy;
54
64
  /**
55
65
  * Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
56
- * @deprecated Use `ssrfPolicy: { allowPrivateNetwork: true }` instead.
66
+ * @deprecated Use `ssrfPolicy: { dangerouslyAllowPrivateNetwork: true }` instead.
57
67
  */
58
68
  allowInternal?: boolean;
59
69
  }
@@ -61,12 +71,13 @@ interface LaunchOptions {
61
71
  interface ConnectOptions {
62
72
  /**
63
73
  * SSRF policy controlling which URLs navigation is allowed to reach.
64
- * By default all private/internal addresses are blocked.
74
+ * Defaults to trusted-network mode (private/internal addresses allowed).
75
+ * Set `dangerouslyAllowPrivateNetwork: false` to enforce strict public-only checks.
65
76
  */
66
77
  ssrfPolicy?: SsrfPolicy;
67
78
  /**
68
79
  * Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
69
- * @deprecated Use `ssrfPolicy: { allowPrivateNetwork: true }` instead.
80
+ * @deprecated Use `ssrfPolicy: { dangerouslyAllowPrivateNetwork: true }` instead.
70
81
  */
71
82
  allowInternal?: boolean;
72
83
  /**
package/dist/index.js CHANGED
@@ -1403,7 +1403,7 @@ async function assertBrowserNavigationAllowed(opts) {
1403
1403
  throw new InvalidBrowserNavigationUrlError(`Navigation blocked: unsupported protocol "${parsed.protocol}"`);
1404
1404
  }
1405
1405
  const policy = opts.ssrfPolicy;
1406
- if (policy?.allowPrivateNetwork) return;
1406
+ if (policy?.dangerouslyAllowPrivateNetwork ?? policy?.allowPrivateNetwork ?? true) return;
1407
1407
  const allowedHostnames = [
1408
1408
  ...policy?.allowedHostnames ?? [],
1409
1409
  ...policy?.hostnameAllowlist ?? []
@@ -1414,7 +1414,7 @@ async function assertBrowserNavigationAllowed(opts) {
1414
1414
  }
1415
1415
  if (await isInternalUrlResolved(rawUrl, opts.lookupFn)) {
1416
1416
  throw new InvalidBrowserNavigationUrlError(
1417
- `Navigation to internal/loopback address blocked: "${rawUrl}". Use ssrfPolicy: { allowPrivateNetwork: true } if this is intentional.`
1417
+ `Navigation to internal/loopback address blocked: "${rawUrl}". ssrfPolicy.dangerouslyAllowPrivateNetwork is false (strict mode).`
1418
1418
  );
1419
1419
  }
1420
1420
  }
@@ -1561,7 +1561,7 @@ async function isInternalUrlResolved(url, lookupFn = lookup) {
1561
1561
  async function navigateViaPlaywright(opts) {
1562
1562
  const url = String(opts.url ?? "").trim();
1563
1563
  if (!url) throw new Error("url is required");
1564
- const policy = opts.allowInternal ? { ...opts.ssrfPolicy, allowPrivateNetwork: true } : opts.ssrfPolicy;
1564
+ const policy = opts.allowInternal ? { ...opts.ssrfPolicy, dangerouslyAllowPrivateNetwork: true } : opts.ssrfPolicy;
1565
1565
  await assertBrowserNavigationAllowed({ url, ssrfPolicy: policy });
1566
1566
  const page = await getPageForTargetId({ cdpUrl: opts.cdpUrl, targetId: opts.targetId });
1567
1567
  ensurePageState(page);
@@ -1586,7 +1586,7 @@ async function listPagesViaPlaywright(opts) {
1586
1586
  async function createPageViaPlaywright(opts) {
1587
1587
  const targetUrl = (opts.url ?? "").trim() || "about:blank";
1588
1588
  if (targetUrl !== "about:blank") {
1589
- const policy = opts.allowInternal ? { ...opts.ssrfPolicy, allowPrivateNetwork: true } : opts.ssrfPolicy;
1589
+ const policy = opts.allowInternal ? { ...opts.ssrfPolicy, dangerouslyAllowPrivateNetwork: true } : opts.ssrfPolicy;
1590
1590
  await assertBrowserNavigationAllowed({ url: targetUrl, ssrfPolicy: policy });
1591
1591
  }
1592
1592
  const { browser } = await connectBrowser(opts.cdpUrl);
@@ -3010,7 +3010,7 @@ var BrowserClaw = class _BrowserClaw {
3010
3010
  static async launch(opts = {}) {
3011
3011
  const chrome = await launchChrome(opts);
3012
3012
  const cdpUrl = `http://127.0.0.1:${chrome.cdpPort}`;
3013
- const ssrfPolicy = opts.allowInternal ? { ...opts.ssrfPolicy, allowPrivateNetwork: true } : opts.ssrfPolicy;
3013
+ const ssrfPolicy = opts.allowInternal ? { ...opts.ssrfPolicy, dangerouslyAllowPrivateNetwork: true } : opts.ssrfPolicy;
3014
3014
  return new _BrowserClaw(cdpUrl, chrome, ssrfPolicy);
3015
3015
  }
3016
3016
  /**
@@ -3032,7 +3032,7 @@ var BrowserClaw = class _BrowserClaw {
3032
3032
  throw new Error(`Cannot connect to Chrome at ${cdpUrl}. Is Chrome running with --remote-debugging-port?`);
3033
3033
  }
3034
3034
  await connectBrowser(cdpUrl, opts?.authToken);
3035
- const ssrfPolicy = opts?.allowInternal ? { ...opts.ssrfPolicy, allowPrivateNetwork: true } : opts?.ssrfPolicy;
3035
+ const ssrfPolicy = opts?.allowInternal ? { ...opts.ssrfPolicy, dangerouslyAllowPrivateNetwork: true } : opts?.ssrfPolicy;
3036
3036
  return new _BrowserClaw(cdpUrl, null, ssrfPolicy);
3037
3037
  }
3038
3038
  /**