@global.engg/switcher-lib 0.1.43 → 0.1.45

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.
@@ -187,16 +187,21 @@
187
187
  // }, 500); // 500ms delay
188
188
  this.executeAppSwitch(app, kyc_status, windowRef);
189
189
  };
190
- AppSwitcherService.prototype.setHandoffCookie = function () {
191
- var value = this.userData.token;
190
+ AppSwitcherService.prototype.setHandoffCookie = function (targetUrl) {
191
+ var token = this.userData.token;
192
+ if (!token) {
193
+ return;
194
+ }
195
+ var host = new URL(targetUrl, window.location.href).host;
196
+ var value = encodeURIComponent(host + '|' + token);
192
197
  document.cookie = this.HANDOFF_COOKIE + "=" + value + "; Domain=." + this.HANDOFF_COOKIE_DOMAIN + "; Path=/; Max-Age=" + this.HANDOFF_COOKIE_MAX_AGE + "; Secure; SameSite=Lax";
193
198
  };
194
199
  AppSwitcherService.prototype.executeAppSwitch = function (app, kyc_status, windowRef) {
195
- var _this = this;
196
200
  var _a, _b, _c;
197
201
  if (this.userData.allow_engage && app === 'engage') {
198
- this.setHandoffCookie();
199
- windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper", '_blank');
202
+ var targetUrl = this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper";
203
+ this.setHandoffCookie(targetUrl);
204
+ windowRef.open(targetUrl, '_blank');
200
205
  }
201
206
  else if (app === 'checkout') {
202
207
  if (this.userData.is_admin) {
@@ -204,6 +209,7 @@
204
209
  }
205
210
  var url = "https://fastrr-dashboard.pickrr.com/dashboard?utm_source=sr_dashboard&utm_medium=appswitcher&utm_campaign=appswitcher01&utm_content=appswitcher01&cid=" + this.userData.company_id;
206
211
  url = url + "&token=" + this.userData.token;
212
+ this.setHandoffCookie(url);
207
213
  windowRef.open(url, '_blank');
208
214
  // if ((this.isCheckoutAllowed(this.userData?.company_id) || this.userData.allow_checkout)) {
209
215
  // url = `${url}&token=${this.userData.token}`
@@ -213,12 +219,14 @@
213
219
  // }
214
220
  }
215
221
  else if (this.userData.allow_fbs && app === 'fullfilment') {
216
- this.setHandoffCookie();
217
- windowRef.open(this.SR_CONSTANTS.SrfWebBaseUrl + "login", '_blank');
222
+ var targetUrl = this.SR_CONSTANTS.SrfWebBaseUrl + "login";
223
+ this.setHandoffCookie(targetUrl);
224
+ windowRef.open(targetUrl, '_blank');
218
225
  }
219
226
  else if (!this.userData.allow_fbs && app === 'fullfilment') {
220
- this.setHandoffCookie();
221
- windowRef.open(this.SR_CONSTANTS.FulfillmentWebBaseUrl + "?utm_source=panel&utm_medium=app_switcher&utm_campaign=SR-Panel-non-srf-switcher", '_blank');
227
+ var targetUrl = this.SR_CONSTANTS.FulfillmentWebBaseUrl + "?utm_source=panel&utm_medium=app_switcher&utm_campaign=SR-Panel-non-srf-switcher";
228
+ this.setHandoffCookie(targetUrl);
229
+ windowRef.open(targetUrl, '_blank');
222
230
  }
223
231
  else if (app === 'rocketbox') {
224
232
  if (this.userData.is_admin) {
@@ -226,26 +234,31 @@
226
234
  }
227
235
  if (this.userData.allow_rb_panel || this.userData.is_rb_user) {
228
236
  // Use setTimeout for window.location.href redirects
229
- this.setHandoffCookie();
230
237
  var url_1 = "https://app-cargo.shiprocket.in/auth/confirm?next=/client/dashboard#expires_in=36000&token_type=Bearer&source=sr";
238
+ this.setHandoffCookie(url_1);
231
239
  setTimeout(function () {
232
240
  window.open(url_1, '_blank');
233
241
  }, 500);
234
242
  }
235
243
  else {
244
+ var targetUrl_1 = this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
245
+ this.setHandoffCookie(targetUrl_1);
236
246
  setTimeout(function () {
237
- window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
247
+ window.location.href = targetUrl_1;
238
248
  }, 500);
239
249
  }
240
250
  }
241
251
  else if (((_a = this.userData) === null || _a === void 0 ? void 0 : _a.allow_sr_convert) &&
242
252
  !((_b = this.userData) === null || _b === void 0 ? void 0 : _b.allow_engage) &&
243
253
  app === 'sr_convert') {
244
- this.setHandoffCookie();
245
- windowRef.open("" + this.SR_CONSTANTS.WigzoWebBaseUrl, '_blank');
254
+ var targetUrl = "" + this.SR_CONSTANTS.WigzoWebBaseUrl;
255
+ this.setHandoffCookie(targetUrl);
256
+ windowRef.open(targetUrl, '_blank');
246
257
  }
247
258
  else if (app === 'sr_genie') {
248
- windowRef.open("https://ai-test.kartrocket.com/login?token=" + this.userData.token, '_blank');
259
+ var targetUrl = "https://ai-test.kartrocket.com/login?token=" + this.userData.token;
260
+ this.setHandoffCookie(targetUrl);
261
+ windowRef.open(targetUrl, '_blank');
249
262
  }
250
263
  else if (app === 'one_impression') {
251
264
  // Calling one-impression and redirecting to new tab
@@ -255,10 +268,14 @@
255
268
  this.fetchOpenInAppLink();
256
269
  }
257
270
  else if (app === 'wigzo') {
258
- windowRef.open("https://app.wigzo.com/auth/shiprocket/login/" + this.userData.token, '_blank');
271
+ var targetUrl = "https://app.wigzo.com/auth/shiprocket/login/" + this.userData.token;
272
+ this.setHandoffCookie(targetUrl);
273
+ windowRef.open(targetUrl, '_blank');
259
274
  }
260
275
  else if (app === 'omuni') {
261
- windowRef.open("https://omuni.com/", '_blank');
276
+ var targetUrl = "https://omuni.com/";
277
+ this.setHandoffCookie(targetUrl);
278
+ windowRef.open(targetUrl, '_blank');
262
279
  // if (this.userData?.is_omuni2_user == 1) {
263
280
  // this.httpService.get('omuni/switch').subscribe(
264
281
  // (res) => {
@@ -277,85 +294,106 @@
277
294
  // }
278
295
  }
279
296
  else if (app === 'trends') {
280
- windowRef.open("https://trends.shiprocket.in/", '_blank');
297
+ var targetUrl = "https://trends.shiprocket.in/";
298
+ this.setHandoffCookie(targetUrl);
299
+ windowRef.open(targetUrl, '_blank');
281
300
  }
282
301
  else if (app === 'creditScore') {
283
302
  if ((_c = this.userData) === null || _c === void 0 ? void 0 : _c.is_crif_enabled) {
284
- this.setHandoffCookie();
285
- windowRef.open("https://capital-web.shiprocket.in/crif-home/?utm_source=App-Switcher&utm_medium=Manual-Adhoc&utm_content=crif_credit_score&utm_term=app_switcher_click", '_blank');
303
+ var targetUrl = "https://capital-web.shiprocket.in/crif-home/?utm_source=App-Switcher&utm_medium=Manual-Adhoc&utm_content=crif_credit_score&utm_term=app_switcher_click";
304
+ this.setHandoffCookie(targetUrl);
305
+ windowRef.open(targetUrl, '_blank');
286
306
  }
287
307
  else {
288
- windowRef.open("https://www.shiprocket.in/capital/", '_blank');
308
+ var targetUrl = "https://www.shiprocket.in/capital/";
309
+ this.setHandoffCookie(targetUrl);
310
+ windowRef.open(targetUrl, '_blank');
289
311
  }
290
312
  }
291
313
  else if (app === 'capital') {
292
- this.setHandoffCookie();
293
- windowRef.open("https://capital-web.shiprocket.in/home/?utm_source=App-Switcher&utm_medium=Manual-Adhoc&utm_content=capital&utm_term=flexi_business_loan", '_blank');
314
+ var targetUrl = "https://capital-web.shiprocket.in/home/?utm_source=App-Switcher&utm_medium=Manual-Adhoc&utm_content=capital&utm_term=flexi_business_loan";
315
+ this.setHandoffCookie(targetUrl);
316
+ windowRef.open(targetUrl, '_blank');
294
317
  }
295
318
  else if (app === 'marketing') {
296
- // Use setTimeout for window.location.href redirects
319
+ var targetUrl_2 = this.DOMAIN + "/seller/home";
320
+ this.setHandoffCookie(targetUrl_2);
297
321
  setTimeout(function () {
298
- window.location.href = _this.DOMAIN + "/seller/home";
322
+ window.location.href = targetUrl_2;
299
323
  }, 500);
300
324
  }
301
325
  else if (app === 'whatsapp_solutions') {
302
326
  if (this.userData.allow_engage) {
303
- this.setHandoffCookie();
304
- windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper", '_blank');
327
+ var targetUrl = this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper";
328
+ this.setHandoffCookie(targetUrl);
329
+ windowRef.open(targetUrl, '_blank');
305
330
  }
306
331
  else {
307
- windowRef.open("https://app-engage.shiprocket.in/auth/register", '_blank');
332
+ var targetUrl = "https://app-engage.shiprocket.in/auth/register";
333
+ this.setHandoffCookie(targetUrl);
334
+ windowRef.open(targetUrl, '_blank');
308
335
  }
309
336
  }
310
337
  else if (app === 'internationalParcels') {
311
338
  if (kyc_status == 0 || kyc_status == 1 || kyc_status == 2 || kyc_status == 4) {
312
- // Use setTimeout for window.location.href redirects
339
+ var targetUrl_3 = this.DOMAIN + "/seller/internationalDashboard/overview";
340
+ this.setHandoffCookie(targetUrl_3);
313
341
  setTimeout(function () {
314
- window.location.href = _this.DOMAIN + "/seller/internationalDashboard/overview";
342
+ window.location.href = targetUrl_3;
315
343
  }, 500);
316
344
  }
317
345
  else {
346
+ var targetUrl_4 = this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
347
+ this.setHandoffCookie(targetUrl_4);
318
348
  setTimeout(function () {
319
- window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
349
+ window.location.href = targetUrl_4;
320
350
  }, 500);
321
351
  }
322
352
  }
323
353
  else if (app === 'i_rocketbox') {
324
- // Use setTimeout for window.location.href redirects
354
+ var targetUrl_5 = this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
355
+ this.setHandoffCookie(targetUrl_5);
325
356
  setTimeout(function () {
326
- window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
357
+ window.location.href = targetUrl_5;
327
358
  }, 500);
328
359
  }
329
360
  else if (app === 'brand_launch') {
330
- // Use setTimeout for window.location.href redirects
361
+ var targetUrl_6 = this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
362
+ this.setHandoffCookie(targetUrl_6);
331
363
  setTimeout(function () {
332
- window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
364
+ window.location.href = targetUrl_6;
333
365
  }, 500);
334
366
  }
335
367
  else if (app === 'express_parcel') {
336
- // Use setTimeout for window.location.href redirects
368
+ var targetUrl_7 = this.DOMAIN + "/seller/home";
369
+ this.setHandoffCookie(targetUrl_7);
337
370
  setTimeout(function () {
338
- window.location.href = _this.DOMAIN + "/seller/home";
371
+ window.location.href = targetUrl_7;
339
372
  }, 500);
340
373
  }
341
374
  else if (app === 'instant_deliveries') {
342
- this.setHandoffCookie();
343
- windowRef.open(this.SR_CONSTANTS.QuickWebBaseUrl + "gate-keeper", '_blank');
375
+ var targetUrl = this.SR_CONSTANTS.QuickWebBaseUrl + "gate-keeper";
376
+ this.setHandoffCookie(targetUrl);
377
+ windowRef.open(targetUrl, '_blank');
344
378
  return;
345
379
  }
346
380
  else if (app === 'warehousing') {
347
- windowRef.open("https://fulfillment.shiprocket.in/", '_blank');
381
+ var targetUrl = "https://fulfillment.shiprocket.in/";
382
+ this.setHandoffCookie(targetUrl);
383
+ windowRef.open(targetUrl, '_blank');
348
384
  }
349
385
  else if (app == 'srocketbox') {
350
- // Use setTimeout for window.location.href redirects
386
+ var targetUrl_8 = this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
387
+ this.setHandoffCookie(targetUrl_8);
351
388
  setTimeout(function () {
352
- window.location.href = _this.DOMAIN + "/seller/settings/internationalsettings/internationalkyc";
389
+ window.location.href = targetUrl_8;
353
390
  }, 500);
354
391
  }
355
392
  else if (app == 'somuni') {
356
- // Use setTimeout for window.location.href redirects
393
+ var targetUrl_9 = this.DOMAIN + "/seller/home";
394
+ this.setHandoffCookie(targetUrl_9);
357
395
  setTimeout(function () {
358
- window.location.href = _this.DOMAIN + "/seller/home";
396
+ window.location.href = targetUrl_9;
359
397
  }, 500);
360
398
  }
361
399
  };
@@ -471,16 +509,20 @@
471
509
  }
472
510
  };
473
511
  AppSwitcherService.prototype.fetchOpenInAppLink = function () {
512
+ var _this = this;
474
513
  this._http.get('oneimpression/open-app-redirection_url')
475
514
  .subscribe(function (res) {
476
515
  if (res && (res === null || res === void 0 ? void 0 : res.url)) {
516
+ _this.setHandoffCookie(res.url);
477
517
  window.open(res === null || res === void 0 ? void 0 : res.url, '_blank');
478
518
  }
479
519
  });
480
520
  };
481
521
  AppSwitcherService.prototype.fetchOneImpressionLoginLink = function () {
522
+ var _this = this;
482
523
  this._http.get(this._getURL() + 'oneimpression/get-login-link').subscribe(function (res) {
483
524
  if (res && (res === null || res === void 0 ? void 0 : res.url)) {
525
+ _this.setHandoffCookie(res.url);
484
526
  window.open(res === null || res === void 0 ? void 0 : res.url, '_blank');
485
527
  }
486
528
  else if ((res === null || res === void 0 ? void 0 : res.status) == 'fail') {