@melio-eng/web-sdk 1.0.18 → 1.0.19-pr.34.273bb1a
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 +0 -2
- package/dist/index.js +23 -18
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
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
|
-
|
|
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
|
}
|
|
@@ -268,13 +276,20 @@ class InitFlow extends Flow {
|
|
|
268
276
|
});
|
|
269
277
|
return `${baseUrl}/${this.partnerName}/start?${params.toString()}`;
|
|
270
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
|
|
286
|
+
}
|
|
271
287
|
}
|
|
272
288
|
/**
|
|
273
289
|
* Main SDK implementation - now partner agnostic
|
|
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
|
|
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
|
-
|
|
311
|
+
initFlow.initialize();
|
|
298
312
|
console.log('InitFlow initialized successfully');
|
|
299
|
-
|
|
300
|
-
|
|
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
package/package.json
CHANGED