Skip to content

Commit

Permalink
Merge branch 'main' into 3972-checkmarx-one-client-dom-xss
Browse files Browse the repository at this point in the history
  • Loading branch information
walmazacn authored Oct 9, 2024
2 parents b5ba6e1 + 93413ce commit 52fc1ed
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 84 deletions.
11 changes: 8 additions & 3 deletions container/src/services/container.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class ContainerService {
*/
sendCustomMessageToIframe(iframeHandle: any, msg: any, msgName?: string) {
const messageName = msgName || 'custom';

if (iframeHandle.iframe.contentWindow) {
const iframeUrl = new URL(iframeHandle.iframe.src);
messageName === 'custom'
Expand All @@ -42,22 +43,25 @@ export class ContainerService {
*/
dispatch(msg: string, targetCnt: HTMLElement, data: any, callback?: Function, callbackName?: string): void {
const customEvent = new CustomEvent(msg, { detail: data });

if (callback && GenericHelperFunctions.isFunction(callback) && callbackName) {
(customEvent as any)[callbackName] = data => {
callback(data);
};
}

targetCnt.dispatchEvent(customEvent);
}

/**
* Retrieves the target container based on the event source.
*
*
* @param event The event object representing the source of the container.
@returns {Object| undefined} The target container object or undefined if not found.
* @returns {Object| undefined} The target container object or undefined if not found.
*/
getTargetContainer(event) {
let cnt;

globalThis.__luigi_container_manager.container.forEach(element => {
if (element.iframeHandle?.iframe && element.iframeHandle.iframe.contentWindow === event.source) {
cnt = element;
Expand Down Expand Up @@ -113,7 +117,7 @@ export class ContainerService {
},
authData: targetCnt.authData || {}
},
'*'
target.origin
);
break;
case LuigiInternalMessageID.NAVIGATION_REQUEST:
Expand Down Expand Up @@ -185,6 +189,7 @@ export class ContainerService {
};
window.addEventListener('message', globalThis.__luigi_container_manager.messageListener);
}

return globalThis.__luigi_container_manager;
}

Expand Down
Loading

0 comments on commit 52fc1ed

Please sign in to comment.