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

window-post-message-proxy

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

window-post-message-proxy

A library used in place of the native window.postMessage which when used on both the sending and receiving windows allow for a nicer asynchronouse promise messaging between the windows

  • 0.2.9
  • beta
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
190K
increased by2.94%
Maintainers
1
Weekly downloads
 
Created

What is window-post-message-proxy?

The window-post-message-proxy npm package is designed to facilitate communication between different windows or iframes in a web application using the postMessage API. It provides a simple and consistent interface for sending and receiving messages, handling message events, and managing message listeners.

What are window-post-message-proxy's main functionalities?

Sending Messages

This feature allows you to send messages from one window to another. The `postMessage` method takes the target window, the message object, and the target origin as parameters.

const proxy = new WindowPostMessageProxy();
proxy.postMessage(window, { type: 'greeting', text: 'Hello, world!' }, '*');

Receiving Messages

This feature allows you to set up handlers to receive and process messages. The `addHandler` method takes an object with `test` and `handle` functions. The `test` function determines if the handler should process the message, and the `handle` function processes the message.

const proxy = new WindowPostMessageProxy();
proxy.addHandler({
  test: message => message.type === 'greeting',
  handle: message => console.log('Received message:', message)
});

Removing Handlers

This feature allows you to remove previously added message handlers. The `removeHandler` method takes the handler object that was added using `addHandler`.

const proxy = new WindowPostMessageProxy();
const handler = {
  test: message => message.type === 'greeting',
  handle: message => console.log('Received message:', message)
};
proxy.addHandler(handler);
proxy.removeHandler(handler);

Other packages similar to window-post-message-proxy

Keywords

FAQs

Package last updated on 08 Jul 2024

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