browserclaw 0.2.2 → 0.2.4

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
@@ -33,6 +33,27 @@ interface LaunchOptions {
33
33
  profileColor?: string;
34
34
  /** Additional Chrome command-line arguments (e.g. `['--start-maximized']`). */
35
35
  chromeArgs?: string[];
36
+ /**
37
+ * Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
38
+ * Default: `false` — internal URLs are blocked to prevent SSRF attacks.
39
+ * Set to `true` if you need to access local development servers.
40
+ */
41
+ allowInternal?: boolean;
42
+ }
43
+ /** Options for connecting to an existing browser instance. */
44
+ interface ConnectOptions {
45
+ /**
46
+ * Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
47
+ * Default: `false` — internal URLs are blocked to prevent SSRF attacks.
48
+ * Set to `true` if you need to access local development servers.
49
+ */
50
+ allowInternal?: boolean;
51
+ /**
52
+ * Bearer token for authenticating with the CDP endpoint.
53
+ * Required when connecting to a browser instance that has auth enabled
54
+ * (e.g. OpenClaw browser control with gateway.auth.token).
55
+ */
56
+ authToken?: string;
36
57
  }
37
58
  /**
38
59
  * Describes a single interactive element found during a snapshot.
@@ -48,6 +69,19 @@ interface RoleRefInfo {
48
69
  }
49
70
  /** Map of ref IDs (e.g. `'e1'`, `'e2'`) to their element information. */
50
71
  type RoleRefs = Record<string, RoleRefInfo>;
72
+ /**
73
+ * Metadata about the source of untrusted external content.
74
+ * Used by consumers (e.g. OpenClaw) to wrap browser outputs with
75
+ * structured external-content markers for prompt-injection mitigation.
76
+ */
77
+ interface UntrustedContentMeta {
78
+ /** The source URL of the content at the time of capture */
79
+ sourceUrl?: string;
80
+ /** Content type identifier (e.g. `'browser-snapshot'`, `'browser-aria-tree'`) */
81
+ contentType: string;
82
+ /** ISO 8601 timestamp of when the content was captured */
83
+ capturedAt: string;
84
+ }
51
85
  /** Result of taking a page snapshot. */
52
86
  interface SnapshotResult {
53
87
  /** AI-readable text representation of the page with numbered refs */
@@ -56,6 +90,14 @@ interface SnapshotResult {
56
90
  refs: RoleRefs;
57
91
  /** Statistics about the snapshot */
58
92
  stats?: SnapshotStats;
93
+ /**
94
+ * Indicates this content originates from an untrusted external source (the web page).
95
+ * AI agents should treat snapshot content as potentially adversarial
96
+ * (e.g. prompt injection via page text). Always `true` for browser snapshots.
97
+ */
98
+ untrusted?: true;
99
+ /** Structured metadata about the untrusted content source */
100
+ contentMeta?: UntrustedContentMeta;
59
101
  }
60
102
  /** Statistics about a snapshot's content. */
61
103
  interface SnapshotStats {
@@ -110,6 +152,13 @@ interface AriaNode {
110
152
  interface AriaSnapshotResult {
111
153
  /** Flat list of accessibility tree nodes */
112
154
  nodes: AriaNode[];
155
+ /**
156
+ * Indicates this content originates from an untrusted external source (the web page).
157
+ * AI agents should treat snapshot content as potentially adversarial. Always `true`.
158
+ */
159
+ untrusted?: true;
160
+ /** Structured metadata about the untrusted content source */
161
+ contentMeta?: UntrustedContentMeta;
113
162
  }
114
163
  /** A form field to fill as part of a batch `fill()` operation. */
115
164
  interface FormField {
@@ -341,8 +390,9 @@ interface HttpCredentials {
341
390
  declare class CrawlPage {
342
391
  private readonly cdpUrl;
343
392
  private readonly targetId;
393
+ private readonly allowInternal;
344
394
  /** @internal */
345
- constructor(cdpUrl: string, targetId: string);
395
+ constructor(cdpUrl: string, targetId: string, allowInternal?: boolean);
346
396
  /** The CDP target ID for this page. Use this to identify the page in multi-tab scenarios. */
347
397
  get id(): string;
348
398
  /**
@@ -699,8 +749,11 @@ declare class CrawlPage {
699
749
  * Stop recording a trace and save it to a file.
700
750
  *
701
751
  * @param path - File path to save the trace (e.g. `'trace.zip'`)
752
+ * @param opts - Options (allowedOutputRoots: constrain output to specific directories)
702
753
  */
703
- traceStop(path: string): Promise<void>;
754
+ traceStop(path: string, opts?: {
755
+ allowedOutputRoots?: string[];
756
+ }): Promise<void>;
704
757
  /**
705
758
  * Wait for a network response matching a URL pattern and return its body.
706
759
  *
@@ -824,6 +877,7 @@ declare class CrawlPage {
824
877
  */
825
878
  download(ref: string, path: string, opts?: {
826
879
  timeoutMs?: number;
880
+ allowedOutputRoots?: string[];
827
881
  }): Promise<DownloadResult>;
828
882
  /**
829
883
  * Wait for the next download event (without clicking).
@@ -836,6 +890,7 @@ declare class CrawlPage {
836
890
  waitForDownload(opts?: {
837
891
  path?: string;
838
892
  timeoutMs?: number;
893
+ allowedOutputRoots?: string[];
839
894
  }): Promise<DownloadResult>;
840
895
  /**
841
896
  * Set the browser to offline or online mode.
@@ -932,6 +987,7 @@ declare class CrawlPage {
932
987
  */
933
988
  declare class BrowserClaw {
934
989
  private readonly cdpUrl;
990
+ private readonly allowInternal;
935
991
  private chrome;
936
992
  private constructor();
937
993
  /**
@@ -972,7 +1028,7 @@ declare class BrowserClaw {
972
1028
  * const browser = await BrowserClaw.connect('http://localhost:9222');
973
1029
  * ```
974
1030
  */
975
- static connect(cdpUrl: string): Promise<BrowserClaw>;
1031
+ static connect(cdpUrl: string, opts?: ConnectOptions): Promise<BrowserClaw>;
976
1032
  /**
977
1033
  * Open a URL in a new tab and return the page handle.
978
1034
  *
@@ -1031,4 +1087,4 @@ declare class BrowserClaw {
1031
1087
  stop(): Promise<void>;
1032
1088
  }
1033
1089
 
1034
- export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConsoleMessage, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, type LaunchOptions, type NetworkRequest, type PageError, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type StorageKind, type TraceStartOptions, type TypeOptions, type WaitOptions };
1090
+ export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, type LaunchOptions, type NetworkRequest, type PageError, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions };
package/dist/index.d.ts CHANGED
@@ -33,6 +33,27 @@ interface LaunchOptions {
33
33
  profileColor?: string;
34
34
  /** Additional Chrome command-line arguments (e.g. `['--start-maximized']`). */
35
35
  chromeArgs?: string[];
36
+ /**
37
+ * Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
38
+ * Default: `false` — internal URLs are blocked to prevent SSRF attacks.
39
+ * Set to `true` if you need to access local development servers.
40
+ */
41
+ allowInternal?: boolean;
42
+ }
43
+ /** Options for connecting to an existing browser instance. */
44
+ interface ConnectOptions {
45
+ /**
46
+ * Allow navigation to internal/loopback addresses (localhost, 127.x, private IPs).
47
+ * Default: `false` — internal URLs are blocked to prevent SSRF attacks.
48
+ * Set to `true` if you need to access local development servers.
49
+ */
50
+ allowInternal?: boolean;
51
+ /**
52
+ * Bearer token for authenticating with the CDP endpoint.
53
+ * Required when connecting to a browser instance that has auth enabled
54
+ * (e.g. OpenClaw browser control with gateway.auth.token).
55
+ */
56
+ authToken?: string;
36
57
  }
37
58
  /**
38
59
  * Describes a single interactive element found during a snapshot.
@@ -48,6 +69,19 @@ interface RoleRefInfo {
48
69
  }
49
70
  /** Map of ref IDs (e.g. `'e1'`, `'e2'`) to their element information. */
50
71
  type RoleRefs = Record<string, RoleRefInfo>;
72
+ /**
73
+ * Metadata about the source of untrusted external content.
74
+ * Used by consumers (e.g. OpenClaw) to wrap browser outputs with
75
+ * structured external-content markers for prompt-injection mitigation.
76
+ */
77
+ interface UntrustedContentMeta {
78
+ /** The source URL of the content at the time of capture */
79
+ sourceUrl?: string;
80
+ /** Content type identifier (e.g. `'browser-snapshot'`, `'browser-aria-tree'`) */
81
+ contentType: string;
82
+ /** ISO 8601 timestamp of when the content was captured */
83
+ capturedAt: string;
84
+ }
51
85
  /** Result of taking a page snapshot. */
52
86
  interface SnapshotResult {
53
87
  /** AI-readable text representation of the page with numbered refs */
@@ -56,6 +90,14 @@ interface SnapshotResult {
56
90
  refs: RoleRefs;
57
91
  /** Statistics about the snapshot */
58
92
  stats?: SnapshotStats;
93
+ /**
94
+ * Indicates this content originates from an untrusted external source (the web page).
95
+ * AI agents should treat snapshot content as potentially adversarial
96
+ * (e.g. prompt injection via page text). Always `true` for browser snapshots.
97
+ */
98
+ untrusted?: true;
99
+ /** Structured metadata about the untrusted content source */
100
+ contentMeta?: UntrustedContentMeta;
59
101
  }
60
102
  /** Statistics about a snapshot's content. */
61
103
  interface SnapshotStats {
@@ -110,6 +152,13 @@ interface AriaNode {
110
152
  interface AriaSnapshotResult {
111
153
  /** Flat list of accessibility tree nodes */
112
154
  nodes: AriaNode[];
155
+ /**
156
+ * Indicates this content originates from an untrusted external source (the web page).
157
+ * AI agents should treat snapshot content as potentially adversarial. Always `true`.
158
+ */
159
+ untrusted?: true;
160
+ /** Structured metadata about the untrusted content source */
161
+ contentMeta?: UntrustedContentMeta;
113
162
  }
114
163
  /** A form field to fill as part of a batch `fill()` operation. */
115
164
  interface FormField {
@@ -341,8 +390,9 @@ interface HttpCredentials {
341
390
  declare class CrawlPage {
342
391
  private readonly cdpUrl;
343
392
  private readonly targetId;
393
+ private readonly allowInternal;
344
394
  /** @internal */
345
- constructor(cdpUrl: string, targetId: string);
395
+ constructor(cdpUrl: string, targetId: string, allowInternal?: boolean);
346
396
  /** The CDP target ID for this page. Use this to identify the page in multi-tab scenarios. */
347
397
  get id(): string;
348
398
  /**
@@ -699,8 +749,11 @@ declare class CrawlPage {
699
749
  * Stop recording a trace and save it to a file.
700
750
  *
701
751
  * @param path - File path to save the trace (e.g. `'trace.zip'`)
752
+ * @param opts - Options (allowedOutputRoots: constrain output to specific directories)
702
753
  */
703
- traceStop(path: string): Promise<void>;
754
+ traceStop(path: string, opts?: {
755
+ allowedOutputRoots?: string[];
756
+ }): Promise<void>;
704
757
  /**
705
758
  * Wait for a network response matching a URL pattern and return its body.
706
759
  *
@@ -824,6 +877,7 @@ declare class CrawlPage {
824
877
  */
825
878
  download(ref: string, path: string, opts?: {
826
879
  timeoutMs?: number;
880
+ allowedOutputRoots?: string[];
827
881
  }): Promise<DownloadResult>;
828
882
  /**
829
883
  * Wait for the next download event (without clicking).
@@ -836,6 +890,7 @@ declare class CrawlPage {
836
890
  waitForDownload(opts?: {
837
891
  path?: string;
838
892
  timeoutMs?: number;
893
+ allowedOutputRoots?: string[];
839
894
  }): Promise<DownloadResult>;
840
895
  /**
841
896
  * Set the browser to offline or online mode.
@@ -932,6 +987,7 @@ declare class CrawlPage {
932
987
  */
933
988
  declare class BrowserClaw {
934
989
  private readonly cdpUrl;
990
+ private readonly allowInternal;
935
991
  private chrome;
936
992
  private constructor();
937
993
  /**
@@ -972,7 +1028,7 @@ declare class BrowserClaw {
972
1028
  * const browser = await BrowserClaw.connect('http://localhost:9222');
973
1029
  * ```
974
1030
  */
975
- static connect(cdpUrl: string): Promise<BrowserClaw>;
1031
+ static connect(cdpUrl: string, opts?: ConnectOptions): Promise<BrowserClaw>;
976
1032
  /**
977
1033
  * Open a URL in a new tab and return the page handle.
978
1034
  *
@@ -1031,4 +1087,4 @@ declare class BrowserClaw {
1031
1087
  stop(): Promise<void>;
1032
1088
  }
1033
1089
 
1034
- export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConsoleMessage, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, type LaunchOptions, type NetworkRequest, type PageError, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type StorageKind, type TraceStartOptions, type TypeOptions, type WaitOptions };
1090
+ export { type AriaNode, type AriaSnapshotResult, BrowserClaw, type BrowserTab, type ChromeExecutable, type ChromeKind, type ClickOptions, type ColorScheme, type ConnectOptions, type ConsoleMessage, type CookieData, CrawlPage, type DialogOptions, type DownloadResult, type FormField, type FrameEvalResult, type GeolocationOptions, type HttpCredentials, type LaunchOptions, type NetworkRequest, type PageError, type ResponseBodyResult, type RoleRefInfo, type RoleRefs, type ScreenshotOptions, type SnapshotOptions, type SnapshotResult, type SnapshotStats, type StorageKind, type TraceStartOptions, type TypeOptions, type UntrustedContentMeta, type WaitOptions };