@global.engg/switcher-lib 0.1.43 → 0.1.44

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,22 @@
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
200
  var _this = this;
196
201
  var _a, _b, _c;
197
202
  if (this.userData.allow_engage && app === 'engage') {
198
- this.setHandoffCookie();
199
- windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper", '_blank');
203
+ var targetUrl = this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper";
204
+ this.setHandoffCookie(targetUrl);
205
+ windowRef.open(targetUrl, '_blank');
200
206
  }
201
207
  else if (app === 'checkout') {
202
208
  if (this.userData.is_admin) {
@@ -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,8 +234,8 @@
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);
@@ -241,8 +249,9 @@
241
249
  else if (((_a = this.userData) === null || _a === void 0 ? void 0 : _a.allow_sr_convert) &&
242
250
  !((_b = this.userData) === null || _b === void 0 ? void 0 : _b.allow_engage) &&
243
251
  app === 'sr_convert') {
244
- this.setHandoffCookie();
245
- windowRef.open("" + this.SR_CONSTANTS.WigzoWebBaseUrl, '_blank');
252
+ var targetUrl = "" + this.SR_CONSTANTS.WigzoWebBaseUrl;
253
+ this.setHandoffCookie(targetUrl);
254
+ windowRef.open(targetUrl, '_blank');
246
255
  }
247
256
  else if (app === 'sr_genie') {
248
257
  windowRef.open("https://ai-test.kartrocket.com/login?token=" + this.userData.token, '_blank');
@@ -281,16 +290,18 @@
281
290
  }
282
291
  else if (app === 'creditScore') {
283
292
  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');
293
+ 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";
294
+ this.setHandoffCookie(targetUrl);
295
+ windowRef.open(targetUrl, '_blank');
286
296
  }
287
297
  else {
288
298
  windowRef.open("https://www.shiprocket.in/capital/", '_blank');
289
299
  }
290
300
  }
291
301
  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');
302
+ var targetUrl = "https://capital-web.shiprocket.in/home/?utm_source=App-Switcher&utm_medium=Manual-Adhoc&utm_content=capital&utm_term=flexi_business_loan";
303
+ this.setHandoffCookie(targetUrl);
304
+ windowRef.open(targetUrl, '_blank');
294
305
  }
295
306
  else if (app === 'marketing') {
296
307
  // Use setTimeout for window.location.href redirects
@@ -300,8 +311,9 @@
300
311
  }
301
312
  else if (app === 'whatsapp_solutions') {
302
313
  if (this.userData.allow_engage) {
303
- this.setHandoffCookie();
304
- windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper", '_blank');
314
+ var targetUrl = this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper";
315
+ this.setHandoffCookie(targetUrl);
316
+ windowRef.open(targetUrl, '_blank');
305
317
  }
306
318
  else {
307
319
  windowRef.open("https://app-engage.shiprocket.in/auth/register", '_blank');
@@ -339,8 +351,9 @@
339
351
  }, 500);
340
352
  }
341
353
  else if (app === 'instant_deliveries') {
342
- this.setHandoffCookie();
343
- windowRef.open(this.SR_CONSTANTS.QuickWebBaseUrl + "gate-keeper", '_blank');
354
+ var targetUrl = this.SR_CONSTANTS.QuickWebBaseUrl + "gate-keeper";
355
+ this.setHandoffCookie(targetUrl);
356
+ windowRef.open(targetUrl, '_blank');
344
357
  return;
345
358
  }
346
359
  else if (app === 'warehousing') {