@melio-eng/web-sdk 1.0.8-pr.21.9ad5c63 → 1.0.9-pr.21.507aad3
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 +26 -17
- package/dist/types.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,11 +23,12 @@ function getBaseUrl(environment) {
|
|
|
23
23
|
* Flow class implementation for handling iframe flows and events
|
|
24
24
|
*/
|
|
25
25
|
class Flow {
|
|
26
|
-
constructor(containerId, config, partnerName, environment) {
|
|
26
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
27
27
|
this.containerId = containerId;
|
|
28
28
|
this.config = config;
|
|
29
29
|
this.partnerName = partnerName;
|
|
30
30
|
this.environment = environment;
|
|
31
|
+
this.branchOverride = branchOverride;
|
|
31
32
|
this.iframe = null;
|
|
32
33
|
this.container = null;
|
|
33
34
|
this.eventListeners = new Map();
|
|
@@ -64,12 +65,13 @@ class Flow {
|
|
|
64
65
|
console.log('📝 Config:', this.config);
|
|
65
66
|
console.log('🏢 Partner:', this.partnerName);
|
|
66
67
|
console.log('🌍 Environment:', this.environment);
|
|
68
|
+
console.log('🔝 Branch Override:', this.branchOverride);
|
|
67
69
|
const baseUrl = getBaseUrl(this.environment);
|
|
68
70
|
let finalUrl = this.constructFlowUrl(baseUrl);
|
|
69
|
-
// Add cdn_branch_override parameter for
|
|
70
|
-
if (this.environment
|
|
71
|
+
// Add cdn_branch_override parameter for non-production environments
|
|
72
|
+
if (this.branchOverride && this.environment !== 'production') {
|
|
71
73
|
const separator = finalUrl.includes('?') ? '&' : '?';
|
|
72
|
-
finalUrl += `${separator}cdn_branch_override
|
|
74
|
+
finalUrl += `${separator}cdn_branch_override=${this.branchOverride}`;
|
|
73
75
|
}
|
|
74
76
|
console.log('🌐 Final URL:', finalUrl);
|
|
75
77
|
return finalUrl;
|
|
@@ -153,8 +155,8 @@ class Flow {
|
|
|
153
155
|
* SinglePayFlow subclass with custom URL construction
|
|
154
156
|
*/
|
|
155
157
|
class SinglePayFlow extends Flow {
|
|
156
|
-
constructor(containerId, config, partnerName, environment) {
|
|
157
|
-
super(containerId, config, partnerName, environment);
|
|
158
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
159
|
+
super(containerId, config, partnerName, environment, branchOverride);
|
|
158
160
|
this.billId = config.billId;
|
|
159
161
|
}
|
|
160
162
|
/**
|
|
@@ -168,8 +170,8 @@ class SinglePayFlow extends Flow {
|
|
|
168
170
|
* BatchPayFlow subclass with custom URL construction
|
|
169
171
|
*/
|
|
170
172
|
class BatchPayFlow extends Flow {
|
|
171
|
-
constructor(containerId, config, partnerName, environment) {
|
|
172
|
-
super(containerId, config, partnerName, environment);
|
|
173
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
174
|
+
super(containerId, config, partnerName, environment, branchOverride);
|
|
173
175
|
this.billIds = config.billIds;
|
|
174
176
|
}
|
|
175
177
|
/**
|
|
@@ -184,6 +186,9 @@ class BatchPayFlow extends Flow {
|
|
|
184
186
|
* SettingsFlow subclass with custom URL construction
|
|
185
187
|
*/
|
|
186
188
|
class SettingsFlow extends Flow {
|
|
189
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
190
|
+
super(containerId, config, partnerName, environment, branchOverride);
|
|
191
|
+
}
|
|
187
192
|
/**
|
|
188
193
|
* Construct the specific flow URL for settings
|
|
189
194
|
*/
|
|
@@ -192,6 +197,9 @@ class SettingsFlow extends Flow {
|
|
|
192
197
|
}
|
|
193
198
|
}
|
|
194
199
|
class PaymentsDashboardFlow extends Flow {
|
|
200
|
+
constructor(containerId, config, partnerName, environment, branchOverride) {
|
|
201
|
+
super(containerId, config, partnerName, environment, branchOverride);
|
|
202
|
+
}
|
|
195
203
|
/**
|
|
196
204
|
* Construct the specific flow URL for payments dashboard
|
|
197
205
|
*/
|
|
@@ -211,6 +219,7 @@ export class MelioSDK {
|
|
|
211
219
|
this.initPromise = null;
|
|
212
220
|
this.environment = 'production';
|
|
213
221
|
this.partnerName = '';
|
|
222
|
+
this.branchOverride = undefined;
|
|
214
223
|
}
|
|
215
224
|
/**
|
|
216
225
|
* Initialize the SDK by creating an authentication iframe
|
|
@@ -223,6 +232,7 @@ export class MelioSDK {
|
|
|
223
232
|
// Set partner name and environment from options
|
|
224
233
|
this.partnerName = options.partnerName;
|
|
225
234
|
this.environment = options.environment || 'production';
|
|
235
|
+
this.branchOverride = options.branchOverride;
|
|
226
236
|
this.initPromise = this.performInit(authorizationCode, options);
|
|
227
237
|
return this.initPromise;
|
|
228
238
|
}
|
|
@@ -240,7 +250,6 @@ export class MelioSDK {
|
|
|
240
250
|
this.authIframe.style.width = '1px';
|
|
241
251
|
this.authIframe.style.height = '1px';
|
|
242
252
|
// Add iframe to document
|
|
243
|
-
console.log('Adding iframe to document');
|
|
244
253
|
document.body.appendChild(this.authIframe);
|
|
245
254
|
this.setupKeepAlive();
|
|
246
255
|
resolve();
|
|
@@ -256,9 +265,9 @@ export class MelioSDK {
|
|
|
256
265
|
});
|
|
257
266
|
const baseUrl = getBaseUrl(this.environment);
|
|
258
267
|
let finalUrl = `${baseUrl}/${this.partnerName}/start?${params.toString()}`;
|
|
259
|
-
// Add cdn_branch_override parameter for
|
|
260
|
-
if (this.environment
|
|
261
|
-
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}`;
|
|
262
271
|
}
|
|
263
272
|
return finalUrl;
|
|
264
273
|
}
|
|
@@ -276,7 +285,7 @@ export class MelioSDK {
|
|
|
276
285
|
* Launch the onboarding flow
|
|
277
286
|
*/
|
|
278
287
|
openOnboarding(config) {
|
|
279
|
-
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);
|
|
280
289
|
flow.initialize();
|
|
281
290
|
return flow;
|
|
282
291
|
}
|
|
@@ -284,7 +293,7 @@ export class MelioSDK {
|
|
|
284
293
|
* Launch the single pay flow
|
|
285
294
|
*/
|
|
286
295
|
openSinglePayFlow(config) {
|
|
287
|
-
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);
|
|
288
297
|
flow.initialize();
|
|
289
298
|
return flow;
|
|
290
299
|
}
|
|
@@ -292,7 +301,7 @@ export class MelioSDK {
|
|
|
292
301
|
* Launch the batch pay flow
|
|
293
302
|
*/
|
|
294
303
|
openBatchPay(config) {
|
|
295
|
-
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);
|
|
296
305
|
flow.initialize();
|
|
297
306
|
return flow;
|
|
298
307
|
}
|
|
@@ -300,7 +309,7 @@ export class MelioSDK {
|
|
|
300
309
|
* Launch the settings flow
|
|
301
310
|
*/
|
|
302
311
|
openSettings(config) {
|
|
303
|
-
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);
|
|
304
313
|
flow.initialize();
|
|
305
314
|
return flow;
|
|
306
315
|
}
|
|
@@ -308,7 +317,7 @@ export class MelioSDK {
|
|
|
308
317
|
* Launch the payments dashboard flow
|
|
309
318
|
*/
|
|
310
319
|
openPaymentsDashboard(config) {
|
|
311
|
-
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);
|
|
312
321
|
flow.initialize();
|
|
313
322
|
return flow;
|
|
314
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' | '
|
|
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@melio-eng/web-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9-pr.21.507aad3",
|
|
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",
|