Socket
Socket
Sign inDemoInstall

chromium-bidi

Package Overview
Dependencies
Maintainers
0
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chromium-bidi - npm Package Compare versions

Comparing version 0.5.24 to 0.6.0

3

lib/cjs/bidiMapper/BidiServer.d.ts

@@ -19,3 +19,3 @@ /**

import type { CdpConnection } from '../cdp/CdpConnection.js';
import type { ChromiumBidi } from '../protocol/protocol.js';
import type { ChromiumBidi, Session } from '../protocol/protocol.js';
import { EventEmitter } from '../utils/EventEmitter.js';

@@ -32,2 +32,3 @@ import { type LoggerFn } from '../utils/log.js';

acceptInsecureCerts: boolean;
unhandledPromptBehavior?: Session.UserPromptHandler;
};

@@ -34,0 +35,0 @@ export declare class BidiServer extends EventEmitter<BidiServerEvent> {

@@ -58,4 +58,4 @@ "use strict";

this.#eventManager = new EventManager_js_1.EventManager(this.#browsingContextStorage);
const networkStorage = new NetworkStorage_js_1.NetworkStorage(this.#eventManager, browserCdpClient, logger);
new CdpTargetManager_js_1.CdpTargetManager(cdpConnection, browserCdpClient, selfTargetId, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, networkStorage, this.#preloadScriptStorage, options?.acceptInsecureCerts ?? false, defaultUserContextId, logger);
const networkStorage = new NetworkStorage_js_1.NetworkStorage(this.#eventManager, this.#browsingContextStorage, browserCdpClient, logger);
new CdpTargetManager_js_1.CdpTargetManager(cdpConnection, browserCdpClient, selfTargetId, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, networkStorage, this.#preloadScriptStorage, options?.acceptInsecureCerts ?? false, defaultUserContextId, options?.unhandledPromptBehavior, logger);
this.#commandProcessor = new CommandProcessor_js_1.CommandProcessor(cdpConnection, browserCdpClient, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, this.#preloadScriptStorage, networkStorage, parser, this.#logger);

@@ -62,0 +62,0 @@ this.#eventManager.on("event" /* EventManagerEvents.Event */, ({ message, event }) => {

import type { Protocol } from 'devtools-protocol';
import type { CdpClient } from '../../../cdp/CdpClient.js';
import type { ChromiumBidi } from '../../../protocol/protocol.js';
import type { ChromiumBidi, Session } from '../../../protocol/protocol.js';
import { Deferred } from '../../../utils/Deferred.js';

@@ -15,4 +15,4 @@ import type { LoggerFn } from '../../../utils/log.js';

#private;
static create(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, realmStorage: RealmStorage, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, acceptInsecureCerts: boolean, logger?: LoggerFn): CdpTarget;
constructor(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, eventManager: EventManager, realmStorage: RealmStorage, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, acceptInsecureCerts: boolean, logger?: LoggerFn);
static create(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, realmStorage: RealmStorage, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, acceptInsecureCerts: boolean, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn): CdpTarget;
constructor(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, eventManager: EventManager, realmStorage: RealmStorage, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, acceptInsecureCerts: boolean, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
/** Returns a deferred that resolves when the target is unblocked. */

@@ -19,0 +19,0 @@ get unblocked(): Deferred<Result<void>>;

@@ -19,2 +19,3 @@ "use strict";

#unblocked = new Deferred_js_1.Deferred();
#unhandledPromptBehavior;
#acceptInsecureCerts;

@@ -28,4 +29,4 @@ #logger;

};
static create(targetId, cdpClient, browserCdpClient, realmStorage, eventManager, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts, logger) {
const cdpTarget = new CdpTarget(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts, logger);
static create(targetId, cdpClient, browserCdpClient, realmStorage, eventManager, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts, unhandledPromptBehavior, logger) {
const cdpTarget = new CdpTarget(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts, unhandledPromptBehavior, logger);
LogManager_js_1.LogManager.create(cdpTarget, realmStorage, eventManager, logger);

@@ -38,3 +39,3 @@ cdpTarget.#setEventListeners();

}
constructor(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts, logger) {
constructor(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, acceptInsecureCerts, unhandledPromptBehavior, logger) {
this.#id = targetId;

@@ -49,2 +50,3 @@ this.#cdpClient = cdpClient;

this.#acceptInsecureCerts = acceptInsecureCerts;
this.#unhandledPromptBehavior = unhandledPromptBehavior;
this.#logger = logger;

@@ -129,3 +131,3 @@ }

const parentBrowsingContext = this.#browsingContextStorage.getContext(frame.parentId);
BrowsingContextImpl_js_1.BrowsingContextImpl.create(frame.id, frame.parentId, parentBrowsingContext.userContext, parentBrowsingContext.cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, frame.url, undefined, this.#logger);
BrowsingContextImpl_js_1.BrowsingContextImpl.create(frame.id, frame.parentId, parentBrowsingContext.userContext, parentBrowsingContext.cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, frame.url, undefined, this.#unhandledPromptBehavior, this.#logger);
}

@@ -132,0 +134,0 @@ frameTree.childFrames?.map((frameTree) => this.#restoreFrameTreeState(frameTree));

import type { CdpClient } from '../../../cdp/CdpClient.js';
import type { CdpConnection } from '../../../cdp/CdpConnection.js';
import type { Browser } from '../../../protocol/protocol.js';
import type { Browser, Session } from '../../../protocol/protocol.js';
import { type LoggerFn } from '../../../utils/log.js';

@@ -12,3 +12,3 @@ import type { BrowsingContextStorage } from '../context/BrowsingContextStorage.js';

#private;
constructor(cdpConnection: CdpConnection, browserCdpClient: CdpClient, selfTargetId: string, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, networkStorage: NetworkStorage, preloadScriptStorage: PreloadScriptStorage, acceptInsecureCerts: boolean, defaultUserContextId: Browser.UserContext, logger?: LoggerFn);
constructor(cdpConnection: CdpConnection, browserCdpClient: CdpClient, selfTargetId: string, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, networkStorage: NetworkStorage, preloadScriptStorage: PreloadScriptStorage, acceptInsecureCerts: boolean, defaultUserContextId: Browser.UserContext, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
}

@@ -25,3 +25,4 @@ "use strict";

#logger;
constructor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, preloadScriptStorage, acceptInsecureCerts, defaultUserContextId, logger) {
#unhandledPromptBehavior;
constructor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, preloadScriptStorage, acceptInsecureCerts, defaultUserContextId, unhandledPromptBehavior, logger) {
this.#acceptInsecureCerts = acceptInsecureCerts;

@@ -37,2 +38,3 @@ this.#cdpConnection = cdpConnection;

this.#defaultUserContextId = defaultUserContextId;
this.#unhandledPromptBehavior = unhandledPromptBehavior;
this.#logger = logger;

@@ -63,3 +65,3 @@ this.#setEventListeners(browserCdpClient);

// later.
'about:blank', undefined, this.#logger);
'about:blank', undefined, this.#unhandledPromptBehavior, this.#logger);
}

@@ -104,3 +106,3 @@ }

// TODO: check who to deal with non-null creator and its `creatorOrigin`.
targetInfo.url === '' ? 'about:blank' : targetInfo.url, targetInfo.openerId, this.#logger);
targetInfo.url === '' ? 'about:blank' : targetInfo.url, targetInfo.openerFrameId ?? targetInfo.openerId, this.#unhandledPromptBehavior, this.#logger);
}

@@ -141,3 +143,3 @@ return;

this.#setEventListeners(targetCdpClient);
const target = CdpTarget_js_1.CdpTarget.create(targetInfo.targetId, targetCdpClient, this.#browserCdpClient, this.#realmStorage, this.#eventManager, this.#preloadScriptStorage, this.#browsingContextStorage, this.#networkStorage, this.#acceptInsecureCerts, this.#logger);
const target = CdpTarget_js_1.CdpTarget.create(targetInfo.targetId, targetCdpClient, this.#browserCdpClient, this.#realmStorage, this.#eventManager, this.#preloadScriptStorage, this.#browsingContextStorage, this.#networkStorage, this.#acceptInsecureCerts, this.#unhandledPromptBehavior, this.#logger);
this.#networkStorage.onCdpTargetCreated(target);

@@ -144,0 +146,0 @@ return target;

@@ -18,3 +18,3 @@ /**

import type { Protocol } from 'devtools-protocol';
import { BrowsingContext } from '../../../protocol/protocol.js';
import { BrowsingContext, type Session } from '../../../protocol/protocol.js';
import { type LoggerFn } from '../../../utils/log.js';

@@ -31,3 +31,3 @@ import type { CdpTarget } from '../cdp/CdpTarget.js';

private constructor();
static create(id: BrowsingContext.BrowsingContext, parentId: BrowsingContext.BrowsingContext | null, userContext: string, cdpTarget: CdpTarget, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, url: string, originalOpener?: string, logger?: LoggerFn): BrowsingContextImpl;
static create(id: BrowsingContext.BrowsingContext, parentId: BrowsingContext.BrowsingContext | null, userContext: string, cdpTarget: CdpTarget, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, url: string, originalOpener?: string, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn): BrowsingContextImpl;
static getTimestamp(): number;

@@ -38,2 +38,8 @@ /**

get navigableId(): string | undefined;
/**
* Virtual navigation ID. Required, as CDP `loaderId` cannot be mapped 1:1 to all the
* navigations (e.g. same document navigations). Updated after each navigation,
* including same-document ones.
*/
get virtualNavigationId(): string;
dispose(): void;

@@ -68,3 +74,3 @@ /** Returns the ID of this context. */

setViewport(viewport?: BrowsingContext.Viewport | null, devicePixelRatio?: number | null): Promise<void>;
handleUserPrompt(params: BrowsingContext.HandleUserPromptParameters): Promise<void>;
handleUserPrompt(accept?: boolean, userText?: string): Promise<void>;
activate(): Promise<void>;

@@ -71,0 +77,0 @@ captureScreenshot(params: BrowsingContext.CaptureScreenshotParameters): Promise<BrowsingContext.CaptureScreenshotResult>;

@@ -19,3 +19,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeOrigin = exports.BrowsingContextImpl = void 0;
exports.BrowsingContextImpl = void 0;
exports.serializeOrigin = serializeOrigin;
const protocol_js_1 = require("../../../protocol/protocol.js");

@@ -26,2 +27,3 @@ const assert_js_1 = require("../../../utils/assert.js");

const unitConversions_js_1 = require("../../../utils/unitConversions.js");
const uuid_1 = require("../../../utils/uuid");
const WindowRealm_js_1 = require("../script/WindowRealm.js");

@@ -58,4 +60,13 @@ class BrowsingContextImpl {

#previousViewport = { width: 0, height: 0 };
// The URL of the navigation that is currently in progress. A workaround of the CDP
// lacking URL for the pending navigation events, e.g. `Page.frameStartedLoading`.
// Set on `Page.navigate`, `Page.reload` commands and on deprecated CDP event
// `Page.frameScheduledNavigation`.
#pendingNavigationUrl;
#virtualNavigationId = (0, uuid_1.uuidv4)();
#originalOpener;
constructor(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, url, originalOpener, logger) {
// Set when the user prompt is opened. Required to provide the type in closing event.
#lastUserPromptType;
#unhandledPromptBehavior;
constructor(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, url, originalOpener, unhandledPromptBehavior, logger) {
this.#cdpTarget = cdpTarget;

@@ -68,2 +79,3 @@ this.#id = id;

this.#realmStorage = realmStorage;
this.#unhandledPromptBehavior = unhandledPromptBehavior;
this.#logger = logger;

@@ -73,4 +85,4 @@ this.#url = url;

}
static create(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, url, originalOpener, logger) {
const context = new BrowsingContextImpl(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, url, originalOpener, logger);
static create(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, url, originalOpener, unhandledPromptBehavior, logger) {
const context = new BrowsingContextImpl(id, parentId, userContext, cdpTarget, eventManager, browsingContextStorage, realmStorage, url, originalOpener, unhandledPromptBehavior, logger);
context.#initListeners();

@@ -101,2 +113,10 @@ browsingContextStorage.addContext(context);

}
/**
* Virtual navigation ID. Required, as CDP `loaderId` cannot be mapped 1:1 to all the
* navigations (e.g. same document navigations). Updated after each navigation,
* including same-document ones.
*/
get virtualNavigationId() {
return this.#virtualNavigationId;
}
dispose() {

@@ -235,2 +255,3 @@ this.#deleteAllChildren();

this.#url = params.frame.url + (params.frame.urlFragment ?? '');
this.#pendingNavigationUrl = undefined;
// At the point the page is initialized, all the nested iframes from the

@@ -245,2 +266,3 @@ // previous page are detached and realms are destroyed.

}
this.#pendingNavigationUrl = undefined;
const timestamp = BrowsingContextImpl.getTimestamp();

@@ -254,3 +276,3 @@ this.#url = params.url;

context: this.id,
navigation: null,
navigation: this.#virtualNavigationId,
timestamp,

@@ -265,2 +287,4 @@ url: this.#url,

}
// Generate a new virtual navigation id.
this.#virtualNavigationId = (0, uuid_1.uuidv4)();
this.#eventManager.registerEvent({

@@ -271,8 +295,19 @@ type: 'event',

context: this.id,
navigation: null,
navigation: this.#virtualNavigationId,
timestamp: BrowsingContextImpl.getTimestamp(),
url: '',
// The URL of the navigation that is currently in progress. Although the URL
// is not yet known in case of user-initiated navigations, it is possible to
// provide the URL in case of BiDi-initiated navigations.
// TODO: provide proper URL in case of user-initiated navigations.
url: this.#pendingNavigationUrl ?? 'UNKNOWN',
},
}, this.id);
});
// TODO: don't use deprecated `Page.frameScheduledNavigation` event.
this.#cdpTarget.cdpClient.on('Page.frameScheduledNavigation', (params) => {
if (this.id !== params.frameId) {
return;
}
this.#pendingNavigationUrl = params.url;
});
this.#cdpTarget.cdpClient.on('Page.lifecycleEvent', (params) => {

@@ -308,3 +343,3 @@ if (this.id !== params.frameId) {

context: this.id,
navigation: this.#loaderId ?? null,
navigation: this.#virtualNavigationId,
timestamp,

@@ -322,3 +357,3 @@ url: this.#url,

context: this.id,
navigation: this.#loaderId ?? null,
navigation: this.#virtualNavigationId,
timestamp,

@@ -392,2 +427,5 @@ url: this.#url,

const accepted = params.result;
if (this.#lastUserPromptType === undefined) {
this.#logger?.(log_js_1.LogType.debugError, 'Unexpectedly no opening prompt event before closing one');
}
this.#eventManager.registerEvent({

@@ -399,7 +437,18 @@ type: 'event',

accepted,
// `lastUserPromptType` should never be undefined here, so fallback to
// `UNKNOWN`. The fallback is required to prevent tests from hanging while
// waiting for the closing event. The cast is required, as the `UNKNOWN` value
// is not standard.
type: this.#lastUserPromptType ??
'UNKNOWN',
userText: accepted && params.userInput ? params.userInput : undefined,
},
}, this.id);
this.#lastUserPromptType = undefined;
});
this.#cdpTarget.cdpClient.on('Page.javascriptDialogOpening', (params) => {
const promptType = BrowsingContextImpl.#getPromptType(params.type);
// Set the last prompt type to provide it in closing event.
this.#lastUserPromptType = promptType;
const promptHandler = this.#getPromptHandler(promptType);
this.#eventManager.registerEvent({

@@ -410,3 +459,4 @@ type: 'event',

context: this.id,
type: params.type,
handler: promptHandler,
type: promptType,
message: params.message,

@@ -418,4 +468,49 @@ ...(params.type === 'prompt'

}, this.id);
switch (promptHandler) {
// Based on `unhandledPromptBehavior`, check if the prompt should be handled
// automatically (`accept`, `dismiss`) or wait for the user to do it.
case 'accept':
void this.handleUserPrompt(true);
break;
case 'dismiss':
void this.handleUserPrompt(false);
break;
case 'ignore':
break;
}
});
}
static #getPromptType(cdpType) {
switch (cdpType) {
case 'alert':
return "alert" /* BrowsingContext.UserPromptType.Alert */;
case 'beforeunload':
return "beforeunload" /* BrowsingContext.UserPromptType.Beforeunload */;
case 'confirm':
return "confirm" /* BrowsingContext.UserPromptType.Confirm */;
case 'prompt':
return "prompt" /* BrowsingContext.UserPromptType.Prompt */;
}
}
#getPromptHandler(promptType) {
const defaultPromptHandler = 'dismiss';
switch (promptType) {
case "alert" /* BrowsingContext.UserPromptType.Alert */:
return (this.#unhandledPromptBehavior?.alert ??
this.#unhandledPromptBehavior?.default ??
defaultPromptHandler);
case "beforeunload" /* BrowsingContext.UserPromptType.Beforeunload */:
return (this.#unhandledPromptBehavior?.beforeUnload ??
this.#unhandledPromptBehavior?.default ??
defaultPromptHandler);
case "confirm" /* BrowsingContext.UserPromptType.Confirm */:
return (this.#unhandledPromptBehavior?.confirm ??
this.#unhandledPromptBehavior?.default ??
defaultPromptHandler);
case "prompt" /* BrowsingContext.UserPromptType.Prompt */:
return (this.#unhandledPromptBehavior?.prompt ??
this.#unhandledPromptBehavior?.default ??
defaultPromptHandler);
}
}
#documentChanged(loaderId) {

@@ -465,2 +560,7 @@ // Same document navigation.

await this.targetUnblockedOrThrow();
// Set the pending navigation URL to provide it in `browsingContext.navigationStarted`
// event.
// TODO: detect navigation start not from CDP. Check if
// `Page.frameRequestedNavigation` can be used for this purpose.
this.#pendingNavigationUrl = url;
// TODO: handle loading errors.

@@ -472,2 +572,4 @@ const cdpNavigateResult = await this.#cdpTarget.cdpClient.sendCommand('Page.navigate', {

if (cdpNavigateResult.errorText) {
// If navigation failed, no pending navigation is left.
this.#pendingNavigationUrl = undefined;
this.#eventManager.registerEvent({

@@ -478,3 +580,3 @@ type: 'event',

context: this.id,
navigation: cdpNavigateResult.loaderId ?? null,
navigation: this.#virtualNavigationId,
timestamp: BrowsingContextImpl.getTimestamp(),

@@ -510,3 +612,3 @@ url,

return {
navigation: cdpNavigateResult.loaderId ?? null,
navigation: this.#virtualNavigationId,
// Url can change due to redirect get the latest one.

@@ -533,5 +635,3 @@ url: wait === "none" /* BrowsingContext.ReadinessState.None */ ? url : this.#url,

return {
navigation: wait === "none" /* BrowsingContext.ReadinessState.None */
? null
: this.navigableId ?? null,
navigation: this.#virtualNavigationId,
url: this.url,

@@ -578,6 +678,6 @@ };

}
async handleUserPrompt(params) {
async handleUserPrompt(accept, userText) {
await this.#cdpTarget.cdpClient.sendCommand('Page.handleJavaScriptDialog', {
accept: params.accept ?? true,
promptText: params.userText,
accept: accept ?? true,
promptText: userText,
});

@@ -1090,3 +1190,2 @@ }

}
exports.serializeOrigin = serializeOrigin;
function getImageFormatParameters(params) {

@@ -1093,0 +1192,0 @@ const { quality, type } = params.format ?? {

@@ -125,3 +125,3 @@ "use strict";

try {
await context.handleUserPrompt(params);
await context.handleUserPrompt(params.accept, params.userText);
}

@@ -128,0 +128,0 @@ catch (error) {

@@ -57,9 +57,9 @@ /**

count: number;
"__#90962@#x": number;
"__#90962@#y": number;
"__#90962@#time": number;
"__#91339@#x": number;
"__#91339@#y": number;
"__#91339@#time": number;
compare(context: any): boolean;
};
"__#90962@#DOUBLE_CLICK_TIME_MS": number;
"__#90962@#MAX_DOUBLE_CLICK_RADIUS": number;
"__#91339@#DOUBLE_CLICK_TIME_MS": number;
"__#91339@#MAX_DOUBLE_CLICK_RADIUS": number;
};

@@ -66,0 +66,0 @@ setClickCount(button: number, context: InstanceType<typeof PointerSource.ClickContext>): number;

@@ -19,3 +19,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getKeyLocation = exports.getKeyCode = exports.getNormalizedKey = void 0;
exports.getNormalizedKey = getNormalizedKey;
exports.getKeyCode = getKeyCode;
exports.getKeyLocation = getKeyLocation;
/**

@@ -172,3 +174,2 @@ * Returns the normalized key value for a given key according to the table:

}
exports.getNormalizedKey = getNormalizedKey;
/**

@@ -449,3 +450,2 @@ * Returns the key code for a given key according to the table:

}
exports.getKeyCode = getKeyCode;
/**

@@ -500,3 +500,2 @@ * Returns the location of the key according to the table:

}
exports.getKeyLocation = getKeyLocation;
//# sourceMappingURL=keyUtils.js.map

@@ -19,3 +19,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getRemoteValuesText = exports.logMessageFormatter = void 0;
exports.logMessageFormatter = logMessageFormatter;
exports.getRemoteValuesText = getRemoteValuesText;
const assert_js_1 = require("../../../utils/assert.js");

@@ -81,3 +82,2 @@ const specifiers = ['%s', '%d', '%i', '%f', '%o', '%O', '%c'];

}
exports.logMessageFormatter = logMessageFormatter;
/**

@@ -175,3 +175,2 @@ * @param arg input remote value to be parsed

}
exports.getRemoteValuesText = getRemoteValuesText;
//# sourceMappingURL=logHelper.js.map

@@ -0,1 +1,17 @@

/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Network, type EmptyResult } from '../../../protocol/protocol.js';

@@ -2,0 +18,0 @@ import type { BrowsingContextStorage } from '../context/BrowsingContextStorage.js';

"use strict";
/**
* Copyright 2023 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.NetworkProcessor = void 0;
const protocol_js_1 = require("../../../protocol/protocol.js");
const NetworkUtils_js_1 = require("./NetworkUtils.js");
/** Dispatches Network domain commands. */

@@ -31,3 +46,2 @@ class NetworkProcessor {

async continueRequest(params) {
const { url, method, headers: commandHeaders, body, request: networkId, } = params;
if (params.url !== undefined) {

@@ -38,3 +52,3 @@ NetworkProcessor.parseUrlString(params.url);

if (!NetworkProcessor.isMethodValid(params.method)) {
throw new protocol_js_1.InvalidArgumentException(`Method '${method}' is invalid.`);
throw new protocol_js_1.InvalidArgumentException(`Method '${params.method}' is invalid.`);
}

@@ -45,15 +59,9 @@ }

}
const request = this.#getBlockedRequestOrFail(networkId, [
const request = this.#getBlockedRequestOrFail(params.request, [
"beforeRequestSent" /* Network.InterceptPhase.BeforeRequestSent */,
]);
const headers = (0, NetworkUtils_js_1.cdpFetchHeadersFromBidiNetworkHeaders)(commandHeaders);
// TODO: Set / expand.
// ; Step 9. cookies
try {
await request.continueRequest({
url,
method,
headers,
postData: getCdpBodyFromBiDiBytesValue(body),
});
await request.continueRequest(params);
}

@@ -66,44 +74,16 @@ catch (error) {

async continueResponse(params) {
const { request: networkId, statusCode, reasonPhrase, headers } = params;
if (params.headers) {
NetworkProcessor.validateHeaders(params.headers);
}
const responseHeaders = (0, NetworkUtils_js_1.cdpFetchHeadersFromBidiNetworkHeaders)(headers);
const request = this.#getBlockedRequestOrFail(networkId, [
const request = this.#getBlockedRequestOrFail(params.request, [
"authRequired" /* Network.InterceptPhase.AuthRequired */,
"responseStarted" /* Network.InterceptPhase.ResponseStarted */,
]);
if (request.interceptPhase === "authRequired" /* Network.InterceptPhase.AuthRequired */) {
if (params.credentials) {
await Promise.all([
request.waitNextPhase,
request.continueWithAuth({
response: 'ProvideCredentials',
username: params.credentials.username,
password: params.credentials.password,
}),
]);
}
else {
// We need to use `ProvideCredentials`
// As `Default` may cancel the request
await request.continueWithAuth({
response: 'ProvideCredentials',
});
return {};
}
// TODO: Set / expand.
// ; Step 10. cookies
try {
await request.continueResponse(params);
}
if (request.interceptPhase === "responseStarted" /* Network.InterceptPhase.ResponseStarted */) {
// TODO: Set / expand.
// ; Step 10. cookies
try {
await request.continueResponse({
responseCode: statusCode,
responsePhrase: reasonPhrase,
responseHeaders,
});
}
catch (error) {
throw NetworkProcessor.wrapInterceptionError(error);
}
catch (error) {
throw NetworkProcessor.wrapInterceptionError(error);
}

@@ -117,15 +97,3 @@ return {};

]);
let username;
let password;
if (params.action === 'provideCredentials') {
const { credentials } = params;
username = credentials.username;
password = credentials.password;
}
const response = (0, NetworkUtils_js_1.cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction)(params.action);
await request.continueWithAuth({
response,
username,
password,
});
await request.continueWithAuth(params);
return {};

@@ -145,12 +113,8 @@ }

async provideResponse(params) {
const { statusCode, reasonPhrase: responsePhrase, headers, body, request: networkId, } = params;
if (params.headers) {
NetworkProcessor.validateHeaders(params.headers);
}
// TODO: Step 6
// https://w3c.github.io/webdriver-bidi/#command-network-continueResponse
const responseHeaders = (0, NetworkUtils_js_1.cdpFetchHeadersFromBidiNetworkHeaders)(headers);
// TODO: Set / expand.
// ; Step 10. cookies
const request = this.#getBlockedRequestOrFail(networkId, [
const request = this.#getBlockedRequestOrFail(params.request, [
"beforeRequestSent" /* Network.InterceptPhase.BeforeRequestSent */,

@@ -160,26 +124,4 @@ "responseStarted" /* Network.InterceptPhase.ResponseStarted */,

]);
// We need to pass through if the request is already in
// AuthRequired phase
if (request.interceptPhase === "authRequired" /* Network.InterceptPhase.AuthRequired */) {
// We need to use `ProvideCredentials`
// As `Default` may cancel the request
await request.continueWithAuth({
response: 'ProvideCredentials',
});
return {};
}
// If we don't modify the response
// just continue the request
if (!body && !headers) {
await request.continueRequest();
return {};
}
const responseCode = statusCode ?? request.statusCode ?? 200;
try {
await request.provideResponse({
responseCode,
responsePhrase,
responseHeaders,
body: getCdpBodyFromBiDiBytesValue(body),
});
await request.provideResponse(params);
}

@@ -358,12 +300,2 @@ catch (error) {

}
function getCdpBodyFromBiDiBytesValue(body) {
let parsedBody;
if (body?.type === 'string') {
parsedBody = btoa(body.value);
}
else if (body?.type === 'base64') {
parsedBody = body.value;
}
return parsedBody;
}
//# sourceMappingURL=NetworkProcessor.js.map

@@ -43,11 +43,11 @@ /**

/** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueRequest */
continueRequest(overrides?: Omit<Protocol.Fetch.ContinueRequestRequest, 'requestId'>): Promise<void>;
continueRequest(overrides?: Omit<Network.ContinueRequestParameters, 'request'>): Promise<void>;
/** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueResponse */
continueResponse({ responseCode, responsePhrase, responseHeaders, }?: Omit<Protocol.Fetch.ContinueResponseRequest, 'requestId'>): Promise<void>;
continueResponse(overrides?: Omit<Network.ContinueResponseParameters, 'request'>): Promise<void>;
/** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueWithAuth */
continueWithAuth(authChallengeResponse?: Protocol.Fetch.ContinueWithAuthRequest['authChallengeResponse']): Promise<void>;
continueWithAuth(authChallenge: Omit<Network.ContinueWithAuthParameters, 'request'>): Promise<void>;
/** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-provideResponse */
provideResponse({ responseCode, responsePhrase, responseHeaders, body, }: Omit<Protocol.Fetch.FulfillRequestRequest, 'requestId'>): Promise<void>;
provideResponse(overrides: Omit<Network.ProvideResponseParameters, 'request'>): Promise<void>;
/** Returns the HTTP status code associated with this request if any. */
get statusCode(): number | undefined;
}

@@ -47,2 +47,3 @@ "use strict";

#request = {};
#requestOverrides;
#response = {};

@@ -87,3 +88,3 @@ #eventManager;

this.#response.paused?.request.url ??
this.#request.overrides?.url ??
this.#requestOverrides?.url ??
this.#request.auth?.request.url ??

@@ -96,3 +97,3 @@ this.#request.info?.request.url ??

get method() {
return (this.#request.overrides?.method ??
return (this.#requestOverrides?.method ??
this.#request.info?.request.method ??

@@ -254,3 +255,3 @@ this.#request.paused?.request.method ??

else {
void this.continueResponse();
void this.#continueResponse();
}

@@ -268,3 +269,3 @@ }

else {
void this.continueRequest();
void this.#continueRequest();
}

@@ -283,3 +284,5 @@ }

else {
void this.continueWithAuth();
void this.#continueWithAuth({
response: 'Default',
});
}

@@ -298,2 +301,19 @@ this.#emitEvent(() => {

async continueRequest(overrides = {}) {
const headers = (0, NetworkUtils_js_1.cdpFetchHeadersFromBidiNetworkHeaders)(overrides.headers);
const postData = getCdpBodyFromBiDiBytesValue(overrides.body);
await this.#continueRequest({
url: overrides.url,
method: overrides.method,
headers,
postData,
});
// TODO: Store postData's size only
this.#requestOverrides = {
url: overrides.url,
method: overrides.method,
headers: overrides.headers,
bodySize: getSizeFromBiDiBytesValue(overrides.body),
};
}
async #continueRequest(overrides = {}) {
(0, assert_js_1.assert)(this.#fetchId, 'Network Interception not set-up.');

@@ -307,12 +327,35 @@ await this.cdpClient.sendCommand('Fetch.continueRequest', {

});
// TODO: Store postData's size only
this.#request.overrides = {
url: overrides.url,
method: overrides.method,
headers: overrides.headers,
};
this.#interceptPhase = undefined;
}
/** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueResponse */
async continueResponse({ responseCode, responsePhrase, responseHeaders, } = {}) {
async continueResponse(overrides = {}) {
if (this.interceptPhase === "authRequired" /* Network.InterceptPhase.AuthRequired */) {
if (overrides.credentials) {
await Promise.all([
this.waitNextPhase,
await this.#continueWithAuth({
response: 'ProvideCredentials',
username: overrides.credentials.username,
password: overrides.credentials.password,
}),
]);
}
else {
// We need to use `ProvideCredentials`
// As `Default` may cancel the request
return await this.#continueWithAuth({
response: 'ProvideCredentials',
});
}
}
if (this.#interceptPhase === "responseStarted" /* Network.InterceptPhase.ResponseStarted */) {
const responseHeaders = (0, NetworkUtils_js_1.cdpFetchHeadersFromBidiNetworkHeaders)(overrides.headers);
await this.#continueResponse({
responseCode: overrides.statusCode,
responsePhrase: overrides.reasonPhrase,
responseHeaders,
});
}
}
async #continueResponse({ responseCode, responsePhrase, responseHeaders, } = {}) {
(0, assert_js_1.assert)(this.#fetchId, 'Network Interception not set-up.');

@@ -328,21 +371,44 @@ await this.cdpClient.sendCommand('Fetch.continueResponse', {

/** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueWithAuth */
async continueWithAuth(authChallengeResponse = {
response: 'Default',
}) {
(0, assert_js_1.assert)(this.#fetchId, 'Network Interception not set-up.');
await this.cdpClient.sendCommand('Fetch.continueWithAuth', {
requestId: this.#fetchId,
authChallengeResponse,
async continueWithAuth(authChallenge) {
let username;
let password;
if (authChallenge.action === 'provideCredentials') {
const { credentials } = authChallenge;
username = credentials.username;
password = credentials.password;
}
const response = (0, NetworkUtils_js_1.cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction)(authChallenge.action);
await this.#continueWithAuth({
response,
username,
password,
});
this.#interceptPhase = undefined;
}
/** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-provideResponse */
async provideResponse({ responseCode, responsePhrase, responseHeaders, body, }) {
async provideResponse(overrides) {
(0, assert_js_1.assert)(this.#fetchId, 'Network Interception not set-up.');
// We need to pass through if the request is already in
// AuthRequired phase
if (this.interceptPhase === "authRequired" /* Network.InterceptPhase.AuthRequired */) {
// We need to use `ProvideCredentials`
// As `Default` may cancel the request
return await this.#continueWithAuth({
response: 'ProvideCredentials',
});
}
// If we don't modify the response
// just continue the request
if (!overrides.body && !overrides.headers) {
return await this.#continueRequest();
}
// TODO: Step 6
// https://w3c.github.io/webdriver-bidi/#command-network-continueResponse
const responseHeaders = (0, NetworkUtils_js_1.cdpFetchHeadersFromBidiNetworkHeaders)(overrides.headers);
const responseCode = overrides.statusCode ?? this.statusCode ?? 200;
await this.cdpClient.sendCommand('Fetch.fulfillRequest', {
requestId: this.#fetchId,
responseCode,
responsePhrase,
responsePhrase: overrides.reasonPhrase,
responseHeaders,
body,
body: getCdpBodyFromBiDiBytesValue(overrides.body),
});

@@ -364,2 +430,10 @@ this.#interceptPhase = undefined;

}
async #continueWithAuth(authChallengeResponse) {
(0, assert_js_1.assert)(this.#fetchId, 'Network Interception not set-up.');
await this.cdpClient.sendCommand('Fetch.continueWithAuth', {
requestId: this.#fetchId,
authChallengeResponse,
});
this.#interceptPhase = undefined;
}
#emitEvent(getEvent) {

@@ -449,2 +523,3 @@ let event;

#getNavigationId() {
// Heuristic to determine if this is a navigation request, and if not return null.
if (!this.#request.info ||

@@ -458,3 +533,4 @@ !this.#request.info.loaderId ||

}
return this.#request.info.loaderId;
// Get virtual navigation ID from the browsing context.
return this.#networkStorage.getVirtualNavigationId(this.#request?.info?.frameId);
}

@@ -466,6 +542,4 @@ #getRequestData() {

let headers = [];
if (this.#request.overrides?.headers) {
headers = [
...(0, NetworkUtils_js_1.bidiNetworkHeadersFromCdpNetworkHeadersEntries)(this.#request.overrides?.headers),
];
if (this.#requestOverrides?.headers) {
headers = this.#requestOverrides.headers;
}

@@ -478,2 +552,9 @@ else {

}
let bodySize = 0;
if (typeof this.#requestOverrides?.bodySize === 'number') {
bodySize = this.#requestOverrides.bodySize;
}
else {
bodySize = (0, NetworkUtils_js_1.bidiBodySizeFromCdpPostDataEntries)(this.#request.info?.request.postDataEntries ?? []);
}
return {

@@ -486,4 +567,3 @@ request: this.#id,

headersSize: (0, NetworkUtils_js_1.computeHeadersSize)(headers),
// TODO: implement.
bodySize: 0,
bodySize,
timings: this.#getTimings(),

@@ -593,2 +673,21 @@ };

exports.NetworkRequest = NetworkRequest;
function getCdpBodyFromBiDiBytesValue(body) {
let parsedBody;
if (body?.type === 'string') {
parsedBody = btoa(body.value);
}
else if (body?.type === 'base64') {
parsedBody = body.value;
}
return parsedBody;
}
function getSizeFromBiDiBytesValue(body) {
if (body?.type === 'string') {
return body.value.length;
}
else if (body?.type === 'base64') {
return atob(body.value).length;
}
return 0;
}
//# sourceMappingURL=NetworkRequest.js.map

@@ -5,2 +5,3 @@ import { type BrowsingContext, Network } from '../../../protocol/protocol.js';

import type { CdpTarget } from '../cdp/CdpTarget.js';
import type { BrowsingContextStorage } from '../context/BrowsingContextStorage';
import type { EventManager } from '../session/EventManager.js';

@@ -14,3 +15,3 @@ import { NetworkRequest } from './NetworkRequest.js';

#private;
constructor(eventManager: EventManager, browserClient: CdpClient, logger?: LoggerFn);
constructor(eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, browserClient: CdpClient, logger?: LoggerFn);
onCdpTargetCreated(cdpTarget: CdpTarget): void;

@@ -40,3 +41,7 @@ getInterceptionStages(browsingContextId: BrowsingContext.BrowsingContext): {

deleteRequest(id: Network.Request): void;
/**
* Gets the virtual navigation ID for the given navigable ID.
*/
getVirtualNavigationId(contextId: string | undefined): string | null;
}
export {};

@@ -10,2 +10,3 @@ "use strict";

class NetworkStorage {
#browsingContextStorage;
#eventManager;

@@ -20,3 +21,4 @@ #logger;

#intercepts = new Map();
constructor(eventManager, browserClient, logger) {
constructor(eventManager, browsingContextStorage, browserClient, logger) {
this.#browsingContextStorage = browsingContextStorage;
this.#eventManager = eventManager;

@@ -198,4 +200,14 @@ browserClient.on('Target.detachedFromTarget', ({ sessionId }) => {

}
/**
* Gets the virtual navigation ID for the given navigable ID.
*/
getVirtualNavigationId(contextId) {
if (contextId === undefined) {
return null;
}
return (this.#browsingContextStorage.findContext(contextId)
?.virtualNavigationId ?? null);
}
}
exports.NetworkStorage = NetworkStorage;
//# sourceMappingURL=NetworkStorage.js.map

@@ -49,1 +49,2 @@ /**

export declare function matchUrlPattern(urlPattern: Network.UrlPattern, url: string | undefined): boolean;
export declare function bidiBodySizeFromCdpPostDataEntries(entries: Protocol.Network.PostDataEntry[]): number;

@@ -20,3 +20,16 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.matchUrlPattern = exports.isSpecialScheme = exports.sameSiteBiDiToCdp = exports.bidiToCdpCookie = exports.deserializeByteValue = exports.cdpToBiDiCookie = exports.cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction = exports.cdpFetchHeadersFromBidiNetworkHeaders = exports.bidiNetworkHeadersFromCdpFetchHeaders = exports.cdpNetworkHeadersFromBidiNetworkHeaders = exports.bidiNetworkHeadersFromCdpNetworkHeadersEntries = exports.bidiNetworkHeadersFromCdpNetworkHeaders = exports.computeHeadersSize = void 0;
exports.computeHeadersSize = computeHeadersSize;
exports.bidiNetworkHeadersFromCdpNetworkHeaders = bidiNetworkHeadersFromCdpNetworkHeaders;
exports.bidiNetworkHeadersFromCdpNetworkHeadersEntries = bidiNetworkHeadersFromCdpNetworkHeadersEntries;
exports.cdpNetworkHeadersFromBidiNetworkHeaders = cdpNetworkHeadersFromBidiNetworkHeaders;
exports.bidiNetworkHeadersFromCdpFetchHeaders = bidiNetworkHeadersFromCdpFetchHeaders;
exports.cdpFetchHeadersFromBidiNetworkHeaders = cdpFetchHeadersFromBidiNetworkHeaders;
exports.cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction = cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction;
exports.cdpToBiDiCookie = cdpToBiDiCookie;
exports.deserializeByteValue = deserializeByteValue;
exports.bidiToCdpCookie = bidiToCdpCookie;
exports.sameSiteBiDiToCdp = sameSiteBiDiToCdp;
exports.isSpecialScheme = isSpecialScheme;
exports.matchUrlPattern = matchUrlPattern;
exports.bidiBodySizeFromCdpPostDataEntries = bidiBodySizeFromCdpPostDataEntries;
const ErrorResponse_js_1 = require("../../../protocol/ErrorResponse.js");

@@ -31,3 +44,2 @@ const Base64_js_1 = require("../../../utils/Base64.js");

}
exports.computeHeadersSize = computeHeadersSize;
/** Converts from CDP Network domain headers to BiDi network headers. */

@@ -46,3 +58,2 @@ function bidiNetworkHeadersFromCdpNetworkHeaders(headers) {

}
exports.bidiNetworkHeadersFromCdpNetworkHeaders = bidiNetworkHeadersFromCdpNetworkHeaders;
/** Converts from CDP Fetch domain headers to BiDi network headers. */

@@ -61,3 +72,2 @@ function bidiNetworkHeadersFromCdpNetworkHeadersEntries(headers) {

}
exports.bidiNetworkHeadersFromCdpNetworkHeadersEntries = bidiNetworkHeadersFromCdpNetworkHeadersEntries;
/** Converts from Bidi network headers to CDP Network domain headers. */

@@ -74,3 +84,2 @@ function cdpNetworkHeadersFromBidiNetworkHeaders(headers) {

}
exports.cdpNetworkHeadersFromBidiNetworkHeaders = cdpNetworkHeadersFromBidiNetworkHeaders;
/** Converts from CDP Fetch domain header entries to Bidi network headers. */

@@ -89,3 +98,2 @@ function bidiNetworkHeadersFromCdpFetchHeaders(headers) {

}
exports.bidiNetworkHeadersFromCdpFetchHeaders = bidiNetworkHeadersFromCdpFetchHeaders;
/** Converts from Bidi network headers to CDP Fetch domain header entries. */

@@ -101,3 +109,2 @@ function cdpFetchHeadersFromBidiNetworkHeaders(headers) {

}
exports.cdpFetchHeadersFromBidiNetworkHeaders = cdpFetchHeadersFromBidiNetworkHeaders;
/** Converts from Bidi auth action to CDP auth challenge response. */

@@ -114,3 +121,2 @@ function cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction(action) {

}
exports.cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction = cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction;
/**

@@ -149,3 +155,2 @@ * Converts from CDP Network domain cookie to BiDi network cookie.

}
exports.cdpToBiDiCookie = cdpToBiDiCookie;
/**

@@ -162,3 +167,2 @@ * Decodes a byte value to a string.

}
exports.deserializeByteValue = deserializeByteValue;
/**

@@ -210,3 +214,2 @@ * Converts from BiDi set network cookie params to CDP Network domain cookie.

}
exports.bidiToCdpCookie = bidiToCdpCookie;
function sameSiteCdpToBiDi(sameSite) {

@@ -237,3 +240,2 @@ switch (sameSite) {

}
exports.sameSiteBiDiToCdp = sameSiteBiDiToCdp;
/**

@@ -250,3 +252,2 @@ * Returns true if the given protocol is special.

}
exports.isSpecialScheme = isSpecialScheme;
/** Matches the given URLPattern against the given URL. */

@@ -269,3 +270,9 @@ function matchUrlPattern(urlPattern, url) {

}
exports.matchUrlPattern = matchUrlPattern;
function bidiBodySizeFromCdpPostDataEntries(entries) {
let size = 0;
for (const entry of entries) {
size += atob(entry.bytes ?? '').length;
}
return size;
}
//# sourceMappingURL=NetworkUtils.js.map

@@ -19,3 +19,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseSharedId = exports.getSharedId = void 0;
exports.getSharedId = getSharedId;
exports.parseSharedId = parseSharedId;
const SHARED_ID_DIVIDER = '_element_';

@@ -25,3 +26,2 @@ function getSharedId(frameId, documentId, backendNodeId) {

}
exports.getSharedId = getSharedId;
function parseLegacySharedId(sharedId) {

@@ -76,3 +76,2 @@ const match = sharedId.match(new RegExp(`(.*)${SHARED_ID_DIVIDER}(.*)`));

}
exports.parseSharedId = parseSharedId;
//# sourceMappingURL=SharedId.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertSupportedEvent = exports.isCdpEvent = void 0;
exports.isCdpEvent = isCdpEvent;
exports.assertSupportedEvent = assertSupportedEvent;
/**

@@ -28,3 +29,2 @@ * Copyright 2023 Google LLC.

}
exports.isCdpEvent = isCdpEvent;
/**

@@ -38,3 +38,2 @@ * Asserts that the given event is known to BiDi or BiDi+, or throws otherwise.

}
exports.assertSupportedEvent = assertSupportedEvent;
//# sourceMappingURL=events.js.map

@@ -19,3 +19,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscriptionManager = exports.unrollEvents = exports.cartesianProduct = void 0;
exports.SubscriptionManager = void 0;
exports.cartesianProduct = cartesianProduct;
exports.unrollEvents = unrollEvents;
const protocol_js_1 = require("../../../protocol/protocol.js");

@@ -32,3 +34,2 @@ const events_js_1 = require("./events.js");

}
exports.cartesianProduct = cartesianProduct;
/** Expands "AllEvents" events into atomic events. */

@@ -62,3 +63,2 @@ function unrollEvents(events) {

}
exports.unrollEvents = unrollEvents;
class SubscriptionManager {

@@ -65,0 +65,0 @@ #subscriptionPriority = 0;

@@ -22,3 +22,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCommandLineArgs = void 0;
exports.parseCommandLineArgs = parseCommandLineArgs;
const yargs_1 = __importDefault(require("yargs"));

@@ -44,3 +44,2 @@ const helpers_1 = require("yargs/helpers");

}
exports.parseCommandLineArgs = parseCommandLineArgs;
(() => {

@@ -47,0 +46,0 @@ try {

@@ -22,3 +22,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getMapperTabSource = void 0;
exports.getMapperTabSource = getMapperTabSource;
const promises_1 = __importDefault(require("fs/promises"));

@@ -29,3 +29,2 @@ const path_1 = __importDefault(require("path"));

}
exports.getMapperTabSource = getMapperTabSource;
//# sourceMappingURL=reader.js.map

@@ -319,3 +319,4 @@ "use strict";

const acceptInsecureCerts = capabilities?.alwaysMatch?.acceptInsecureCerts ?? false;
return { acceptInsecureCerts };
const unhandledPromptBehavior = capabilities?.alwaysMatch?.unhandledPromptBehavior ?? undefined;
return { acceptInsecureCerts, unhandledPromptBehavior };
}

@@ -322,0 +323,0 @@ #getChromeOptions(capabilities) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.log = exports.generatePage = void 0;
exports.generatePage = generatePage;
exports.log = log;
/**

@@ -32,3 +33,2 @@ * Copyright 2022 Google LLC.

}
exports.generatePage = generatePage;
function stringify(message) {

@@ -64,3 +64,2 @@ if (typeof message === 'object') {

}
exports.log = log;
//# sourceMappingURL=mapperTabPage.js.map

@@ -42,3 +42,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Permissions = exports.Cdp = exports.Storage = exports.Input = exports.Session = exports.BrowsingContext = exports.Script = exports.Network = exports.Browser = exports.parseObject = void 0;
exports.Permissions = exports.Cdp = exports.Storage = exports.Input = exports.Session = exports.BrowsingContext = exports.Script = exports.Network = exports.Browser = void 0;
exports.parseObject = parseObject;
/**

@@ -63,3 +64,2 @@ * @fileoverview Provides parsing and validator for WebDriver BiDi protocol.

}
exports.parseObject = parseObject;
/** @see https://w3c.github.io/webdriver-bidi/#module-browser */

@@ -66,0 +66,0 @@ var Browser;

@@ -101,3 +101,3 @@ /**

proxy?: Session.ProxyConfiguration;
webSocketUrl?: boolean;
unhandledPromptBehavior?: Session.UserPromptHandler;
} & Extensible;

@@ -146,2 +146,18 @@ }

export declare namespace Session {
const enum UserPromptHandlerType {
Accept = "accept",
Dismiss = "dismiss",
Ignore = "ignore"
}
}
export declare namespace Session {
type UserPromptHandler = {
alert?: Session.UserPromptHandlerType;
beforeUnload?: Session.UserPromptHandlerType;
confirm?: Session.UserPromptHandlerType;
default?: Session.UserPromptHandlerType;
prompt?: Session.UserPromptHandlerType;
};
}
export declare namespace Session {
type SubscriptionRequest = {

@@ -189,2 +205,3 @@ events: [string, ...string[]];

proxy?: Session.ProxyConfiguration;
unhandledPromptBehavior?: Session.UserPromptHandler;
webSocketUrl?: string;

@@ -330,2 +347,10 @@ } & Extensible;

export declare namespace BrowsingContext {
const enum UserPromptType {
Alert = "alert",
Beforeunload = "beforeunload",
Confirm = "confirm",
Prompt = "prompt"
}
}
export declare namespace BrowsingContext {
type Activate = {

@@ -700,2 +725,3 @@ method: 'browsingContext.activate';

accepted: boolean;
type: BrowsingContext.UserPromptType;
userText?: string;

@@ -713,4 +739,5 @@ };

context: BrowsingContext.BrowsingContext;
type: 'alert' | 'confirm' | 'prompt' | 'beforeunload';
handler: 'accept' | 'dismiss' | 'ignore';
message: string;
type: BrowsingContext.UserPromptType;
defaultValue?: string;

@@ -717,0 +744,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assert = void 0;
exports.assert = assert;
/**

@@ -25,3 +25,2 @@ * Copyright 2023 Google LLC.

}
exports.assert = assert;
//# sourceMappingURL=assert.js.map

@@ -19,3 +19,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.base64ToString = void 0;
exports.base64ToString = base64ToString;
/**

@@ -36,3 +36,2 @@ * Encodes a string to base64.

}
exports.base64ToString = base64ToString;
//# sourceMappingURL=Base64.js.map

@@ -19,3 +19,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.deterministicJSONStringify = exports.distinctValues = void 0;
exports.distinctValues = distinctValues;
exports.deterministicJSONStringify = deterministicJSONStringify;
/**

@@ -33,3 +34,2 @@ * Returns an array of distinct values. Order is not guaranteed.

}
exports.distinctValues = distinctValues;
/**

@@ -45,3 +45,2 @@ * Returns a stringified version of the object with keys sorted. This is required to

}
exports.deterministicJSONStringify = deterministicJSONStringify;
function normalizeObject(obj) {

@@ -48,0 +47,0 @@ if (obj === undefined ||

@@ -19,3 +19,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isSingleGrapheme = exports.isSingleComplexGrapheme = void 0;
exports.isSingleComplexGrapheme = isSingleComplexGrapheme;
exports.isSingleGrapheme = isSingleGrapheme;
/**

@@ -28,3 +29,2 @@ * Check if the given string is a single complex grapheme. A complex grapheme is one that

}
exports.isSingleComplexGrapheme = isSingleComplexGrapheme;
/**

@@ -40,3 +40,2 @@ * Check if the given string is a single grapheme.

}
exports.isSingleGrapheme = isSingleGrapheme;
//# sourceMappingURL=GraphemeTools.js.map

@@ -19,3 +19,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.inchesFromCm = void 0;
exports.inchesFromCm = inchesFromCm;
/** @return Given an input in cm, convert it to inches. */

@@ -25,3 +25,2 @@ function inchesFromCm(cm) {

}
exports.inchesFromCm = inchesFromCm;
//# sourceMappingURL=unitConversions.js.map

@@ -19,3 +19,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.uuidv4 = void 0;
exports.uuidv4 = uuidv4;
/**

@@ -63,3 +63,2 @@ * Generates a random v4 UUID, as specified in RFC4122.

}
exports.uuidv4 = uuidv4;
//# sourceMappingURL=uuid.js.map
{
"name": "chromium-bidi",
"version": "0.5.24",
"version": "0.6.0",
"description": "An implementation of the WebDriver BiDi protocol for Chromium implemented as a JavaScript layer translating between BiDi and CDP, running inside a Chrome tab.",

@@ -146,3 +146,3 @@ "scripts": {

"@puppeteer/browsers": "2.2.3",
"@rollup/plugin-commonjs": "25.0.8",
"@rollup/plugin-commonjs": "26.0.1",
"@rollup/plugin-node-resolve": "15.2.3",

@@ -153,4 +153,4 @@ "@rollup/wasm-node": "4.18.0",

"@types/debug": "4.1.12",
"@types/mocha": "10.0.6",
"@types/node": "20.14.0",
"@types/mocha": "10.0.7",
"@types/node": "20.14.8",
"@types/sinon": "17.0.3",

@@ -160,8 +160,8 @@ "@types/websocket": "1.0.10",

"@types/yargs": "17.0.32",
"@typescript-eslint/eslint-plugin": "7.11.0",
"@typescript-eslint/parser": "7.11.0",
"@typescript-eslint/eslint-plugin": "7.13.1",
"@typescript-eslint/parser": "7.13.1",
"chai": "4.4.1",
"chai-as-promised": "7.1.2",
"debug": "4.3.5",
"devtools-protocol": "0.0.1312386",
"devtools-protocol": "0.0.1319565",
"eslint": "8.57.0",

@@ -174,18 +174,18 @@ "eslint-config-prettier": "9.1.0",

"eslint-plugin-promise": "6.2.0",
"gts": "5.3.0",
"gts": "5.3.1",
"mocha": "10.4.0",
"pkg-dir": "8.0.0",
"prettier": "3.3.0",
"prettier": "3.3.2",
"rimraf": "5.0.7",
"rollup": "4.18.0",
"rollup-plugin-license": "3.4.0",
"selenium-webdriver": "4.21.0",
"rollup-plugin-license": "3.5.1",
"selenium-webdriver": "4.22.0",
"sinon": "18.0.0",
"source-map-support": "0.5.21",
"tslib": "2.6.2",
"typescript": "5.4.5",
"webdriverio": "8.38.0",
"tslib": "2.6.3",
"typescript": "5.5.2",
"webdriverio": "8.39.0",
"websocket": "1.0.35",
"wireit": "0.14.4",
"ws": "8.17.0",
"ws": "8.17.1",
"yargs": "17.7.2"

@@ -192,0 +192,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc