Skip to content

Chrome Messages

Fingermark Chrome Messages protocol

Overview

Chrome messages is an abstraction over Chrome's port messaging system. This abstraction provides a standard format for describing and sending messages from the web UI to the chrome application.

Usage

While this library is mainly inteded to be used in conjunction with @fingermarkglobal/protocols, it can be used standalone.

js
import { sender, receiver } from '@fingermarkglobal/chrome-messages';

const handler = message => console.log(message);

receiver({ handler }); // this is meant to be setup on the chrome app and requires `chrome` connection to be on the window

const send = sender({ port });

const payload = {
  buffer: 12345,
};

const response = await send({ type: 'tcp', method: 'write', payload });