1.0.2 • Published 1 year ago

@developerportalsg/console-radar v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

console-radar

For dev console app, there will be multiple tenant apps that exists in iframe.

console-radar is a node package to catch route changes in the tenant app and communicate said change to the parent dev console app.

Installation

npm i @developerportalsg/console-radar --save

Getting Started

import { ConsoleRadar } from "@developerportalsg/console-radar";

const radar = new ConsoleRadar(config.parentEndpoint) // defaults to localhost:3003

// setSessionMngCallback accepts a callback function with isAuthenticated andd csrfToken as the input
// This function will get triggered when csrf message is sent from dev console
let clientSideCsrf = ''
radar.setSessionMngCallback(function({isAuthenticated, csrfToken}){
    if(isAuthenticated){
       clientSideCsrf = csrfToken
    }
})

// notifyExpiredSession will tell parent that current session is expired and to restart the login flow
const notifySessionExpiry = (e) => {
    e.preventDefault()
    radar.notifyExpiredSession()
}