@melio-eng/web-sdk 1.0.23-pr.45.99d35aa → 1.0.23-pr.45.dffe470

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.
Files changed (2) hide show
  1. package/dist/index.js +36 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -307,39 +307,46 @@ export class MelioSDK {
307
307
  * Initialize the SDK by creating an authentication flow
308
308
  */
309
309
  init(authenticationCode, options) {
310
- if (this.currentInitFlow) {
311
- console.warn('SDK initialization already in progress. Cleaning up previous initialization...');
312
- this.currentInitFlow.close();
313
- this.currentInitFlow = null;
314
- this.isInitialized = false;
315
- }
316
- else if (this.isInitialized) {
317
- console.warn('SDK already initialized. Reinitializing with new configuration...');
310
+ try {
311
+ if (this.currentInitFlow) {
312
+ this.currentInitFlow.close();
313
+ this.currentInitFlow = null;
314
+ }
315
+ this.partnerName = options.partnerName;
316
+ this.environment = options.environment || 'production';
317
+ this.branchOverride = options.branchOverride;
318
318
  this.isInitialized = false;
319
+ console.log('starting init flow', {
320
+ partnerName: this.partnerName,
321
+ environment: this.environment,
322
+ });
323
+ const initFlow = new InitFlow('', // no need container id for init flow as it is created inside the initialization
324
+ { authCode: authenticationCode, containerId: '' }, this.partnerName, this.environment, this.branchOverride);
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
+ });
332
+ initFlow.on('authenticationFailed', () => {
333
+ console.log('Authentication failed - resetting SDK initialization state');
334
+ if (this.currentInitFlow === initFlow) {
335
+ this.isInitialized = false;
336
+ this.currentInitFlow = null;
337
+ }
338
+ });
339
+ initFlow.initialize();
340
+ if (options.keepAlive)
341
+ initFlow.setupKeepAlive();
342
+ return initFlow;
319
343
  }
320
- this.partnerName = options.partnerName;
321
- this.environment = options.environment || 'production';
322
- this.branchOverride = options.branchOverride;
323
- console.log('starting init flow', {
324
- partnerName: this.partnerName,
325
- environment: this.environment,
326
- });
327
- const initFlow = new InitFlow('', // no need container id for init flow as it is created inside the initialization
328
- { authCode: authenticationCode, containerId: '' }, this.partnerName, this.environment, this.branchOverride);
329
- this.currentInitFlow = initFlow;
330
- initFlow.on('authenticationSucceeded', () => {
331
- console.log('Authentication succeeded - SDK is now initialized');
332
- this.isInitialized = true;
333
- });
334
- initFlow.on('authenticationFailed', () => {
335
- console.log('Authentication failed - resetting SDK initialization state');
344
+ catch (error) {
336
345
  this.isInitialized = false;
337
346
  this.currentInitFlow = null;
338
- });
339
- initFlow.initialize();
340
- if (options.keepAlive)
341
- initFlow.setupKeepAlive();
342
- return initFlow;
347
+ console.error('Failed to initialize SDK:', error);
348
+ throw error;
349
+ }
343
350
  }
344
351
  /**
345
352
  * Launch the onboarding flow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melio-eng/web-sdk",
3
- "version": "1.0.23-pr.45.99d35aa",
3
+ "version": "1.0.23-pr.45.dffe470",
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",