Skip to content

bengreenier/browserd

Repository files navigation

browserd

Project Logo

Headless electron app platform for the cloud 🤕☁✨

Quality Gate Status

We needed a way to run chrome-based browser experiences inside a container, and to stream that container to remote clients using webrtc. Browserd (named to indicate it's a browser daemon) uses electron to do so.

This app is broken down into two main components the stream-provider which contains and provides the 'browser experiences' and the stream-consumer an example of a 'remote client'. These components are supported by the shared component which houses shared functionality.

Components

Stream-Consumer

This simple web app connects to the stream-provider through a signaling server. It receives and displays a stream from the cloud, and it can send input to the cloud.

Build Status

Stream-Provider

This electron app connects to the stream-consumer through a signaling server. It receives input from the consumer, and streams its view to the consumer.

Build Status

Deploy to Azure

Using Lerna

We use Lerna to help manage our monorepo. It links our local dependencies and it reduces redundant packages and ensures consistent versioning. To run anything locally, you will need to npm install Lerna globally. With Lerna, we can automatically install all node_modules for all components, cross link them, and move shared dependencies up to the root.

npm install -g lerna

Signaling server

Our service is compatible with any standard WebRTC signaling implementation. If you need a simple one that communicates over HTTP/1.1, webrtc-signal-http is a good option.

Configuration

Our service can be configured using a dotenv file - .env containing one environment variable key and value per line. For example KEY=value. Below are the possible options:

  • SERVICE_URL (string) - the web service address (to render)
  • TURN_URL (string) - a turn address
  • TURN_USERNAME (string) - a turn username
  • TURN_PASSWORD (string) - a turn password credential
  • POLL_URL (string) - a signaling server base address
  • POLL_INTERVAL (number) - a signaling poll interval in ms
  • HEIGHT (number) - the window height
  • WIDTH (number) - the window width
  • EXP_HIDE_STREAMER (boolean) - experiment flag for hiding the streamer window
  • TWILIO_ACCOUNT_SID (string) - a Twilio AccountSid required to get a Network Traversal Service Token
  • TWILIO_AUTH_TOKEN (string) - a Twilio AuthToken required to get a Network Traversal Service Token

Turn server

Our service supports both coturn and Twilio's STUN/TURN service. In the dotenv file, if TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN values are set, our service will attempt to get a turn server from Twilio. Otherwise, you can leave them empty to use a stun server or coturn turn server.

Electron security

Our service follows electron security guideline and enables the following behaviors:

  • Enabling contextIsolation, which allows scripts running in the renderer to make changes to its javascript environment without worrying about conflicting with the scripts in the electron API or the preload script.
  • Blocking mouse middle-clicking, which opens a new window and makes our remote input stop working.
  • Disabling popup dialog for file downloading (when clicking on a link) so that it doesn't interfere with the streamer window.
  • Displaying warning about using insecure http protocol or when the streamer window navigates to a new origin, which is different from the SERVICE_URL.

Running

Note: Please refer the README of any component subdirectory for more detailed instructions.

Ensure you've installed dependencies (npm i) before continuing.

Follow these steps to get browserd up and running:

Note: npm run magic will complete all these steps for you.

Contributing

Coming soon. ✨

License

MIT