@global.engg/switcher-lib 0.1.42 → 0.1.43

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.
@@ -78,6 +78,9 @@
78
78
  EngagePlusWebBaseURL: 'https://app-engage.shiprocket.in/'
79
79
  };
80
80
  this.DOMAIN = 'https://app.shiprocket.in';
81
+ this.HANDOFF_COOKIE = 'sr_handoff';
82
+ this.HANDOFF_COOKIE_DOMAIN = 'shiprocket.in';
83
+ this.HANDOFF_COOKIE_MAX_AGE = 60;
81
84
  this.userData = JSON.parse(localStorage.getItem('ngStorage-USER') || localStorage.getItem('_userData') || '{}');
82
85
  this.isDesktop = false;
83
86
  this.appSwitchList = [
@@ -184,11 +187,16 @@
184
187
  // }, 500); // 500ms delay
185
188
  this.executeAppSwitch(app, kyc_status, windowRef);
186
189
  };
190
+ AppSwitcherService.prototype.setHandoffCookie = function () {
191
+ var value = this.userData.token;
192
+ document.cookie = this.HANDOFF_COOKIE + "=" + value + "; Domain=." + this.HANDOFF_COOKIE_DOMAIN + "; Path=/; Max-Age=" + this.HANDOFF_COOKIE_MAX_AGE + "; Secure; SameSite=Lax";
193
+ };
187
194
  AppSwitcherService.prototype.executeAppSwitch = function (app, kyc_status, windowRef) {
188
195
  var _this = this;
189
196
  var _a, _b, _c;
190
197
  if (this.userData.allow_engage && app === 'engage') {
191
- windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper?token=" + this.userData.token, '_blank');
198
+ this.setHandoffCookie();
199
+ windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper", '_blank');
192
200
  }
193
201
  else if (app === 'checkout') {
194
202
  if (this.userData.is_admin) {
@@ -205,10 +213,12 @@
205
213
  // }
206
214
  }
207
215
  else if (this.userData.allow_fbs && app === 'fullfilment') {
208
- windowRef.open(this.SR_CONSTANTS.SrfWebBaseUrl + "login?token=" + this.userData.token, '_blank');
216
+ this.setHandoffCookie();
217
+ windowRef.open(this.SR_CONSTANTS.SrfWebBaseUrl + "login", '_blank');
209
218
  }
210
219
  else if (!this.userData.allow_fbs && app === 'fullfilment') {
211
- windowRef.open(this.SR_CONSTANTS.FulfillmentWebBaseUrl + "?utm_source=panel&utm_medium=app_switcher&utm_campaign=SR-Panel-non-srf-switcher&token=" + this.userData.token, '_blank');
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');
212
222
  }
213
223
  else if (app === 'rocketbox') {
214
224
  if (this.userData.is_admin) {
@@ -216,9 +226,8 @@
216
226
  }
217
227
  if (this.userData.allow_rb_panel || this.userData.is_rb_user) {
218
228
  // Use setTimeout for window.location.href redirects
219
- var access_token = this.userData.token;
220
- // https://app-cargo.shiprocket.in/auth/confirm?next=/client/dashboard#access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vYXBpdjIuc2hpcHJvY2tldC5jby92MS9hdXRoL2xvZ2luIiwiaWF0IjoxNzcwNjI0ODQ2LCJleHAiOjE3NzE0ODg4NDYsIm5iZiI6MTc3MDYyNDg0NiwianRpIjoiMFFEc2NvTHFHQ0VIUGVESSIsInN1YiI6MjUyMDgsInBydiI6IjA1YmI2NjBmNjdjYWM3NDVmN2IzZGExZWVmMTk3MTk1YTIxMWU2ZDkiLCJjaWQiOjI1MTQ5fQ.3wMPidc7CaIkRhfAsPU9a61HsM-S5Ni_3eJ_kisWKKU&expires_in=36000&token_type=Bearer&source=sr
221
- var url_1 = "https://app-cargo.shiprocket.in/auth/confirm?next=/client/dashboard#access_token=" + access_token + "&expires_in=36000&token_type=Bearer&source=sr";
229
+ this.setHandoffCookie();
230
+ var url_1 = "https://app-cargo.shiprocket.in/auth/confirm?next=/client/dashboard#expires_in=36000&token_type=Bearer&source=sr";
222
231
  setTimeout(function () {
223
232
  window.open(url_1, '_blank');
224
233
  }, 500);
@@ -232,7 +241,8 @@
232
241
  else if (((_a = this.userData) === null || _a === void 0 ? void 0 : _a.allow_sr_convert) &&
233
242
  !((_b = this.userData) === null || _b === void 0 ? void 0 : _b.allow_engage) &&
234
243
  app === 'sr_convert') {
235
- windowRef.open(this.SR_CONSTANTS.WigzoWebBaseUrl + "/" + this.userData.token, '_blank');
244
+ this.setHandoffCookie();
245
+ windowRef.open("" + this.SR_CONSTANTS.WigzoWebBaseUrl, '_blank');
236
246
  }
237
247
  else if (app === 'sr_genie') {
238
248
  windowRef.open("https://ai-test.kartrocket.com/login?token=" + this.userData.token, '_blank');
@@ -271,14 +281,16 @@
271
281
  }
272
282
  else if (app === 'creditScore') {
273
283
  if ((_c = this.userData) === null || _c === void 0 ? void 0 : _c.is_crif_enabled) {
274
- 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&authToken=" + this.userData.token, '_blank');
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');
275
286
  }
276
287
  else {
277
288
  windowRef.open("https://www.shiprocket.in/capital/", '_blank');
278
289
  }
279
290
  }
280
291
  else if (app === 'capital') {
281
- windowRef.open("https://capital-web.shiprocket.in/home/?utm_source=App-Switcher&utm_medium=Manual-Adhoc&utm_content=capital&utm_term=flexi_business_loan&authToken=" + this.userData.token, '_blank');
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');
282
294
  }
283
295
  else if (app === 'marketing') {
284
296
  // Use setTimeout for window.location.href redirects
@@ -288,7 +300,8 @@
288
300
  }
289
301
  else if (app === 'whatsapp_solutions') {
290
302
  if (this.userData.allow_engage) {
291
- windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper?token=" + this.userData.token, '_blank');
303
+ this.setHandoffCookie();
304
+ windowRef.open(this.SR_CONSTANTS.EngageWebBaseUrl + "gate-keeper", '_blank');
292
305
  }
293
306
  else {
294
307
  windowRef.open("https://app-engage.shiprocket.in/auth/register", '_blank');
@@ -326,7 +339,8 @@
326
339
  }, 500);
327
340
  }
328
341
  else if (app === 'instant_deliveries') {
329
- windowRef.open(this.SR_CONSTANTS.QuickWebBaseUrl + "gate-keeper?token=" + this.userData.token, '_blank');
342
+ this.setHandoffCookie();
343
+ windowRef.open(this.SR_CONSTANTS.QuickWebBaseUrl + "gate-keeper", '_blank');
330
344
  return;
331
345
  }
332
346
  else if (app === 'warehousing') {
@@ -774,7 +788,6 @@
774
788
  SwitcherComponent.prototype.openModal = function (param) {
775
789
  var _this = this;
776
790
  var _a, _b, _c, _d, _e;
777
- console.log("testing log only");
778
791
  if (param == 'mobile') {
779
792
  (_b = (_a = this.windowRef.nativeWindow) === null || _a === void 0 ? void 0 : _a.Moengage) === null || _b === void 0 ? void 0 : _b.track_event("bottom_navigation_clicked", { "company_id": this.company_id, "button_name": 'Switcher', "bu_name": "Domestic" });
780
793
  }