@frontegg/redux-store 6.122.0 → 6.123.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.
Files changed (75) hide show
  1. package/auth/AcceptInvitationState/index.d.ts +0 -2
  2. package/auth/AccountSettingsState/index.d.ts +0 -2
  3. package/auth/ActivateState/index.d.ts +0 -3
  4. package/auth/ApiTokensState/index.d.ts +0 -2
  5. package/auth/CustomLoginState/index.d.ts +0 -2
  6. package/auth/Entitlements/index.d.ts +2 -0
  7. package/auth/Entitlements/index.js +4 -0
  8. package/auth/{EntitlementsState → Entitlements}/interfaces.d.ts +1 -6
  9. package/auth/Entitlements/saga.d.ts +28 -0
  10. package/auth/Entitlements/saga.js +48 -0
  11. package/auth/{EntitlementsState → Entitlements}/utils.d.ts +5 -8
  12. package/auth/{EntitlementsState → Entitlements}/utils.js +13 -17
  13. package/auth/ForgotPasswordState/index.d.ts +0 -2
  14. package/auth/GroupsState/groupsDialogsState.d.ts +0 -12
  15. package/auth/GroupsState/index.d.ts +0 -2
  16. package/auth/ImpersonationState/index.d.ts +0 -2
  17. package/auth/LoginState/index.d.ts +0 -2
  18. package/auth/LoginState/interfaces.d.ts +0 -1
  19. package/auth/LoginState/interfaces.js +1 -2
  20. package/auth/LoginState/saga.d.ts +2 -2
  21. package/auth/LoginState/saga.js +36 -26
  22. package/auth/MSP/AllAccountsState/allAccountsDialogsState.d.ts +0 -14
  23. package/auth/MSP/AllAccountsState/index.d.ts +0 -3
  24. package/auth/MfaState/index.d.ts +0 -2
  25. package/auth/PasskeysState/index.d.ts +0 -2
  26. package/auth/ProfileState/index.d.ts +0 -2
  27. package/auth/Provisioning/index.d.ts +0 -2
  28. package/auth/ResetPhoneNumberState/index.d.ts +0 -2
  29. package/auth/RestrictionsState/index.d.ts +12 -15
  30. package/auth/RolesState/index.d.ts +0 -2
  31. package/auth/SSOState/index.d.ts +0 -2
  32. package/auth/SecurityCenterState/index.d.ts +4 -6
  33. package/auth/SecurityCenterState/index.js +2 -2
  34. package/auth/SecurityCenterState/saga.d.ts +2 -2
  35. package/auth/SecurityCenterState/saga.js +4 -4
  36. package/auth/SecurityPolicyState/index.d.ts +0 -13
  37. package/auth/SessionsPolicyState/index.d.ts +0 -2
  38. package/auth/SessionsState/index.d.ts +0 -2
  39. package/auth/SignUp/index.d.ts +0 -2
  40. package/auth/SocialLogins/index.d.ts +0 -2
  41. package/auth/TeamState/index.d.ts +0 -2
  42. package/auth/TenantsState/index.d.ts +0 -2
  43. package/auth/index.d.ts +6 -6
  44. package/auth/index.js +2 -2
  45. package/auth/initialState.js +1 -3
  46. package/auth/interfaces.d.ts +0 -2
  47. package/auth/reducer.d.ts +8 -6
  48. package/auth/reducer.js +8 -6
  49. package/auth/saga.js +1 -1
  50. package/auth/utils.d.ts +0 -6
  51. package/index.js +1 -1
  52. package/node/auth/Entitlements/index.js +27 -0
  53. package/node/auth/Entitlements/saga.js +57 -0
  54. package/node/auth/{EntitlementsState → Entitlements}/utils.js +12 -16
  55. package/node/auth/LoginState/interfaces.js +1 -4
  56. package/node/auth/LoginState/saga.js +34 -25
  57. package/node/auth/SecurityCenterState/index.js +2 -2
  58. package/node/auth/SecurityCenterState/saga.js +6 -6
  59. package/node/auth/index.js +5 -5
  60. package/node/auth/initialState.js +1 -3
  61. package/node/auth/reducer.js +6 -4
  62. package/node/auth/saga.js +8 -8
  63. package/node/index.js +1 -1
  64. package/node/toolkit/index.js +2 -5
  65. package/package.json +1 -1
  66. package/toolkit/index.d.ts +2 -3
  67. package/toolkit/index.js +2 -5
  68. package/auth/EntitlementsState/index.d.ts +0 -72
  69. package/auth/EntitlementsState/index.js +0 -29
  70. package/auth/EntitlementsState/saga.d.ts +0 -10
  71. package/auth/EntitlementsState/saga.js +0 -40
  72. package/node/auth/EntitlementsState/index.js +0 -52
  73. package/node/auth/EntitlementsState/saga.js +0 -47
  74. /package/auth/{EntitlementsState → Entitlements}/interfaces.js +0 -0
  75. /package/node/auth/{EntitlementsState → Entitlements}/interfaces.js +0 -0
@@ -49,7 +49,6 @@ declare const reducers: {
49
49
  customLoginState?: import("..").CustomLoginState | undefined;
50
50
  allAccountsState?: import("..").IAllAccountsState | undefined;
51
51
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
52
- entitlementsState?: import("..").EntitlementsState | undefined;
53
52
  securityCenterState?: import("..").SecurityCenterState | undefined;
54
53
  routes: import("..").AuthPageRoutes;
55
54
  header?: any;
@@ -96,7 +95,6 @@ declare const reducers: {
96
95
  customLoginState?: import("..").CustomLoginState | undefined;
97
96
  allAccountsState?: import("..").IAllAccountsState | undefined;
98
97
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
99
- entitlementsState?: import("..").EntitlementsState | undefined;
100
98
  securityCenterState?: import("..").SecurityCenterState | undefined;
101
99
  routes: import("..").AuthPageRoutes;
102
100
  header?: any;
@@ -50,7 +50,6 @@ declare const reducers: {
50
50
  customLoginState?: import("..").CustomLoginState | undefined;
51
51
  allAccountsState?: import("..").IAllAccountsState | undefined;
52
52
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
53
- entitlementsState?: import("..").EntitlementsState | undefined;
54
53
  securityCenterState?: import("..").SecurityCenterState | undefined;
55
54
  routes: import("..").AuthPageRoutes;
56
55
  header?: any;
@@ -97,7 +96,6 @@ declare const reducers: {
97
96
  customLoginState?: import("..").CustomLoginState | undefined;
98
97
  allAccountsState?: import("..").IAllAccountsState | undefined;
99
98
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
100
- entitlementsState?: import("..").EntitlementsState | undefined;
101
99
  securityCenterState?: import("..").SecurityCenterState | undefined;
102
100
  routes: import("..").AuthPageRoutes;
103
101
  header?: any;
@@ -50,7 +50,6 @@ declare const reducers: {
50
50
  customLoginState?: import("..").CustomLoginState | undefined;
51
51
  allAccountsState?: import("..").IAllAccountsState | undefined;
52
52
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
53
- entitlementsState?: import("..").EntitlementsState | undefined;
54
53
  securityCenterState?: import("..").SecurityCenterState | undefined;
55
54
  routes: import("..").AuthPageRoutes;
56
55
  header?: any;
@@ -97,7 +96,6 @@ declare const reducers: {
97
96
  customLoginState?: import("..").CustomLoginState | undefined;
98
97
  allAccountsState?: import("..").IAllAccountsState | undefined;
99
98
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
100
- entitlementsState?: import("..").EntitlementsState | undefined;
101
99
  securityCenterState?: import("..").SecurityCenterState | undefined;
102
100
  routes: import("..").AuthPageRoutes;
103
101
  header?: any;
@@ -150,7 +148,6 @@ declare const reducers: {
150
148
  customLoginState?: import("..").CustomLoginState | undefined;
151
149
  allAccountsState?: import("..").IAllAccountsState | undefined;
152
150
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
153
- entitlementsState?: import("..").EntitlementsState | undefined;
154
151
  securityCenterState?: import("..").SecurityCenterState | undefined;
155
152
  routes: import("..").AuthPageRoutes;
156
153
  header?: any;
@@ -67,7 +67,6 @@ declare const reducers: {
67
67
  customLoginState?: import("..").CustomLoginState | undefined;
68
68
  allAccountsState?: import("..").IAllAccountsState | undefined;
69
69
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
70
- entitlementsState?: import("..").EntitlementsState | undefined;
71
70
  securityCenterState?: import("..").SecurityCenterState | undefined;
72
71
  routes: import("..").AuthPageRoutes;
73
72
  header?: any;
@@ -114,7 +113,6 @@ declare const reducers: {
114
113
  customLoginState?: import("..").CustomLoginState | undefined;
115
114
  allAccountsState?: import("..").IAllAccountsState | undefined;
116
115
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
117
- entitlementsState?: import("..").EntitlementsState | undefined;
118
116
  securityCenterState?: import("..").SecurityCenterState | undefined;
119
117
  routes: import("..").AuthPageRoutes;
120
118
  header?: any;
@@ -49,7 +49,6 @@ declare const reducers: {
49
49
  customLoginState?: CustomLoginState | undefined;
50
50
  allAccountsState?: import("..").IAllAccountsState | undefined;
51
51
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
52
- entitlementsState?: import("..").EntitlementsState | undefined;
53
52
  securityCenterState?: import("..").SecurityCenterState | undefined;
54
53
  routes: import("..").AuthPageRoutes;
55
54
  header?: any;
@@ -96,7 +95,6 @@ declare const reducers: {
96
95
  customLoginState?: CustomLoginState | undefined;
97
96
  allAccountsState?: import("..").IAllAccountsState | undefined;
98
97
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
99
- entitlementsState?: import("..").EntitlementsState | undefined;
100
98
  securityCenterState?: import("..").SecurityCenterState | undefined;
101
99
  routes: import("..").AuthPageRoutes;
102
100
  header?: any;
@@ -0,0 +1,2 @@
1
+ export * from './saga';
2
+ export * from './utils';
@@ -0,0 +1,4 @@
1
+ // Pay attention: Entitlements is not stored as a slice in the state, but as part of User
2
+
3
+ export * from './saga';
4
+ export * from './utils';
@@ -1,9 +1,4 @@
1
- import { WithStatus } from '../../interfaces';
2
- import { UserEntitlementsResponse, NotEntitledReason } from '@frontegg/rest-api';
3
- export declare type EntitlementsState = WithStatus & {
4
- entitlements: UserEntitlementsResponse | undefined;
5
- options?: EntitlementsOptions | undefined;
6
- };
1
+ import { NotEntitledReason } from '@frontegg/rest-api';
7
2
  export interface EntitlementsOptions {
8
3
  enabled: boolean;
9
4
  }
@@ -0,0 +1,28 @@
1
+ import { UserEntitlementsResponse } from '@frontegg/rest-api';
2
+ /**
3
+ * @param oldEntitlements
4
+ * @param newEntitlements
5
+ * @returns true when there is a change between old and new entitlements
6
+ */
7
+ export declare function isEntitlementsChanged(oldEntitlements: UserEntitlementsResponse | undefined, newEntitlements: UserEntitlementsResponse | undefined): boolean;
8
+ /**
9
+ * Handle fetched entitlements response by deep comparison with the stored entitlements to prevent
10
+ * useless renders due to store update
11
+ * Updating loading state anyway
12
+ * @param newEntitlementsResponse
13
+ */
14
+ export declare function handleFetchedEntitlements(newEntitlementsResponse: UserEntitlementsResponse): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<{
15
+ payload: Partial<UserEntitlementsResponse>;
16
+ type: string;
17
+ }>, void, UserEntitlementsResponse>;
18
+ /**
19
+ * Load entitlements list
20
+ * Don't update entitlements data in the store when data is equal (deep check) to the existing store data
21
+ * @param _ saga default argument for dispatched actions
22
+ * @param callback called to notify the caller that the call is completed (for loading state)
23
+ */
24
+ export declare function loadEntitlements(_: any, callback?: () => void): Generator<Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<{
25
+ payload: Partial<UserEntitlementsResponse>;
26
+ type: string;
27
+ }>, void, UserEntitlementsResponse> | import("redux-saga/effects").CallEffect<UserEntitlementsResponse>, void, UserEntitlementsResponse>;
28
+ export declare function entitlementsSagas(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
@@ -0,0 +1,48 @@
1
+ import isEqual from 'fast-deep-equal';
2
+ import { call, put, takeLeading, select } from 'redux-saga/effects';
3
+ import { api } from '@frontegg/rest-api';
4
+ import { actions } from '../reducer';
5
+
6
+ /**
7
+ * @param oldEntitlements
8
+ * @param newEntitlements
9
+ * @returns true when there is a change between old and new entitlements
10
+ */
11
+ export function isEntitlementsChanged(oldEntitlements, newEntitlements) {
12
+ return isEqual(oldEntitlements, newEntitlements);
13
+ }
14
+
15
+ /**
16
+ * Handle fetched entitlements response by deep comparison with the stored entitlements to prevent
17
+ * useless renders due to store update
18
+ * Updating loading state anyway
19
+ * @param newEntitlementsResponse
20
+ */
21
+ export function* handleFetchedEntitlements(newEntitlementsResponse) {
22
+ const oldEntitlements = yield select(state => {
23
+ var _state$auth$user;
24
+ return (_state$auth$user = state.auth.user) == null ? void 0 : _state$auth$user.entitlements;
25
+ });
26
+ if (isEntitlementsChanged(oldEntitlements, newEntitlementsResponse)) {
27
+ return;
28
+ }
29
+ yield put(actions.setEntitlements(newEntitlementsResponse));
30
+ }
31
+
32
+ /**
33
+ * Load entitlements list
34
+ * Don't update entitlements data in the store when data is equal (deep check) to the existing store data
35
+ * @param _ saga default argument for dispatched actions
36
+ * @param callback called to notify the caller that the call is completed (for loading state)
37
+ */
38
+ export function* loadEntitlements(_, callback) {
39
+ try {
40
+ const entitlements = yield call(api.entitlements.loadEntitlements);
41
+ yield handleFetchedEntitlements(entitlements);
42
+ } catch (e) {} finally {
43
+ callback == null ? void 0 : callback();
44
+ }
45
+ }
46
+ export function* entitlementsSagas() {
47
+ yield takeLeading(actions.loadEntitlements, loadEntitlements);
48
+ }
@@ -1,26 +1,23 @@
1
1
  import { UserEntitlementsResponse } from '@frontegg/rest-api';
2
- import { EntitlementsOptions, EntitledToOptions, Entitlement } from './interfaces';
2
+ import { EntitledToOptions, Entitlement } from './interfaces';
3
3
  /**
4
4
  @param entitlements
5
5
  @param key
6
- @param entitlementsVendorConfig entitlements frontegg provider configuration
7
6
  @returns if the user is entitled to the given permission. Attaching the justification if not
8
7
  @throws when entitlement is not enabled via frontegg options
9
8
  */
10
- export declare const getPermissionEntitlements: (entitlements: UserEntitlementsResponse | undefined, key: string, entitlementsVendorConfig: EntitlementsOptions | undefined) => Entitlement;
9
+ export declare const getPermissionEntitlements: (entitlements: UserEntitlementsResponse | undefined, key: string) => Entitlement;
11
10
  /**
12
11
  @param entitlements
13
12
  @param key
14
- @param entitlementsVendorConfig entitlements frontegg provider configuration
15
13
  @returns if the user is entitled to the given feature. Attaching the justification if not
16
14
  @throws when entitlement is not enabled via frontegg options
17
15
  */
18
- export declare const getFeatureEntitlements: (entitlements: UserEntitlementsResponse | undefined, key: string, entitlementsVendorConfig: EntitlementsOptions | undefined) => Entitlement;
16
+ export declare const getFeatureEntitlements: (entitlements: UserEntitlementsResponse | undefined, key: string) => Entitlement;
19
17
  /**
20
18
  @param entitlements
21
- @param entitledToOptions including permission or feature
22
- @param entitlementsVendorConfig entitlements frontegg provider configuration
19
+ @param options including permission or feature
23
20
  @returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
24
21
  @throws when entitlement is not enabled via frontegg options
25
22
  */
26
- export declare const getEntitlements: (entitlements: UserEntitlementsResponse | undefined, options: EntitledToOptions, entitlementsVendorConfig: EntitlementsOptions | undefined) => Entitlement;
23
+ export declare const getEntitlements: (entitlements: UserEntitlementsResponse | undefined, options: EntitledToOptions) => Entitlement;
@@ -1,24 +1,23 @@
1
- import { NotEntitledReason } from '@frontegg/rest-api';
1
+ import { NotEntitledReason, ContextHolder } from '@frontegg/rest-api';
2
2
  const ENTITLEMENTS_NOT_ENABLED_EXCEPTION_TEXT = 'You must first enable entitlements via Frontegg options to use this function';
3
3
 
4
4
  /**
5
5
  * Guard entitlements feature by checking if it is enabled by the vendor
6
6
  * @throws when entitlement is not enabled via frontegg options
7
7
  */
8
- const guardEntitlementsUsage = entitlementsOptions => {
9
- if (entitlementsOptions != null && entitlementsOptions.enabled) return;
8
+ const guardEntitlementsUsage = () => {
9
+ if (ContextHolder.shouldLoadEntitlements()) return;
10
10
  throw new Error(ENTITLEMENTS_NOT_ENABLED_EXCEPTION_TEXT);
11
11
  };
12
12
 
13
13
  /**
14
14
  @param keyEntitlements permission or feature data object
15
- @param entitlementsVendorConfig entitlements frontegg provider configuration
16
15
  @param missingKeyEnum missing key for scenario that the key does not exist in entitlementsValuePerKeys
17
16
  @returns if the user is entitled to the given key. Attaching the justification if not
18
17
  @throws when entitlement is not enabled via frontegg options
19
18
  */
20
- const getEntitlementsHelper = (keyEntitlements, entitlementsVendorConfig, missingKeyEnum) => {
21
- guardEntitlementsUsage(entitlementsVendorConfig);
19
+ const getEntitlementsHelper = (keyEntitlements, missingKeyEnum) => {
20
+ guardEntitlementsUsage();
22
21
  if (!keyEntitlements) {
23
22
  return {
24
23
  isEntitled: false,
@@ -39,37 +38,34 @@ const getEntitlementsHelper = (keyEntitlements, entitlementsVendorConfig, missin
39
38
  /**
40
39
  @param entitlements
41
40
  @param key
42
- @param entitlementsVendorConfig entitlements frontegg provider configuration
43
41
  @returns if the user is entitled to the given permission. Attaching the justification if not
44
42
  @throws when entitlement is not enabled via frontegg options
45
43
  */
46
- export const getPermissionEntitlements = (entitlements, key, entitlementsVendorConfig) => {
44
+ export const getPermissionEntitlements = (entitlements, key) => {
47
45
  var _entitlements$permiss;
48
- return getEntitlementsHelper(entitlements == null ? void 0 : (_entitlements$permiss = entitlements.permissions) == null ? void 0 : _entitlements$permiss[key], entitlementsVendorConfig, NotEntitledReason.MISSING_PERMISSION);
46
+ return getEntitlementsHelper(entitlements == null ? void 0 : (_entitlements$permiss = entitlements.permissions) == null ? void 0 : _entitlements$permiss[key], NotEntitledReason.MISSING_PERMISSION);
49
47
  };
50
48
 
51
49
  /**
52
50
  @param entitlements
53
51
  @param key
54
- @param entitlementsVendorConfig entitlements frontegg provider configuration
55
52
  @returns if the user is entitled to the given feature. Attaching the justification if not
56
53
  @throws when entitlement is not enabled via frontegg options
57
54
  */
58
- export const getFeatureEntitlements = (entitlements, key, entitlementsVendorConfig) => {
55
+ export const getFeatureEntitlements = (entitlements, key) => {
59
56
  var _entitlements$feature;
60
- return getEntitlementsHelper(entitlements == null ? void 0 : (_entitlements$feature = entitlements.features) == null ? void 0 : _entitlements$feature[key], entitlementsVendorConfig, NotEntitledReason.MISSING_FEATURE);
57
+ return getEntitlementsHelper(entitlements == null ? void 0 : (_entitlements$feature = entitlements.features) == null ? void 0 : _entitlements$feature[key], NotEntitledReason.MISSING_FEATURE);
61
58
  };
62
59
 
63
60
  /**
64
61
  @param entitlements
65
- @param entitledToOptions including permission or feature
66
- @param entitlementsVendorConfig entitlements frontegg provider configuration
62
+ @param options including permission or feature
67
63
  @returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
68
64
  @throws when entitlement is not enabled via frontegg options
69
65
  */
70
- export const getEntitlements = (entitlements, options, entitlementsVendorConfig) => {
66
+ export const getEntitlements = (entitlements, options) => {
71
67
  if ('permissionKey' in options) {
72
- return getPermissionEntitlements(entitlements, options.permissionKey, entitlementsVendorConfig);
68
+ return getPermissionEntitlements(entitlements, options.permissionKey);
73
69
  }
74
- return getFeatureEntitlements(entitlements, options.featureKey, entitlementsVendorConfig);
70
+ return getFeatureEntitlements(entitlements, options.featureKey);
75
71
  };
@@ -49,7 +49,6 @@ declare const reducers: {
49
49
  customLoginState?: import("..").CustomLoginState | undefined;
50
50
  allAccountsState?: import("..").IAllAccountsState | undefined;
51
51
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
52
- entitlementsState?: import("..").EntitlementsState | undefined;
53
52
  securityCenterState?: import("..").SecurityCenterState | undefined;
54
53
  routes: import("..").AuthPageRoutes;
55
54
  header?: any;
@@ -96,7 +95,6 @@ declare const reducers: {
96
95
  customLoginState?: import("..").CustomLoginState | undefined;
97
96
  allAccountsState?: import("..").IAllAccountsState | undefined;
98
97
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
99
- entitlementsState?: import("..").EntitlementsState | undefined;
100
98
  securityCenterState?: import("..").SecurityCenterState | undefined;
101
99
  routes: import("..").AuthPageRoutes;
102
100
  header?: any;
@@ -48,7 +48,6 @@ declare const reducers: {
48
48
  customLoginState?: import("..").CustomLoginState | undefined;
49
49
  allAccountsState?: import("..").IAllAccountsState | undefined;
50
50
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
51
- entitlementsState?: import("..").EntitlementsState | undefined;
52
51
  securityCenterState?: import("..").SecurityCenterState | undefined;
53
52
  routes: import("..").AuthPageRoutes;
54
53
  header?: any;
@@ -95,7 +94,6 @@ declare const reducers: {
95
94
  customLoginState?: import("..").CustomLoginState | undefined;
96
95
  allAccountsState?: import("..").IAllAccountsState | undefined;
97
96
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
98
- entitlementsState?: import("..").EntitlementsState | undefined;
99
97
  securityCenterState?: import("..").SecurityCenterState | undefined;
100
98
  routes: import("..").AuthPageRoutes;
101
99
  header?: any;
@@ -141,7 +139,6 @@ declare const reducers: {
141
139
  customLoginState?: import("..").CustomLoginState | undefined;
142
140
  allAccountsState?: import("..").IAllAccountsState | undefined;
143
141
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
144
- entitlementsState?: import("..").EntitlementsState | undefined;
145
142
  securityCenterState?: import("..").SecurityCenterState | undefined;
146
143
  routes: import("..").AuthPageRoutes;
147
144
  header?: any;
@@ -187,7 +184,6 @@ declare const reducers: {
187
184
  customLoginState?: import("..").CustomLoginState | undefined;
188
185
  allAccountsState?: import("..").IAllAccountsState | undefined;
189
186
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
190
- entitlementsState?: import("..").EntitlementsState | undefined;
191
187
  securityCenterState?: import("..").SecurityCenterState | undefined;
192
188
  routes: import("..").AuthPageRoutes;
193
189
  header?: any;
@@ -240,7 +236,6 @@ declare const reducers: {
240
236
  customLoginState?: import("..").CustomLoginState | undefined;
241
237
  allAccountsState?: import("..").IAllAccountsState | undefined;
242
238
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
243
- entitlementsState?: import("..").EntitlementsState | undefined;
244
239
  securityCenterState?: import("..").SecurityCenterState | undefined;
245
240
  routes: import("..").AuthPageRoutes;
246
241
  header?: any;
@@ -287,7 +282,6 @@ declare const reducers: {
287
282
  customLoginState?: import("..").CustomLoginState | undefined;
288
283
  allAccountsState?: import("..").IAllAccountsState | undefined;
289
284
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
290
- entitlementsState?: import("..").EntitlementsState | undefined;
291
285
  securityCenterState?: import("..").SecurityCenterState | undefined;
292
286
  routes: import("..").AuthPageRoutes;
293
287
  header?: any;
@@ -361,7 +355,6 @@ declare const reducers: {
361
355
  customLoginState?: import("..").CustomLoginState | undefined;
362
356
  allAccountsState?: import("..").IAllAccountsState | undefined;
363
357
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
364
- entitlementsState?: import("..").EntitlementsState | undefined;
365
358
  securityCenterState?: import("..").SecurityCenterState | undefined;
366
359
  routes: import("..").AuthPageRoutes;
367
360
  header?: any;
@@ -408,7 +401,6 @@ declare const reducers: {
408
401
  customLoginState?: import("..").CustomLoginState | undefined;
409
402
  allAccountsState?: import("..").IAllAccountsState | undefined;
410
403
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
411
- entitlementsState?: import("..").EntitlementsState | undefined;
412
404
  securityCenterState?: import("..").SecurityCenterState | undefined;
413
405
  routes: import("..").AuthPageRoutes;
414
406
  header?: any;
@@ -454,7 +446,6 @@ declare const reducers: {
454
446
  customLoginState?: import("..").CustomLoginState | undefined;
455
447
  allAccountsState?: import("..").IAllAccountsState | undefined;
456
448
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
457
- entitlementsState?: import("..").EntitlementsState | undefined;
458
449
  securityCenterState?: import("..").SecurityCenterState | undefined;
459
450
  routes: import("..").AuthPageRoutes;
460
451
  header?: any;
@@ -500,7 +491,6 @@ declare const reducers: {
500
491
  customLoginState?: import("..").CustomLoginState | undefined;
501
492
  allAccountsState?: import("..").IAllAccountsState | undefined;
502
493
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
503
- entitlementsState?: import("..").EntitlementsState | undefined;
504
494
  securityCenterState?: import("..").SecurityCenterState | undefined;
505
495
  routes: import("..").AuthPageRoutes;
506
496
  header?: any;
@@ -553,7 +543,6 @@ declare const reducers: {
553
543
  customLoginState?: import("..").CustomLoginState | undefined;
554
544
  allAccountsState?: import("..").IAllAccountsState | undefined;
555
545
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
556
- entitlementsState?: import("..").EntitlementsState | undefined;
557
546
  securityCenterState?: import("..").SecurityCenterState | undefined;
558
547
  routes: import("..").AuthPageRoutes;
559
548
  header?: any;
@@ -600,7 +589,6 @@ declare const reducers: {
600
589
  customLoginState?: import("..").CustomLoginState | undefined;
601
590
  allAccountsState?: import("..").IAllAccountsState | undefined;
602
591
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
603
- entitlementsState?: import("..").EntitlementsState | undefined;
604
592
  securityCenterState?: import("..").SecurityCenterState | undefined;
605
593
  routes: import("..").AuthPageRoutes;
606
594
  header?: any;
@@ -66,7 +66,6 @@ declare const reducers: {
66
66
  customLoginState?: import("..").CustomLoginState | undefined;
67
67
  allAccountsState?: import("..").IAllAccountsState | undefined;
68
68
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
69
- entitlementsState?: import("..").EntitlementsState | undefined;
70
69
  securityCenterState?: import("..").SecurityCenterState | undefined;
71
70
  routes: import("..").AuthPageRoutes;
72
71
  header?: any;
@@ -113,7 +112,6 @@ declare const reducers: {
113
112
  customLoginState?: import("..").CustomLoginState | undefined;
114
113
  allAccountsState?: import("..").IAllAccountsState | undefined;
115
114
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
116
- entitlementsState?: import("..").EntitlementsState | undefined;
117
115
  securityCenterState?: import("..").SecurityCenterState | undefined;
118
116
  routes: import("..").AuthPageRoutes;
119
117
  header?: any;
@@ -49,7 +49,6 @@ declare const reducers: {
49
49
  customLoginState?: import("..").CustomLoginState | undefined;
50
50
  allAccountsState?: import("..").IAllAccountsState | undefined;
51
51
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
52
- entitlementsState?: import("..").EntitlementsState | undefined;
53
52
  securityCenterState?: import("..").SecurityCenterState | undefined;
54
53
  routes: import("..").AuthPageRoutes;
55
54
  header?: any;
@@ -96,7 +95,6 @@ declare const reducers: {
96
95
  customLoginState?: import("..").CustomLoginState | undefined;
97
96
  allAccountsState?: import("..").IAllAccountsState | undefined;
98
97
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
99
- entitlementsState?: import("..").EntitlementsState | undefined;
100
98
  securityCenterState?: import("..").SecurityCenterState | undefined;
101
99
  routes: import("..").AuthPageRoutes;
102
100
  header?: any;
@@ -51,7 +51,6 @@ declare const reducers: {
51
51
  customLoginState?: import("..").CustomLoginState | undefined;
52
52
  allAccountsState?: import("..").IAllAccountsState | undefined;
53
53
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
54
- entitlementsState?: import("..").EntitlementsState | undefined;
55
54
  securityCenterState?: import("..").SecurityCenterState | undefined;
56
55
  routes: import("..").AuthPageRoutes;
57
56
  header?: any;
@@ -98,7 +97,6 @@ declare const reducers: {
98
97
  customLoginState?: import("..").CustomLoginState | undefined;
99
98
  allAccountsState?: import("..").IAllAccountsState | undefined;
100
99
  allAccountsDialogsState?: import("..").IAllAccountsDialogsState | undefined;
101
- entitlementsState?: import("..").EntitlementsState | undefined;
102
100
  securityCenterState?: import("..").SecurityCenterState | undefined;
103
101
  routes: import("..").AuthPageRoutes;
104
102
  header?: any;
@@ -94,4 +94,3 @@ export declare type IVerifyMFAWebAuthnPayload = WithCallback<WithDeviceId<Omit<I
94
94
  export interface IRecoverMFATokenPayload extends WithCallback<IRecoverMFAToken> {
95
95
  recaptchaToken?: string;
96
96
  }
97
- export declare const ADMIN_PORTAL_ENTITLEMENTS_FF = "admin_portal_entitlements";
@@ -29,5 +29,4 @@ export let QuickLoginStrategy;
29
29
  QuickLoginStrategy["Android"] = "android";
30
30
  QuickLoginStrategy["Sms"] = "sms";
31
31
  })(QuickLoginStrategy || (QuickLoginStrategy = {}));
32
- export { AuthStrategyEnum };
33
- export const ADMIN_PORTAL_ENTITLEMENTS_FF = 'admin_portal_entitlements';
32
+ export { AuthStrategyEnum };
@@ -54,8 +54,8 @@ export declare function getMfaRequiredState(user: any): Generator<import("redux-
54
54
  isAllowedToRemember: any;
55
55
  mfaDeviceExpiration: any;
56
56
  }>;
57
- export declare function refreshToken(): Generator<import("redux-saga/effects").SelectEffect | Generator<import("redux-saga/effects").SelectEffect | CallEffect<boolean[]> | CallEffect<void>, void, (false & boolean[]) | (true & boolean[])> | CallEffect<any>, void, AuthState>;
58
- export declare function refreshTokenForSocialLogins(): Generator<import("redux-saga/effects").SelectEffect | Generator<import("redux-saga/effects").SelectEffect | CallEffect<boolean[]> | CallEffect<void>, void, (false & boolean[]) | (true & boolean[])> | CallEffect<any>, void, AuthState>;
57
+ export declare function refreshToken(): Generator<import("redux-saga/effects").SelectEffect | CallEffect<any>, void, AuthState>;
58
+ export declare function refreshTokenForSocialLogins(): Generator<import("redux-saga/effects").SelectEffect | CallEffect<any>, void, AuthState>;
59
59
  export declare function shouldShowPromptPasskeys(): Generator<import("redux-saga/effects").SelectEffect | CallEffect<boolean[]> | CallEffect<IWebAuthnDevices> | import("redux-saga/effects").PutEffect<{
60
60
  payload: Partial<import("../..").PasskeysState>;
61
61
  type: string;
@@ -26,7 +26,7 @@ import { api, AuthStrategyEnum, ContextHolder, fetch, WebAuthnDeviceType } from
26
26
  import { actions } from '../reducer';
27
27
  import { FRONTEGG_AFTER_AUTH_REDIRECT_URL, HOSTED_LOGIN_VERIFIER_KEY } from '../../constants';
28
28
  import { UserVeirifedOriginTypes } from '../interfaces';
29
- import { LoginFlow, LoginStep, ADMIN_PORTAL_ENTITLEMENTS_FF } from './interfaces';
29
+ import { LoginFlow, LoginStep } from './interfaces';
30
30
  import { loadAllowSignUps } from '../SignUp/saga';
31
31
  import { MFAStep } from '../MfaState/interfaces';
32
32
  import { dummyIps, userDemo } from '../dummy';
@@ -39,8 +39,29 @@ import { loadPublicAuthStrategiesPolicy } from '../SecurityPolicyState/saga';
39
39
  import { getPasskeysVendorPolicy } from '../PasskeysState/helpers';
40
40
  import { getPathAndSearchParamsFromUrl, getRedirectUrl, getSearchParamsFromUrl, getSearchParam, TENANT_ID_PARAM_KEY, getMfaStepForEnrolledUsers, getMfaStepForNotEnrolledUsers, isMfaRequired } from './utils';
41
41
  import { errorHandler } from '../../utils';
42
- import { loadEntitlements } from '../EntitlementsState/saga';
43
42
  import { authStrategyLoginStepMap } from './consts';
43
+ import { isEntitlementsChanged } from '../Entitlements';
44
+
45
+ /**
46
+ * Prevent unnecessary entitlements reference update inside the user object by
47
+ * deep equality with the stored user.entitlements
48
+ * This function should not be used for first login because no stored entitlements.
49
+ * @param updatedUser new user response from the BE
50
+ * @returns final user object with the correct entitlements reference
51
+ */
52
+ function* handleUnnecessaryEntitlementsUpdate(updatedUser) {
53
+ const oldEntitlements = yield select(state => {
54
+ var _state$auth$user;
55
+ return (_state$auth$user = state.auth.user) == null ? void 0 : _state$auth$user.entitlements;
56
+ });
57
+ if (isEntitlementsChanged(oldEntitlements, updatedUser == null ? void 0 : updatedUser.entitlements)) {
58
+ // set the previous entitlemenets object
59
+ return _extends({}, updatedUser, {
60
+ entitlements: oldEntitlements
61
+ });
62
+ }
63
+ return updatedUser;
64
+ }
44
65
  export function* afterAuthenticationStateUpdate({
45
66
  user,
46
67
  tenants = [],
@@ -191,23 +212,6 @@ function* shouldNevigateToRegisterQuickLogin(user) {
191
212
  const quickLoginToRegister = (_ref = localStorage.getItem('register-quick-login')) != null ? _ref : loginState.quickLoginToRegister;
192
213
  return quickLoginToRegister && localStorage.getItem(`${user.id}-${quickLoginToRegister}`) !== 'true' && !window.location.pathname.endsWith(routes.logoutUrl);
193
214
  }
194
- function* handleLoadEntitlements() {
195
- const isAuthenticated = yield select(state => {
196
- var _state$auth;
197
- return (_state$auth = state.auth) == null ? void 0 : _state$auth.isAuthenticated;
198
- });
199
- const isEntitlementsEnabledByUser = yield select(state => {
200
- var _state$auth2, _state$auth2$entitlem, _state$auth2$entitlem2;
201
- return (_state$auth2 = state.auth) == null ? void 0 : (_state$auth2$entitlem = _state$auth2.entitlementsState) == null ? void 0 : (_state$auth2$entitlem2 = _state$auth2$entitlem.options) == null ? void 0 : _state$auth2$entitlem2.enabled;
202
- });
203
- if (!isAuthenticated || !isEntitlementsEnabledByUser) {
204
- return;
205
- }
206
- const [isEntitlementsFFOn] = yield call(getFeatureFlags, [ADMIN_PORTAL_ENTITLEMENTS_FF]);
207
- if (isEntitlementsFFOn) {
208
- yield call(loadEntitlements);
209
- }
210
- }
211
215
  export function* refreshToken() {
212
216
  const {
213
217
  hostedLoginBox
@@ -217,7 +221,6 @@ export function* refreshToken() {
217
221
  } else {
218
222
  yield call(refreshTokenEmbedded);
219
223
  }
220
- yield handleLoadEntitlements();
221
224
  }
222
225
  export function* refreshTokenForSocialLogins() {
223
226
  const {
@@ -228,7 +231,6 @@ export function* refreshTokenForSocialLogins() {
228
231
  } else {
229
232
  yield call(refreshTokenEmbeddedSocialLogins);
230
233
  }
231
- yield handleLoadEntitlements();
232
234
  }
233
235
  function* refreshTokenHosted() {
234
236
  const {
@@ -249,7 +251,10 @@ function* refreshTokenHosted() {
249
251
  refresh_token: user == null ? void 0 : user.refreshToken
250
252
  };
251
253
  const response = yield call(api.auth.exchangeOAuthTokensV2, body);
252
- yield call(afterAuthenticationStateUpdate, response, {
254
+ const updatedUser = yield call(handleUnnecessaryEntitlementsUpdate, response.user);
255
+ yield call(afterAuthenticationStateUpdate, _extends({}, response, {
256
+ user: updatedUser
257
+ }), {
253
258
  isAuthenticated: true
254
259
  });
255
260
  } catch (e) {
@@ -280,7 +285,10 @@ function* refreshTokenHostedSocialLogins() {
280
285
  refresh_token: currentUser == null ? void 0 : currentUser.refreshToken
281
286
  };
282
287
  const response = yield call(api.auth.exchangeOAuthTokensV2, body);
283
- yield call(afterAuthenticationStateUpdate, response, {
288
+ const updatedUser = yield call(handleUnnecessaryEntitlementsUpdate, response.user);
289
+ yield call(afterAuthenticationStateUpdate, _extends({}, response, {
290
+ user: updatedUser
291
+ }), {
284
292
  isAuthenticated: true
285
293
  });
286
294
  } catch (e) {
@@ -317,8 +325,9 @@ function* refreshTokenEmbedded() {
317
325
  }
318
326
  const quickLoginToRegister = (_ref2 = localStorage.getItem('register-quick-login')) != null ? _ref2 : loginState.quickLoginToRegister;
319
327
  const shouldNavigateToRegisterQuickLogin = yield shouldNevigateToRegisterQuickLogin(user);
328
+ const updatedUser = yield call(handleUnnecessaryEntitlementsUpdate, user);
320
329
  yield call(afterAuthenticationStateUpdate, {
321
- user,
330
+ user: updatedUser,
322
331
  tenants,
323
332
  activeTenant
324
333
  }, {
@@ -358,6 +367,7 @@ function* refreshTokenEmbeddedSocialLogins() {
358
367
  preserveQueryParams: true
359
368
  });
360
369
  } else {
370
+ const updatedUser = yield call(handleUnnecessaryEntitlementsUpdate, user);
361
371
  const shouldShowPrompt = yield call(shouldShowPromptPasskeys);
362
372
  if (shouldShowPrompt) {
363
373
  yield put(actions.setLoginState({
@@ -365,7 +375,7 @@ function* refreshTokenEmbeddedSocialLogins() {
365
375
  loading: false
366
376
  }));
367
377
  yield call(afterAuthenticationStateUpdate, {
368
- user,
378
+ user: updatedUser,
369
379
  tenants,
370
380
  activeTenant
371
381
  }, {
@@ -382,7 +392,7 @@ function* refreshTokenEmbeddedSocialLogins() {
382
392
  const quickLoginToRegister = (_ref3 = localStorage.getItem('register-quick-login')) != null ? _ref3 : loginState.quickLoginToRegister;
383
393
  const shouldNavigateToRegisterQuickLogin = yield shouldNevigateToRegisterQuickLogin(user);
384
394
  yield call(afterAuthenticationStateUpdate, {
385
- user,
395
+ user: updatedUser,
386
396
  tenants,
387
397
  activeTenant
388
398
  }, {