@melio-eng/web-sdk 1.0.23-pr.45.7e7fc86 → 1.0.23-pr.45.a9e1d28
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 +1 -0
- package/dist/index.js +19 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -293,6 +293,7 @@ export class MelioSDK {
|
|
|
293
293
|
this.partnerName = '';
|
|
294
294
|
this.branchOverride = undefined;
|
|
295
295
|
this.isInitialized = false;
|
|
296
|
+
this.currentInitFlow = null;
|
|
296
297
|
}
|
|
297
298
|
/**
|
|
298
299
|
* Check if SDK is initialized and throw error if not
|
|
@@ -307,28 +308,42 @@ export class MelioSDK {
|
|
|
307
308
|
*/
|
|
308
309
|
init(authenticationCode, options) {
|
|
309
310
|
try {
|
|
311
|
+
if (this.currentInitFlow) {
|
|
312
|
+
this.currentInitFlow.close();
|
|
313
|
+
this.currentInitFlow = null;
|
|
314
|
+
}
|
|
310
315
|
this.partnerName = options.partnerName;
|
|
311
316
|
this.environment = options.environment || 'production';
|
|
312
317
|
this.branchOverride = options.branchOverride;
|
|
318
|
+
this.isInitialized = false;
|
|
313
319
|
console.log('starting init flow', {
|
|
314
320
|
partnerName: this.partnerName,
|
|
315
321
|
environment: this.environment,
|
|
316
322
|
});
|
|
317
323
|
const initFlow = new InitFlow('', // no need container id for init flow as it is created inside the initialization
|
|
318
324
|
{ authCode: authenticationCode, containerId: '' }, this.partnerName, this.environment, this.branchOverride);
|
|
319
|
-
initFlow
|
|
320
|
-
|
|
321
|
-
|
|
325
|
+
this.currentInitFlow = initFlow;
|
|
326
|
+
initFlow.on('authenticationSucceeded', () => {
|
|
327
|
+
console.log('Authentication succeeded - SDK is now initialized');
|
|
328
|
+
if (this.currentInitFlow === initFlow) {
|
|
329
|
+
this.isInitialized = true;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
322
332
|
initFlow.on('authenticationFailed', () => {
|
|
323
333
|
console.log('Authentication failed - resetting SDK initialization state');
|
|
324
|
-
this.
|
|
334
|
+
if (this.currentInitFlow === initFlow) {
|
|
335
|
+
this.isInitialized = false;
|
|
336
|
+
this.currentInitFlow = null;
|
|
337
|
+
}
|
|
325
338
|
});
|
|
339
|
+
initFlow.initialize();
|
|
326
340
|
if (options.keepAlive)
|
|
327
341
|
initFlow.setupKeepAlive();
|
|
328
342
|
return initFlow;
|
|
329
343
|
}
|
|
330
344
|
catch (error) {
|
|
331
345
|
this.isInitialized = false;
|
|
346
|
+
this.currentInitFlow = null;
|
|
332
347
|
console.error('Failed to initialize SDK:', error);
|
|
333
348
|
throw error;
|
|
334
349
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@melio-eng/web-sdk",
|
|
3
|
-
"version": "1.0.23-pr.45.
|
|
3
|
+
"version": "1.0.23-pr.45.a9e1d28",
|
|
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",
|