@melio-eng/web-sdk 1.0.23-pr.45.dffe470 → 1.0.23
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 -6
- package/dist/index.js +15 -55
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,13 +7,7 @@ export declare class MelioSDK implements MelioSDK {
|
|
|
7
7
|
private environment;
|
|
8
8
|
private partnerName;
|
|
9
9
|
private branchOverride;
|
|
10
|
-
private isInitialized;
|
|
11
|
-
private currentInitFlow;
|
|
12
10
|
constructor();
|
|
13
|
-
/**
|
|
14
|
-
* Check if SDK is initialized and throw error if not
|
|
15
|
-
*/
|
|
16
|
-
private ensureInitialized;
|
|
17
11
|
/**
|
|
18
12
|
* Initialize the SDK by creating an authentication flow
|
|
19
13
|
*/
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
function getBaseUrl(environment) {
|
|
5
5
|
switch (environment) {
|
|
6
6
|
case 'production':
|
|
7
|
-
return 'https://partnerships.melioservices.com';
|
|
7
|
+
return 'https://partnerships.production.melioservices.com';
|
|
8
8
|
case 'staging01':
|
|
9
9
|
return 'https://partnerships.staging01.melioservices.com';
|
|
10
10
|
case 'public-qa':
|
|
@@ -292,67 +292,30 @@ export class MelioSDK {
|
|
|
292
292
|
this.environment = 'production';
|
|
293
293
|
this.partnerName = '';
|
|
294
294
|
this.branchOverride = undefined;
|
|
295
|
-
this.isInitialized = false;
|
|
296
|
-
this.currentInitFlow = null;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Check if SDK is initialized and throw error if not
|
|
300
|
-
*/
|
|
301
|
-
ensureInitialized() {
|
|
302
|
-
if (!this.isInitialized) {
|
|
303
|
-
throw new Error('SDK must be initialized with init() before calling any flow methods');
|
|
304
|
-
}
|
|
305
295
|
}
|
|
306
296
|
/**
|
|
307
297
|
* Initialize the SDK by creating an authentication flow
|
|
308
298
|
*/
|
|
309
299
|
init(authenticationCode, options) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
this.
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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;
|
|
343
|
-
}
|
|
344
|
-
catch (error) {
|
|
345
|
-
this.isInitialized = false;
|
|
346
|
-
this.currentInitFlow = null;
|
|
347
|
-
console.error('Failed to initialize SDK:', error);
|
|
348
|
-
throw error;
|
|
349
|
-
}
|
|
300
|
+
this.partnerName = options.partnerName;
|
|
301
|
+
this.environment = options.environment || 'production';
|
|
302
|
+
this.branchOverride = options.branchOverride;
|
|
303
|
+
console.log('starting init flow', {
|
|
304
|
+
partnerName: this.partnerName,
|
|
305
|
+
environment: this.environment,
|
|
306
|
+
});
|
|
307
|
+
const initFlow = new InitFlow('', // no need container id for init flow as it is created inside the initialization
|
|
308
|
+
{ authCode: authenticationCode, containerId: '' }, this.partnerName, this.environment, this.branchOverride);
|
|
309
|
+
initFlow.initialize();
|
|
310
|
+
console.log('InitFlow initialized successfully');
|
|
311
|
+
if (options.keepAlive)
|
|
312
|
+
initFlow.setupKeepAlive();
|
|
313
|
+
return initFlow;
|
|
350
314
|
}
|
|
351
315
|
/**
|
|
352
316
|
* Launch the onboarding flow
|
|
353
317
|
*/
|
|
354
318
|
openOnboarding(config) {
|
|
355
|
-
this.ensureInitialized();
|
|
356
319
|
const flow = new OnboardingFlow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
|
|
357
320
|
flow.initialize();
|
|
358
321
|
return flow;
|
|
@@ -361,7 +324,6 @@ export class MelioSDK {
|
|
|
361
324
|
* Launch the pay flow
|
|
362
325
|
*/
|
|
363
326
|
openPayFlow(config) {
|
|
364
|
-
this.ensureInitialized();
|
|
365
327
|
const flow = new PayFlow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
|
|
366
328
|
flow.initialize();
|
|
367
329
|
return flow;
|
|
@@ -370,7 +332,6 @@ export class MelioSDK {
|
|
|
370
332
|
* Launch the settings flow
|
|
371
333
|
*/
|
|
372
334
|
openSettings(config) {
|
|
373
|
-
this.ensureInitialized();
|
|
374
335
|
const flow = new SettingsFlow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
|
|
375
336
|
flow.initialize();
|
|
376
337
|
return flow;
|
|
@@ -379,7 +340,6 @@ export class MelioSDK {
|
|
|
379
340
|
* Launch the payments dashboard flow
|
|
380
341
|
*/
|
|
381
342
|
openPaymentsDashboard(config) {
|
|
382
|
-
this.ensureInitialized();
|
|
383
343
|
const flow = new PaymentsDashboardFlow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
|
|
384
344
|
flow.initialize();
|
|
385
345
|
return flow;
|
package/package.json
CHANGED