@melio-eng/web-sdk 1.0.17-pr.34.f5d0d62 → 1.0.17-pr.35.6d53e91
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 +2 -1
- package/dist/index.js +22 -15
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class MelioSDK implements MelioSDK {
|
|
|
13
13
|
* Initialize the SDK by creating an authentication flow
|
|
14
14
|
*/
|
|
15
15
|
init(authenticationCode: string, options: InitOptions): FlowInstance;
|
|
16
|
+
private setupKeepAlive;
|
|
16
17
|
/**
|
|
17
18
|
* Launch the onboarding flow
|
|
18
19
|
*/
|
|
@@ -34,4 +35,4 @@ export declare class MelioSDK implements MelioSDK {
|
|
|
34
35
|
* Export the SDK instance
|
|
35
36
|
*/
|
|
36
37
|
export declare const melioSDK: MelioSDK;
|
|
37
|
-
export * from
|
|
38
|
+
export * from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -230,12 +230,18 @@ class PaymentsDashboardFlow extends Flow {
|
|
|
230
230
|
return `${baseUrl}/${this.partnerName}/pay-dashboard/payments`;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
+
const isEmptyString = (str) => {
|
|
234
|
+
return !str?.trim();
|
|
235
|
+
};
|
|
233
236
|
/**
|
|
234
237
|
* InitFlow subclass for handling initialization with callbacks
|
|
235
238
|
*/
|
|
236
239
|
class InitFlow extends Flow {
|
|
237
240
|
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
238
241
|
super(containerId, config, partnerName, environment, branchOverride);
|
|
242
|
+
if (isEmptyString(config.authCode)) {
|
|
243
|
+
throw new Error('Authorization code is required for init flow');
|
|
244
|
+
}
|
|
239
245
|
this.authorizationCode = config.authCode;
|
|
240
246
|
}
|
|
241
247
|
/**
|
|
@@ -262,16 +268,6 @@ class InitFlow extends Flow {
|
|
|
262
268
|
});
|
|
263
269
|
return `${baseUrl}/${this.partnerName}/start?${params.toString()}`;
|
|
264
270
|
}
|
|
265
|
-
setupKeepAlive() {
|
|
266
|
-
this.keepAliveInterval = window.setInterval(() => {
|
|
267
|
-
if (this.iframe && this.iframe.contentWindow) {
|
|
268
|
-
console.log('Sending keep-alive ping!');
|
|
269
|
-
this.iframe.contentWindow.postMessage({
|
|
270
|
-
type: 'USER_ACTIVE_PING',
|
|
271
|
-
}, 'https://app.melio.com');
|
|
272
|
-
}
|
|
273
|
-
}, 30000); // Send ping every 30 seconds
|
|
274
|
-
}
|
|
275
271
|
}
|
|
276
272
|
/**
|
|
277
273
|
* Main SDK implementation - now partner agnostic
|
|
@@ -288,14 +284,25 @@ export class MelioSDK {
|
|
|
288
284
|
* Initialize the SDK by creating an authentication flow
|
|
289
285
|
*/
|
|
290
286
|
init(authenticationCode, options) {
|
|
287
|
+
// Set partner name and environment from options
|
|
291
288
|
this.partnerName = options.partnerName;
|
|
292
289
|
this.environment = options.environment || 'production';
|
|
293
290
|
this.branchOverride = options.branchOverride;
|
|
294
|
-
const
|
|
291
|
+
const flow = new InitFlow('', // no need container id for init flow as it is created inside the initialization
|
|
295
292
|
{ authCode: authenticationCode, containerId: '' }, this.partnerName, this.environment, this.branchOverride);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
return
|
|
293
|
+
flow.initialize();
|
|
294
|
+
this.setupKeepAlive();
|
|
295
|
+
return flow;
|
|
296
|
+
}
|
|
297
|
+
setupKeepAlive() {
|
|
298
|
+
// Send periodic pings to keep session alive
|
|
299
|
+
this.keepAliveInterval = window.setInterval(() => {
|
|
300
|
+
if (this.keepAliveIframe && this.keepAliveIframe.contentWindow) {
|
|
301
|
+
this.keepAliveIframe.contentWindow.postMessage({
|
|
302
|
+
type: 'USER_ACTIVE_PING',
|
|
303
|
+
}, 'https://app.melio.com');
|
|
304
|
+
}
|
|
305
|
+
}, 30000); // Send ping every 30 seconds
|
|
299
306
|
}
|
|
300
307
|
/**
|
|
301
308
|
* Launch the onboarding flow
|
|
@@ -335,4 +342,4 @@ export class MelioSDK {
|
|
|
335
342
|
*/
|
|
336
343
|
export const melioSDK = new MelioSDK();
|
|
337
344
|
// Export types for consumers
|
|
338
|
-
export * from
|
|
345
|
+
export * from './types.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@melio-eng/web-sdk",
|
|
3
|
-
"version": "1.0.17-pr.
|
|
3
|
+
"version": "1.0.17-pr.35.6d53e91",
|
|
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",
|