@melio-eng/web-sdk 1.0.8 → 1.0.9-pr.23.fb97633
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 +28 -17
- package/dist/types.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -11,6 +11,8 @@ function getBaseUrl(environment) {
|
|
|
11
11
|
return 'https://partnerships.public-qa.melioservices.com';
|
|
12
12
|
case 'certification':
|
|
13
13
|
return 'https://partnerships.certification.melioservices.com';
|
|
14
|
+
case 'eilat':
|
|
15
|
+
return 'https://partnerships.eilat.melioservices.com';
|
|
14
16
|
case 'localhost':
|
|
15
17
|
return 'http://localhost:3005';
|
|
16
18
|
default:
|
|
@@ -21,11 +23,12 @@ function getBaseUrl(environment) {
|
|
|
21
23
|
* Flow class implementation for handling iframe flows and events
|
|
22
24
|
*/
|
|
23
25
|
class Flow {
|
|
24
|
-
constructor(containerId, config, partnerName, environment) {
|
|
26
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
25
27
|
this.containerId = containerId;
|
|
26
28
|
this.config = config;
|
|
27
29
|
this.partnerName = partnerName;
|
|
28
30
|
this.environment = environment;
|
|
31
|
+
this.branchOverride = branchOverride;
|
|
29
32
|
this.iframe = null;
|
|
30
33
|
this.container = null;
|
|
31
34
|
this.eventListeners = new Map();
|
|
@@ -62,12 +65,13 @@ class Flow {
|
|
|
62
65
|
console.log('📝 Config:', this.config);
|
|
63
66
|
console.log('🏢 Partner:', this.partnerName);
|
|
64
67
|
console.log('🌍 Environment:', this.environment);
|
|
68
|
+
console.log('🔝 Branch Override:', this.branchOverride);
|
|
65
69
|
const baseUrl = getBaseUrl(this.environment);
|
|
66
70
|
let finalUrl = this.constructFlowUrl(baseUrl);
|
|
67
|
-
// Add cdn_branch_override parameter for
|
|
68
|
-
if (this.environment
|
|
71
|
+
// Add cdn_branch_override parameter for non-production environments
|
|
72
|
+
if (this.branchOverride && this.environment !== 'production') {
|
|
69
73
|
const separator = finalUrl.includes('?') ? '&' : '?';
|
|
70
|
-
finalUrl += `${separator}cdn_branch_override
|
|
74
|
+
finalUrl += `${separator}cdn_branch_override=${this.branchOverride}`;
|
|
71
75
|
}
|
|
72
76
|
console.log('🌐 Final URL:', finalUrl);
|
|
73
77
|
return finalUrl;
|
|
@@ -151,8 +155,8 @@ class Flow {
|
|
|
151
155
|
* SinglePayFlow subclass with custom URL construction
|
|
152
156
|
*/
|
|
153
157
|
class SinglePayFlow extends Flow {
|
|
154
|
-
constructor(containerId, config, partnerName, environment) {
|
|
155
|
-
super(containerId, config, partnerName, environment);
|
|
158
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
159
|
+
super(containerId, config, partnerName, environment, branchOverride);
|
|
156
160
|
this.billId = config.billId;
|
|
157
161
|
}
|
|
158
162
|
/**
|
|
@@ -166,8 +170,8 @@ class SinglePayFlow extends Flow {
|
|
|
166
170
|
* BatchPayFlow subclass with custom URL construction
|
|
167
171
|
*/
|
|
168
172
|
class BatchPayFlow extends Flow {
|
|
169
|
-
constructor(containerId, config, partnerName, environment) {
|
|
170
|
-
super(containerId, config, partnerName, environment);
|
|
173
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
174
|
+
super(containerId, config, partnerName, environment, branchOverride);
|
|
171
175
|
this.billIds = config.billIds;
|
|
172
176
|
}
|
|
173
177
|
/**
|
|
@@ -182,6 +186,9 @@ class BatchPayFlow extends Flow {
|
|
|
182
186
|
* SettingsFlow subclass with custom URL construction
|
|
183
187
|
*/
|
|
184
188
|
class SettingsFlow extends Flow {
|
|
189
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
190
|
+
super(containerId, config, partnerName, environment, branchOverride);
|
|
191
|
+
}
|
|
185
192
|
/**
|
|
186
193
|
* Construct the specific flow URL for settings
|
|
187
194
|
*/
|
|
@@ -190,6 +197,9 @@ class SettingsFlow extends Flow {
|
|
|
190
197
|
}
|
|
191
198
|
}
|
|
192
199
|
class PaymentsDashboardFlow extends Flow {
|
|
200
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
201
|
+
super(containerId, config, partnerName, environment, branchOverride);
|
|
202
|
+
}
|
|
193
203
|
/**
|
|
194
204
|
* Construct the specific flow URL for payments dashboard
|
|
195
205
|
*/
|
|
@@ -209,6 +219,7 @@ export class MelioSDK {
|
|
|
209
219
|
this.initPromise = null;
|
|
210
220
|
this.environment = 'production';
|
|
211
221
|
this.partnerName = '';
|
|
222
|
+
this.branchOverride = undefined;
|
|
212
223
|
}
|
|
213
224
|
/**
|
|
214
225
|
* Initialize the SDK by creating an authentication iframe
|
|
@@ -221,6 +232,7 @@ export class MelioSDK {
|
|
|
221
232
|
// Set partner name and environment from options
|
|
222
233
|
this.partnerName = options.partnerName;
|
|
223
234
|
this.environment = options.environment || 'production';
|
|
235
|
+
this.branchOverride = options.branchOverride;
|
|
224
236
|
this.initPromise = this.performInit(authorizationCode, options);
|
|
225
237
|
return this.initPromise;
|
|
226
238
|
}
|
|
@@ -238,7 +250,6 @@ export class MelioSDK {
|
|
|
238
250
|
this.authIframe.style.width = '1px';
|
|
239
251
|
this.authIframe.style.height = '1px';
|
|
240
252
|
// Add iframe to document
|
|
241
|
-
console.log('Adding iframe to document');
|
|
242
253
|
document.body.appendChild(this.authIframe);
|
|
243
254
|
this.setupKeepAlive();
|
|
244
255
|
resolve();
|
|
@@ -254,9 +265,9 @@ export class MelioSDK {
|
|
|
254
265
|
});
|
|
255
266
|
const baseUrl = getBaseUrl(this.environment);
|
|
256
267
|
let finalUrl = `${baseUrl}/${this.partnerName}/auth?${params.toString()}`;
|
|
257
|
-
// Add cdn_branch_override parameter for
|
|
258
|
-
if (this.environment
|
|
259
|
-
finalUrl +=
|
|
268
|
+
// Add cdn_branch_override parameter for non-production environments
|
|
269
|
+
if (this.branchOverride && this.environment !== 'production') {
|
|
270
|
+
finalUrl += `&cdn_branch_override=${this.branchOverride}`;
|
|
260
271
|
}
|
|
261
272
|
return finalUrl;
|
|
262
273
|
}
|
|
@@ -274,7 +285,7 @@ export class MelioSDK {
|
|
|
274
285
|
* Launch the onboarding flow
|
|
275
286
|
*/
|
|
276
287
|
openOnboarding(config) {
|
|
277
|
-
const flow = new Flow(config.containerId, config, this.partnerName, this.environment);
|
|
288
|
+
const flow = new Flow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
|
|
278
289
|
flow.initialize();
|
|
279
290
|
return flow;
|
|
280
291
|
}
|
|
@@ -282,7 +293,7 @@ export class MelioSDK {
|
|
|
282
293
|
* Launch the single pay flow
|
|
283
294
|
*/
|
|
284
295
|
openSinglePayFlow(config) {
|
|
285
|
-
const flow = new SinglePayFlow(config.containerId, config, this.partnerName, this.environment);
|
|
296
|
+
const flow = new SinglePayFlow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
|
|
286
297
|
flow.initialize();
|
|
287
298
|
return flow;
|
|
288
299
|
}
|
|
@@ -290,7 +301,7 @@ export class MelioSDK {
|
|
|
290
301
|
* Launch the batch pay flow
|
|
291
302
|
*/
|
|
292
303
|
openBatchPay(config) {
|
|
293
|
-
const flow = new BatchPayFlow(config.containerId, config, this.partnerName, this.environment);
|
|
304
|
+
const flow = new BatchPayFlow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
|
|
294
305
|
flow.initialize();
|
|
295
306
|
return flow;
|
|
296
307
|
}
|
|
@@ -298,7 +309,7 @@ export class MelioSDK {
|
|
|
298
309
|
* Launch the settings flow
|
|
299
310
|
*/
|
|
300
311
|
openSettings(config) {
|
|
301
|
-
const flow = new SettingsFlow(config.containerId, config, this.partnerName, this.environment);
|
|
312
|
+
const flow = new SettingsFlow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
|
|
302
313
|
flow.initialize();
|
|
303
314
|
return flow;
|
|
304
315
|
}
|
|
@@ -306,7 +317,7 @@ export class MelioSDK {
|
|
|
306
317
|
* Launch the payments dashboard flow
|
|
307
318
|
*/
|
|
308
319
|
openPaymentsDashboard(config) {
|
|
309
|
-
const flow = new PaymentsDashboardFlow(config.containerId, config, this.partnerName, this.environment);
|
|
320
|
+
const flow = new PaymentsDashboardFlow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
|
|
310
321
|
flow.initialize();
|
|
311
322
|
return flow;
|
|
312
323
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Available environments for the SDK
|
|
3
3
|
*/
|
|
4
|
-
export type Environment = 'production' | 'staging01' | 'public-qa' | 'certification' | 'localhost';
|
|
4
|
+
export type Environment = 'production' | 'staging01' | 'public-qa' | 'certification' | 'eilat' | 'localhost';
|
|
5
5
|
/**
|
|
6
6
|
* Configuration options for SDK initialization
|
|
7
7
|
*/
|
|
@@ -12,6 +12,8 @@ export interface InitOptions {
|
|
|
12
12
|
keepAlive?: boolean;
|
|
13
13
|
/** The environment to use for API endpoints. Defaults to 'production' */
|
|
14
14
|
environment?: Environment;
|
|
15
|
+
/** The branch to use for the melio platform. Defaults to 'main' */
|
|
16
|
+
branchOverride?: string;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Base configuration for all flows
|
package/package.json
CHANGED