browserscale-ts 1.4.0 → 1.7.0
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 +34 -3
- package/dist/auth-session.d.ts +37 -0
- package/dist/auth-session.js +1 -0
- package/dist/browser.d.ts +5 -1
- package/dist/browser.js +5 -0
- package/dist/browserscale.browser.js +1662 -42
- package/dist/client.d.ts +350 -7
- package/dist/client.js +637 -8
- package/dist/dom-mirror.d.ts +271 -0
- package/dist/dom-mirror.js +613 -0
- package/dist/gen/wrc_pb.d.ts +1490 -168
- package/dist/gen/wrc_pb.js +234 -39
- package/dist/index.d.ts +32 -1
- package/dist/index.js +61 -0
- package/dist/internal/convert.d.ts +11 -2
- package/dist/internal/convert.js +84 -1
- package/dist/network-capture.d.ts +84 -0
- package/dist/network-capture.js +107 -0
- package/dist/scripts.d.ts +205 -0
- package/dist/scripts.js +234 -0
- package/dist/types.d.ts +157 -0
- package/dist/ws-transport.d.ts +15 -1
- package/dist/ws-transport.js +155 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Rent an isolated browser session in seconds, automate it with human-like input,
|
|
|
23
23
|
pages, frames, cookies, storage and network state. No local binary.
|
|
24
24
|
- **Parallel isolated contexts** — each task gets its own session, fingerprint
|
|
25
25
|
and lifecycle; large queues never share browser state. Sessions are browser
|
|
26
|
-
contexts, not VMs or processes, so they spin up in under
|
|
26
|
+
contexts, not VMs or processes, so they spin up in under 250 ms and fan out to
|
|
27
27
|
thousands in parallel.
|
|
28
28
|
- **Fingerprint & proxy handling** — pinnable server-side fingerprints,
|
|
29
29
|
native Chrome control without CDP/Playwright/Puppeteer leaks, bring your own
|
|
@@ -60,11 +60,37 @@ Rent an isolated browser session in seconds, automate it with human-like input,
|
|
|
60
60
|
through. Wait for, block, mock or modify requests and responses without
|
|
61
61
|
leaving the SDK; mark repeated assets as static with `setStaticPaths` to
|
|
62
62
|
serve them from a server-side cache and cut proxy bandwidth on repeat runs.
|
|
63
|
+
- **Streaming network capture** — `captureNetwork` reports every request the
|
|
64
|
+
session completes as it happens, and "every request" is literal: capture sits
|
|
65
|
+
in the browser process rather than in a page, so cross-process iframes,
|
|
66
|
+
workers and service workers are included, the headers are the ones actually
|
|
67
|
+
put on the wire, and each hop of a redirect chain arrives as its own exchange.
|
|
68
|
+
Requests are never paused, so the page loads at full speed.
|
|
69
|
+
- **Live DOM mirror** — `mirrorDom` holds the page as one incrementally updated
|
|
70
|
+
tree: the browser sends the top once and from then on only what changed in the
|
|
71
|
+
part you expanded, so a page churning inside a collapsed subtree costs one
|
|
72
|
+
number per batch instead of a re-serialized document. An `<iframe>` is an
|
|
73
|
+
ordinary element whose one child is the document it hosts, however deeply
|
|
74
|
+
nested or cross-origin, and `getDomRevision` is the O(1) change detector to
|
|
75
|
+
poll when you are not consuming events.
|
|
63
76
|
- **Agent-friendly observation** — `getObservation` returns one line per visible
|
|
64
77
|
element across every frame, under headers carrying the URL, title and scroll
|
|
65
78
|
offset, with live form state (typed values, checkbox state, `<select>`
|
|
66
79
|
options) and a node handle to act on. A model reasons over what matters
|
|
67
80
|
instead of raw HTML, and doesn't need a JS round-trip to ask where it is.
|
|
81
|
+
- **Scripts that run inside the browser** — `runScript` sends JavaScript to the
|
|
82
|
+
session and runs it in the browser process itself, with a `browser` object
|
|
83
|
+
giving it the same operations this SDK exposes — but as local calls rather than
|
|
84
|
+
network round trips, so a loop that polls or walks a list costs microseconds
|
|
85
|
+
per step instead of tens of milliseconds. The log streams back as the script
|
|
86
|
+
produces it. `startScript` leaves a script running without the caller, which is
|
|
87
|
+
how work outlives the process that started it, and `followScript` attaches to
|
|
88
|
+
one already under way.
|
|
89
|
+
- **Sessions you can find again** — `listBrowsers` reports what an API key is
|
|
90
|
+
paying for: ids, proxy, egress address and remaining rental. A session
|
|
91
|
+
therefore outlives the process that rented it — recover it after a restart, or
|
|
92
|
+
from another machine entirely, and hand the `grpcUrl` it reports straight to
|
|
93
|
+
`connectSession`.
|
|
68
94
|
- **Flow-optimized TypeScript** — fully typed promise-based API, `wait` races
|
|
69
95
|
multiple outcomes, JS locators target elements by page logic when CSS is
|
|
70
96
|
not enough. Runs in Node.js (native gRPC) and the browser (WebSocket via
|
|
@@ -120,18 +146,23 @@ reports the element that occluded the click.
|
|
|
120
146
|
| --- | --- |
|
|
121
147
|
| `rentBrowser(cfg)` | Rent a fresh session (`new BrowserConfig(key, secs, host, port, user, pass)`). |
|
|
122
148
|
| `connectSession(grpcUrl, apiKey, sessionId)` | Attach to an existing session by id (from a prior rent). |
|
|
149
|
+
| `listBrowsers(apiKey)` | The sessions a key currently holds, each with the `grpcUrl` to hand to `connectSession`. |
|
|
123
150
|
| `browser.navigate(url, opts?)` | Load a URL. |
|
|
124
151
|
| `browser.wait(condition, opts?)` | Wait for a locator condition; returns the matched `frameId`. |
|
|
125
152
|
| `browser.click(target, opts?)` | Human-like click; throws a rich `ClickError` on failure. |
|
|
126
153
|
| `browser.fill(target, text, opts?)` | Per-key typing that fires real input events; `insertText` for bulk commit. |
|
|
127
154
|
| `browser.evaluate(expr)` | Run JS in the page/frame and get a typed value back. |
|
|
155
|
+
| `browser.runScript(source)` | Run JavaScript in the browser process, where every operation is a local call; `startScript` leaves it running, `followScript` watches one already going. |
|
|
128
156
|
| `browser.getObservation(opts?)` | Compact, node-handle-tagged view of the visible page across frames; `opts` tunes budgets and format. |
|
|
157
|
+
| `browser.captureNetwork(opts, onExchange)` | Stream every request the session completes, optionally with response bodies. |
|
|
158
|
+
| `browser.mirrorDom(opts, onChange, onResync?)` | Live, incrementally updated copy of the page's DOM across every frame. |
|
|
129
159
|
| `browser.solveCaptcha(opts?)` | Solve an interactive challenge in the live browser. |
|
|
130
160
|
| `browser.stopBrowser()` | Release the rental. |
|
|
131
161
|
|
|
132
162
|
Locators: `css(...)`, `js(...)` (target by page logic when CSS can't). Plus
|
|
133
|
-
cookies, storage,
|
|
134
|
-
canvas reads — see the
|
|
163
|
+
cookies, storage, auth/DBSC (`getAuthSession`/`setAuthSession`), network
|
|
164
|
+
interception, mouse/scroll/drag/select/key events, and canvas reads — see the
|
|
165
|
+
full reference below.
|
|
135
166
|
|
|
136
167
|
## Documentation
|
|
137
168
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** DbscSession is one Device Bound Session Credentials entry. */
|
|
2
|
+
export interface DbscSession {
|
|
3
|
+
/** Serialized schemeful site key, e.g. "https://google.com". */
|
|
4
|
+
site: string;
|
|
5
|
+
/**
|
|
6
|
+
* Base64 of the serialized DBSC Session proto. It includes the wrapped
|
|
7
|
+
* binding key, which is portable under WRC's software key provider.
|
|
8
|
+
*/
|
|
9
|
+
session: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* AuthSession is a portable snapshot of a context's signed-in Google account
|
|
13
|
+
* and/or DBSC sessions. Every field is optional, so a context that only has
|
|
14
|
+
* DBSC sessions (no primary account) or only a sign-in (no DBSC) round-trips.
|
|
15
|
+
*
|
|
16
|
+
* Pair it with getCookies()/setCookies() and getStorage()/setStorage() to move
|
|
17
|
+
* a whole persona between fresh contexts.
|
|
18
|
+
*/
|
|
19
|
+
export interface AuthSession {
|
|
20
|
+
/** Gaia obfuscated account id. */
|
|
21
|
+
gaiaId?: string;
|
|
22
|
+
/** Account email. */
|
|
23
|
+
email?: string;
|
|
24
|
+
/** OAuth refresh token (persistent). */
|
|
25
|
+
refreshToken?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Base64 of the wrapped device-binding key for the refresh token. Absent
|
|
28
|
+
* means the token is unbound.
|
|
29
|
+
*/
|
|
30
|
+
wrappedBindingKey?: string;
|
|
31
|
+
/** Signin-scoped device id; must travel with the token. */
|
|
32
|
+
signinScopedDeviceId?: string;
|
|
33
|
+
/** True if the account should be restored at Sync consent. */
|
|
34
|
+
syncConsent?: boolean;
|
|
35
|
+
/** Device Bound Session Credentials for this context (all bound sites). */
|
|
36
|
+
dbscSessions?: DbscSession[];
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/browser.d.ts
CHANGED
|
@@ -5,11 +5,15 @@ export { BrowserConfig } from "./config.ts";
|
|
|
5
5
|
export { Locator, css, js, node, at, AllFrames } from "./locator.ts";
|
|
6
6
|
export { DefaultWaitTimeoutMs, DefaultVisible, DefaultSteadyMs, } from "./defaults.ts";
|
|
7
7
|
export { BrowserScaleError, ClickError, FillError, DragError, ScrollError, MoveError, SelectOptionError, WaitError, } from "./errors.ts";
|
|
8
|
-
export type { Rect, FrameInfo, PageInfo, Header, InterceptedRequest, InterceptedResponse, WaitResult, WaitConditionStatus, OccluderInfo, ElementRef, NavigateResult, EvaluateResult, ElementResult, DragResult, SelectOptionResult, ScreenshotResult, ReadCanvasResult, DOMResult, InspectResult, RentResponse, } from "./types.ts";
|
|
8
|
+
export type { Rect, FrameInfo, PageInfo, Header, InterceptedRequest, InterceptedResponse, NetworkExchange, NetworkResourceType, NetworkServedFrom, NetworkBodies, NetworkCaptureOptions, WaitResult, WaitConditionStatus, OccluderInfo, ElementRef, NavigateResult, EvaluateResult, ElementResult, DragResult, SelectOptionResult, ScreenshotResult, ReadCanvasResult, DOMResult, InspectResult, RentResponse, BrowserInfo, } from "./types.ts";
|
|
9
9
|
export type { Button, ClickAction, ClickOpts, FillOpts, SelectOpts, WaitOpts, WaitUntil, NavigateOpts, LoadHTMLOpts, GetDOMOpts, GetObservationOpts, ScreenshotOpts, ReadCanvasOpts, } from "./options.ts";
|
|
10
10
|
export { type RequestPattern, type HeaderModification, type HeaderModificationAction, } from "./network.ts";
|
|
11
|
+
export { ScriptRun, ScriptFollow, type ScriptEvent, type ScriptEventHandler, type ScriptFinished, type ScriptLogEntry, type ScriptResult, type ScriptRunInfo, } from "./scripts.ts";
|
|
12
|
+
export { NetworkCapture, type NetworkExchangeHandler } from "./network-capture.ts";
|
|
13
|
+
export { DomMirror, type DomNode, type DomSnapshot, type DomMirrorOptions, type DomChangeHandler, type DomResyncHandler, type DomResyncReason, } from "./dom-mirror.ts";
|
|
11
14
|
export type { CookieParam } from "./cookies.ts";
|
|
12
15
|
export type { StorageItem, StorageOriginEntry } from "./storage.ts";
|
|
16
|
+
export type { AuthSession, DbscSession } from "./auth-session.ts";
|
|
13
17
|
/**
|
|
14
18
|
* Attaches a {@link CloudBrowser} to an existing session over a raw
|
|
15
19
|
* WebSocket transport.
|
package/dist/browser.js
CHANGED
|
@@ -10,6 +10,11 @@ export { Locator, css, js, node, at, AllFrames } from "./locator.js";
|
|
|
10
10
|
export { DefaultWaitTimeoutMs, DefaultVisible, DefaultSteadyMs, } from "./defaults.js";
|
|
11
11
|
// Errors — base class plus the typed semantic-failure subclasses
|
|
12
12
|
export { BrowserScaleError, ClickError, FillError, DragError, ScrollError, MoveError, SelectOptionError, WaitError, } from "./errors.js";
|
|
13
|
+
// Scripts (automation running inside the browser process)
|
|
14
|
+
export { ScriptRun, ScriptFollow, } from "./scripts.js";
|
|
15
|
+
// Network capture (traffic log)
|
|
16
|
+
export { NetworkCapture } from "./network-capture.js";
|
|
17
|
+
export { DomMirror, } from "./dom-mirror.js";
|
|
13
18
|
// Browser-side factory functions ───────────────────────────────────────
|
|
14
19
|
/**
|
|
15
20
|
* Attaches a {@link CloudBrowser} to an existing session over a raw
|