@frontegg/redux-store 7.60.0 → 7.61.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.
@@ -12,24 +12,38 @@ export default ((store, api, sharedActions) => {
12
12
  const switchTenant = async payload => {
13
13
  const {
14
14
  tenantId,
15
+ silentReload,
15
16
  callback
16
17
  } = payload;
17
- actions.setAuthState({
18
+ silentReload ? actions.setTenantsState({
19
+ switchingTenant: true
20
+ }) : actions.setAuthState({
18
21
  isLoading: true
19
22
  });
20
23
  try {
21
24
  await api.tenants.switchTenant({
22
25
  tenantId
23
26
  });
27
+ if (silentReload) {
28
+ actions.resetAuthState({
29
+ isLoading: false,
30
+ isAuthenticated: true,
31
+ user: store.auth.user
32
+ });
33
+ }
24
34
  await actions.__refreshToken();
25
35
  const callbackConsumed = callback == null ? void 0 : callback(true);
26
36
  if (!callbackConsumed) {
27
- actions.setAuthState({
37
+ silentReload ? actions.setTenantsState({
38
+ switchingTenant: false
39
+ }) : actions.setAuthState({
28
40
  isLoading: false
29
41
  });
30
42
  }
31
43
  } catch (e) {
32
- actions.setAuthState({
44
+ silentReload ? actions.setTenantsState({
45
+ switchingTenant: false
46
+ }) : actions.setAuthState({
33
47
  isLoading: false
34
48
  });
35
49
  callback == null ? void 0 : callback(false, e);
@@ -4,6 +4,7 @@ export type { ISubTenant };
4
4
  export interface TenantsState {
5
5
  tenants: ITenantsResponseV2[];
6
6
  loading: boolean;
7
+ switchingTenant: boolean;
7
8
  error?: any;
8
9
  subTenants: ISubTenant[];
9
10
  tenantTree: ISubTenantTree | null;
@@ -2,6 +2,7 @@ import { createProxy } from '../../toolkit/proxy';
2
2
  export const initialState = {
3
3
  tenants: [],
4
4
  subTenants: [],
5
+ switchingTenant: false,
5
6
  loading: true,
6
7
  tenantTree: null
7
8
  };
package/auth/index.d.ts CHANGED
@@ -145,6 +145,6 @@ export type AuthActions = {
145
145
  setState: (state: Partial<FronteggState['auth']>) => void;
146
146
  setAuthState: (state: Partial<FronteggState['auth']>) => void;
147
147
  setErrorByRequestName: (payload: SingleErrorByRequestDataPayload) => void;
148
- resetAuthState: () => void;
148
+ resetAuthState: (state?: Partial<AuthState>) => void;
149
149
  setUser: (user: User | null) => void;
150
150
  } & AcceptInvitationActions & AccountSettingsActions & UnlockAccountActions & ActivateAccountActions & ApiTokensActions & ApplicationsActions & CustomLoginActions & EntitlementsActions & ForgotPasswordActions & PasswordRotationActions & GroupsActions & GroupsDialogsActions & ImpersonateActions & LoginActions & MfaActions & AllAccountsActions & AllAccountsDialogActions & PasskeysActions & ProfileActions & ProvisioningActions & ResetPhoneNumberActions & RolesActions & RestrictionsActions & SecurityCenterActions & SecurityPolicyActions & SessionsPolicyActions & SessionsActions & SignUpActions & SmsActions & SocialLoginActions & SSOActions & StepUpActions & TeamActions & TenantsActions;
package/auth/index.js CHANGED
@@ -140,8 +140,8 @@ export const buildAuthActions = (store, api, actions, snapshotAuthState) => {
140
140
  }
141
141
  });
142
142
  };
143
- const resetAuthState = () => {
144
- deepResetState(store, ['auth'], snapshotAuthState);
143
+ const resetAuthState = (state = {}) => {
144
+ deepResetState(store, ['auth'], _extends({}, snapshotAuthState, state));
145
145
  };
146
146
  const setUser = user => {
147
147
  setAuthState({
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.60.0
1
+ /** @license Frontegg v7.61.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.
@@ -18,24 +18,38 @@ var _default = (store, api, sharedActions) => {
18
18
  const switchTenant = async payload => {
19
19
  const {
20
20
  tenantId,
21
+ silentReload,
21
22
  callback
22
23
  } = payload;
23
- actions.setAuthState({
24
+ silentReload ? actions.setTenantsState({
25
+ switchingTenant: true
26
+ }) : actions.setAuthState({
24
27
  isLoading: true
25
28
  });
26
29
  try {
27
30
  await api.tenants.switchTenant({
28
31
  tenantId
29
32
  });
33
+ if (silentReload) {
34
+ actions.resetAuthState({
35
+ isLoading: false,
36
+ isAuthenticated: true,
37
+ user: store.auth.user
38
+ });
39
+ }
30
40
  await actions.__refreshToken();
31
41
  const callbackConsumed = callback == null ? void 0 : callback(true);
32
42
  if (!callbackConsumed) {
33
- actions.setAuthState({
43
+ silentReload ? actions.setTenantsState({
44
+ switchingTenant: false
45
+ }) : actions.setAuthState({
34
46
  isLoading: false
35
47
  });
36
48
  }
37
49
  } catch (e) {
38
- actions.setAuthState({
50
+ silentReload ? actions.setTenantsState({
51
+ switchingTenant: false
52
+ }) : actions.setAuthState({
39
53
  isLoading: false
40
54
  });
41
55
  callback == null ? void 0 : callback(false, e);
@@ -8,6 +8,7 @@ var _proxy = require("../../toolkit/proxy");
8
8
  const initialState = {
9
9
  tenants: [],
10
10
  subTenants: [],
11
+ switchingTenant: false,
11
12
  loading: true,
12
13
  tenantTree: null
13
14
  };
@@ -537,8 +537,8 @@ const buildAuthActions = (store, api, actions, snapshotAuthState) => {
537
537
  }
538
538
  });
539
539
  };
540
- const resetAuthState = () => {
541
- (0, _helpers.deepResetState)(store, ['auth'], snapshotAuthState);
540
+ const resetAuthState = (state = {}) => {
541
+ (0, _helpers.deepResetState)(store, ['auth'], (0, _extends2.default)({}, snapshotAuthState, state));
542
542
  };
543
543
  const setUser = user => {
544
544
  setAuthState({
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.60.0
1
+ /** @license Frontegg v7.61.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.60.0",
3
+ "version": "7.61.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.60.0",
10
+ "@frontegg/rest-api": "7.61.0",
11
11
  "fast-deep-equal": "3.1.3",
12
12
  "get-value": "^3.0.1",
13
13
  "proxy-compare": "^3.0.0",