Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chromium-bidi

Package Overview
Dependencies
Maintainers
2
Versions
73
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.5 to 0.5.6

7

lib/cjs/bidiMapper/domains/context/BrowsingContextProcessor.js

@@ -83,4 +83,7 @@ "use strict";

catch (err) {
// https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/devtools/protocol/target_handler.cc;l=1;drc=e80392ac11e48a691f4309964cab83a3a59e01c8
if (err.message.startsWith('Failed to find browser context with id')) {
if (
// See https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/devtools/protocol/target_handler.cc;l=90;drc=e80392ac11e48a691f4309964cab83a3a59e01c8
err.message.startsWith('Failed to find browser context with id') ||
// See https://source.chromium.org/chromium/chromium/src/+/main:headless/lib/browser/protocol/target_handler.cc;l=49;drc=e80392ac11e48a691f4309964cab83a3a59e01c8
err.message === 'browserContextId') {
throw new protocol_js_1.NoSuchUserContextException(`The context ${userContext} was not found`);

@@ -87,0 +90,0 @@ }

@@ -54,9 +54,9 @@ /**

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

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

@@ -528,31 +528,6 @@ "use strict";

})
.map(({ cookie }) => {
return {
name: cookie.name,
value: {
type: 'string',
value: cookie.value,
},
domain: cookie.domain,
path: cookie.path,
expires: cookie.expires,
size: cookie.size,
httpOnly: cookie.httpOnly,
secure: cookie.secure,
sameSite: NetworkRequest.#getCookiesSameSite(cookie.sameSite),
};
});
.map(({ cookie }) => (0, NetworkUtils_js_1.cdpToBiDiCookie)(cookie));
}
static #getCookiesSameSite(cdpSameSiteValue) {
switch (cdpSameSiteValue) {
case 'Strict':
return "strict" /* Network.SameSite.Strict */;
case 'Lax':
return "lax" /* Network.SameSite.Lax */;
default:
return "none" /* Network.SameSite.None */;
}
}
}
exports.NetworkRequest = NetworkRequest;
//# sourceMappingURL=NetworkRequest.js.map

@@ -20,2 +20,6 @@ /**

import type { NetworkRequest } from './NetworkRequest.js';
interface NetworkInterception {
urlPatterns: Network.UrlPattern[];
phases: Network.AddInterceptParameters['phases'];
}
export interface BlockedRequest {

@@ -36,6 +40,3 @@ request: Protocol.Fetch.RequestId;

*/
addIntercept(value: {
urlPatterns: Network.UrlPattern[];
phases: Network.AddInterceptParameters['phases'];
}): Network.Intercept;
addIntercept(value: NetworkInterception): Network.Intercept;
/**

@@ -85,1 +86,2 @@ * Removes the given intercept from the intercept map.

}
export {};

@@ -31,9 +31,2 @@ "use strict";

addIntercept(value) {
// Check if the given intercept entry already exists.
for (const [interceptId, { urlPatterns, phases },] of this.#interceptMap.entries()) {
if (JSON.stringify(value.urlPatterns) === JSON.stringify(urlPatterns) &&
JSON.stringify(value.phases) === JSON.stringify(phases)) {
return interceptId;
}
}
const interceptId = (0, uuid_js_1.uuidv4)();

@@ -40,0 +33,0 @@ this.#interceptMap.set(interceptId, value);

@@ -5,3 +5,3 @@ /**

import type { Protocol } from 'devtools-protocol';
import type { Network } from '../../../protocol/protocol.js';
import { Network, type Storage } from '../../../protocol/protocol.js';
export declare function computeHeadersSize(headers: Network.Header[]): number;

@@ -18,1 +18,13 @@ /** Converts from CDP Network domain headers to Bidi network headers. */

export declare function cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction(action: 'default' | 'cancel' | 'provideCredentials'): "Default" | "CancelAuth" | "ProvideCredentials";
/**
* Converts from CDP Network domain cookie to BiDi network cookie.
* * https://chromedevtools.github.io/devtools-protocol/tot/Network/#type-Cookie
* * https://w3c.github.io/webdriver-bidi/#type-network-Cookie
*/
export declare function cdpToBiDiCookie(cookie: Protocol.Network.Cookie): Network.Cookie;
/**
* Converts from BiDi set network cookie params to CDP Network domain cookie.
* * https://w3c.github.io/webdriver-bidi/#type-network-Cookie
* * https://chromedevtools.github.io/devtools-protocol/tot/Network/#type-CookieParam
*/
export declare function bidiToCdpCookie(params: Storage.SetCookieParameters, partitionKey: Storage.PartitionKey): Protocol.Network.CookieParam;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction = exports.cdpFetchHeadersFromBidiNetworkHeaders = exports.bidiNetworkHeadersFromCdpFetchHeaders = exports.cdpNetworkHeadersFromBidiNetworkHeaders = exports.bidiNetworkHeadersFromCdpNetworkHeaders = exports.computeHeadersSize = void 0;
exports.bidiToCdpCookie = exports.cdpToBiDiCookie = exports.cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction = exports.cdpFetchHeadersFromBidiNetworkHeaders = exports.bidiNetworkHeadersFromCdpFetchHeaders = exports.cdpNetworkHeadersFromBidiNetworkHeaders = exports.bidiNetworkHeadersFromCdpNetworkHeaders = exports.computeHeadersSize = void 0;
const ErrorResponse_1 = require("../../../protocol/ErrorResponse");
function computeHeadersSize(headers) {

@@ -92,2 +93,109 @@ const requestHeaders = headers.reduce((acc, header) => {

exports.cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction = cdpAuthChallengeResponseFromBidiAuthContinueWithAuthAction;
/**
* Converts from CDP Network domain cookie to BiDi network cookie.
* * https://chromedevtools.github.io/devtools-protocol/tot/Network/#type-Cookie
* * https://w3c.github.io/webdriver-bidi/#type-network-Cookie
*/
function cdpToBiDiCookie(cookie) {
const result = {
name: cookie.name,
value: { type: 'string', value: cookie.value },
domain: cookie.domain,
path: cookie.path,
size: cookie.size,
httpOnly: cookie.httpOnly,
secure: cookie.secure,
sameSite: cookie.sameSite === undefined
? "none" /* Network.SameSite.None */
: sameSiteCdpToBiDi(cookie.sameSite),
...(cookie.expires >= 0 ? { expiry: cookie.expires } : undefined),
};
// Extending with CDP-specific properties with `goog:` prefix.
result[`goog:session`] = cookie.session;
result[`goog:priority`] = cookie.priority;
result[`goog:sameParty`] = cookie.sameParty;
result[`goog:sourceScheme`] = cookie.sourceScheme;
result[`goog:sourcePort`] = cookie.sourcePort;
if (cookie.partitionKey !== undefined) {
result[`goog:partitionKey`] = cookie.partitionKey;
}
if (cookie.partitionKeyOpaque !== undefined) {
result[`goog:partitionKeyOpaque`] = cookie.partitionKeyOpaque;
}
return result;
}
exports.cdpToBiDiCookie = cdpToBiDiCookie;
/**
* Converts from BiDi set network cookie params to CDP Network domain cookie.
* * https://w3c.github.io/webdriver-bidi/#type-network-Cookie
* * https://chromedevtools.github.io/devtools-protocol/tot/Network/#type-CookieParam
*/
function bidiToCdpCookie(params, partitionKey) {
if (params.cookie.value.type !== 'string') {
// CDP supports only string values in cookies.
throw new ErrorResponse_1.UnsupportedOperationException('Only string cookie values are supported');
}
const deserializedValue = params.cookie.value.value;
const result = {
name: params.cookie.name,
value: deserializedValue,
domain: params.cookie.domain,
path: params.cookie.path ?? '/',
secure: params.cookie.secure ?? false,
httpOnly: params.cookie.httpOnly ?? false,
// CDP's `partitionKey` is the BiDi's `partition.sourceOrigin`.
...(partitionKey.sourceOrigin !== undefined && {
partitionKey: partitionKey.sourceOrigin,
}),
...(params.cookie.expiry !== undefined && {
expires: params.cookie.expiry,
}),
...(params.cookie.sameSite !== undefined && {
sameSite: sameSiteBiDiToCdp(params.cookie.sameSite),
}),
};
// Extending with CDP-specific properties with `goog:` prefix.
if (params.cookie[`goog:url`] !== undefined) {
result.url = params.cookie[`goog:url`];
}
if (params.cookie[`goog:priority`] !== undefined) {
result.priority = params.cookie[`goog:priority`];
}
if (params.cookie[`goog:sameParty`] !== undefined) {
result.sameParty = params.cookie[`goog:sameParty`];
}
if (params.cookie[`goog:sourceScheme`] !== undefined) {
result.sourceScheme = params.cookie[`goog:sourceScheme`];
}
if (params.cookie[`goog:sourcePort`] !== undefined) {
result.sourcePort = params.cookie[`goog:sourcePort`];
}
return result;
}
exports.bidiToCdpCookie = bidiToCdpCookie;
function sameSiteCdpToBiDi(sameSite) {
switch (sameSite) {
case 'Strict':
return "strict" /* Network.SameSite.Strict */;
case 'None':
return "none" /* Network.SameSite.None */;
case 'Lax':
return "lax" /* Network.SameSite.Lax */;
default:
// Defaults to `Lax`:
// https://web.dev/articles/samesite-cookies-explained#samesitelax_by_default
return "lax" /* Network.SameSite.Lax */;
}
}
function sameSiteBiDiToCdp(sameSite) {
switch (sameSite) {
case "strict" /* Network.SameSite.Strict */:
return 'Strict';
case "lax" /* Network.SameSite.Lax */:
return 'Lax';
case "none" /* Network.SameSite.None */:
return 'None';
}
throw new ErrorResponse_1.InvalidArgumentException(`Unknown 'sameSite' value ${sameSite}`);
}
//# sourceMappingURL=NetworkUtils.js.map

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

const NetworkProcessor_js_1 = require("../network/NetworkProcessor.js");
const NetworkUtils_js_1 = require("../network/NetworkUtils.js");
/**

@@ -31,3 +32,3 @@ * Responsible for handling the `storage` domain.

c.partitionKey === partitionKey.sourceOrigin)
.map((c) => this.#cdpToBiDiCookie(c))
.map((c) => (0, NetworkUtils_js_1.cdpToBiDiCookie)(c))
.filter((c) => this.#matchCookie(c, params.filter));

@@ -41,3 +42,3 @@ return {

const partitionKey = this.#expandStoragePartitionSpec(params.partition);
const cdpCookie = this.#bidiToCdpCookie(params, partitionKey);
const cdpCookie = (0, NetworkUtils_js_1.bidiToCdpCookie)(params, partitionKey);
try {

@@ -108,85 +109,2 @@ await this.#browserCdpClient.sendCommand('Storage.setCookies', {

}
#bidiToCdpCookie(params, partitionKey) {
if (params.cookie.value.type !== 'string') {
// CDP supports only string values in cookies.
throw new protocol_js_1.UnsupportedOperationException('Only string cookie values are supported');
}
const deserializedValue = params.cookie.value.value;
return {
name: params.cookie.name,
value: deserializedValue,
domain: params.cookie.domain,
path: params.cookie.path ?? '/',
secure: params.cookie.secure ?? false,
httpOnly: params.cookie.httpOnly ?? false,
// CDP's `partitionKey` is the BiDi's `partition.sourceOrigin`.
...(partitionKey.sourceOrigin !== undefined && {
partitionKey: partitionKey.sourceOrigin,
}),
...(params.cookie.expiry !== undefined && {
expires: params.cookie.expiry,
}),
...(params.cookie.sameSite !== undefined && {
sameSite: StorageProcessor.#sameSiteBiDiToCdp(params.cookie.sameSite),
}),
// TODO: extend with CDP-specific properties with `goog:` prefix after
// https://github.com/w3c/webdriver-bidi/pull/637
// * session: boolean;
// * priority: CookiePriority;
// * sameParty: boolean;
// * sourceScheme: CookieSourceScheme;
// * sourcePort: integer;
// * partitionKey?: string;
// * partitionKeyOpaque?: boolean;
};
}
#cdpToBiDiCookie(cookie) {
return {
name: cookie.name,
value: { type: 'string', value: cookie.value },
domain: cookie.domain,
path: cookie.path,
size: cookie.size,
httpOnly: cookie.httpOnly,
secure: cookie.secure,
sameSite: cookie.sameSite === undefined
? "none" /* Network.SameSite.None */
: StorageProcessor.#sameSiteCdpToBiDi(cookie.sameSite),
...(cookie.expires >= 0 ? { expiry: cookie.expires } : undefined),
// TODO: extend with CDP-specific properties with `goog:` prefix after
// https://github.com/w3c/webdriver-bidi/pull/637
// * session: boolean;
// * priority: CookiePriority;
// * sameParty: boolean;
// * sourceScheme: CookieSourceScheme;
// * sourcePort: integer;
// * partitionKey?: string;
// * partitionKeyOpaque?: boolean;
};
}
static #sameSiteCdpToBiDi(sameSite) {
switch (sameSite) {
case 'Strict':
return "strict" /* Network.SameSite.Strict */;
case 'None':
return "none" /* Network.SameSite.None */;
case 'Lax':
return "lax" /* Network.SameSite.Lax */;
default:
// Defaults to `Lax`:
// https://web.dev/articles/samesite-cookies-explained#samesitelax_by_default
return "lax" /* Network.SameSite.Lax */;
}
}
static #sameSiteBiDiToCdp(sameSite) {
switch (sameSite) {
case "strict" /* Network.SameSite.Strict */:
return 'Strict';
case "lax" /* Network.SameSite.Lax */:
return 'Lax';
case "none" /* Network.SameSite.None */:
return 'None';
}
throw new protocol_js_1.InvalidArgumentException(`Unknown 'sameSite' value ${sameSite}`);
}
#matchCookie(cookie, filter) {

@@ -193,0 +111,0 @@ if (filter === undefined) {

{
"name": "chromium-bidi",
"version": "0.5.5",
"version": "0.5.6",
"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.",

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

"@types/mocha": "10.0.6",
"@types/node": "20.10.6",
"@types/node": "20.11.6",
"@types/sinon": "17.0.3",

@@ -190,3 +190,3 @@ "@types/websocket": "1.0.10",

"argparse": "2.0.1",
"chai": "4.3.10",
"chai": "4.4.1",
"chai-as-promised": "7.1.1",

@@ -224,4 +224,4 @@ "debug": "4.3.4",

"mitt": "3.0.1",
"urlpattern-polyfill": "9.0.0"
"urlpattern-polyfill": "10.0.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 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