0.0.2 • Published 8 months ago

imedia-embed-test1 v0.0.2

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
8 months ago

GSU Embedded Shell

This package is intended for partners of GetSetUp to include into their build processes. It will inject GetSetUp embedded content into the partner's site using iframes.

Installing

npm i imedia-embed-test1

Quick Start Example

import * as GSU from 'imedia-embed-test1'

let pathnameArr = window.location.pathname.split("/");

// This function is supplied by the hosting page.
// They should preform any checking and sanitation they wish to here.
const navigationCallBack = (navigationAction, sessionId, classSlug) => {
  let path = "/"+navigationAction;
  if (navigationAction === "class") {
    path = path + "/"+classSlug;
  }
  if (navigationAction === "discover" && classSlug) {
    path = path + "/"+classSlug;
  }
  window.location.pathname = path;
};

// Generate a JWE token using the key provided to you by GetSetUp.
const tokenRequestCallBack = () => {
  const token = callSomeBackEndProcessToGenerateToken();
  return "token";
};

GSU.createIframe({
  targetElementId: "app",
  targetPage: pathnameArr[1],
  navigationCallBack,
  tokenRequestCallBack,
  classTitle: pathnameArr[2],
});

Using The Package

The package exposes one function: GSU.createIframe(options). This function will create an iframe in the host page and create the event listeners needed for postMessage communication with the iframe.

Options

The GSU.createIframe function takes an options object as its single argument. The TypeScript interface for that options object is as follows:

export type TargetPage = "discover" | "class"
0.0.2

8 months ago

0.0.1

8 months ago