@mearl/browser-core 3.1.11 → 3.2.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 +9 -0
- package/dist/browserManagement.js +3 -1
- package/dist/extensionAgentAccess.js +2 -0
- package/dist/extensionServiceProtocol.d.ts +18 -0
- package/dist/extensionServiceProtocol.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/providerTask.d.ts +10 -0
- package/dist/providerTask.js +28 -0
- package/dist/proxyPermissions.d.ts +6 -0
- package/dist/proxyPermissions.js +27 -0
- package/package.json +1 -1
|
@@ -156,6 +156,10 @@ export type BrowserDetails = Record<string, BrowserJsonValue> & {
|
|
|
156
156
|
domains: string[];
|
|
157
157
|
count: number;
|
|
158
158
|
};
|
|
159
|
+
/** A discoverable browser can open native tasks; a session target belongs to one Mearl session. */
|
|
160
|
+
taskSessionScope?: 'browser' | 'session';
|
|
161
|
+
taskSessionCreated?: true;
|
|
162
|
+
taskSessionBrowserId?: string;
|
|
159
163
|
};
|
|
160
164
|
export interface BrowserReference extends BrowserProviderLocales<'label'> {
|
|
161
165
|
kind: string;
|
|
@@ -271,6 +275,10 @@ export interface ControlSessionInfo {
|
|
|
271
275
|
url?: string;
|
|
272
276
|
}>;
|
|
273
277
|
reason?: string;
|
|
278
|
+
task?: {
|
|
279
|
+
reference?: BrowserReference;
|
|
280
|
+
pageTransport: 'extension' | 'provider';
|
|
281
|
+
};
|
|
274
282
|
}
|
|
275
283
|
export interface BrowserReleaseParams {
|
|
276
284
|
/** Defaults to closing session-created pages. Attached pages are always kept. */
|
|
@@ -401,6 +409,7 @@ export type BrowserManageParams = ({
|
|
|
401
409
|
};
|
|
402
410
|
export type SessionManageParams = {
|
|
403
411
|
operation: 'new';
|
|
412
|
+
providerOptions?: Record<string, BrowserJsonValue>;
|
|
404
413
|
} | {
|
|
405
414
|
operation: 'handoff';
|
|
406
415
|
sessionId?: string;
|
|
@@ -51,7 +51,9 @@ export function parseSessionManageParams(value) {
|
|
|
51
51
|
const data = record(value);
|
|
52
52
|
switch (data.operation) {
|
|
53
53
|
case 'new':
|
|
54
|
-
allow(data, []);
|
|
54
|
+
allow(data, ['providerOptions']);
|
|
55
|
+
if (data.providerOptions !== undefined)
|
|
56
|
+
record(data.providerOptions);
|
|
55
57
|
break;
|
|
56
58
|
case 'handoff':
|
|
57
59
|
allow(data, ['sessionId', 'reason']);
|
|
@@ -12,6 +12,8 @@ export function requiresExtensionAgentAccess(action, data, trustedInternal = fal
|
|
|
12
12
|
return data?.operation !== 'abort';
|
|
13
13
|
if (action === '__browser_enhancement')
|
|
14
14
|
return data?.operation !== 'release';
|
|
15
|
+
if (action === '__provider_task_target' || action === '__provider_task_authorize_open')
|
|
16
|
+
return true;
|
|
15
17
|
return false;
|
|
16
18
|
}
|
|
17
19
|
export function isExtensionAgentPolicy(value) {
|
|
@@ -200,6 +200,22 @@ export type ExtensionUiServiceRequest<A extends ExtensionUiServiceAction> = Exte
|
|
|
200
200
|
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
201
|
export declare function isExtensionUiServiceAction(value: unknown): value is ExtensionUiServiceAction;
|
|
202
202
|
export interface HostToExtensionActionMap {
|
|
203
|
+
__provider_task_target: {
|
|
204
|
+
request: {
|
|
205
|
+
targetId: string;
|
|
206
|
+
};
|
|
207
|
+
response: {
|
|
208
|
+
tabId: number;
|
|
209
|
+
} | null;
|
|
210
|
+
};
|
|
211
|
+
__provider_task_authorize_open: {
|
|
212
|
+
request: {
|
|
213
|
+
url: string;
|
|
214
|
+
};
|
|
215
|
+
response: {
|
|
216
|
+
authorized: true;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
203
219
|
__browser_enhancement: {
|
|
204
220
|
request: BrowserEnhancementRequest;
|
|
205
221
|
response: BrowserEnhancementResponse;
|
|
@@ -328,6 +344,8 @@ export interface HostToExtensionActionMap {
|
|
|
328
344
|
};
|
|
329
345
|
}
|
|
330
346
|
export declare const HOST_TO_EXTENSION_ACTIONS: {
|
|
347
|
+
readonly __provider_task_target: true;
|
|
348
|
+
readonly __provider_task_authorize_open: true;
|
|
331
349
|
readonly __browser_enhancement: true;
|
|
332
350
|
readonly __preset_installation: true;
|
|
333
351
|
readonly __profile_install: true;
|
|
@@ -29,6 +29,8 @@ export function isExtensionUiServiceAction(value) {
|
|
|
29
29
|
isCloudConnectorAction(value));
|
|
30
30
|
}
|
|
31
31
|
export const HOST_TO_EXTENSION_ACTIONS = {
|
|
32
|
+
__provider_task_target: true,
|
|
33
|
+
__provider_task_authorize_open: true,
|
|
32
34
|
__browser_enhancement: true,
|
|
33
35
|
__preset_installation: true,
|
|
34
36
|
__profile_install: true,
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './browserEnhancement.js';
|
|
|
4
4
|
export * from './browserDiscovery.js';
|
|
5
5
|
export * from './externalBrowserControl.js';
|
|
6
6
|
export * from './providerAppResources.js';
|
|
7
|
+
export * from './providerTask.js';
|
|
7
8
|
export * from './eventFilters.js';
|
|
8
9
|
export * from './requestSerializer.js';
|
|
9
10
|
export * from './boundedRequestBuffer.js';
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from './browserEnhancement.js';
|
|
|
4
4
|
export * from './browserDiscovery.js';
|
|
5
5
|
export * from './externalBrowserControl.js';
|
|
6
6
|
export * from './providerAppResources.js';
|
|
7
|
+
export * from './providerTask.js';
|
|
7
8
|
export * from './eventFilters.js';
|
|
8
9
|
export * from './requestSerializer.js';
|
|
9
10
|
export * from './boundedRequestBuffer.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BrowserDetails } from './browserActionProtocol.js';
|
|
2
|
+
export declare const PROVIDER_TASK_SESSION_VERSION = 1;
|
|
3
|
+
/** Operations whose page inputs and outputs can be kept on the same execution route. */
|
|
4
|
+
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
|
+
export type ProviderTaskExtensionAction = (typeof PROVIDER_TASK_EXTENSION_ACTIONS)[number];
|
|
6
|
+
export declare function isProviderTaskExtensionAction(action: string): action is ProviderTaskExtensionAction;
|
|
7
|
+
/** Task handles are addressed by session ID. Each ordinary browser route remains selectable. */
|
|
8
|
+
export declare function isDiscoverableBrowser(browser: {
|
|
9
|
+
details?: BrowserDetails;
|
|
10
|
+
}): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const PROVIDER_TASK_SESSION_VERSION = 1;
|
|
2
|
+
/** Operations whose page inputs and outputs can be kept on the same execution route. */
|
|
3
|
+
export const PROVIDER_TASK_EXTENSION_ACTIONS = [
|
|
4
|
+
'page_navigate',
|
|
5
|
+
'page_snapshot',
|
|
6
|
+
'page_eval',
|
|
7
|
+
'page_click',
|
|
8
|
+
'page_type',
|
|
9
|
+
'page_press',
|
|
10
|
+
'page_scroll',
|
|
11
|
+
'page_hover',
|
|
12
|
+
'page_wait',
|
|
13
|
+
'page_frames',
|
|
14
|
+
'page_screenshot',
|
|
15
|
+
'set_timezone',
|
|
16
|
+
'set_device_emulation',
|
|
17
|
+
'set_app_profile',
|
|
18
|
+
'tab_checkpoint',
|
|
19
|
+
'get_requests',
|
|
20
|
+
'get_logs',
|
|
21
|
+
];
|
|
22
|
+
export function isProviderTaskExtensionAction(action) {
|
|
23
|
+
return PROVIDER_TASK_EXTENSION_ACTIONS.includes(action);
|
|
24
|
+
}
|
|
25
|
+
/** Task handles are addressed by session ID. Each ordinary browser route remains selectable. */
|
|
26
|
+
export function isDiscoverableBrowser(browser) {
|
|
27
|
+
return browser.details?.taskSessionScope !== 'session';
|
|
28
|
+
}
|
|
@@ -7,6 +7,7 @@ export interface DomainPermissionFailure {
|
|
|
7
7
|
domain: string;
|
|
8
8
|
requestDispatched: false;
|
|
9
9
|
}
|
|
10
|
+
export declare const DOMAIN_PERMISSION_ACTION_TIMEOUT_MS = 100000;
|
|
10
11
|
export declare class DomainPermissionError extends Error implements DomainPermissionFailure {
|
|
11
12
|
readonly action: string;
|
|
12
13
|
readonly domain: string;
|
|
@@ -14,6 +15,11 @@ export declare class DomainPermissionError extends Error implements DomainPermis
|
|
|
14
15
|
readonly requestDispatched = false;
|
|
15
16
|
constructor(action: string, domain: string, message?: string);
|
|
16
17
|
}
|
|
18
|
+
export declare function getDomainPermissionFailure(value: unknown): DomainPermissionFailure | undefined;
|
|
19
|
+
export declare function browserActionResponseError(response: {
|
|
20
|
+
error?: string;
|
|
21
|
+
errorDetails?: unknown;
|
|
22
|
+
}, fallback: string): Error;
|
|
17
23
|
export declare const ALLOWED_ORIGINS: readonly ["*://localhost/*", "*://127.0.0.1/*"];
|
|
18
24
|
export declare const ALLOWED_ORIGINS_LIST: string[];
|
|
19
25
|
export declare function normalizeDomainInputToOrigin(input: string): string | null;
|
package/dist/proxyPermissions.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Proxy/cookie domain permission utilities — pure functions, no chrome.* or storage deps.
|
|
3
3
|
*/
|
|
4
|
+
// Leave time for the browser's confirmation window to return its decision.
|
|
5
|
+
export const DOMAIN_PERMISSION_ACTION_TIMEOUT_MS = 100_000;
|
|
4
6
|
export class DomainPermissionError extends Error {
|
|
5
7
|
action;
|
|
6
8
|
domain;
|
|
@@ -13,6 +15,28 @@ export class DomainPermissionError extends Error {
|
|
|
13
15
|
this.name = 'DomainPermissionError';
|
|
14
16
|
}
|
|
15
17
|
}
|
|
18
|
+
export function getDomainPermissionFailure(value) {
|
|
19
|
+
const failure = value;
|
|
20
|
+
if (failure?.code === 'DOMAIN_PERMISSION_REQUIRED' &&
|
|
21
|
+
failure.requestDispatched === false &&
|
|
22
|
+
typeof failure.action === 'string' &&
|
|
23
|
+
failure.action.length > 0 &&
|
|
24
|
+
typeof failure.domain === 'string' &&
|
|
25
|
+
failure.domain.length > 0) {
|
|
26
|
+
return {
|
|
27
|
+
code: failure.code,
|
|
28
|
+
action: failure.action,
|
|
29
|
+
domain: failure.domain,
|
|
30
|
+
requestDispatched: false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function browserActionResponseError(response, fallback) {
|
|
35
|
+
const failure = getDomainPermissionFailure(response.errorDetails);
|
|
36
|
+
return failure
|
|
37
|
+
? new DomainPermissionError(failure.action, failure.domain, response.error || undefined)
|
|
38
|
+
: new Error(response.error || fallback);
|
|
39
|
+
}
|
|
16
40
|
export const ALLOWED_ORIGINS = ['*://localhost/*', '*://127.0.0.1/*'];
|
|
17
41
|
export const ALLOWED_ORIGINS_LIST = [...ALLOWED_ORIGINS];
|
|
18
42
|
function normalizeHost(input) {
|
|
@@ -91,6 +115,9 @@ export const ACTIONS_SKIP_DOMAIN_CHECK = new Set([
|
|
|
91
115
|
'__control_release',
|
|
92
116
|
'__control_cleanup',
|
|
93
117
|
'__control_deactivate',
|
|
118
|
+
'__provider_task_target',
|
|
119
|
+
// The task open preflight checks its destination in the handler.
|
|
120
|
+
'__provider_task_authorize_open',
|
|
94
121
|
// The recording handler authorizes the recorded tab and its navigation history.
|
|
95
122
|
'__page_record',
|
|
96
123
|
'__page_record_status',
|
package/package.json
CHANGED