Socket
Book a DemoInstallSign in
Socket

@onirix/embed-sdk

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onirix/embed-sdk

Onirix helper library for iframe event communication.

npmnpm
Version
1.6.0
Version published
Weekly downloads
97
3.19%
Maintainers
1
Weekly downloads
 
Created
Source

Onirix Embed SDK

This library acts as a wrapper of window.postMessage for simplifying communication with Onirix iframes.

Full documentation available at Onirix Docs.

Usage

Using a bundler (Webpack, Rollup):

  • Install the dependency:
npm install @onirix/embed-sdk
  • Import and use it within your code:
const iframeElement = document.getElementById("<iframe_element_id>");
const embedSDK = new OnirixEmbedSDK(iframeElement);

embedSDK.connect().then(() => {

    // Ready to subscribe to events and/or execute actions

});

Using plain HTML

  • Include the dependency within the HTML head tag:
<head>
...
    <script src="https://unpkg.com/@onirix/embed-sdk@latest/dist/ox-embed-sdk.umd.js">
...
</head>
  • Use it from any other script:
<script>

    const iframeElement = document.getElementById("<iframe_element_id>");
    const embedSDK = new OnirixEmbedSDK(iframeElement);

    embedSDK.connect().then(() => {

        // Ready to subscribe to events and/or execute actions

    });

</script>
  • As ESM modules:
import OnirixEmbedSDK from "https://unpkg.com/@onirix/embed-sdk@latest/dist/ox-embed-sdk.umd.js";
const embedSDK = new OnirixEmbedSDK();
await embedSDK.connect();

embedSDK.subscribe(OnirixEmbedSDK.Events.ELEMENT_CLICK, (params) => {
    console.log('somebodey clicks me!', params);
});

FAQs

Package last updated on 09 Oct 2023

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