
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
@agent-infra/browser-ui
Advanced tools
A React component library that provides remote browser interaction capabilities. This package allows you to display and interact with a remote browser instance through Chrome DevTools Protocol (CDP) in your React application.
A React component library that provides remote browser interaction capabilities. This package allows you to display and interact with a remote browser instance through Chrome DevTools Protocol (CDP) in your React application.
This package enables you to:
The main component BrowserCanvas renders the browser content on an HTML5 canvas and forwards user interactions to the remote browser via CDP WebSocket connection.
npm install @agent-infra/browser-ui
First, you need a Chrome/Chromium browser running with remote debugging enabled:
import puppeteer from 'puppeteer-core';
const browser = await puppeteer.launch({
executablePath: '/path/to/chrome',
headless: false,
args: [
'--remote-debugging-port=9222',
'--remote-debugging-address=0.0.0.0',
'--disable-web-security',
'--remote-allow-origins=*'
]
});
console.log('WebSocket endpoint:', browser.wsEndpoint());
import React, { useRef } from 'react';
import { BrowserCanvas, BrowserCanvasRef, Browser, Page } from '@agent-infra/browser-ui';
function App() {
const canvasRef = useRef<BrowserCanvasRef>(null);
const handleReady = ({ browser, page }: { browser: Browser; page: Page }) => {
console.log('Browser connected, current URL:', page.url());
// Listen for navigation events
page.on('framenavigated', (frame) => {
if (frame === page.mainFrame()) {
console.log('Navigated to:', frame.url());
}
});
};
const handleError = (error: Error) => {
console.error('Browser connection error:', error);
};
return (
<div style={{ width: '100%', height: '800px', position: 'relative' }}>
<BrowserCanvas
ref={canvasRef}
wsEndpoint="ws://127.0.0.1:9222/devtools/browser/YOUR_BROWSER_ID"
onReady={handleReady}
onError={handleError}
onSessionEnd={() => console.log('Session ended')}
/>
</div>
);
}
| Prop | Type | Required | Description |
|---|---|---|---|
wsEndpoint | string | No* | CDP WebSocket URL for browser connection |
cdpEndpoint | string | No* | CDP HTTP endpoint (higher priority than wsEndpoint) |
onReady | (ctx: {browser: Browser, page: Page}) => void | No | Callback when browser connection is established |
onError | (error: Error) => void | No | Error callback for connection/runtime errors |
onSessionEnd | () => void | No | Callback when browser session ends |
defaultViewport | Viewport | No | Initial viewport configuration |
style | React.CSSProperties | No | Custom CSS styles for the canvas |
*Either wsEndpoint or cdpEndpoint is required.
The ref object provides access to:
interface BrowserCanvasRef {
browser: Browser | null; // Puppeteer browser instance
page: Page | null; // Current page instance
client: any; // CDP client
endSession: () => void; // Manually end the session
}
const defaultViewport = {
width: 1280,
height: 720,
deviceScaleFactor: 1,
hasTouch: false,
isLandscape: true,
isMobile: false
};
Instead of providing the WebSocket URL directly, you can use the CDP HTTP endpoint:
<BrowserCanvas
cdpEndpoint="http://127.0.0.1:9222/json/version"
onReady={handleReady}
/>
The component will automatically fetch the WebSocket URL from the CDP endpoint.
Page.startScreencast to receive live screenshotsInput.dispatchMouseEvent and Input.dispatchKeyEventimport puppeteer from 'puppeteer-core';
async function startBrowser() {
const browser = await puppeteer.launch({
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', // macOS
// executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', // Windows
// executablePath: '/usr/bin/google-chrome', // Linux
headless: false,
args: [
'--remote-debugging-port=9222',
'--remote-debugging-address=0.0.0.0',
'--disable-web-security',
'--remote-allow-origins=*'
]
});
return browser.wsEndpoint();
}
# macOS/Linux
google-chrome --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --disable-web-security --remote-allow-origins=*
# Windows
chrome.exe --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --disable-web-security --remote-allow-origins=*
ISC
FAQs
简体中文 | English
The npm package @agent-infra/browser-ui receives a total of 12 weekly downloads. As such, @agent-infra/browser-ui popularity was classified as not popular.
We found that @agent-infra/browser-ui demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.