Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@randlabs/communication-bridge

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@randlabs/communication-bridge

* [Overview](#Overview) * [Installation](#Installation) * [API Usage](#API-Usage) * [Copyright and License](#Copyright-and-License)

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
37K
decreased by-10.7%
Maintainers
3
Weekly downloads
 
Created
Source

Communication-bridge

  • Overview
  • Installation
  • API Usage
  • Copyright and License

Overview

A cross-domain communication library develop by Rand Labs that enables send and receive messages between browser windows/tabs.

Instalation

The library can be installed via npm:

npm i @randlabs/communication-bridge

API Usage

Import and define the communication channel

const Messenger = require("@randlabs/communication-bridge");
const channelName = "channel name";
Tab #1
const client = new Messenger(channelName); // If listener is undefined, it will ignore all incoming request

const window = window.open("https://another.website.com");

const response = await client.sendMessage(window, { customMethod: "doSomething" }, { waitForReply: true, origin: "*" }); // If you are sending sensitive data, put a specific origin, for example: https://another.website.com

console.log(response); // { response: "OK" }

Tab #2
const hub = new Messenger(channelName, function(data, origin, source, sendResponse) {
    console.log(data); // { customMethod: "doSomething" }
    sendResponse({ response: "OK" });
});

See LICENSE file.

FAQs

Package last updated on 05 Sep 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc