@melio-eng/web-sdk 1.0.31 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flows/Flow.d.ts +1 -0
- package/dist/flows/Flow.js +8 -2
- package/package.json +1 -1
package/dist/flows/Flow.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class Flow implements FlowInstance {
|
|
|
12
12
|
protected container: HTMLElement | null;
|
|
13
13
|
private eventListeners;
|
|
14
14
|
protected keepAliveInterval: number | null;
|
|
15
|
+
private messageHandler;
|
|
15
16
|
constructor(containerId: string, config: BaseFlowConfig, partnerName: string, environment: Environment, branchOverride?: string | undefined);
|
|
16
17
|
/**
|
|
17
18
|
* Initialize the flow by creating and injecting the iframe
|
package/dist/flows/Flow.js
CHANGED
|
@@ -13,6 +13,7 @@ export class Flow {
|
|
|
13
13
|
this.container = null;
|
|
14
14
|
this.eventListeners = new Map();
|
|
15
15
|
this.keepAliveInterval = null;
|
|
16
|
+
this.messageHandler = null;
|
|
16
17
|
this.setupEventListeners();
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
@@ -59,7 +60,7 @@ export class Flow {
|
|
|
59
60
|
setupEventListeners() {
|
|
60
61
|
// Add post message handlers for internal events - setHeight, scroll etc
|
|
61
62
|
// Also need to implement callbacks for flow completed exit etc in the platform-app
|
|
62
|
-
|
|
63
|
+
this.messageHandler = (event) => {
|
|
63
64
|
if (!/melio\.com|melioservices\.com/.test(event.origin)) {
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
@@ -102,7 +103,8 @@ export class Flow {
|
|
|
102
103
|
}
|
|
103
104
|
break;
|
|
104
105
|
}
|
|
105
|
-
}
|
|
106
|
+
};
|
|
107
|
+
window.addEventListener('message', this.messageHandler);
|
|
106
108
|
}
|
|
107
109
|
emit(event, data) {
|
|
108
110
|
const listeners = this.eventListeners.get(event);
|
|
@@ -145,6 +147,10 @@ export class Flow {
|
|
|
145
147
|
this.container.removeChild(this.iframe);
|
|
146
148
|
this.iframe = null;
|
|
147
149
|
}
|
|
150
|
+
if (this.messageHandler) {
|
|
151
|
+
window.removeEventListener('message', this.messageHandler);
|
|
152
|
+
this.messageHandler = null;
|
|
153
|
+
}
|
|
148
154
|
this.eventListeners.clear();
|
|
149
155
|
}
|
|
150
156
|
}
|
package/package.json
CHANGED