@melio-eng/web-sdk 1.0.18 → 1.0.19-pr.34.95e1e5d

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/index.d.ts CHANGED
@@ -3,7 +3,6 @@ import { InitOptions, OnboardingConfig, SettingsConfig, FlowInstance, PaymentsDa
3
3
  * Main SDK implementation - now partner agnostic
4
4
  */
5
5
  export declare class MelioSDK implements MelioSDK {
6
- private keepAliveIframe;
7
6
  private keepAliveInterval;
8
7
  private environment;
9
8
  private partnerName;
@@ -13,7 +12,6 @@ export declare class MelioSDK implements MelioSDK {
13
12
  * Initialize the SDK by creating an authentication flow
14
13
  */
15
14
  init(authenticationCode: string, options: InitOptions): FlowInstance;
16
- private setupKeepAlive;
17
15
  /**
18
16
  * Launch the onboarding flow
19
17
  */
package/dist/index.js CHANGED
@@ -165,8 +165,9 @@ class Flow {
165
165
  class OnboardingFlow extends Flow {
166
166
  constructor(containerId, config, partnerName, environment, branchOverride) {
167
167
  super(containerId, config, partnerName, environment, branchOverride);
168
- const { userDetails, organizationDetails } = config;
168
+ const { userDetails, organizationDetails, enforceOnboarding } = config;
169
169
  this.preFilledParams = { userDetails, organizationDetails };
170
+ this.enforceOnboarding = enforceOnboarding;
170
171
  }
171
172
  /**
172
173
  * Construct the specific flow URL for onboarding
@@ -184,8 +185,15 @@ class OnboardingFlow extends Flow {
184
185
  }
185
186
  }
186
187
  let url = `${baseUrl}/${this.partnerName}/welcome`;
188
+ const queryParams = [];
187
189
  if (preFilledBase64) {
188
- url += `?preFilledParams=${encodeURIComponent(preFilledBase64)}`;
190
+ queryParams.push(`preFilledParams=${encodeURIComponent(preFilledBase64)}`);
191
+ }
192
+ if (this.enforceOnboarding !== undefined) {
193
+ queryParams.push(`enforceOnboarding=${this.enforceOnboarding}`);
194
+ }
195
+ if (queryParams.length > 0) {
196
+ url += `?${queryParams.join('&')}`;
189
197
  }
190
198
  return url;
191
199
  }
@@ -266,7 +274,15 @@ class InitFlow extends Flow {
266
274
  token: this.authorizationCode,
267
275
  theme: this.partnerName,
268
276
  });
269
- return `${baseUrl}/${this.partnerName}/start?${params.toString()}`;
277
+ return `${baseUrl}/${this.partnerName}/start?${params.toString()}&cdn_branch_override=refresh_token_on_user_ping`;
278
+ }
279
+ setupKeepAlive() {
280
+ this.keepAliveInterval = window.setInterval(() => {
281
+ if (this.iframe && this.iframe.contentWindow) {
282
+ console.log('Sending keep-alive ping!');
283
+ this.iframe.contentWindow.postMessage({ type: 'USER_ACTIVE_PING' }, '*');
284
+ }
285
+ }, 30000); // Send ping every 30 seconds
270
286
  }
271
287
  }
272
288
  /**
@@ -274,7 +290,6 @@ class InitFlow extends Flow {
274
290
  */
275
291
  export class MelioSDK {
276
292
  constructor() {
277
- this.keepAliveIframe = null;
278
293
  this.keepAliveInterval = null;
279
294
  this.environment = 'production';
280
295
  this.partnerName = '';
@@ -284,7 +299,6 @@ export class MelioSDK {
284
299
  * Initialize the SDK by creating an authentication flow
285
300
  */
286
301
  init(authenticationCode, options) {
287
- // Set partner name and environment from options
288
302
  this.partnerName = options.partnerName;
289
303
  this.environment = options.environment || 'production';
290
304
  this.branchOverride = options.branchOverride;
@@ -292,22 +306,13 @@ export class MelioSDK {
292
306
  partnerName: this.partnerName,
293
307
  environment: this.environment,
294
308
  });
295
- const flow = new InitFlow('', // no need container id for init flow as it is created inside the initialization
309
+ const initFlow = new InitFlow('', // no need container id for init flow as it is created inside the initialization
296
310
  { authCode: authenticationCode, containerId: '' }, this.partnerName, this.environment, this.branchOverride);
297
- flow.initialize();
311
+ initFlow.initialize();
298
312
  console.log('InitFlow initialized successfully');
299
- this.setupKeepAlive();
300
- return flow;
301
- }
302
- setupKeepAlive() {
303
- // Send periodic pings to keep session alive
304
- this.keepAliveInterval = window.setInterval(() => {
305
- if (this.keepAliveIframe && this.keepAliveIframe.contentWindow) {
306
- this.keepAliveIframe.contentWindow.postMessage({
307
- type: 'USER_ACTIVE_PING',
308
- }, 'https://app.melio.com');
309
- }
310
- }, 30000); // Send ping every 30 seconds
313
+ if (options.keepAlive)
314
+ initFlow.setupKeepAlive();
315
+ return initFlow;
311
316
  }
312
317
  /**
313
318
  * Launch the onboarding flow
package/dist/types.d.ts CHANGED
@@ -47,6 +47,7 @@ export interface UserDetails {
47
47
  export interface OnboardingConfig extends BaseFlowConfig {
48
48
  userDetails?: UserDetails;
49
49
  organizationDetails?: OrganizationDetails;
50
+ enforceOnboarding?: boolean;
50
51
  }
51
52
  /**
52
53
  * Configuration for pay flow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melio-eng/web-sdk",
3
- "version": "1.0.18",
3
+ "version": "1.0.19-pr.34.95e1e5d",
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",