@cbxss/eoka 0.1.0-beta.4 → 0.1.0-beta.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 +19 -3
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +7 -0
- package/dist/cloudflare.d.ts +12 -0
- package/dist/cloudflare.js +19 -0
- package/dist/generated/protocol.d.ts +955 -22
- package/dist/generated/protocol.js +2 -2
- package/dist/generated/schema-bundle.json +5074 -258
- package/dist/index.d.ts +1 -0
- package/dist/page.d.ts +19 -9
- package/dist/page.js +31 -40
- package/dist/release-manifest.json +29 -29
- package/dist/release.js +1 -1
- package/examples/explicit-paths.mjs +1 -1
- package/examples/offline.mjs +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Node.js SDK for eoka, a stealth Chrome automation sidecar.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
npm install @cbxss/eoka@
|
|
6
|
+
npm install @cbxss/eoka@latest
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
Requires Node.js 24.21+ (ESM only). Supported platforms: Linux x64/arm64 (glibc 2.35+), macOS x64/arm64, Windows x64.
|
|
@@ -36,7 +36,7 @@ await page.click("button[type=submit]", {
|
|
|
36
36
|
|
|
37
37
|
await page.waitForText("Welcome");
|
|
38
38
|
const heading = await page.getText("h1");
|
|
39
|
-
const count = await page.evaluate("document.querySelectorAll('li').length");
|
|
39
|
+
const count = await page.evaluate("()=>document.querySelectorAll('li').length");
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
String targets are CSS selectors. An action resolves only after its result is verified. `click`, `type`, `pressKey`, `submit` and `drag` need an `expect` that describes the result.
|
|
@@ -57,7 +57,23 @@ if (challenge) {
|
|
|
57
57
|
}
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
`page.solveTurnstile({ timeoutMs })` is a best-effort helper for interactive Cloudflare challenge pages.
|
|
60
|
+
`page.solveTurnstile({ timeoutMs })` is a best-effort helper for interactive Cloudflare challenge pages. The server finds the challenge frame, clicks the checkbox, and waits for the page to leave the challenge state, then resolves with `{ clicks, elapsedMs }` (zero clicks on a normal page). It is not a general CAPTCHA solver.
|
|
61
|
+
|
|
62
|
+
### Automatic challenge handling
|
|
63
|
+
|
|
64
|
+
`Browser.launch({ autoSolveCloudflare: true })` (and `Browser.connect`) has the server watch every tab and solve full-page Cloudflare challenges as they appear. It does not click Turnstile widgets embedded in normal forms. The Go SDK, CLI (`--auto-solve-cloudflare`) and MCP server (`EOKA_AUTO_SOLVE_CLOUDFLARE=1`) use the same server watcher.
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
const browser = await Browser.launch({ autoSolveCloudflare: true });
|
|
68
|
+
try {
|
|
69
|
+
const page = await browser.newPage("https://1337x.to/");
|
|
70
|
+
console.log(await page.title()); // Torrent Search Engine | 1337x.to
|
|
71
|
+
} finally {
|
|
72
|
+
await browser.close();
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Tune it with `{ intervalMs, timeoutMs }` (defaults 500 and 30000). The server logs each challenge and result to its stderr. The watcher stops with `browser.close()`.
|
|
61
77
|
|
|
62
78
|
## Screenshots and recording
|
|
63
79
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -4,12 +4,15 @@ import { Operation } from './operations.js';
|
|
|
4
4
|
import { Page, type PerformOptions } from './page.js';
|
|
5
5
|
import { Recording } from './recording.js';
|
|
6
6
|
import { type InstallProgress } from './browser-install.js';
|
|
7
|
+
import { type CloudflareOptions } from './cloudflare.js';
|
|
7
8
|
export interface BrowserOptions {
|
|
8
9
|
serverPath?: string;
|
|
9
10
|
serverEnv?: NodeJS.ProcessEnv;
|
|
10
11
|
signal?: AbortSignal;
|
|
11
12
|
timeoutMs?: number;
|
|
12
13
|
shutdownTimeoutMs?: number;
|
|
14
|
+
/** Have the server watch every tab and solve full-page Cloudflare challenges. */
|
|
15
|
+
autoSolveCloudflare?: boolean | CloudflareOptions;
|
|
13
16
|
}
|
|
14
17
|
export interface LaunchOptions extends BrowserOptions {
|
|
15
18
|
executablePath?: string;
|
package/dist/browser.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Page } from './page.js';
|
|
|
8
8
|
import { Recording } from './recording.js';
|
|
9
9
|
import { SidecarTransport } from './transport.js';
|
|
10
10
|
import { installBrowser } from './browser-install.js';
|
|
11
|
+
import { resolveCloudflareOptions } from './cloudflare.js';
|
|
11
12
|
import { resolveServerBinary } from './server-binary.js';
|
|
12
13
|
function validateTimeout(value, name) {
|
|
13
14
|
if (value !== undefined && (!Number.isFinite(value) || value <= 0 || value > 2_147_483_647)) {
|
|
@@ -288,6 +289,12 @@ export class Browser {
|
|
|
288
289
|
if (expectedServerVersion !== undefined && transport.hello.serverVersion !== expectedServerVersion) {
|
|
289
290
|
throw new ProtocolError(`Packaged server version mismatch: expected ${expectedServerVersion}, received ${transport.hello.serverVersion}`, { requestState: 'acknowledged' });
|
|
290
291
|
}
|
|
292
|
+
const cloudflare = resolveCloudflareOptions(options.autoSolveCloudflare);
|
|
293
|
+
if (cloudflare !== undefined) {
|
|
294
|
+
if (!transport.hasCapability('cloudflareAutoSolve'))
|
|
295
|
+
throw new ConfigurationError('autoSolveCloudflare requires a server with the cloudflareAutoSolve capability');
|
|
296
|
+
params = { ...params, autoSolveCloudflare: cloudflare };
|
|
297
|
+
}
|
|
291
298
|
const session = await transport.invoke(method, params, localOptions(options, deadline));
|
|
292
299
|
if (!session || !['owned', 'borrowed'].includes(session.ownership) || typeof session.browserVersion !== 'string' || !session.browserVersion.trim() || (method === 'browser.connect' && session.ownership !== 'borrowed')) {
|
|
293
300
|
throw new ProtocolError('Invalid browser session ownership or browserVersion', { requestState: 'acknowledged' });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Options for the server-side Cloudflare challenge watcher. */
|
|
2
|
+
export interface CloudflareOptions {
|
|
3
|
+
/** Poll interval in milliseconds. Defaults to 500. */
|
|
4
|
+
intervalMs?: number;
|
|
5
|
+
/** Deadline for each challenge solve. Defaults to 30000. */
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ResolvedCloudflareOptions {
|
|
9
|
+
intervalMs: number;
|
|
10
|
+
timeoutMs: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function resolveCloudflareOptions(value: boolean | CloudflareOptions | undefined): ResolvedCloudflareOptions | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ConfigurationError } from './errors.js';
|
|
2
|
+
export function resolveCloudflareOptions(value) {
|
|
3
|
+
if (value === undefined || value === false)
|
|
4
|
+
return undefined;
|
|
5
|
+
const options = value === true ? {} : value;
|
|
6
|
+
for (const name of Object.keys(options)) {
|
|
7
|
+
if (name !== 'intervalMs' && name !== 'timeoutMs')
|
|
8
|
+
throw new ConfigurationError(`autoSolveCloudflare.${name} is not supported; the server solves challenges and reports them in its log`);
|
|
9
|
+
}
|
|
10
|
+
const intervalMs = options.intervalMs ?? 500;
|
|
11
|
+
const timeoutMs = options.timeoutMs ?? 30_000;
|
|
12
|
+
if (!Number.isInteger(intervalMs) || intervalMs < 100 || intervalMs > 60_000) {
|
|
13
|
+
throw new ConfigurationError('autoSolveCloudflare.intervalMs must be an integer between 100 and 60000 milliseconds');
|
|
14
|
+
}
|
|
15
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 120_000) {
|
|
16
|
+
throw new ConfigurationError('autoSolveCloudflare.timeoutMs must be an integer between 1 and 120000 milliseconds');
|
|
17
|
+
}
|
|
18
|
+
return { intervalMs, timeoutMs };
|
|
19
|
+
}
|