BrowserSocket.org

Overview

BrowserSockets are a proposed way to allow web pages to listen for incoming WebSocket connections using Javascript.

To make use of BrowserSocket an application developer needs to write a connection handler, include it in a web page, and register the handler with the browser using the javascript API.

After registering a handler, the web page is able to receive connections on some TCP port for all WebSocket resources having some prefix. For security reasons the web page has no control over the selection of the prefix or the port, instead these are decided by the browser.

The BrowserSocket proposal has been implemented as a proof-of-concept Firefox extension.

Usage Example

Embedding a minimal echo service in a web page is done as follows.

  1. define a connection handler function EchoHandler() { this.onmessage = function(msg) { this.send(msg.data); } }
  2. define a connection handler factory function echoHandlerFactory() { return new EchoHandler(); }
  3. register the connection handler factory with the browser var bs = new BrowserSocket(echoHandlerFactory);
  4. get an address which clients can connect to var address = 'ws://127.0.0.1:' + bs.port + bs.resourcePrefix;

Useful information

How to spot and remove malicious Firefox extensions

Guide on identifying and mitigating malicious browser extensions, detailing their mechanisms and potential risks to user data security.

view