@frontegg/redux-store 7.88.0 → 7.90.0-alpha.0

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.
@@ -2,6 +2,7 @@ import type { IGetUserPasswordConfig } from '@frontegg/rest-api';
2
2
  import type { FronteggState, RestApi, SharedActions } from '../../interfaces';
3
3
  import type { ForgotPasswordState, IForgotPasswordPayload, IResetPasswordPayload, IDeterminePasswordRecoveryStrategyPayload, IVerifyPasswordViaSmsPayload } from './interfaces';
4
4
  declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
5
+ loadPasswordRecoveryStrategies: () => Promise<void>;
5
6
  setForgotPasswordState: (payload: Partial<ForgotPasswordState>) => void;
6
7
  resetForgotPasswordState: () => void;
7
8
  forgotPassword: (payload: IForgotPasswordPayload) => Promise<void>;
@@ -6,6 +6,23 @@ import { initialState } from './state';
6
6
  import { errorHandler, deepResetState } from '../../helpers';
7
7
  export default ((store, api, sharedActions) => {
8
8
  const actions = sharedActions;
9
+ const loadPasswordRecoveryStrategies = async () => {
10
+ setForgotPasswordState({
11
+ loading: true
12
+ });
13
+ try {
14
+ const strategies = await api.auth.getPasswordRecoveryStrategies();
15
+ setForgotPasswordState({
16
+ loading: false,
17
+ activeStrategies: strategies
18
+ });
19
+ } catch (e) {
20
+ setForgotPasswordState({
21
+ loading: false,
22
+ error: errorHandler(e)
23
+ });
24
+ }
25
+ };
9
26
  const setForgotPasswordState = payload => {
10
27
  Object.assign(store.auth.forgotPasswordState, payload);
11
28
  };
@@ -204,6 +221,7 @@ export default ((store, api, sharedActions) => {
204
221
  }
205
222
  };
206
223
  return {
224
+ loadPasswordRecoveryStrategies,
207
225
  setForgotPasswordState,
208
226
  resetForgotPasswordState,
209
227
  forgotPassword,
@@ -26,7 +26,7 @@ import { LoginFlow, LoginStep } from '../interfaces';
26
26
  import { base64urlDecode, deepResetState, delay, errorHandler, errorTraceId, GTMEventAction, publicKeyCredentialToJSON, reportGTMEvent, retryIfNeeded, withRetryConfig } from '../../../helpers';
27
27
  import { initialState } from '../state';
28
28
  import { getSearchParam, isEmailPayload, isUsernamePayload, shouldShowPasswordRotationPromptFunc, TENANT_ID_PARAM_KEY } from '../helpers';
29
- import { AuthStrategyEnum, ContextHolder, removeTabTenantFromSessionStorage, WebAuthnDeviceType } from '@frontegg/rest-api';
29
+ import { AuthStrategyEnum, ContextHolder, FeatureFlags, removeTabTenantFromSessionStorage, WebAuthnDeviceType } from '@frontegg/rest-api';
30
30
  import hostedLoginAuthorizeActions from './hostedLoginAuthorize.actions';
31
31
  import { FronteggNativeModule, isEntitlementsDeeplyEqual } from '../../../toolkit';
32
32
  import { REQUEST_NAME, UserVerifiedOriginTypes } from '../../interfaces';
@@ -119,7 +119,9 @@ export default ((store, api, sharedActions) => {
119
119
  }),
120
120
  isAuthenticated: true
121
121
  });
122
- await __handleRedirectRefreshToken(shouldNavigateToRegisterQuickLogin);
122
+ await __handleRedirectRefreshToken({
123
+ shouldNavigateToRegisterQuickLogin
124
+ });
123
125
  }
124
126
  } catch (e) {
125
127
  contextHolder.setAccessToken(null);
@@ -162,9 +164,11 @@ export default ((store, api, sharedActions) => {
162
164
  }
163
165
  return updatedUser;
164
166
  };
165
-
166
167
  /** @private */
167
- const __handleRedirectRefreshToken = async shouldNavigateToRegisterQuickLogin => {
168
+ const __handleRedirectRefreshToken = async ({
169
+ shouldNavigateToRegisterQuickLogin,
170
+ isSocialLoginRefreshToken = false
171
+ }) => {
168
172
  var _window;
169
173
  const url = new URL((_window = window) == null ? void 0 : _window.location.href);
170
174
  const {
@@ -172,6 +176,7 @@ export default ((store, api, sharedActions) => {
172
176
  loginState,
173
177
  onRedirectTo
174
178
  } = store.auth;
179
+ const [preventAuthRedirectOnSocialLogin] = FeatureFlags.getFeatureFlags(['prevent-auth-redirect-on-social-login'], store.root.appName);
175
180
  const invitationToken = url.searchParams.get('invitationToken');
176
181
  const redirectRoutes = [routes.socialLoginCallbackUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl, routes.magicLinkCallbackUrl];
177
182
  if (!invitationToken) {
@@ -185,6 +190,10 @@ export default ((store, api, sharedActions) => {
185
190
  refresh: routes.signUpSuccessUrl.startsWith('http')
186
191
  });
187
192
  } else {
193
+ const isSocialLoginCallbackUrl = routes.socialLoginCallbackUrl && window.location.pathname.endsWith(routes.socialLoginCallbackUrl);
194
+ if (!isSocialLoginRefreshToken && preventAuthRedirectOnSocialLogin && isSocialLoginCallbackUrl) {
195
+ return;
196
+ }
188
197
  await actions.afterAuthNavigation();
189
198
  }
190
199
  }
@@ -1332,7 +1341,10 @@ export default ((store, api, sharedActions) => {
1332
1341
  }),
1333
1342
  isAuthenticated: true
1334
1343
  });
1335
- await __handleRedirectRefreshToken(shouldNavigateToRegisterQuickLogin);
1344
+ await __handleRedirectRefreshToken({
1345
+ shouldNavigateToRegisterQuickLogin,
1346
+ isSocialLoginRefreshToken: true
1347
+ });
1336
1348
  }
1337
1349
  }
1338
1350
  } catch (e) {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.88.0
1
+ /** @license Frontegg v7.90.0-alpha.0
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.
@@ -1,6 +1,7 @@
1
1
  import { FronteggState, RestApi, SharedActions } from '../../interfaces';
2
2
  import type { IGetUserPasswordConfig } from '@frontegg/rest-api';
3
3
  declare const _default: (store: FronteggState, api: RestApi, actions: SharedActions) => {
4
+ loadPasswordRecoveryStrategies: () => Promise<void>;
4
5
  setForgotPasswordState: (payload: Partial<import("../..").ForgotPasswordState>) => void;
5
6
  resetForgotPasswordState: () => void;
6
7
  forgotPassword: (payload: import("../..").IForgotPasswordPayload) => Promise<void>;
@@ -13,6 +13,23 @@ var _helpers = require("../../helpers");
13
13
  const _excluded = ["callback"];
14
14
  var _default = (store, api, sharedActions) => {
15
15
  const actions = sharedActions;
16
+ const loadPasswordRecoveryStrategies = async () => {
17
+ setForgotPasswordState({
18
+ loading: true
19
+ });
20
+ try {
21
+ const strategies = await api.auth.getPasswordRecoveryStrategies();
22
+ setForgotPasswordState({
23
+ loading: false,
24
+ activeStrategies: strategies
25
+ });
26
+ } catch (e) {
27
+ setForgotPasswordState({
28
+ loading: false,
29
+ error: (0, _helpers.errorHandler)(e)
30
+ });
31
+ }
32
+ };
16
33
  const setForgotPasswordState = payload => {
17
34
  Object.assign(store.auth.forgotPasswordState, payload);
18
35
  };
@@ -211,6 +228,7 @@ var _default = (store, api, sharedActions) => {
211
228
  }
212
229
  };
213
230
  return {
231
+ loadPasswordRecoveryStrategies,
214
232
  setForgotPasswordState,
215
233
  resetForgotPasswordState,
216
234
  forgotPassword,
@@ -126,7 +126,9 @@ var _default = (store, api, sharedActions) => {
126
126
  }),
127
127
  isAuthenticated: true
128
128
  });
129
- await __handleRedirectRefreshToken(shouldNavigateToRegisterQuickLogin);
129
+ await __handleRedirectRefreshToken({
130
+ shouldNavigateToRegisterQuickLogin
131
+ });
130
132
  }
131
133
  } catch (e) {
132
134
  contextHolder.setAccessToken(null);
@@ -169,9 +171,11 @@ var _default = (store, api, sharedActions) => {
169
171
  }
170
172
  return updatedUser;
171
173
  };
172
-
173
174
  /** @private */
174
- const __handleRedirectRefreshToken = async shouldNavigateToRegisterQuickLogin => {
175
+ const __handleRedirectRefreshToken = async ({
176
+ shouldNavigateToRegisterQuickLogin,
177
+ isSocialLoginRefreshToken = false
178
+ }) => {
175
179
  var _window;
176
180
  const url = new URL((_window = window) == null ? void 0 : _window.location.href);
177
181
  const {
@@ -179,6 +183,7 @@ var _default = (store, api, sharedActions) => {
179
183
  loginState,
180
184
  onRedirectTo
181
185
  } = store.auth;
186
+ const [preventAuthRedirectOnSocialLogin] = _restApi.FeatureFlags.getFeatureFlags(['prevent-auth-redirect-on-social-login'], store.root.appName);
182
187
  const invitationToken = url.searchParams.get('invitationToken');
183
188
  const redirectRoutes = [routes.socialLoginCallbackUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl, routes.magicLinkCallbackUrl];
184
189
  if (!invitationToken) {
@@ -192,6 +197,10 @@ var _default = (store, api, sharedActions) => {
192
197
  refresh: routes.signUpSuccessUrl.startsWith('http')
193
198
  });
194
199
  } else {
200
+ const isSocialLoginCallbackUrl = routes.socialLoginCallbackUrl && window.location.pathname.endsWith(routes.socialLoginCallbackUrl);
201
+ if (!isSocialLoginRefreshToken && preventAuthRedirectOnSocialLogin && isSocialLoginCallbackUrl) {
202
+ return;
203
+ }
195
204
  await actions.afterAuthNavigation();
196
205
  }
197
206
  }
@@ -1339,7 +1348,10 @@ var _default = (store, api, sharedActions) => {
1339
1348
  }),
1340
1349
  isAuthenticated: true
1341
1350
  });
1342
- await __handleRedirectRefreshToken(shouldNavigateToRegisterQuickLogin);
1351
+ await __handleRedirectRefreshToken({
1352
+ shouldNavigateToRegisterQuickLogin,
1353
+ isSocialLoginRefreshToken: true
1354
+ });
1343
1355
  }
1344
1356
  }
1345
1357
  } catch (e) {
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.88.0
1
+ /** @license Frontegg v7.90.0-alpha.0
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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
- "version": "7.88.0",
3
+ "version": "7.90.0-alpha.0",
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
9
  "@frontegg/entitlements-javascript-commons": "1.1.2",
10
- "@frontegg/rest-api": "7.88.0",
10
+ "@frontegg/rest-api": "7.90.0-alpha.0",
11
11
  "fast-deep-equal": "3.1.3",
12
12
  "get-value": "^3.0.1",
13
13
  "proxy-compare": "^3.0.0",