/cross-origin-storage

A same-origin storage for cross-domain access using Session Storage.

Primary LanguageTypeScriptMIT LicenseMIT

Cross-Origin Storage

A same-origin storage for cross-domain access using Session Storage.
GitHub package.json version Package Version NPM

Table of Contents

  • Instalation
  • Usage
  • API

Instalation

Simply install the package in two applications, one that is going to be considered the Host, containing all the data you want to transfer, and a second one known as the Guest which will receive the data.

npm install cross-origin-storage

Usage

Host

Use CrossOriginStorageHost from cross-origin-storage whenever you want to transfer data from Host to Guest:

import { CrossOriginStorageHost } from "cross-origin-storage";

const host = new CrossOriginStorageHost({
	excludes: [],
	whitelist: ["${GUEST_APPLICATION_URL}"],
	identifier: "${SAME_IDENTIFIER_HOST_GUEST}",
	iframeUrl: "${GUEST_APPLICATION_URL}",
	initCallback: () => {},
});

Guest

Use CrossOriginStorageGuest from cross-origin-storage whenever you want to retrieve data from Host:

import { CrossOriginStorageGuest } from "cross-origin-storage";

const guest = new CrossOriginStorageGuest({
	whitelist: ["${HOST_APPLICATION_URL}"],
	identifier: "${SAME_IDENTIFIER_HOST_GUEST}",
});

API

CrossOriginStorageHost

CrossOriginStorageGuest