@frontegg/redux-store 7.10.0 → 7.11.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.
Files changed (108) hide show
  1. package/audits/AuditLogsState/actions.js +2 -2
  2. package/audits/AuditsMetadataState/actions.js +2 -2
  3. package/auth/AcceptInvitationState/actions.js +2 -2
  4. package/auth/AccountSettingsState/actions.js +2 -2
  5. package/auth/ActivateAccountState/actions.js +2 -2
  6. package/auth/ApiTokensState/actions.js +2 -2
  7. package/auth/ApplicationsState/actions.js +2 -2
  8. package/auth/CustomLoginState/actions.js +2 -2
  9. package/auth/ForgotPasswordState/actions.js +2 -2
  10. package/auth/GroupsDialogsState/actions.js +2 -2
  11. package/auth/GroupsState/actions.js +2 -2
  12. package/auth/ImpersonateState/actions.js +2 -2
  13. package/auth/LoginState/actions/index.js +2 -2
  14. package/auth/LoginState/actions/mfaRequiredState.actions.js +7 -4
  15. package/auth/MSP/actions.js +3 -3
  16. package/auth/MSP/dialogs/actions.js +11 -12
  17. package/auth/MfaState/actions.js +2 -2
  18. package/auth/PasskeysState/actions.js +2 -2
  19. package/auth/ProfileState/actions.js +2 -2
  20. package/auth/ProvisioningState/actions.js +2 -2
  21. package/auth/ResetPhoneNumberState/actions.js +2 -2
  22. package/auth/RolesState/actions.js +2 -2
  23. package/auth/SSOState/actions/actions.v1.js +2 -2
  24. package/auth/Security/SecurityCenterState/actions.js +2 -2
  25. package/auth/Security/SecurityPolicyState/actions.js +2 -2
  26. package/auth/Security/SessionsPolicyState/actions.js +2 -2
  27. package/auth/SessionsState/actions.js +2 -2
  28. package/auth/SignUpState/actions.js +2 -2
  29. package/auth/SmsState/actions.js +2 -2
  30. package/auth/SocialLoginState/actions.js +2 -2
  31. package/auth/StepUpState/actions/index.js +2 -2
  32. package/auth/TeamState/actions/index.js +2 -2
  33. package/auth/TenantsState/actions.js +2 -2
  34. package/auth/UnlockAccountState/actions.js +2 -2
  35. package/auth/index.js +2 -2
  36. package/connectivity/actions.js +2 -2
  37. package/helpers/common.d.ts +9 -1
  38. package/helpers/common.js +27 -4
  39. package/index.js +1 -1
  40. package/mocks/auth-mocks/index.d.ts +2 -2
  41. package/mocks/auth-mocks/index.js +5 -3
  42. package/mocks/index.d.ts +4 -3
  43. package/mocks/index.js +2 -2
  44. package/mocks/subscriptions-mocks/stripeActions.mocks.d.ts +2 -0
  45. package/node/audits/AuditLogsState/actions.js +1 -1
  46. package/node/audits/AuditsMetadataState/actions.js +1 -1
  47. package/node/auth/AcceptInvitationState/actions.js +1 -1
  48. package/node/auth/AccountSettingsState/actions.js +1 -1
  49. package/node/auth/ActivateAccountState/actions.js +1 -1
  50. package/node/auth/ApiTokensState/actions.js +1 -1
  51. package/node/auth/ApplicationsState/actions.js +1 -1
  52. package/node/auth/CustomLoginState/actions.js +1 -1
  53. package/node/auth/ForgotPasswordState/actions.js +1 -1
  54. package/node/auth/GroupsDialogsState/actions.js +1 -1
  55. package/node/auth/GroupsState/actions.js +1 -1
  56. package/node/auth/ImpersonateState/actions.js +1 -1
  57. package/node/auth/LoginState/actions/index.js +1 -1
  58. package/node/auth/LoginState/actions/mfaRequiredState.actions.js +7 -4
  59. package/node/auth/MSP/actions.js +2 -2
  60. package/node/auth/MSP/dialogs/actions.js +10 -11
  61. package/node/auth/MfaState/actions.js +1 -1
  62. package/node/auth/PasskeysState/actions.js +1 -1
  63. package/node/auth/ProfileState/actions.js +1 -1
  64. package/node/auth/ProvisioningState/actions.js +1 -1
  65. package/node/auth/ResetPhoneNumberState/actions.js +1 -1
  66. package/node/auth/RolesState/actions.js +1 -1
  67. package/node/auth/SSOState/actions/actions.v1.js +1 -1
  68. package/node/auth/Security/SecurityCenterState/actions.js +1 -1
  69. package/node/auth/Security/SecurityPolicyState/actions.js +1 -1
  70. package/node/auth/Security/SessionsPolicyState/actions.js +1 -1
  71. package/node/auth/SessionsState/actions.js +1 -1
  72. package/node/auth/SignUpState/actions.js +1 -1
  73. package/node/auth/SmsState/actions.js +1 -1
  74. package/node/auth/SocialLoginState/actions.js +1 -1
  75. package/node/auth/StepUpState/actions/index.js +1 -1
  76. package/node/auth/TeamState/actions/index.js +1 -1
  77. package/node/auth/TenantsState/actions.js +1 -1
  78. package/node/auth/UnlockAccountState/actions.js +1 -1
  79. package/node/auth/index.js +1 -1
  80. package/node/connectivity/actions.js +1 -1
  81. package/node/helpers/common.js +30 -6
  82. package/node/index.js +1 -1
  83. package/node/mocks/auth-mocks/index.js +4 -2
  84. package/node/mocks/index.js +2 -2
  85. package/node/subscriptions/Billing/Information/actions.js +1 -1
  86. package/node/subscriptions/Billing/Invoices/actions.js +1 -1
  87. package/node/subscriptions/Billing/PaymentMethod/actions.js +1 -1
  88. package/node/subscriptions/Billing/Subscription/actions.js +1 -1
  89. package/node/subscriptions/Checkout/actions.js +1 -1
  90. package/node/subscriptions/Config/actions.js +1 -1
  91. package/node/subscriptions/Plans/actions.js +1 -1
  92. package/node/subscriptions/Stripe/actions.js +4 -2
  93. package/node/subscriptions/VendorPublicConfig/actions.js +1 -1
  94. package/node/toolkit/store.js +4 -3
  95. package/node/vendor/actions.js +1 -1
  96. package/package.json +2 -1
  97. package/subscriptions/Billing/Information/actions.js +2 -2
  98. package/subscriptions/Billing/Invoices/actions.js +2 -2
  99. package/subscriptions/Billing/PaymentMethod/actions.js +2 -2
  100. package/subscriptions/Billing/Subscription/actions.js +2 -2
  101. package/subscriptions/Checkout/actions.js +2 -2
  102. package/subscriptions/Config/actions.js +2 -2
  103. package/subscriptions/Plans/actions.js +2 -2
  104. package/subscriptions/Stripe/actions.d.ts +3 -1
  105. package/subscriptions/Stripe/actions.js +5 -3
  106. package/subscriptions/VendorPublicConfig/actions.js +2 -2
  107. package/toolkit/store.js +4 -3
  108. package/vendor/actions.js +2 -2
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { deepClone } from '../../../helpers';
2
+ import { deepResetState } from '../../../helpers';
3
3
  import { initialState } from '../state';
4
4
  import generateStepUpSessionActions from './generateStepUpSession.actions';
5
5
  import stepUpHostedLoginActions from './stepUpHostedLogin.actions';
@@ -9,7 +9,7 @@ export default ((store, api, sharedActions) => {
9
9
  Object.assign(store.auth.stepUpState, state);
10
10
  };
11
11
  const resetStepUpState = () => {
12
- store.auth.stepUpState = deepClone(initialState);
12
+ deepResetState(store, ['auth', 'stepUpState'], initialState);
13
13
  };
14
14
 
15
15
  /**
@@ -3,7 +3,7 @@ import usersActions from './users.actions';
3
3
  import subTenantsActions from './sub-tenants.actions';
4
4
  import activationLinkActions from './activation-link.actions';
5
5
  import invitationLinkActions from './invitation-link.actions';
6
- import { deepClone } from '../../../helpers';
6
+ import { deepResetState } from '../../../helpers';
7
7
  import { initialState } from '../state';
8
8
  export default ((store, api, sharedActions) => {
9
9
  const actions = sharedActions;
@@ -11,7 +11,7 @@ export default ((store, api, sharedActions) => {
11
11
  Object.assign(store.auth.teamState, payload);
12
12
  };
13
13
  const resetTeamState = () => {
14
- store.auth.teamState = deepClone(initialState);
14
+ deepResetState(store, ['auth', 'teamState'], initialState);
15
15
  };
16
16
  const setTeamLoader = payload => {
17
17
  Object.assign(store.auth.teamState, {
@@ -1,5 +1,5 @@
1
1
  import { initialState } from './state';
2
- import { deepClone } from '../../helpers';
2
+ import { deepResetState } from '../../helpers';
3
3
  import { getCurrentUserTenantsFunction } from '@frontegg/rest-api';
4
4
  export default ((store, api, sharedActions) => {
5
5
  const actions = sharedActions;
@@ -7,7 +7,7 @@ export default ((store, api, sharedActions) => {
7
7
  Object.assign(store.auth.tenantsState, state);
8
8
  };
9
9
  const resetTenantsState = () => {
10
- store.auth.tenantsState = deepClone(initialState);
10
+ deepResetState(store, ['auth', 'tenantsState'], initialState);
11
11
  };
12
12
  const switchTenant = async payload => {
13
13
  const {
@@ -1,12 +1,12 @@
1
1
  import { initialState } from './state';
2
- import { errorHandler, deepClone, delay } from '../../helpers';
2
+ import { errorHandler, delay, deepResetState } from '../../helpers';
3
3
  import { ContextHolder } from '@frontegg/rest-api';
4
4
  export default ((store, api, sharedActions) => {
5
5
  const setUnlockAccountState = state => {
6
6
  Object.assign(store.auth.unlockAccountState, state);
7
7
  };
8
8
  const resetUnlockAccountState = () => {
9
- store.auth.activateAccountState = deepClone(initialState);
9
+ deepResetState(store, ['auth', 'activateAccountState'], initialState);
10
10
  };
11
11
  const unlockAccount = async _payload => {
12
12
  const {
package/auth/index.js CHANGED
@@ -68,7 +68,7 @@ import { createStepUpState, buildStepUpActions } from './StepUpState';
68
68
  import { createTeamState, buildTeamActions } from './TeamState';
69
69
  import { createTenantsState, buildTenantsActions } from './TenantsState';
70
70
  import { defaultFronteggRoutes } from './LoginState/consts';
71
- import { isProxy } from '../helpers';
71
+ import { deepResetState, isProxy } from '../helpers';
72
72
  import { buildEntitlementsActions } from './Entitlements';
73
73
  import { createProxy } from '../toolkit/proxy';
74
74
  export const createAuthState = _overrideState => {
@@ -134,7 +134,7 @@ export const buildAuthActions = (store, api, actions, snapshotAuthState) => {
134
134
  });
135
135
  };
136
136
  const resetAuthState = () => {
137
- setAuthState(snapshotAuthState);
137
+ deepResetState(store, ['auth'], snapshotAuthState);
138
138
  };
139
139
  const setUser = user => {
140
140
  setAuthState({
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["id"],
4
4
  _excluded2 = ["id", "enabled"];
5
5
  import { channels, channels2Platform } from './consts';
6
- import { deepClone, errorHandler } from '../helpers';
6
+ import { deepResetState, errorHandler } from '../helpers';
7
7
  import { initialState } from './state';
8
8
  export default ((store, api, sharedActions) => {
9
9
  const type2ApiGet = {
@@ -30,7 +30,7 @@ export default ((store, api, sharedActions) => {
30
30
  store.connectivity.retryResult = _extends({}, retryResult, result);
31
31
  };
32
32
  const resetConnectivityState = () => {
33
- store.connectivity = deepClone(initialState);
33
+ deepResetState(store, ['connectivity'], initialState);
34
34
  };
35
35
  const loadConfigurationFor = async (api, params) => {
36
36
  try {
@@ -1,4 +1,4 @@
1
- export declare const deepClone: (objectToClone: any) => any;
1
+ import { FronteggState } from '../interfaces';
2
2
  export declare const delay: (ms?: number) => Promise<unknown>;
3
3
  export declare const retry: <T>(asyncFunc: () => Promise<T>, retryCount: number, delay: number) => Promise<T>;
4
4
  export declare function omitProps<T>(props: any, keys: string[]): T;
@@ -6,3 +6,11 @@ export declare function omitProps<T>(props: any, keys: string[]): T;
6
6
  * Check if the object is a proxy object to avoid cloning it
7
7
  */
8
8
  export declare function isProxy(obj: any): boolean | undefined;
9
+ export declare const deepClone: (objectToClone: any) => any;
10
+ /**
11
+ * Used to reset the state of the store to the initial state
12
+ * @param store - the store object
13
+ * @param statePath - the path to the state that needs to be reset
14
+ * @param initialState - the initial state object
15
+ */
16
+ export declare const deepResetState: (store: FronteggState, statePath: string[], initialState: any) => void;
package/helpers/common.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- export const deepClone = objectToClone => {
3
- return JSON.parse(JSON.stringify(objectToClone));
4
- };
2
+ import getValue from 'get-value';
3
+ import setValue from 'set-value';
5
4
  export const delay = (ms = 500) => new Promise(resolve => {
6
5
  setTimeout(resolve, ms);
7
6
  });
@@ -41,4 +40,28 @@ export function isProxy(obj) {
41
40
  }
42
41
  const _shouldBeCloneable = shouldBeCloneable(obj);
43
42
  return _shouldBeCloneable && obj.__isProxy !== undefined;
44
- }
43
+ }
44
+ export const deepClone = objectToClone => {
45
+ return JSON.parse(JSON.stringify(objectToClone));
46
+ };
47
+
48
+ /**
49
+ * Used to reset the state of the store to the initial state
50
+ * @param store - the store object
51
+ * @param statePath - the path to the state that needs to be reset
52
+ * @param initialState - the initial state object
53
+ */
54
+ export const deepResetState = (store, statePath, initialState) => {
55
+ const initialLoginState = deepClone(initialState);
56
+ const currentState = getValue(store, statePath);
57
+ for (const key in currentState) {
58
+ if (key === '__isProxy') {
59
+ continue;
60
+ }
61
+ if (key in initialLoginState) {
62
+ setValue(store, [...statePath, key], initialLoginState[key]);
63
+ } else {
64
+ setValue(store, [...statePath, key], undefined);
65
+ }
66
+ }
67
+ };
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.10.0
1
+ /** @license Frontegg v7.11.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,6 @@
1
- import { AuthActions, AuthStateActions } from '../../auth';
1
+ import { AuthActions, AuthState, AuthStateActions } from '../../auth';
2
2
  import { FronteggState, RestApi, SharedActions } from '../../interfaces';
3
- export declare const buildAuthActions: (store: FronteggState, api: RestApi, actions: SharedActions) => {
3
+ export declare const buildAuthActions: (store: FronteggState, api: RestApi, actions: SharedActions, snapshotAuthState: AuthState) => {
4
4
  authActions: AuthActions;
5
5
  authStateActions: AuthStateActions;
6
6
  };
@@ -34,8 +34,8 @@ import buildStepUpActions from './stepUpActions.mocks';
34
34
  import buildTeamActions from './teamActions.mocks';
35
35
  import buildTenantsActions from './tenantsActions.mocks';
36
36
  import buildUnlockAccountActions from './unlockAccountActions.mocks';
37
- import { isProxy } from '../../helpers';
38
- export const buildAuthActions = (store, api, actions) => {
37
+ import { deepResetState, isProxy } from '../../helpers';
38
+ export const buildAuthActions = (store, api, actions, snapshotAuthState) => {
39
39
  const acceptInvitationActions = buildAcceptInvitationActions(store, api, actions);
40
40
  const accountSettingsActions = buildAccountSettingsActions(store, api, actions);
41
41
  const unlockAccountActions = buildUnlockAccountActions(store, api, actions);
@@ -115,7 +115,9 @@ export const buildAuthActions = (store, api, actions) => {
115
115
  });
116
116
  };
117
117
  // eslint-disable-next-line @typescript-eslint/no-empty-function
118
- const resetAuthState = () => {};
118
+ const resetAuthState = () => {
119
+ deepResetState(store, ['auth'], snapshotAuthState);
120
+ };
119
121
  const setUser = user => {
120
122
  setAuthState({
121
123
  user
package/mocks/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { FronteggState, RestApi, SharedActions } from '../interfaces';
2
- declare const buildMockActions: (store: FronteggState, api: RestApi, actions: SharedActions) => {
3
- authActions: import("..").AuthActions;
4
- authStateActions: import("..").AuthStateActions;
2
+ import { AuthState } from '../auth';
3
+ declare const buildMockActions: (store: FronteggState, api: RestApi, actions: SharedActions, snapshotAuthState: AuthState) => {
4
+ authActions: import("../auth").AuthActions;
5
+ authStateActions: import("../auth").AuthStateActions;
5
6
  connectivityActions: {
6
7
  setConnectivityState: (state: Partial<import("..").ConnectivityState>) => void;
7
8
  initData: () => void;
package/mocks/index.js CHANGED
@@ -3,11 +3,11 @@ import { buildAuditsActions } from './audits-mocks';
3
3
  import { buildConnectivityActions } from './connectivity-mocks';
4
4
  import { buildSubscriptionsActions } from './subscriptions-mocks';
5
5
  import { buildVendorActions } from './vendor-mocks';
6
- const buildMockActions = (store, api, actions) => {
6
+ const buildMockActions = (store, api, actions, snapshotAuthState) => {
7
7
  const {
8
8
  authActions,
9
9
  authStateActions
10
- } = buildAuthActions(store, api, actions);
10
+ } = buildAuthActions(store, api, actions, snapshotAuthState);
11
11
  const connectivityActions = buildConnectivityActions(store, api, actions);
12
12
  const [subscriptionsActions, subscriptionsStateActions] = buildSubscriptionsActions(store, api, actions);
13
13
  const vendorActions = buildVendorActions(store, api, actions);
@@ -1,5 +1,7 @@
1
1
  import { FronteggState, RestApi, SharedActions } from '../../interfaces';
2
2
  declare const _default: (store: FronteggState, api: RestApi, actions: SharedActions) => {
3
3
  createCardSetupIntentSecret: (payload: import("../..").PaymentMethodId) => Promise<void>;
4
+ setStripeState: (state: Partial<import("../..").StripeState>) => void;
5
+ resetStripeState: () => void;
4
6
  };
5
7
  export default _default;
@@ -14,7 +14,7 @@ var _default = (store, api, sharedActions) => {
14
14
  Object.assign(store.auditLogs.auditLogsState, state);
15
15
  };
16
16
  const resetAuditLogsState = () => {
17
- store.auditLogs.auditLogsState = (0, _helpers.deepClone)(_state.initialState);
17
+ (0, _helpers.deepResetState)(store, ['auditLogs', 'auditLogsState'], _state.initialState);
18
18
  };
19
19
  const exportAuditsCsv = async () => {
20
20
  const state = store.auditLogs.auditLogsState;
@@ -12,7 +12,7 @@ var _default = (store, api, sharedActions) => {
12
12
  Object.assign(store.auditLogs.auditsMetadataState, state);
13
13
  };
14
14
  const resetAuditsMetadataState = () => {
15
- store.auditLogs.auditsMetadataState = (0, _helpers.deepClone)(_state.initialState);
15
+ (0, _helpers.deepResetState)(store, ['auditLogs', 'auditsMetadataState'], _state.initialState);
16
16
  };
17
17
  const loadAuditsMetadata = async () => {
18
18
  setAuditsMetadataState({
@@ -13,7 +13,7 @@ var _default = (store, api, sharedActions) => {
13
13
  Object.assign(store.auth.acceptInvitationState, state);
14
14
  };
15
15
  const resetAcceptInvitationState = () => {
16
- store.auth.acceptInvitationState = (0, _helpers.deepClone)(_state.initialState);
16
+ (0, _helpers.deepResetState)(store, ['auth', 'acceptInvitationState'], _state.initialState);
17
17
  };
18
18
  const acceptInvitation = async payload => {
19
19
  if (!payload.token || !payload.userId) {
@@ -16,7 +16,7 @@ var _default = (store, api, sharedActions) => {
16
16
  Object.assign(store.auth.accountSettingsState, state);
17
17
  };
18
18
  const resetAccountSettingsState = () => {
19
- store.auth.accountSettingsState = (0, _helpers.deepClone)(_state.initialState);
19
+ (0, _helpers.deepResetState)(store, ['auth', 'accountSettingsState'], _state.initialState);
20
20
  };
21
21
  const updateTenantState = ({
22
22
  newSettingValues
@@ -25,7 +25,7 @@ var _default = (store, api, sharedActions) => {
25
25
  Object.assign(store.auth.activateAccountState, state);
26
26
  };
27
27
  const resetActivateState = () => {
28
- store.auth.activateAccountState = (0, _helpers.deepClone)(_state.initialState);
28
+ (0, _helpers.deepResetState)(store, ['auth', 'activateAccountState'], _state.initialState);
29
29
  };
30
30
  const setActivateStrategyState = state => {
31
31
  Object.assign(store.auth.activateAccountState.activationStrategy, state);
@@ -33,7 +33,7 @@ var _default = (store, api, sharedActions) => {
33
33
  Object.assign(store.auth.apiTokensState, state);
34
34
  };
35
35
  const resetApiTokensState = () => {
36
- store.auth.apiTokensState = (0, _helpers.deepClone)(_state.initialState);
36
+ (0, _helpers.deepResetState)(store, ['auth', 'apiTokensState'], _state.initialState);
37
37
  };
38
38
  const loadApiTokens = async payload => {
39
39
  if (!(payload != null && payload.silentLoading)) {
@@ -16,7 +16,7 @@ var _default = (store, api, sharedActions) => {
16
16
  Object.assign(store.auth.applicationsState, payload);
17
17
  };
18
18
  const resetApplicationsState = () => {
19
- store.auth.applicationsState = (0, _helpers.deepClone)(_state.initialState);
19
+ (0, _helpers.deepResetState)(store, ['auth', 'applicationsState'], _state.initialState);
20
20
  };
21
21
  const loadUserApplications = async () => {
22
22
  setApplicationsState({
@@ -19,7 +19,7 @@ var _default = (store, api, sharedActions) => {
19
19
  Object.assign(store.auth.customLoginState, payload);
20
20
  };
21
21
  const resetCustomLoginState = () => {
22
- store.auth.customLoginState = (0, _helpers.deepClone)(_state.initialState);
22
+ (0, _helpers.deepResetState)(store, ['auth', 'customLoginState'], _state.initialState);
23
23
  };
24
24
  const loadTenantMetadata = async () => {
25
25
  setCustomLoginState({
@@ -16,7 +16,7 @@ var _default = (store, api, sharedActions) => {
16
16
  Object.assign(store.auth.forgotPasswordState, payload);
17
17
  };
18
18
  const resetForgotPasswordState = () => {
19
- store.auth.forgotPasswordState = (0, _helpers.deepClone)(_state.initialState);
19
+ (0, _helpers.deepResetState)(store, ['auth', 'forgotPasswordState'], _state.initialState);
20
20
  };
21
21
  const forgotPassword = async payload => {
22
22
  setForgotPasswordState({
@@ -13,7 +13,7 @@ var _default = (store, api, sharedActions) => {
13
13
  Object.assign(store.auth.groupsDialogsState, payload);
14
14
  };
15
15
  const resetGroupsDialogsState = () => {
16
- store.auth.groupsDialogsState = (0, _helpers.deepClone)(_state.initialState);
16
+ (0, _helpers.deepResetState)(store, ['auth', 'groupsDialogsState'], _state.initialState);
17
17
  };
18
18
  const openAddGroupDialog = () => {
19
19
  store.auth.groupsDialogsState.addGroupDialogState.open = true;
@@ -33,7 +33,7 @@ var _default = (store, api, sharedActions) => {
33
33
  Object.assign(store.auth.groupsState, payload);
34
34
  };
35
35
  const resetUsersGroupsState = () => {
36
- store.auth.groupsState = (0, _helpers.deepClone)(_state.initialState);
36
+ (0, _helpers.deepResetState)(store, ['auth', 'groupsState'], _state.initialState);
37
37
  };
38
38
  const loadGroups = async () => {
39
39
  const key = _interfaces.GroupsStateKeys.GET_GROUPS;
@@ -16,7 +16,7 @@ var _default = (store, api, sharedActions) => {
16
16
  Object.assign(store.auth.impersonateState, state);
17
17
  };
18
18
  const resetImpersonateState = () => {
19
- store.auth.impersonateState = (0, _helpers.deepClone)(_state.initialState);
19
+ (0, _helpers.deepResetState)(store, ['auth', 'impersonateState'], _state.initialState);
20
20
  };
21
21
  const impersonate = async _payload => {
22
22
  const {
@@ -253,7 +253,7 @@ var _default = (store, api, sharedActions) => {
253
253
  Object.assign(store.auth.loginState, state);
254
254
  };
255
255
  const resetLoginState = () => {
256
- store.auth.loginState = (0, _helpers.deepClone)(_state.initialState);
256
+ (0, _helpers.deepResetState)(store, ['auth', 'loginState'], _state.initialState);
257
257
  };
258
258
  const requestAuthorize = async firstTime => {
259
259
  const calls = [];
@@ -8,19 +8,22 @@ exports.default = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _helpers = require("../helpers");
10
10
  var _interfaces = require("../interfaces");
11
- var _helpers2 = require("../../../helpers");
12
- var _state = require("../../MfaState/state");
11
+ var _interfaces2 = require("../../MfaState/interfaces");
13
12
  var _default = (store, api, sharedActions) => {
14
13
  const actions = sharedActions;
15
14
  const getMfaRequiredState = async user => {
16
15
  let step = _interfaces.LoginStep.loginWithTwoFactor;
17
- const mfaState = (0, _helpers2.deepClone)(_state.initialState);
16
+ const mfaState = {
17
+ step: _interfaces2.MFAStep.verify,
18
+ loading: false,
19
+ saving: false
20
+ };
18
21
  const loginState = store.auth.loginState;
19
22
  const {
20
23
  isAllowedToRemember,
21
24
  mfaDeviceExpiration
22
25
  } = await api.auth.checkIfAllowToRememberMfaDevice(user.mfaToken);
23
- const isEnrolled = !(user.hasOwnProperty('mfaEnrolled') && !user.mfaEnrolled);
26
+ const isEnrolled = !('mfaEnrolled' in user && !user.mfaEnrolled);
24
27
  if (isEnrolled) {
25
28
  Object.assign(mfaState, {
26
29
  mfaDevices: user.mfaDevices,
@@ -36,10 +36,10 @@ var _default = (store, api, sharedActions) => {
36
36
  Object.assign(store.auth.allAccountsState.selectedAccount, payload);
37
37
  };
38
38
  const resetAllAccountsState = () => {
39
- store.auth.allAccountsState = (0, _helpers.deepClone)(_state.initialState);
39
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsState'], _state.initialState);
40
40
  };
41
41
  const clearSelectedAccount = () => {
42
- store.auth.allAccountsState.selectedAccount = (0, _helpers.deepClone)(_state.initialState.selectedAccount);
42
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsState', 'selectedAccount'], _state.initialState.selectedAccount);
43
43
  };
44
44
  const selectAllAccountsState = () => {
45
45
  return store.auth.allAccountsState;
@@ -9,12 +9,11 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _helpers = require("../../../helpers");
10
10
  var _state = require("./state");
11
11
  var _default = (store, api, sharedActions) => {
12
- const dialogsInitialState = (0, _helpers.deepClone)(_state.initialState);
13
12
  const setAllAccountDialogsState = payload => {
14
13
  Object.assign(store.auth.allAccountsDialogsState, payload);
15
14
  };
16
15
  const resetAllAccountDialogsState = () => {
17
- store.auth.allAccountsDialogsState = (0, _helpers.deepClone)(_state.initialState);
16
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState'], _state.initialState);
18
17
  };
19
18
 
20
19
  // Create new account dialog
@@ -24,7 +23,7 @@ var _default = (store, api, sharedActions) => {
24
23
  }));
25
24
  };
26
25
  const closeCreateSubAccountDialog = () => {
27
- store.auth.allAccountsDialogsState.createSubAccountDialog = dialogsInitialState.createSubAccountDialog;
26
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState', 'createSubAccountDialog'], _state.initialState.createSubAccountDialog);
28
27
  };
29
28
 
30
29
  // Update account dialog
@@ -34,7 +33,7 @@ var _default = (store, api, sharedActions) => {
34
33
  }));
35
34
  };
36
35
  const closeUpdateSubAccountDialog = () => {
37
- store.auth.allAccountsDialogsState.updateSubAccountDialog = dialogsInitialState.updateSubAccountDialog;
36
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState', 'updateSubAccountDialog'], _state.initialState.updateSubAccountDialog);
38
37
  };
39
38
 
40
39
  // Enable sub account management dialog
@@ -44,7 +43,7 @@ var _default = (store, api, sharedActions) => {
44
43
  }));
45
44
  };
46
45
  const closeEnableSubAccountManagementDialog = () => {
47
- store.auth.allAccountsDialogsState.enableSubAccountManagementDialog = dialogsInitialState.enableSubAccountManagementDialog;
46
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState', 'enableSubAccountManagementDialog'], _state.initialState.enableSubAccountManagementDialog);
48
47
  };
49
48
 
50
49
  // Enable sub account management dialog
@@ -54,7 +53,7 @@ var _default = (store, api, sharedActions) => {
54
53
  }));
55
54
  };
56
55
  const closeUpdateSubAccountHierarchySettingsDialog = () => {
57
- store.auth.allAccountsDialogsState.updateSubAccountHierarchySettingsDialog = dialogsInitialState.updateSubAccountHierarchySettingsDialog;
56
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState', 'updateSubAccountHierarchySettingsDialog'], _state.initialState.updateSubAccountHierarchySettingsDialog);
58
57
  };
59
58
 
60
59
  // Disable sub account management dialog
@@ -64,7 +63,7 @@ var _default = (store, api, sharedActions) => {
64
63
  }));
65
64
  };
66
65
  const closeDisableSubAccountManagementDialog = () => {
67
- store.auth.allAccountsDialogsState.disableSubAccountManagementDialog = dialogsInitialState.disableSubAccountManagementDialog;
66
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState', 'disableSubAccountManagementDialog'], _state.initialState.disableSubAccountManagementDialog);
68
67
  };
69
68
 
70
69
  // Delete account dialog
@@ -74,7 +73,7 @@ var _default = (store, api, sharedActions) => {
74
73
  }));
75
74
  };
76
75
  const closeDeleteSubAccountDialog = () => {
77
- store.auth.allAccountsDialogsState.deleteSubAccountDialog = dialogsInitialState.deleteSubAccountDialog;
76
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState', 'deleteSubAccountDialog'], _state.initialState.deleteSubAccountDialog);
78
77
  };
79
78
 
80
79
  // Add users to account dialog
@@ -84,7 +83,7 @@ var _default = (store, api, sharedActions) => {
84
83
  }));
85
84
  };
86
85
  const closeAddUsersToAccountDialog = () => {
87
- store.auth.allAccountsDialogsState.addUsersToAccountDialog = dialogsInitialState.addUsersToAccountDialog;
86
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState', 'addUsersToAccountDialog'], _state.initialState.addUsersToAccountDialog);
88
87
  };
89
88
 
90
89
  // Delete user from account dialog
@@ -94,7 +93,7 @@ var _default = (store, api, sharedActions) => {
94
93
  }));
95
94
  };
96
95
  const closeDeleteUserFromAccountDialog = () => {
97
- store.auth.allAccountsDialogsState.deleteUserFromAccountDialog = dialogsInitialState.deleteUserFromAccountDialog;
96
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState', 'deleteUserFromAccountDialog'], _state.initialState.deleteUserFromAccountDialog);
98
97
  };
99
98
 
100
99
  // Edit user roles dialog
@@ -104,7 +103,7 @@ var _default = (store, api, sharedActions) => {
104
103
  }));
105
104
  };
106
105
  const closeEditUserRolesDialog = () => {
107
- store.auth.allAccountsDialogsState.editUserRolesDialog = dialogsInitialState.editUserRolesDialog;
106
+ (0, _helpers.deepResetState)(store, ['auth', 'allAccountsDialogsState', 'editUserRolesDialog'], _state.initialState.editUserRolesDialog);
108
107
  };
109
108
  return {
110
109
  setAllAccountDialogsState,
@@ -39,7 +39,7 @@ var _default = (store, api, sharedActions) => {
39
39
  Object.assign(store.auth.mfaState, state);
40
40
  };
41
41
  const resetMfaState = () => {
42
- store.auth.mfaState = (0, _helpers.deepClone)(_state.initialState);
42
+ (0, _helpers.deepResetState)(store, ['auth', 'mfaState'], _state.initialState);
43
43
  };
44
44
  const getMFADevices = async () => {
45
45
  setMfaState({
@@ -13,7 +13,7 @@ var _default = (store, api, sharedActions) => {
13
13
  Object.assign(store.auth.passkeysState, payload);
14
14
  };
15
15
  const resetPasskeysState = () => {
16
- store.auth.passkeysState = (0, _helpers.deepClone)(_state.initialState);
16
+ (0, _helpers.deepResetState)(store, ['auth', 'passkeysState'], _state.initialState);
17
17
  };
18
18
  const loadWebAuthnDevices = async () => {
19
19
  setPasskeysState({
@@ -16,7 +16,7 @@ var _default = (store, api, sharedActions) => {
16
16
  Object.assign(store.auth.profileState, state);
17
17
  };
18
18
  const resetProfileState = () => {
19
- store.auth.profileState = (0, _helpers.deepClone)(_state.initialState);
19
+ (0, _helpers.deepResetState)(store, ['auth', 'profileState'], _state.initialState);
20
20
  };
21
21
  const loadProfile = async () => {
22
22
  setProfileState({
@@ -17,7 +17,7 @@ var _default = (store, api, sharedActions) => {
17
17
  Object.assign(store.auth.provisioningState, state);
18
18
  };
19
19
  const resetProvisioningState = () => {
20
- store.auth.provisioningState = (0, _helpers.deepClone)(_state.initialState);
20
+ (0, _helpers.deepResetState)(store, ['auth', 'provisioningState'], _state.initialState);
21
21
  };
22
22
 
23
23
  /**
@@ -20,7 +20,7 @@ var _default = (store, api, sharedActions) => {
20
20
  Object.assign(store.auth.resetPhoneNumberState, state);
21
21
  };
22
22
  const resetResetPhoneNumberState = () => {
23
- store.auth.resetPhoneNumberState = (0, _helpers.deepClone)(_state.initialState);
23
+ (0, _helpers.deepResetState)(store, ['auth', 'resetPhoneNumberState'], _state.initialState);
24
24
  };
25
25
  const resetPhoneNumber = async payload => {
26
26
  const {
@@ -22,7 +22,7 @@ var _default = (store, api, sharedActions) => {
22
22
  Object.assign(store.auth.rolesState, state);
23
23
  };
24
24
  const resetRolesState = () => {
25
- store.auth.rolesState = (0, _helpers.deepClone)(_state.initialState);
25
+ (0, _helpers.deepResetState)(store, ['auth', 'rolesState'], _state.initialState);
26
26
  };
27
27
  const setRolesStateLoader = payload => {
28
28
  Object.assign(store.auth.rolesState, {
@@ -54,7 +54,7 @@ var _default = (store, api, sharedActions) => {
54
54
  Object.assign(store.auth.ssoState, state);
55
55
  };
56
56
  const resetSSOState = () => {
57
- store.auth.ssoState = (0, _helpers.deepClone)(_state.initialState);
57
+ (0, _helpers.deepResetState)(store, ['auth', 'ssoState'], _state.initialState);
58
58
  };
59
59
  const setSSOLoader = payload => {
60
60
  Object.assign(store.auth.ssoState, {
@@ -135,7 +135,7 @@ var _default = (store, api, sharedActions) => {
135
135
  Object.assign(store.auth.securityCenterState, state);
136
136
  };
137
137
  const resetSecurityCenterState = () => {
138
- store.auth.securityCenterState = (0, _helpers.deepClone)(_state.initialState);
138
+ (0, _helpers.deepResetState)(store, ['auth', 'securityCenterState'], _state.initialState);
139
139
  };
140
140
  const setSecurityCenterStateLoader = payload => {
141
141
  Object.assign(store.auth.securityCenterState, {
@@ -105,7 +105,7 @@ var _default = (store, api, sharedActions) => {
105
105
  Object.assign(store.auth.securityPolicyState.publicAuthStrategyPolicy, state);
106
106
  };
107
107
  const resetSecurityPolicyState = () => {
108
- store.auth.securityPolicyState = (0, _helpers.deepClone)(_state.initialState);
108
+ (0, _helpers.deepResetState)(store, ['auth', 'securityPolicyState'], _state.initialState);
109
109
  };
110
110
  const loadSecurityPolicy = async () => {
111
111
  await Promise.all([loadGlobalSecurityPolicy(), loadSecurityPolicyMfa(), loadSecurityPolicyVendorMfa(), loadSecurityPolicyLockout(), loadSecurityPolicyVendorLockout(), loadSecurityPolicyVendorPasswordHistory(), loadSecurityPolicyCaptcha(), loadPublicAuthStrategiesPolicy()]);
@@ -15,7 +15,7 @@ var _default = (store, api, sharedActions) => {
15
15
  Object.assign(store.auth.sessionsPolicyState, state);
16
16
  };
17
17
  const resetSessionsPolicyState = () => {
18
- store.auth.sessionsPolicyState = (0, _helpers.deepClone)(_state.initialState);
18
+ (0, _helpers.deepResetState)(store, ['auth', 'sessionsPolicyState'], _state.initialState);
19
19
  };
20
20
  const loadSessionsPolicy = async () => {
21
21
  setSessionsPolicyState({
@@ -11,7 +11,7 @@ var _default = (store, api, sharedActions) => {
11
11
  Object.assign(store.auth.sessionsState, state);
12
12
  };
13
13
  const resetSessionsState = () => {
14
- store.auth.sessionsState = (0, _helpers.deepClone)(_state.initialState);
14
+ (0, _helpers.deepResetState)(store, ['auth', 'sessionsState'], _state.initialState);
15
15
  };
16
16
  const loadUserSessions = async () => {
17
17
  setSessionsState({