Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
chrome-debugging-client
Advanced tools
An async/await friendly Chrome debugging client with TypeScript support
An async/await friendly Chrome debugging client with TypeScript support, designed with automation in mind.
DEBUG=chrome-debugging-client
const { spawnChrome } = require("chrome-debugging-client");
const { writeFileSync } = require("fs");
main();
async function main() {
const chrome = spawnChrome();
try {
const browser = chrome.connection;
browser.on("error", err => {
// underlying connection error or error dispatching events.
console.error(`connection error ${err.stack}`);
});
const { targetId } = await browser.send("Target.createTarget", {
url: "about:blank",
});
await browser.send("Target.activateTarget", { targetId });
const page = browser.connection(
await browser.send("Target.attachToTarget", {
targetId,
// this library only supports flattened sessions
flatten: true,
}),
);
let buffer = "";
await page.send("HeapProfiler.enable");
page.on("HeapProfiler.addHeapSnapshotChunk", params => {
buffer += params.chunk;
});
await page.send("HeapProfiler.takeHeapSnapshot", {
reportProgress: false,
});
writeFileSync("heapsnapshot.json", buffer);
await browser.send("Target.closeTarget", { targetId });
await browser.send("Browser.close");
await chrome.waitForExit();
} finally {
await chrome.dispose();
}
}
const { spawnWithWebSocket } = require("chrome-debugging-client");
main();
async function main() {
// start node requesting it break on start at debug port that
// is available
const node = await spawnWithWebSocket(process.execPath, [
"--inspect-brk=0",
"-e",
`const obj = {
hello: "world",
};
debugger;
console.log("end");`,
]);
const { connection } = node;
try {
// we requested Node to break on start, so we runIfWaitingForDebugger
// and wait for it to break at the start of our script
await Promise.all([
connection.until("Debugger.paused"),
connection.send("Debugger.enable"),
connection.send("Runtime.enable"),
connection.send("Runtime.runIfWaitingForDebugger"),
]);
// right now we are paused at the start of the script
// resume until debugger statement hit
const [debuggerStatement] = await Promise.all([
connection.until("Debugger.paused"),
connection.send("Debugger.resume"),
]);
// get the call frame of the debugger statement
const [callFrame] = debuggerStatement.callFrames;
const { callFrameId } = callFrame;
// eval obj at the debugger call frame
const { result } = await connection.send(
"Debugger.evaluateOnCallFrame",
{
callFrameId,
expression: "obj",
returnByValue: true,
},
);
console.log(result.value); //= { hello: "world" }
// resume and wait for execution to be done
await Promise.all([
connection.until("Runtime.executionContextDestroyed"),
connection.send("Debugger.resume"),
]);
// Node is still alive here and waiting for the debugger to disconnect
// when we close the websocket after resuming
// Node should exit on its own
node.close();
await node.waitForExit();
} finally {
await node.dispose();
}
}
FAQs
An async/await friendly Chrome debugging client with TypeScript support
The npm package chrome-debugging-client receives a total of 1,069 weekly downloads. As such, chrome-debugging-client popularity was classified as popular.
We found that chrome-debugging-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.