@melio-eng/web-sdk 1.0.32 → 1.0.33-pr.61.c0daefe

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.
@@ -12,7 +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
+ protected messageHandler: ((event: MessageEvent) => void) | null;
16
16
  constructor(containerId: string, config: BaseFlowConfig, partnerName: string, environment: Environment, branchOverride?: string | undefined);
17
17
  /**
18
18
  * Initialize the flow by creating and injecting the iframe
@@ -26,7 +26,7 @@ export declare class Flow implements FlowInstance {
26
26
  * Create flow URL using partner name and environment
27
27
  */
28
28
  protected createFlowUrl(): string;
29
- private setupEventListeners;
29
+ protected setupEventListeners(): void;
30
30
  /**
31
31
  * Emit events to registered listeners
32
32
  */
@@ -80,12 +80,6 @@ export class Flow {
80
80
  case 'NAVIGATED_TO_TARGET':
81
81
  this.emit('navigated', data);
82
82
  break;
83
- case 'AUTHENTICATION_SUCCESS':
84
- this.emit('authenticationSucceeded');
85
- break;
86
- case 'AUTHENTICATION_ERROR':
87
- this.emit('authenticationFailed');
88
- break;
89
83
  case 'ONBOARDING_COMPLETED':
90
84
  this.emit('completed', { flowName: 'onboarding', ...data });
91
85
  break;
@@ -14,5 +14,9 @@ export declare class InitFlow extends Flow {
14
14
  * Construct the specific flow URL for initialization
15
15
  */
16
16
  protected constructFlowUrl(baseUrl: string): string;
17
+ /**
18
+ * Override setupEventListeners to only handle authentication events
19
+ */
20
+ protected setupEventListeners(): void;
17
21
  setupKeepAlive(): void;
18
22
  }
@@ -35,6 +35,36 @@ export class InitFlow extends Flow {
35
35
  });
36
36
  return `${baseUrl}/${this.partnerName}/auth?${params.toString()}`;
37
37
  }
38
+ /**
39
+ * Override setupEventListeners to only handle authentication events
40
+ */
41
+ setupEventListeners() {
42
+ this.messageHandler = (event) => {
43
+ if (!/melio\.com|melioservices\.com/.test(event.origin)) {
44
+ return;
45
+ }
46
+ const { type, ...data } = event.data;
47
+ console.log('📬 Received message from iframe:', {
48
+ type,
49
+ data,
50
+ origin: event.origin,
51
+ });
52
+ switch (type) {
53
+ case 'AUTHENTICATION_SUCCESS':
54
+ this.emit('authenticationSucceeded');
55
+ break;
56
+ case 'AUTHENTICATION_ERROR':
57
+ this.emit('authenticationFailed');
58
+ break;
59
+ case 'HEIGHT_CHANGE':
60
+ if (this.iframe) {
61
+ this.iframe.style.height = `${data.height}px`;
62
+ }
63
+ break;
64
+ }
65
+ };
66
+ window.addEventListener('message', this.messageHandler);
67
+ }
38
68
  setupKeepAlive() {
39
69
  this.keepAliveInterval = window.setInterval(() => {
40
70
  if (this.iframe && this.iframe.contentWindow) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melio-eng/web-sdk",
3
- "version": "1.0.32",
3
+ "version": "1.0.33-pr.61.c0daefe",
4
4
  "description": "Melio Web SDK - Embed core Melio workflows directly into partner UI with minimal effort",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",