From fa0f22df0d23b5b706306c8970f0e76b1c8efb39 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Mon, 19 Sep 2022 10:30:15 -0700 Subject: [PATCH 1/9] initial europa commit From bbc070436c4f68f51b8fe79cccf1d655b346df84 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Mon, 26 Sep 2022 09:24:00 -0700 Subject: [PATCH 2/9] temp: add console log to messenger.send --- src/client/modules/app/services/route.ts | 5 +++++ src/client/modules/lib/messenger.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/client/modules/app/services/route.ts b/src/client/modules/app/services/route.ts index 4b5f7ae94..06aa97303 100644 --- a/src/client/modules/app/services/route.ts +++ b/src/client/modules/app/services/route.ts @@ -71,6 +71,11 @@ export class RouteService extends Service { this.currentRouteHandler = null; this.receivers = []; this.eventListeners = []; + this.runtime.receive('app', 'route-component', (routed) => { + if(window.parent){ + window.parent.postMessage(routed,'https://ci-europa.kbase.us') + } + }); } doRoute() { diff --git a/src/client/modules/lib/messenger.ts b/src/client/modules/lib/messenger.ts index b6b4c1c44..adfe5903f 100644 --- a/src/client/modules/lib/messenger.ts +++ b/src/client/modules/lib/messenger.ts @@ -131,6 +131,9 @@ export class Messenger { const channelName = publishDef.channel; const message = publishDef.message; + const console_workaround = console; + console_workaround.log("Messenger.send",publishDef) + const channel = this.channels.get(channelName); if (!channel) { return; From 0bce81ce08bf032684114a7a2cf3ac88e02b44fc Mon Sep 17 00:00:00 2001 From: David Lyon Date: Wed, 28 Sep 2022 10:02:32 -0700 Subject: [PATCH 3/9] add europa messaging listener/postMessage --- src/client/modules/app/services/europa.ts | 20 ++++++++++++++++++++ src/client/modules/app/services/route.ts | 7 ++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 src/client/modules/app/services/europa.ts diff --git a/src/client/modules/app/services/europa.ts b/src/client/modules/app/services/europa.ts new file mode 100644 index 000000000..8147184a2 --- /dev/null +++ b/src/client/modules/app/services/europa.ts @@ -0,0 +1,20 @@ +import { Runtime } from '../../lib/types'; + +export const initEuropaRoutes = (runtime: Runtime) => { + runtime.receive('app', 'route-component', (payload) => { + if (window.parent) { + window.parent.postMessage( + { source: 'kbase-ui.app.route-component', payload }, + 'https://ci-europa.kbase.us' + ); + } + }); + runtime.receive('ui', 'setTitle', (payload) => { + if (window.parent) { + window.parent.postMessage( + { source: 'kbase-ui.ui.setTitle', payload }, + 'https://ci-europa.kbase.us' + ); + } + }); +}; diff --git a/src/client/modules/app/services/route.ts b/src/client/modules/app/services/route.ts index 06aa97303..4c691c8e7 100644 --- a/src/client/modules/app/services/route.ts +++ b/src/client/modules/app/services/route.ts @@ -11,6 +11,7 @@ import { RoutingLocation, } from "./router"; import { Receiver, Runtime, Service, SimpleMap } from "../../lib/types"; +import { initEuropaRoutes } from "./europa"; type RouteHandler = RoutedRequest; @@ -71,11 +72,7 @@ export class RouteService extends Service { this.currentRouteHandler = null; this.receivers = []; this.eventListeners = []; - this.runtime.receive('app', 'route-component', (routed) => { - if(window.parent){ - window.parent.postMessage(routed,'https://ci-europa.kbase.us') - } - }); + initEuropaRoutes(this.runtime); } doRoute() { From ab38028dd5ad9872978e9e9995ee73aa7e621ce5 Mon Sep 17 00:00:00 2001 From: Dakota Blair Date: Tue, 27 Sep 2022 16:49:43 -0400 Subject: [PATCH 4/9] Hide kbase-ui chrome. --- .../modules/reactComponents/MainWindow/style.css | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/client/modules/reactComponents/MainWindow/style.css b/src/client/modules/reactComponents/MainWindow/style.css index b6b9cf6af..1a1aa7eb9 100644 --- a/src/client/modules/reactComponents/MainWindow/style.css +++ b/src/client/modules/reactComponents/MainWindow/style.css @@ -28,6 +28,10 @@ flex: 0 0 75px; } +.MainWindow .-header, .MainWindow .-nav { + display: none; +} + .MainWindow .-body > .-content { flex: 1 1 0px; display: flex; @@ -136,7 +140,7 @@ /* Navbar */ -/* +/* * Main Navigation Bar */ @@ -245,8 +249,8 @@ /* Body */ -/* Tweak navbar, sidebar and main content areas to fit together -The navbar and sidebar are fixed -- so out of flow and need absolute positioning +/* Tweak navbar, sidebar and main content areas to fit together +The navbar and sidebar are fixed -- so out of flow and need absolute positioning Although the sidebar is partially positioned with part of the navbar. The content area is normal flow and just needs to have a matching top margin. */ From 73e6becbec6235f359945db43390e423c8bcd76b Mon Sep 17 00:00:00 2001 From: David Lyon Date: Thu, 29 Sep 2022 11:39:14 -0700 Subject: [PATCH 5/9] add (hacky) listener for europa navigate events --- src/client/modules/app/services/europa.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/client/modules/app/services/europa.ts b/src/client/modules/app/services/europa.ts index 8147184a2..485d2b2d4 100644 --- a/src/client/modules/app/services/europa.ts +++ b/src/client/modules/app/services/europa.ts @@ -1,11 +1,14 @@ import { Runtime } from '../../lib/types'; +// TODO: DO NOT MERGE WITHOUT SAFER TARGET ORIGIN +const europaTargetOrigin = '*'; // 'https://ci-europa.kbase.us' + export const initEuropaRoutes = (runtime: Runtime) => { runtime.receive('app', 'route-component', (payload) => { if (window.parent) { window.parent.postMessage( { source: 'kbase-ui.app.route-component', payload }, - 'https://ci-europa.kbase.us' + europaTargetOrigin ); } }); @@ -13,8 +16,17 @@ export const initEuropaRoutes = (runtime: Runtime) => { if (window.parent) { window.parent.postMessage( { source: 'kbase-ui.ui.setTitle', payload }, - 'https://ci-europa.kbase.us' + europaTargetOrigin ); } }); + window.addEventListener('message', (message) => { + if (message.source !== window.parent) return; + if ( + message?.data?.source && + message?.data?.source == 'europa.navigate' + ) { + runtime.send('app', 'navigate', message.data.payload); + } + }); }; From c027ec5cbc753c6ce79e96e18ec3c069859eb255 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Thu, 6 Oct 2022 10:55:35 -0700 Subject: [PATCH 6/9] set target to _top on AutoPostForm, rename europa init func --- src/client/modules/app/services/europa.ts | 2 +- src/client/modules/app/services/route.ts | 4 ++-- src/client/modules/pluginSupport/AutoPostForm.js | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/modules/app/services/europa.ts b/src/client/modules/app/services/europa.ts index 485d2b2d4..bec58c333 100644 --- a/src/client/modules/app/services/europa.ts +++ b/src/client/modules/app/services/europa.ts @@ -3,7 +3,7 @@ import { Runtime } from '../../lib/types'; // TODO: DO NOT MERGE WITHOUT SAFER TARGET ORIGIN const europaTargetOrigin = '*'; // 'https://ci-europa.kbase.us' -export const initEuropaRoutes = (runtime: Runtime) => { +export const initEuropa = (runtime: Runtime) => { runtime.receive('app', 'route-component', (payload) => { if (window.parent) { window.parent.postMessage( diff --git a/src/client/modules/app/services/route.ts b/src/client/modules/app/services/route.ts index 4c691c8e7..ab6bc83ce 100644 --- a/src/client/modules/app/services/route.ts +++ b/src/client/modules/app/services/route.ts @@ -11,7 +11,7 @@ import { RoutingLocation, } from "./router"; import { Receiver, Runtime, Service, SimpleMap } from "../../lib/types"; -import { initEuropaRoutes } from "./europa"; +import { initEuropa } from "./europa"; type RouteHandler = RoutedRequest; @@ -72,7 +72,7 @@ export class RouteService extends Service { this.currentRouteHandler = null; this.receivers = []; this.eventListeners = []; - initEuropaRoutes(this.runtime); + initEuropa(this.runtime); } doRoute() { diff --git a/src/client/modules/pluginSupport/AutoPostForm.js b/src/client/modules/pluginSupport/AutoPostForm.js index 694c3dada..316522f47 100644 --- a/src/client/modules/pluginSupport/AutoPostForm.js +++ b/src/client/modules/pluginSupport/AutoPostForm.js @@ -41,6 +41,7 @@ define([ return html`
Date: Thu, 6 Oct 2022 11:06:57 -0700 Subject: [PATCH 7/9] TEMP: add hardcoded domain to session cookie setter --- src/client/modules/lib/kb_lib/Auth2Session.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/modules/lib/kb_lib/Auth2Session.ts b/src/client/modules/lib/kb_lib/Auth2Session.ts index c0e1a2f25..b7899d3ac 100644 --- a/src/client/modules/lib/kb_lib/Auth2Session.ts +++ b/src/client/modules/lib/kb_lib/Auth2Session.ts @@ -649,6 +649,7 @@ export class Auth2Session { setSessionCookie(token: string, expiration: number) { const sessionCookie = new Cookie(this.cookieName, token) .setPath('/') + .setDomain('ci-europa.kbase.us') .setSecure(true); sessionCookie.setExpires(new Date(expiration).toUTCString()); From 8a2957e18cd130df37c0624ebe2f734e2f82edd8 Mon Sep 17 00:00:00 2001 From: David Lyon Date: Thu, 6 Oct 2022 12:43:52 -0700 Subject: [PATCH 8/9] add europa login message, undo previous TEMP commit --- src/client/modules/app/services/europa.ts | 13 +++++++++++++ src/client/modules/lib/kb_lib/Auth2Session.ts | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/client/modules/app/services/europa.ts b/src/client/modules/app/services/europa.ts index bec58c333..c9ce7dee4 100644 --- a/src/client/modules/app/services/europa.ts +++ b/src/client/modules/app/services/europa.ts @@ -20,6 +20,19 @@ export const initEuropa = (runtime: Runtime) => { ); } }); + runtime.receive('session', 'loggedin', () => { + if (window.parent) { + window.parent.postMessage( + { + source: 'kbase-ui.session.loggedin', + payload: { + token: runtime.service('session').getAuthToken(), + }, + }, + europaTargetOrigin + ); + } + }); window.addEventListener('message', (message) => { if (message.source !== window.parent) return; if ( diff --git a/src/client/modules/lib/kb_lib/Auth2Session.ts b/src/client/modules/lib/kb_lib/Auth2Session.ts index b7899d3ac..c0e1a2f25 100644 --- a/src/client/modules/lib/kb_lib/Auth2Session.ts +++ b/src/client/modules/lib/kb_lib/Auth2Session.ts @@ -649,7 +649,6 @@ export class Auth2Session { setSessionCookie(token: string, expiration: number) { const sessionCookie = new Cookie(this.cookieName, token) .setPath('/') - .setDomain('ci-europa.kbase.us') .setSecure(true); sessionCookie.setExpires(new Date(expiration).toUTCString()); From 47d1c288007bda5022a72fff8dab4eac1e78b752 Mon Sep 17 00:00:00 2001 From: David Lyon <5115845+dauglyon@users.noreply.github.com> Date: Wed, 8 Mar 2023 11:06:03 -0800 Subject: [PATCH 9/9] Update Auth2Session.ts --- src/client/modules/lib/kb_lib/Auth2Session.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/client/modules/lib/kb_lib/Auth2Session.ts b/src/client/modules/lib/kb_lib/Auth2Session.ts index c0e1a2f25..f9d613a54 100644 --- a/src/client/modules/lib/kb_lib/Auth2Session.ts +++ b/src/client/modules/lib/kb_lib/Auth2Session.ts @@ -674,19 +674,6 @@ export class Auth2Session { new Cookie(this.cookieName, '').setPath('/') ); - // Also remove the domain level cookie in case it was in advertently - // created. This can be a cause for a corrupt token, since the old auth - // system tokens are invalid, and it could create domain level cookies. - // New auth code does not (other than the backup cookie.) - const domainParts = window.location.hostname.split('.'); - let domain; - for (let len = 2; len <= domainParts.length; len += 1) { - domain = domainParts.slice(-len).join('.'); - this.cookieManager.removeItem( - new Cookie(this.cookieName, '').setPath('/').setDomain(domain) - ); - } - if (this.extraCookies) { this.extraCookies.forEach((cookieConfig) => { this.cookieManager.removeItem(