@mearl/browser-core 3.2.0 → 3.3.0-beta.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/browserActionProtocol.d.ts +10 -1
- package/dist/browserManagement.d.ts +1 -0
- package/dist/browserManagement.js +6 -1
- package/dist/extensionAgentAccess.js +2 -0
- package/dist/extensionCdpProtocol.d.ts +74 -0
- package/dist/extensionCdpProtocol.js +4 -0
- package/dist/extensionServiceProtocol.d.ts +20 -4
- package/dist/extensionServiceProtocol.js +6 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/providerTask.d.ts +3 -1
- package/dist/providerTask.js +5 -0
- package/package.json +1 -1
|
@@ -152,6 +152,8 @@ export type BrowserDetails = Record<string, BrowserJsonValue> & {
|
|
|
152
152
|
headless?: boolean;
|
|
153
153
|
createdAt?: string;
|
|
154
154
|
cdpPort?: number;
|
|
155
|
+
/** This local extension connection can export CDP on request. */
|
|
156
|
+
cdpExport?: true;
|
|
155
157
|
copiedCookies?: {
|
|
156
158
|
domains: string[];
|
|
157
159
|
count: number;
|
|
@@ -406,7 +408,14 @@ export type BrowserManageParams = ({
|
|
|
406
408
|
operation: 'detach';
|
|
407
409
|
} | {
|
|
408
410
|
operation: 'release';
|
|
411
|
+
} | {
|
|
412
|
+
operation: 'export_cdp' | 'revoke_cdp';
|
|
409
413
|
};
|
|
414
|
+
export interface BrowserCdpAccess {
|
|
415
|
+
httpUrl: string;
|
|
416
|
+
webSocketUrl: string;
|
|
417
|
+
sensitive: true;
|
|
418
|
+
}
|
|
410
419
|
export type SessionManageParams = {
|
|
411
420
|
operation: 'new';
|
|
412
421
|
providerOptions?: Record<string, BrowserJsonValue>;
|
|
@@ -948,7 +957,7 @@ export interface BrowserActionMap {
|
|
|
948
957
|
};
|
|
949
958
|
browser_manage: {
|
|
950
959
|
request: BrowserManageParams;
|
|
951
|
-
response: ManagedBrowserInfo | BrowserReleaseResult | {
|
|
960
|
+
response: ManagedBrowserInfo | BrowserReleaseResult | BrowserCdpAccess | {
|
|
952
961
|
closed: boolean;
|
|
953
962
|
} | {
|
|
954
963
|
detached: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BrowserManageParams, SessionManageParams } from './browserActionProtocol.js';
|
|
2
|
+
export declare function isCdpExportOperation(operation: unknown): operation is 'export_cdp' | 'revoke_cdp';
|
|
2
3
|
export declare function parseBrowserManageParams(value: unknown): BrowserManageParams;
|
|
3
4
|
export declare function parseSessionManageParams(value: unknown): SessionManageParams;
|
|
4
5
|
export declare function resolveSessionManageId(command: SessionManageParams, transportId?: string): string | undefined;
|
|
@@ -8,6 +8,9 @@ function allow(data, keys) {
|
|
|
8
8
|
if (extra)
|
|
9
9
|
throw new Error(`${extra} is not valid for operation "${data.operation}"`);
|
|
10
10
|
}
|
|
11
|
+
export function isCdpExportOperation(operation) {
|
|
12
|
+
return operation === 'export_cdp' || operation === 'revoke_cdp';
|
|
13
|
+
}
|
|
11
14
|
export function parseBrowserManageParams(value) {
|
|
12
15
|
const data = record(value);
|
|
13
16
|
switch (data.operation) {
|
|
@@ -36,10 +39,12 @@ export function parseBrowserManageParams(value) {
|
|
|
36
39
|
break;
|
|
37
40
|
case 'detach':
|
|
38
41
|
case 'release':
|
|
42
|
+
case 'export_cdp':
|
|
43
|
+
case 'revoke_cdp':
|
|
39
44
|
allow(data, []);
|
|
40
45
|
break;
|
|
41
46
|
default:
|
|
42
|
-
throw new Error('browser_manage requires launch, attach, detach, close or
|
|
47
|
+
throw new Error('browser_manage requires launch, attach, detach, close, release, export_cdp or revoke_cdp');
|
|
43
48
|
}
|
|
44
49
|
if (data.provider !== undefined && (typeof data.provider !== 'string' || !data.provider.trim()))
|
|
45
50
|
throw new Error('provider must be a nonempty string');
|
|
@@ -4,6 +4,8 @@ export function requiresExtensionAgentAccess(action, data, trustedInternal = fal
|
|
|
4
4
|
return true;
|
|
5
5
|
if (!action.startsWith('__') && action !== 'get_browser_info')
|
|
6
6
|
return true;
|
|
7
|
+
if (action === '__cdp_bridge')
|
|
8
|
+
return data?.operation !== 'disconnect' && data?.operation !== 'cancel_authorization';
|
|
7
9
|
if (action === '__capture_download' || action === '__export_cookies')
|
|
8
10
|
return true;
|
|
9
11
|
if (action === '__page_record')
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface ExtensionCdpCommand {
|
|
2
|
+
id: number;
|
|
3
|
+
method: string;
|
|
4
|
+
params?: Record<string, unknown>;
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
}
|
|
7
|
+
export type ExtensionCdpMessage = {
|
|
8
|
+
id: number;
|
|
9
|
+
result: unknown;
|
|
10
|
+
sessionId?: string;
|
|
11
|
+
} | {
|
|
12
|
+
id: number;
|
|
13
|
+
error: {
|
|
14
|
+
code: number;
|
|
15
|
+
message: string;
|
|
16
|
+
data?: unknown;
|
|
17
|
+
};
|
|
18
|
+
sessionId?: string;
|
|
19
|
+
} | {
|
|
20
|
+
method: string;
|
|
21
|
+
params?: Record<string, unknown>;
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
};
|
|
24
|
+
export interface ExtensionCdpVersion {
|
|
25
|
+
product: string;
|
|
26
|
+
protocolVersion: string;
|
|
27
|
+
userAgent: string;
|
|
28
|
+
revision: string;
|
|
29
|
+
jsVersion: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ExtensionCdpTarget {
|
|
32
|
+
targetId: string;
|
|
33
|
+
type: 'page';
|
|
34
|
+
title: string;
|
|
35
|
+
url: string;
|
|
36
|
+
attached: boolean;
|
|
37
|
+
canAccessOpener: boolean;
|
|
38
|
+
openerId?: string;
|
|
39
|
+
}
|
|
40
|
+
export type ExtensionCdpRequest = {
|
|
41
|
+
operation: 'version';
|
|
42
|
+
requestId?: string;
|
|
43
|
+
deadline?: number;
|
|
44
|
+
} | {
|
|
45
|
+
operation: 'cancel_authorization';
|
|
46
|
+
requestId: string;
|
|
47
|
+
} | {
|
|
48
|
+
operation: 'targets';
|
|
49
|
+
} | {
|
|
50
|
+
operation: 'connect';
|
|
51
|
+
connectionId: string;
|
|
52
|
+
targetId?: string;
|
|
53
|
+
} | {
|
|
54
|
+
operation: 'disconnect';
|
|
55
|
+
connectionId: string;
|
|
56
|
+
} | {
|
|
57
|
+
operation: 'command';
|
|
58
|
+
connectionId: string;
|
|
59
|
+
command: ExtensionCdpCommand;
|
|
60
|
+
};
|
|
61
|
+
export type ExtensionCdpEvent = {
|
|
62
|
+
type: 'cdp_bridge_frame';
|
|
63
|
+
connectionId: string;
|
|
64
|
+
chunk: string;
|
|
65
|
+
final: boolean;
|
|
66
|
+
reply?: Pick<ExtensionCdpCommand, 'id' | 'sessionId'>;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'cdp_bridge_closed';
|
|
69
|
+
connectionId: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'cdp_bridge_revoked';
|
|
72
|
+
};
|
|
73
|
+
export declare const EXTENSION_CDP_CHUNK_LENGTH: number;
|
|
74
|
+
export declare const EXTENSION_CDP_MESSAGE_LIMIT: number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Chrome limits each extension-to-host Native Messaging message to 1 MiB.
|
|
2
|
+
// Even with six JSON escape bytes per code unit, a frame fits under that limit.
|
|
3
|
+
export const EXTENSION_CDP_CHUNK_LENGTH = 128 * 1024;
|
|
4
|
+
export const EXTENSION_CDP_MESSAGE_LIMIT = 32 * 1024 * 1024;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { BrowserAccessResult, BrowserActionMap, BrowserJsonValue, BrowserProviderListResult, BrowserProviderLaunchForm, ControlSessionInfo, CookieCopyScope, ManagedBrowserInfo, BrowserReleaseParams, BrowserReleaseResult, PageDownloadParams, PageRecordingOptions } from './browserActionProtocol.js';
|
|
1
|
+
import type { BrowserAccessResult, BrowserActionMap, BrowserCdpAccess, BrowserJsonValue, BrowserProviderListResult, BrowserProviderLaunchForm, ControlSessionInfo, CookieCopyScope, ManagedBrowserInfo, BrowserReleaseParams, BrowserReleaseResult, PageDownloadParams, PageRecordingOptions } from './browserActionProtocol.js';
|
|
2
2
|
import { type AgentServiceActionMap } from './agentServiceProtocol.js';
|
|
3
|
+
import type { ExtensionCdpRequest, ExtensionCdpTarget, ExtensionCdpVersion } from './extensionCdpProtocol.js';
|
|
3
4
|
import type { BrowserEnhancementRequest, BrowserEnhancementResponse } from './browserEnhancement.js';
|
|
4
5
|
import { type ToolboxServiceActionMap, type ToolboxTaskRequest, type ToolboxTaskResponse } from './toolbox.js';
|
|
5
6
|
export declare const EXTENSION_RPC_VERSION = 1;
|
|
@@ -134,14 +135,20 @@ export interface BrowserManagementActionMap {
|
|
|
134
135
|
browser: string;
|
|
135
136
|
} & Extract<BrowserActionMap['browser_manage']['request'], {
|
|
136
137
|
operation: 'close' | 'detach';
|
|
137
|
-
}>)
|
|
138
|
+
}>) | Extract<BrowserActionMap['browser_manage']['request'], {
|
|
139
|
+
operation: 'export_cdp' | 'revoke_cdp';
|
|
140
|
+
}>;
|
|
138
141
|
response: BrowserActionMap['browser_manage']['response'];
|
|
139
142
|
};
|
|
140
143
|
get_browser_access_url: {
|
|
141
144
|
request: {
|
|
142
145
|
browser: string;
|
|
146
|
+
} | {
|
|
147
|
+
browser?: undefined;
|
|
148
|
+
};
|
|
149
|
+
response: {
|
|
150
|
+
browserAccess: BrowserAccessResult['browserAccess'] | null;
|
|
143
151
|
};
|
|
144
|
-
response: BrowserAccessResult;
|
|
145
152
|
};
|
|
146
153
|
}
|
|
147
154
|
export declare const BROWSER_MANAGEMENT_ACTIONS: {
|
|
@@ -153,7 +160,11 @@ export declare const BROWSER_MANAGEMENT_ACTIONS: {
|
|
|
153
160
|
readonly get_browser_access_url: true;
|
|
154
161
|
};
|
|
155
162
|
export type BrowserManagementAction = keyof BrowserManagementActionMap;
|
|
156
|
-
export type BrowserManagementResponse<A extends BrowserManagementAction, R> = A extends 'browser_sessions' ? OperationResponse<BrowserSessionOperations, R> : A extends 'browser_instances' ? OperationResponse<BrowserInstanceOperations, R> : A extends 'browser_providers' ? OperationResponse<BrowserProviderOperations, R> :
|
|
163
|
+
export type BrowserManagementResponse<A extends BrowserManagementAction, R> = A extends 'browser_sessions' ? OperationResponse<BrowserSessionOperations, R> : A extends 'browser_instances' ? OperationResponse<BrowserInstanceOperations, R> : A extends 'browser_providers' ? OperationResponse<BrowserProviderOperations, R> : A extends 'get_browser_access_url' ? R extends {
|
|
164
|
+
browser: string;
|
|
165
|
+
} ? BrowserAccessResult : BrowserManagementActionMap[A]['response'] : A extends 'browser_manage' ? R extends {
|
|
166
|
+
operation: 'export_cdp';
|
|
167
|
+
} ? BrowserCdpAccess : Exclude<BrowserManagementActionMap[A]['response'], BrowserCdpAccess> : BrowserManagementActionMap[A]['response'];
|
|
157
168
|
export declare function isBrowserManagementAction(value: unknown): value is BrowserManagementAction;
|
|
158
169
|
export declare const CLOUD_CONNECTOR_ACTIONS: {
|
|
159
170
|
readonly start_cloud_connector: true;
|
|
@@ -200,6 +211,10 @@ export type ExtensionUiServiceRequest<A extends ExtensionUiServiceAction> = Exte
|
|
|
200
211
|
export type ExtensionUiServiceResponse<A extends ExtensionUiServiceAction, R> = A extends BrowserManagementAction ? BrowserManagementResponse<A, R> : A extends 'toolbox_task' ? R extends ToolboxTaskRequest ? ToolboxTaskResponse<R> : never : ExtensionUiServiceActionMap[A]['response'];
|
|
201
212
|
export declare function isExtensionUiServiceAction(value: unknown): value is ExtensionUiServiceAction;
|
|
202
213
|
export interface HostToExtensionActionMap {
|
|
214
|
+
__cdp_bridge: {
|
|
215
|
+
request: ExtensionCdpRequest;
|
|
216
|
+
response: ExtensionCdpVersion | ExtensionCdpTarget[] | undefined;
|
|
217
|
+
};
|
|
203
218
|
__provider_task_target: {
|
|
204
219
|
request: {
|
|
205
220
|
targetId: string;
|
|
@@ -344,6 +359,7 @@ export interface HostToExtensionActionMap {
|
|
|
344
359
|
};
|
|
345
360
|
}
|
|
346
361
|
export declare const HOST_TO_EXTENSION_ACTIONS: {
|
|
362
|
+
readonly __cdp_bridge: true;
|
|
347
363
|
readonly __provider_task_target: true;
|
|
348
364
|
readonly __provider_task_authorize_open: true;
|
|
349
365
|
readonly __browser_enhancement: true;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isAgentServiceAction } from './agentServiceProtocol.js';
|
|
2
|
+
import { DOMAIN_PERMISSION_ACTION_TIMEOUT_MS } from './proxyPermissions.js';
|
|
2
3
|
import { isToolboxServiceAction, } from './toolbox.js';
|
|
3
4
|
export const EXTENSION_RPC_VERSION = 1;
|
|
4
5
|
export const PAGE_UPLOAD_TRANSFER_MAX_BYTES = 256 * 1024 * 1024;
|
|
@@ -29,6 +30,7 @@ export function isExtensionUiServiceAction(value) {
|
|
|
29
30
|
isCloudConnectorAction(value));
|
|
30
31
|
}
|
|
31
32
|
export const HOST_TO_EXTENSION_ACTIONS = {
|
|
33
|
+
__cdp_bridge: true,
|
|
32
34
|
__provider_task_target: true,
|
|
33
35
|
__provider_task_authorize_open: true,
|
|
34
36
|
__browser_enhancement: true,
|
|
@@ -84,8 +86,11 @@ export function getExtensionServiceTimeout(action, data = {}) {
|
|
|
84
86
|
return data.operation === 'detach' ? 60000 : 120000;
|
|
85
87
|
if (action === 'browser_providers')
|
|
86
88
|
return data.operation === 'launch_form' ? 120000 : data.operation === 'list' ? 15000 : 60000;
|
|
87
|
-
if (action === 'browser_manage')
|
|
89
|
+
if (action === 'browser_manage') {
|
|
90
|
+
if (data.operation === 'export_cdp')
|
|
91
|
+
return DOMAIN_PERMISSION_ACTION_TIMEOUT_MS + 10_000;
|
|
88
92
|
return data.operation === 'launch' || data.operation === 'attach' ? 120000 : 60000;
|
|
93
|
+
}
|
|
89
94
|
if (action === 'get_browser_access_url')
|
|
90
95
|
return 60000;
|
|
91
96
|
if (action === 'toolbox_plugin_uninstall' || action === 'toolbox_page')
|
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ export * from './pluginRecovery.js';
|
|
|
63
63
|
export * from './pluginDiagnostics.js';
|
|
64
64
|
export * from './rootWebViewDocument.js';
|
|
65
65
|
export * from './extensionServiceProtocol.js';
|
|
66
|
+
export * from './extensionCdpProtocol.js';
|
|
66
67
|
export * from './requestStreamCapture.js';
|
|
67
68
|
export * from './responseText.js';
|
|
68
69
|
export * from './consumeSseResponse.js';
|
package/dist/index.js
CHANGED
|
@@ -62,6 +62,7 @@ export * from './pluginRecovery.js';
|
|
|
62
62
|
export * from './pluginDiagnostics.js';
|
|
63
63
|
export * from './rootWebViewDocument.js';
|
|
64
64
|
export * from './extensionServiceProtocol.js';
|
|
65
|
+
export * from './extensionCdpProtocol.js';
|
|
65
66
|
export * from './requestStreamCapture.js';
|
|
66
67
|
export * from './responseText.js';
|
|
67
68
|
export * from './consumeSseResponse.js';
|
package/dist/providerTask.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { BrowserDetails } from './browserActionProtocol.js';
|
|
1
|
+
import type { BrowserDetails, BrowserProviderObjectSchema } from './browserActionProtocol.js';
|
|
2
2
|
export declare const PROVIDER_TASK_SESSION_VERSION = 1;
|
|
3
|
+
/** The host injects this reserved launch parameter when creating a Provider task. */
|
|
4
|
+
export declare function declaresProviderTaskSessions(schema: BrowserProviderObjectSchema): boolean;
|
|
3
5
|
/** Operations whose page inputs and outputs can be kept on the same execution route. */
|
|
4
6
|
export declare const PROVIDER_TASK_EXTENSION_ACTIONS: readonly ["page_navigate", "page_snapshot", "page_eval", "page_click", "page_type", "page_press", "page_scroll", "page_hover", "page_wait", "page_frames", "page_screenshot", "set_timezone", "set_device_emulation", "set_app_profile", "tab_checkpoint", "get_requests", "get_logs"];
|
|
5
7
|
export type ProviderTaskExtensionAction = (typeof PROVIDER_TASK_EXTENSION_ACTIONS)[number];
|
package/dist/providerTask.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export const PROVIDER_TASK_SESSION_VERSION = 1;
|
|
2
|
+
/** The host injects this reserved launch parameter when creating a Provider task. */
|
|
3
|
+
export function declaresProviderTaskSessions(schema) {
|
|
4
|
+
const field = schema.properties.taskSession;
|
|
5
|
+
return field?.type === 'object' && field.formHidden === true;
|
|
6
|
+
}
|
|
2
7
|
/** Operations whose page inputs and outputs can be kept on the same execution route. */
|
|
3
8
|
export const PROVIDER_TASK_EXTENSION_ACTIONS = [
|
|
4
9
|
'page_navigate',
|
package/package.json
CHANGED