@frontegg/js 6.155.0-alpha.4 → 6.155.0-alpha.6

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.155.0-alpha.4
1
+ /** @license Frontegg v6.155.0-alpha.6
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.155.0-alpha.4
1
+ /** @license Frontegg v6.155.0-alpha.6
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/node/version.js CHANGED
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _default = {
8
- cdnVersion: '6.155.0-alpha.4'
8
+ cdnVersion: '6.155.0-alpha.6'
9
9
  };
10
10
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@frontegg/js",
3
- "version": "6.155.0-alpha.4",
3
+ "version": "6.155.0-alpha.6",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Frontegg LTD",
7
7
  "dependencies": {
8
8
  "@babel/runtime": "^7.18.6",
9
- "@frontegg/types": "6.155.0-alpha.4"
9
+ "@frontegg/types": "6.155.0-alpha.6"
10
10
  },
11
11
  "browserslist": {
12
12
  "production": [
@@ -1414,7 +1414,7 @@ __webpack_require__.r(__webpack_exports__);
1414
1414
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1415
1415
  /* harmony export */ });
1416
1416
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
1417
- cdnVersion: '6.155.0-alpha.4'
1417
+ cdnVersion: '6.155.0-alpha.6'
1418
1418
  });
1419
1419
 
1420
1420
  /***/ }),
@@ -7567,6 +7567,18 @@ __webpack_require__.r(__webpack_exports__);
7567
7567
 
7568
7568
 
7569
7569
 
7570
+ /**
7571
+ * @param url
7572
+ * @returns url without the origin if it's the same origin as the current window origin
7573
+ */
7574
+ function cleanUrlIfSameOrigin(url) {
7575
+ var _window, _window2;
7576
+ if (!url.startsWith((_window = window) == null ? void 0 : _window.location.origin)) {
7577
+ return url;
7578
+ }
7579
+ return url.replace((_window2 = window) == null ? void 0 : _window2.location.origin, '');
7580
+ }
7581
+
7570
7582
  /**
7571
7583
  * @param customLoginAuthenticatedUrl custom login authenticated url if exists
7572
7584
  * @returns the authenticated url to redirect to after auth navigation
@@ -7592,32 +7604,47 @@ function* getUrlForAfterAuthNavigation(customLoginAuthenticatedUrl) {
7592
7604
  if (!finalUrl || [loginUrl, logoutUrl, socialLoginCallbackUrl, activateUrl].includes(finalUrl)) {
7593
7605
  finalUrl = authenticatedUrl;
7594
7606
  }
7595
- return (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getRedirectUrl)({
7607
+ const redirectUrl = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.getRedirectUrl)({
7596
7608
  authenticatedUrl: finalUrl,
7597
7609
  includeQueryParam,
7598
7610
  enforceRedirectToSameSite,
7599
7611
  allowedRedirectOrigins
7600
7612
  });
7613
+
7614
+ // clean origin if it's the same origin as the current window origin to avoid refresh in afterAuthNavigationUtil
7615
+ return cleanUrlIfSameOrigin(redirectUrl);
7601
7616
  }
7602
7617
  /**
7603
7618
  * Utility to share after auth navigation flow between login and step up
7604
7619
  * @param resetStateAction reset state action
7605
7620
  * @param customLoginAuthenticatedUrl custom login authenticated url if exists
7621
+ * @param shouldStepUpDuringLogin true when it's login after step up flow
7606
7622
  */
7607
7623
  function* afterAuthNavigationUtil(resetStateAction, {
7608
7624
  customLoginAuthenticatedUrl,
7609
- forceStepUpUrl
7625
+ forceStepUpUrl,
7626
+ shouldStepUpDuringLogin
7610
7627
  } = {}) {
7611
7628
  const onRedirectTo = _frontegg_rest_api__WEBPACK_IMPORTED_MODULE_3__.ContextHolder.onRedirectTo;
7612
- let redirectUrl;
7629
+ let redirectUrl = undefined;
7613
7630
  if (forceStepUpUrl) {
7614
7631
  // scenario to get to here: invalid max age, try to step up -> logout, login with magic code/link -> redirect to step up page for email code as the second factor
7615
7632
  // we don't want to remove the FRONTEGG_AFTER_AUTH_REDIRECT_URL when we are in the step up flow
7616
7633
  redirectUrl = forceStepUpUrl;
7617
7634
  } else {
7618
- var _window;
7619
- redirectUrl = yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_0__.call)(getUrlForAfterAuthNavigation, customLoginAuthenticatedUrl);
7620
- (_window = window) == null ? void 0 : _window.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_2__.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
7635
+ var _window3;
7636
+ if (shouldStepUpDuringLogin) {
7637
+ // getUrlForAfterAuthNavigation give priority to the redirectUrl
7638
+ // avoiding use of getUrlForAfterAuthNavigation because we don't want to use the redirectUrl for magic link for example
7639
+ const localStorageRedirectUrl = window.localStorage.getItem(_constants__WEBPACK_IMPORTED_MODULE_2__.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
7640
+ if (localStorageRedirectUrl && !(0,_utils__WEBPACK_IMPORTED_MODULE_1__.isAbsoluteUrl)(localStorageRedirectUrl)) {
7641
+ redirectUrl = localStorageRedirectUrl;
7642
+ }
7643
+ }
7644
+ if (!redirectUrl) {
7645
+ redirectUrl = yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_0__.call)(getUrlForAfterAuthNavigation, customLoginAuthenticatedUrl);
7646
+ }
7647
+ (_window3 = window) == null ? void 0 : _window3.localStorage.removeItem(_constants__WEBPACK_IMPORTED_MODULE_2__.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
7621
7648
  }
7622
7649
  yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_0__.delay)(200);
7623
7650
  (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_0__.put)(resetStateAction());
@@ -7631,7 +7658,7 @@ function* afterAuthNavigationUtil(resetStateAction, {
7631
7658
  * Handling also step up scenario when user silently logout to continue to step up
7632
7659
  */
7633
7660
  function* afterAuthNavigation() {
7634
- var _window2;
7661
+ var _window4;
7635
7662
  const {
7636
7663
  routes: {
7637
7664
  customLoginAuthenticatedUrl,
@@ -7640,13 +7667,13 @@ function* afterAuthNavigation() {
7640
7667
  } = yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_0__.select)(state => state.auth);
7641
7668
 
7642
7669
  // login with magic code, try to step up, no other mfa, invalid max age, force_enroll -> logout, login with first factor, not-stepped up jwt -> navigate to step up
7643
- const shouldStepUp = (_window2 = window) == null ? void 0 : _window2.localStorage.getItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_4__.SHOULD_STEP_UP_KEY);
7670
+ const shouldStepUp = (_window4 = window) == null ? void 0 : _window4.localStorage.getItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_4__.SHOULD_STEP_UP_KEY);
7644
7671
  const user = yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_0__.select)(({
7645
7672
  auth
7646
7673
  }) => auth.user);
7647
7674
  if (shouldStepUp) {
7648
- var _window3;
7649
- (_window3 = window) == null ? void 0 : _window3.localStorage.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_4__.SHOULD_STEP_UP_KEY);
7675
+ var _window5;
7676
+ (_window5 = window) == null ? void 0 : _window5.localStorage.removeItem(_StepUpState_consts__WEBPACK_IMPORTED_MODULE_4__.SHOULD_STEP_UP_KEY);
7650
7677
  }
7651
7678
  if (stepUpUrl && shouldStepUp && !(0,_StepUpState__WEBPACK_IMPORTED_MODULE_5__.isSteppedUp)(user)) {
7652
7679
  yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_0__.call)(afterAuthNavigationUtil, _reducer__WEBPACK_IMPORTED_MODULE_6__.actions.resetLoginState, {
@@ -7663,7 +7690,8 @@ function* afterAuthNavigation() {
7663
7690
  });
7664
7691
  }
7665
7692
  yield (0,redux_saga_effects__WEBPACK_IMPORTED_MODULE_0__.call)(afterAuthNavigationUtil, _reducer__WEBPACK_IMPORTED_MODULE_6__.actions.resetLoginState, {
7666
- customLoginAuthenticatedUrl: customLoginURL
7693
+ customLoginAuthenticatedUrl: customLoginURL,
7694
+ shouldStepUpDuringLogin: !!shouldStepUp
7667
7695
  });
7668
7696
  }
7669
7697
 
@@ -8436,6 +8464,7 @@ __webpack_require__.r(__webpack_exports__);
8436
8464
  /* harmony export */ "getRedirectUrl": () => (/* binding */ getRedirectUrl),
8437
8465
  /* harmony export */ "getSearchParam": () => (/* binding */ getSearchParam),
8438
8466
  /* harmony export */ "getSearchParamsFromUrl": () => (/* binding */ getSearchParamsFromUrl),
8467
+ /* harmony export */ "isAbsoluteUrl": () => (/* binding */ isAbsoluteUrl),
8439
8468
  /* harmony export */ "isEmailPayload": () => (/* binding */ isEmailPayload),
8440
8469
  /* harmony export */ "isMfaRequired": () => (/* binding */ isMfaRequired),
8441
8470
  /* harmony export */ "isOauthCallbackRoute": () => (/* binding */ isOauthCallbackRoute)
@@ -24342,7 +24371,7 @@ __webpack_require__.r(__webpack_exports__);
24342
24371
  /* harmony export */ });
24343
24372
  /* harmony import */ var _ThemeOptions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ThemeOptions */ "../../dist/@frontegg/types/ThemeOptions/index.js");
24344
24373
  /* harmony import */ var _Metadata__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Metadata */ "../../dist/@frontegg/types/Metadata/index.js");
24345
- /** @license Frontegg v6.155.0-alpha.4
24374
+ /** @license Frontegg v6.155.0-alpha.6
24346
24375
  *
24347
24376
  * This source code is licensed under the MIT license found in the
24348
24377
  * LICENSE file in the root directory of this source tree.