@hyperbrowser/sdk 0.89.8 → 0.90.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/dist/services/base.js
CHANGED
|
@@ -51,9 +51,10 @@ class BaseService {
|
|
|
51
51
|
}
|
|
52
52
|
const headerKeys = Object.keys(init?.headers || {});
|
|
53
53
|
const contentTypeKey = headerKeys.find((key) => key.toLowerCase() === "content-type");
|
|
54
|
+
const requestTimeout = init?.timeout ?? this.timeout;
|
|
54
55
|
const response = await (0, node_fetch_1.default)(url.toString(), {
|
|
55
56
|
...init,
|
|
56
|
-
timeout:
|
|
57
|
+
timeout: requestTimeout,
|
|
57
58
|
headers: {
|
|
58
59
|
"x-api-key": this.apiKey,
|
|
59
60
|
...(contentTypeKey && init?.headers
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BasicResponse, CreateSessionParams, GetActiveSessionsCountResponse, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, GetSessionVideoRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording, UploadFileOptions, UploadFileResponse, SessionEventLogListParams, SessionEventLogListResponse, UpdateSessionProfileParams, UpdateSessionProxyParams, UpdateSessionScreenParams, SessionGetParams } from "../types/session";
|
|
1
|
+
import { BasicResponse, CaptchaEvaluationParams, CaptchaEvaluationResponse, CreateSessionParams, GetActiveSessionsCountResponse, GetSessionDownloadsUrlResponse, GetSessionRecordingUrlResponse, GetSessionVideoRecordingUrlResponse, SessionDetail, SessionListParams, SessionListResponse, SessionRecording, UploadFileOptions, UploadFileResponse, SessionEventLogListParams, SessionEventLogListResponse, UpdateSessionProfileParams, UpdateSessionProxyParams, UpdateSessionScreenParams, UpdateSessionSolveCaptchasParams, UpdateSessionSolveCaptchasResponse, SessionGetParams } from "../types/session";
|
|
2
2
|
import { BaseService } from "./base";
|
|
3
3
|
/**
|
|
4
4
|
* Service for managing session event logs
|
|
@@ -29,6 +29,12 @@ export declare class SessionsService extends BaseService {
|
|
|
29
29
|
* @param id The ID of the session to stop
|
|
30
30
|
*/
|
|
31
31
|
stop(id: string): Promise<BasicResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* Manually evaluate captchas in a running session.
|
|
34
|
+
* @param id The ID of the session to evaluate
|
|
35
|
+
* @param params Optional captcha evaluation parameters
|
|
36
|
+
*/
|
|
37
|
+
evaluateCaptcha(id: string, params?: CaptchaEvaluationParams): Promise<CaptchaEvaluationResponse>;
|
|
32
38
|
/**
|
|
33
39
|
* List all sessions with optional filtering
|
|
34
40
|
* @param params Optional parameters to filter the sessions
|
|
@@ -81,6 +87,17 @@ export declare class SessionsService extends BaseService {
|
|
|
81
87
|
updateProfileParams(id: string, persistChanges: boolean): Promise<BasicResponse>;
|
|
82
88
|
updateProxyParams(id: string, params: UpdateSessionProxyParams): Promise<BasicResponse>;
|
|
83
89
|
updateScreenSize(id: string, params: UpdateSessionScreenParams): Promise<BasicResponse>;
|
|
90
|
+
/**
|
|
91
|
+
* Start automatic captcha solving for a running session.
|
|
92
|
+
* @param id The ID of the session to update
|
|
93
|
+
* @param params Optional captcha solver parameters
|
|
94
|
+
*/
|
|
95
|
+
startCaptchaSolving(id: string, params?: UpdateSessionSolveCaptchasParams): Promise<UpdateSessionSolveCaptchasResponse>;
|
|
96
|
+
/**
|
|
97
|
+
* Stop automatic captcha solving for a running session.
|
|
98
|
+
* @param id The ID of the session to update
|
|
99
|
+
*/
|
|
100
|
+
stopCaptchaSolving(id: string): Promise<UpdateSessionSolveCaptchasResponse>;
|
|
84
101
|
private static hasWarnedUpdateSessionProfileParamsBooleanDeprecated;
|
|
85
102
|
private warnUpdateSessionProfileParamsBooleanDeprecated;
|
|
86
103
|
}
|
|
@@ -32,6 +32,7 @@ const path = __importStar(require("path"));
|
|
|
32
32
|
const form_data_1 = __importDefault(require("form-data"));
|
|
33
33
|
const base_1 = require("./base");
|
|
34
34
|
const client_1 = require("../client");
|
|
35
|
+
const CAPTCHA_EVALUATION_REQUEST_TIMEOUT_MS = 185000;
|
|
35
36
|
/**
|
|
36
37
|
* Service for managing session event logs
|
|
37
38
|
*/
|
|
@@ -113,6 +114,26 @@ class SessionsService extends base_1.BaseService {
|
|
|
113
114
|
throw new client_1.HyperbrowserError(`Failed to stop session ${id}`, undefined);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Manually evaluate captchas in a running session.
|
|
119
|
+
* @param id The ID of the session to evaluate
|
|
120
|
+
* @param params Optional captcha evaluation parameters
|
|
121
|
+
*/
|
|
122
|
+
async evaluateCaptcha(id, params = {}) {
|
|
123
|
+
try {
|
|
124
|
+
return await this.request(`/session/${id}/captcha/evaluate`, {
|
|
125
|
+
method: "POST",
|
|
126
|
+
timeout: Math.max(this.timeout, CAPTCHA_EVALUATION_REQUEST_TIMEOUT_MS),
|
|
127
|
+
body: JSON.stringify(params),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (error instanceof client_1.HyperbrowserError) {
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
throw new client_1.HyperbrowserError(`Failed to evaluate captcha for session ${id}`, undefined);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
116
137
|
/**
|
|
117
138
|
* List all sessions with optional filtering
|
|
118
139
|
* @param params Optional parameters to filter the sessions
|
|
@@ -373,6 +394,54 @@ class SessionsService extends base_1.BaseService {
|
|
|
373
394
|
throw new client_1.HyperbrowserError(`Failed to update screen for session ${id}`, undefined);
|
|
374
395
|
}
|
|
375
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Start automatic captcha solving for a running session.
|
|
399
|
+
* @param id The ID of the session to update
|
|
400
|
+
* @param params Optional captcha solver parameters
|
|
401
|
+
*/
|
|
402
|
+
async startCaptchaSolving(id, params = {}) {
|
|
403
|
+
try {
|
|
404
|
+
return await this.request(`/session/${id}/update`, {
|
|
405
|
+
method: "PUT",
|
|
406
|
+
body: JSON.stringify({
|
|
407
|
+
type: "solveCaptchas",
|
|
408
|
+
params: {
|
|
409
|
+
enabled: true,
|
|
410
|
+
...params,
|
|
411
|
+
},
|
|
412
|
+
}),
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
if (error instanceof client_1.HyperbrowserError) {
|
|
417
|
+
throw error;
|
|
418
|
+
}
|
|
419
|
+
throw new client_1.HyperbrowserError(`Failed to start captcha solving for session ${id}`, undefined);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Stop automatic captcha solving for a running session.
|
|
424
|
+
* @param id The ID of the session to update
|
|
425
|
+
*/
|
|
426
|
+
async stopCaptchaSolving(id) {
|
|
427
|
+
try {
|
|
428
|
+
return await this.request(`/session/${id}/update`, {
|
|
429
|
+
method: "PUT",
|
|
430
|
+
body: JSON.stringify({
|
|
431
|
+
type: "solveCaptchas",
|
|
432
|
+
params: {
|
|
433
|
+
enabled: false,
|
|
434
|
+
},
|
|
435
|
+
}),
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
catch (error) {
|
|
439
|
+
if (error instanceof client_1.HyperbrowserError) {
|
|
440
|
+
throw error;
|
|
441
|
+
}
|
|
442
|
+
throw new client_1.HyperbrowserError(`Failed to stop captcha solving for session ${id}`, undefined);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
376
445
|
warnUpdateSessionProfileParamsBooleanDeprecated() {
|
|
377
446
|
if (SessionsService.hasWarnedUpdateSessionProfileParamsBooleanDeprecated) {
|
|
378
447
|
return;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { StartClaudeComputerUseTaskParams, StartClaudeComputerUseTaskResponse, C
|
|
|
7
7
|
export { StartCuaTaskParams, StartCuaTaskResponse, CuaTaskStatusResponse, CuaTaskResponse, CuaTaskData, CuaStepResponse, CuaApiKeys, CuaTaskMetadata, } from "./agents/cua";
|
|
8
8
|
export { StartHyperAgentTaskParams, StartHyperAgentTaskResponse, HyperAgentTaskStatusResponse, HyperAgentTaskResponse, HyperAgentTaskData, HyperAgentStep, HyperAgentOutput, HyperAgentActionOutput, HyperAgentApiKeys, HyperAgentTaskMetadata, HyperAgentOutputV110, HyperAgentStepV110, } from "./agents/hyper-agent";
|
|
9
9
|
export { StartGeminiComputerUseTaskParams, StartGeminiComputerUseTaskResponse, GeminiComputerUseTaskStatusResponse, GeminiComputerUseTaskResponse, GeminiComputerUseTaskData, GeminiComputerUseStepResponse, GeminiComputerUseApiKeys, GeminiComputerUseTaskMetadata, } from "./agents/gemini-computer-use";
|
|
10
|
-
export { BasicResponse, SessionStatus, Session, SessionDetail, SessionGetParams, SessionListParams, SessionListResponse, ScreenConfig, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionVideoRecordingUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, UploadFileResponse, UploadFileOptions, GetActiveSessionsCountResponse, SessionEventLogListParams, SessionEventLogListResponse, SessionEventLog, SessionProfile, SessionLaunchState, SessionCreditBreakdown, UpdateSessionProfileParams, UpdateSessionProxyLocationParams, UpdateSessionProxyParams, UpdateSessionScreenParams, } from "./session";
|
|
10
|
+
export { BasicResponse, SessionStatus, Session, SessionDetail, SessionGetParams, SessionListParams, SessionListResponse, ScreenConfig, CaptchaEvaluationPageResult, CaptchaEvaluationParams, CaptchaEvaluationResponse, CaptchaEvaluationTarget, CaptchaEvaluationType, CaptchaSolverType, CreateSessionParams, GetSessionDownloadsUrlResponse, GetSessionVideoRecordingUrlResponse, GetSessionRecordingUrlResponse, ImageCaptchaParam, UploadFileResponse, UploadFileOptions, GetActiveSessionsCountResponse, SessionEventLogListParams, SessionEventLogListResponse, SessionEventLog, SessionProfile, SessionLaunchState, SessionCreditBreakdown, UpdateSessionProfileParams, UpdateSessionProxyLocationParams, UpdateSessionProxyParams, UpdateSessionScreenParams, UpdateSessionSolveCaptchasParams, UpdateSessionSolveCaptchasResponse, } from "./session";
|
|
11
11
|
export { SandboxStatus, SandboxRuntimeTarget, Sandbox, SandboxDetail, SandboxVolumeMountType, SandboxVolumeMount, SandboxListParams, SandboxListResponse, SandboxImageSummary, SandboxImageListResponse, SandboxSnapshotStatus, SandboxSnapshotSummary, SandboxSnapshotListParams, SandboxSnapshotListResponse, CreateSandboxParams, SandboxMemorySnapshotParams, SandboxMemorySnapshotResult, SandboxExposeParams, SandboxExposeResult, SandboxUnexposeResult, SandboxProcessStatus, SandboxExecParams, SandboxExecOptions, SandboxProcessSummary, SandboxProcessResult, SandboxProcessListParams, SandboxProcessListResponse, SandboxProcessWaitParams, SandboxProcessSignal, SandboxProcessStdinParams, SandboxProcessStreamEvent, SandboxFileType, SandboxFileInfo, SandboxFileWriteInfo, SandboxFileListOptions, SandboxFileReadFormat, SandboxFileReadOptions, SandboxFileWriteData, SandboxFileWriteEntry, SandboxFileTextWriteOptions, SandboxFileBytesWriteOptions, SandboxFileMakeDirOptions, SandboxFileCopyParams, SandboxFileChmodParams, SandboxFileChownParams, SandboxFileTransferResult, SandboxFileSystemEventType, SandboxFileSystemEvent, SandboxWatchDirOptions, SandboxPresignFileParams, SandboxPresignedUrl, SandboxTerminalCreateParams, SandboxTerminalOutputChunk, SandboxTerminalStatus, SandboxTerminalWaitParams, SandboxTerminalKillParams, SandboxTerminalEvent, } from "./sandbox";
|
|
12
12
|
export { CreateVolumeParams, Volume, VolumeListResponse } from "./volume";
|
|
13
13
|
export { CreateProfileParams, ProfileResponse, CreateProfileResponse, ProfileListParams, ProfileListResponse, } from "./profile";
|
package/dist/types/session.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface SessionLaunchState {
|
|
|
21
21
|
enableVideoWebRecording?: boolean;
|
|
22
22
|
enableLogCapture?: boolean;
|
|
23
23
|
acceptCookies?: boolean;
|
|
24
|
+
solverType?: CaptchaSolverType;
|
|
24
25
|
profile?: SessionProfile;
|
|
25
26
|
staticIpId?: string;
|
|
26
27
|
saveDownloads?: boolean;
|
|
@@ -85,6 +86,39 @@ export interface ImageCaptchaParam {
|
|
|
85
86
|
imageSelector: string;
|
|
86
87
|
inputSelector: string;
|
|
87
88
|
}
|
|
89
|
+
export type CaptchaSolverType = "visual" | (string & {});
|
|
90
|
+
export type CaptchaEvaluationType = "turnstile" | "cloudflare-challenge" | "aliexpress" | "recaptcha" | "recaptcha-visual" | "amazon";
|
|
91
|
+
export type CaptchaEvaluationTarget = CaptchaEvaluationType;
|
|
92
|
+
export interface CaptchaEvaluationParams {
|
|
93
|
+
captcha?: CaptchaEvaluationTarget;
|
|
94
|
+
captchaType?: CaptchaEvaluationTarget;
|
|
95
|
+
text?: CaptchaEvaluationTarget;
|
|
96
|
+
iterations?: number;
|
|
97
|
+
maxIterations?: number;
|
|
98
|
+
solverType?: CaptchaSolverType;
|
|
99
|
+
imageCaptchaParams?: Array<ImageCaptchaParam>;
|
|
100
|
+
useGeminiCaptchaSolver?: boolean;
|
|
101
|
+
useUltraStealth?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface CaptchaEvaluationPageResult {
|
|
104
|
+
url: string;
|
|
105
|
+
targetId: string | null;
|
|
106
|
+
iterationsRun: number;
|
|
107
|
+
solved: boolean;
|
|
108
|
+
solvedCaptchas: CaptchaEvaluationType[];
|
|
109
|
+
checkedCaptchas: CaptchaEvaluationType[];
|
|
110
|
+
captchaSolvedCounts: Record<string, number>;
|
|
111
|
+
lastSolveTime: Record<string, number>;
|
|
112
|
+
}
|
|
113
|
+
export interface CaptchaEvaluationResponse {
|
|
114
|
+
success: true;
|
|
115
|
+
captcha: CaptchaEvaluationType | null;
|
|
116
|
+
iterationsRequested: number;
|
|
117
|
+
iterationsRun: number;
|
|
118
|
+
solved: boolean;
|
|
119
|
+
solvedCaptchas: CaptchaEvaluationType[];
|
|
120
|
+
pages: CaptchaEvaluationPageResult[];
|
|
121
|
+
}
|
|
88
122
|
export interface CreateSessionParams {
|
|
89
123
|
useUltraStealth?: boolean;
|
|
90
124
|
useStealth?: boolean;
|
|
@@ -101,6 +135,7 @@ export interface CreateSessionParams {
|
|
|
101
135
|
locales?: ISO639_1[];
|
|
102
136
|
screen?: ScreenConfig;
|
|
103
137
|
solveCaptchas?: boolean;
|
|
138
|
+
solverType?: CaptchaSolverType;
|
|
104
139
|
adblock?: boolean;
|
|
105
140
|
trackers?: boolean;
|
|
106
141
|
annoyances?: boolean;
|
|
@@ -206,3 +241,11 @@ export interface UpdateSessionScreenParams {
|
|
|
206
241
|
width: number;
|
|
207
242
|
height: number;
|
|
208
243
|
}
|
|
244
|
+
export interface UpdateSessionSolveCaptchasParams {
|
|
245
|
+
solverType?: CaptchaSolverType;
|
|
246
|
+
}
|
|
247
|
+
export interface UpdateSessionSolveCaptchasResponse extends BasicResponse {
|
|
248
|
+
solveCaptchas?: boolean;
|
|
249
|
+
sessionId?: string;
|
|
250
|
+
telemetryReady?: boolean;
|
|
251
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperbrowser/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.0",
|
|
4
4
|
"description": "Node SDK for Hyperbrowser API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"repository": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"prepare": "yarn build",
|
|
22
22
|
"test": "vitest run",
|
|
23
23
|
"test:e2e": "vitest run tests/sandbox/e2e",
|
|
24
|
+
"test:integration": "vitest run tests/integration",
|
|
24
25
|
"test:watch": "vitest",
|
|
25
26
|
"format": "prettier --write 'src/**/*.ts'"
|
|
26
27
|
},
|