cross-origin-client
v1.0.11
Published
A client library for secure cross-origin communication using the postMessage API.
Downloads
22
Maintainers
Readme
Cross-Origin Client
Cross-Origin Client is a client library for secure cross-origin communication using the postMessage API. It simplifies cross-origin communication by providing a straightforward one-liner experience.
Installation
Install the library via npm:
npm install cross-origin-client
Usage
To use Cross-Origin Client in your project, import it and create an instance with trusted origin:
import { CrossOriginClient } from "cross-origin-client";
// Create an instance of Cross-Origin Client
const client = new CrossOriginClient({ trustedOrigin: "https://example.com" });
Sending Messages
You can send messages to trusted origin using the send
method:
const messageType = "messageTypeSupportedByTheReceivingSide";
const response = await client.send({ type: messageType });
console.log("Response received:", response);
License
This project is licensed under the MIT License.