@frontegg/redux-store 6.148.0-alpha.0 → 6.148.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.
@@ -1,4 +1,4 @@
1
- import { UserEntitlementsContext as UserEntitlementsResponseV2 } from '@frontegg/entitlements-javascript-commons';
1
+ import { UserEntitlementsResponse } from '@frontegg/rest-api';
2
2
  import { PayloadAction } from '@reduxjs/toolkit';
3
3
  import { LoadEntitlementsActionPayload } from './interfaces';
4
4
  /**
@@ -6,22 +6,25 @@ import { LoadEntitlementsActionPayload } from './interfaces';
6
6
  * @param newEntitlements
7
7
  * @returns true when old and new entitlements are deeply equal
8
8
  */
9
- export declare function isEntitlementsDeeplyEqual(oldEntitlements: UserEntitlementsResponseV2 | undefined, newEntitlements: UserEntitlementsResponseV2 | undefined): boolean;
9
+ export declare function isEntitlementsDeeplyEqual(oldEntitlements: UserEntitlementsResponse | undefined, newEntitlements: UserEntitlementsResponse | undefined): boolean;
10
10
  /**
11
11
  * Handle fetched entitlements response by deep comparison with the stored entitlements to prevent
12
12
  * useless renders due to store update
13
13
  * Updating loading state anyway
14
14
  * @param newEntitlementsResponse
15
15
  */
16
- export declare function handleFetchedEntitlements(newEntitlementsResponse: UserEntitlementsResponseV2): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<{
17
- payload: Partial<UserEntitlementsResponseV2>;
16
+ export declare function handleFetchedEntitlements(newEntitlementsResponse: UserEntitlementsResponse): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<{
17
+ payload: Partial<UserEntitlementsResponse>;
18
18
  type: string;
19
- }>, void, UserEntitlementsResponseV2>;
19
+ }>, void, UserEntitlementsResponse>;
20
20
  /**
21
21
  * Load entitlements data for saga action
22
22
  * Don't update entitlements data in the store when data is equal (deep check) to the existing store data
23
23
  * @param payloadAction saga payload action including a payload with/out a callback
24
24
  * The callback will be called on request completed with true if succeeded, false if failed
25
25
  */
26
- export declare function loadEntitlements({ payload }: PayloadAction<LoadEntitlementsActionPayload>): any;
26
+ export declare function loadEntitlements({ payload }: PayloadAction<LoadEntitlementsActionPayload>): Generator<Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<{
27
+ payload: Partial<UserEntitlementsResponse>;
28
+ type: string;
29
+ }>, void, UserEntitlementsResponse> | import("redux-saga/effects").CallEffect<UserEntitlementsResponse>, void, UserEntitlementsResponse>;
27
30
  export declare function entitlementsSagas(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
@@ -1,9 +1,7 @@
1
1
  import isEqual from 'fast-deep-equal';
2
2
  import { call, put, takeLeading, select } from 'redux-saga/effects';
3
- import { USE_ENTITLEMENTS_V2_ENDPOINT_FF, api } from '@frontegg/rest-api';
3
+ import { api } from '@frontegg/rest-api';
4
4
  import { actions } from '../reducer';
5
- import { getFeatureFlags } from '../../helpers';
6
-
7
5
  /**
8
6
  * @param oldEntitlements
9
7
  * @param newEntitlements
@@ -40,9 +38,8 @@ export function* loadEntitlements({
40
38
  payload
41
39
  }) {
42
40
  const callback = payload == null ? void 0 : payload.callback;
43
- const [useEntitlementsV2] = yield call(getFeatureFlags, [USE_ENTITLEMENTS_V2_ENDPOINT_FF]);
44
41
  try {
45
- const entitlements = yield call(useEntitlementsV2 ? api.entitlements.loadEntitlementsV2 : api.entitlements.loadEntitlements);
42
+ const entitlements = yield call(api.entitlements.loadEntitlements);
46
43
  yield handleFetchedEntitlements(entitlements);
47
44
  callback == null ? void 0 : callback(true);
48
45
  } catch (e) {
@@ -1,31 +1,23 @@
1
1
  import { UserEntitlementsResponse } from '@frontegg/rest-api';
2
2
  import { EntitledToOptions, Entitlement } from './interfaces';
3
- import { UserEntitlementsContext as UserEntitlementsResponseV2 } from '@frontegg/entitlements-javascript-commons';
4
- import { Attributes } from '@frontegg/entitlements-javascript-commons';
5
3
  /**
6
4
  @param entitlements
7
- @param key permission key
8
- @param attributes entitlements query attributes including comnsumer and frontegg attributes
9
- @param isV2 true when need to use entitlements API V2
5
+ @param key
10
6
  @returns if the user is entitled to the given permission. Attaching the justification if not
11
7
  @throws when entitlement is not enabled via frontegg options
12
8
  */
13
- export declare const getPermissionEntitlements: (entitlements: UserEntitlementsResponseV2 | UserEntitlementsResponse | undefined, key: string, attributes?: Attributes | undefined, isV2?: boolean | undefined) => Entitlement;
9
+ export declare const getPermissionEntitlements: (entitlements: UserEntitlementsResponse | undefined, key: string) => Entitlement;
14
10
  /**
15
11
  @param entitlements
16
- @param key feature key
17
- @param attributes entitlements query attributes including comnsumer and frontegg attributes
18
- @param isV2 true when need to use entitlements API V2
12
+ @param key
19
13
  @returns if the user is entitled to the given feature. Attaching the justification if not
20
14
  @throws when entitlement is not enabled via frontegg options
21
15
  */
22
- export declare const getFeatureEntitlements: (entitlements: UserEntitlementsResponseV2 | UserEntitlementsResponse | undefined, key: string, attributes?: Attributes | undefined, isV2?: boolean | undefined) => Entitlement;
16
+ export declare const getFeatureEntitlements: (entitlements: UserEntitlementsResponse | undefined, key: string) => Entitlement;
23
17
  /**
24
18
  @param entitlements
25
19
  @param options including permission or feature
26
- @param attributes entitlements query attributes including comnsumer and frontegg attributes
27
- @param isV2 true when need to use entitlements API V2
28
20
  @returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
29
21
  @throws when entitlement is not enabled via frontegg options
30
22
  */
31
- export declare const getEntitlements: (entitlements: UserEntitlementsResponseV2 | UserEntitlementsResponse | undefined, options: EntitledToOptions, attributes?: Attributes | undefined, isV2?: boolean | undefined) => Entitlement;
23
+ export declare const getEntitlements: (entitlements: UserEntitlementsResponse | undefined, options: EntitledToOptions) => Entitlement;
@@ -1,16 +1,4 @@
1
1
  import { NotEntitledJustification, ContextHolder } from '@frontegg/rest-api';
2
- import { evaluateIsEntitledToFeature, evaluateIsEntitledToPermissions } from '@frontegg/entitlements-javascript-commons';
3
- /**
4
- * NOTE: This file including the usage of user entitlements API V1 and V2. The BE API response is diffrent.
5
- * V1 is the initial implementation.
6
- * V2 is using the entitlenents package for Rule Based entitlements.
7
- *
8
- * V1 is still supported with feature flag but it's depracated.
9
- *
10
- * The entitlements query functions supports both APIs by an optional argument of [isV2] to decide what version to choose.
11
- * The function returns the same type.
12
- */
13
-
14
2
  const ENTITLEMENTS_NOT_ENABLED_EXCEPTION_TEXT = 'You must first enable entitlements via Frontegg options to use this function';
15
3
 
16
4
  /**
@@ -23,14 +11,13 @@ const guardEntitlementsUsage = () => {
23
11
  };
24
12
 
25
13
  /**
26
- For user entitlements API V1
27
-
28
14
  @param keyEntitlements permission or feature data object
29
15
  @param missingKeyEnum missing key for scenario that the key does not exist in entitlementsValuePerKeys
30
16
  @returns if the user is entitled to the given key. Attaching the justification if not
31
17
  @throws when entitlement is not enabled via frontegg options
32
18
  */
33
- const getEntitlementsHelperV1 = (keyEntitlements, missingKeyEnum) => {
19
+ const getEntitlementsHelper = (keyEntitlements, missingKeyEnum) => {
20
+ guardEntitlementsUsage();
34
21
  if (!keyEntitlements) {
35
22
  return {
36
23
  isEntitled: false,
@@ -50,49 +37,35 @@ const getEntitlementsHelperV1 = (keyEntitlements, missingKeyEnum) => {
50
37
 
51
38
  /**
52
39
  @param entitlements
53
- @param key permission key
54
- @param attributes entitlements query attributes including comnsumer and frontegg attributes
55
- @param isV2 true when need to use entitlements API V2
40
+ @param key
56
41
  @returns if the user is entitled to the given permission. Attaching the justification if not
57
42
  @throws when entitlement is not enabled via frontegg options
58
43
  */
59
- export const getPermissionEntitlements = (entitlements, key, attributes, isV2) => {
60
- var _permissions;
61
- guardEntitlementsUsage();
62
- if (isV2) {
63
- return evaluateIsEntitledToPermissions(key, entitlements, attributes);
64
- }
65
- return getEntitlementsHelperV1(entitlements == null ? void 0 : (_permissions = entitlements.permissions) == null ? void 0 : _permissions[key], NotEntitledJustification.MISSING_PERMISSION);
44
+ export const getPermissionEntitlements = (entitlements, key) => {
45
+ var _entitlements$permiss;
46
+ return getEntitlementsHelper(entitlements == null ? void 0 : (_entitlements$permiss = entitlements.permissions) == null ? void 0 : _entitlements$permiss[key], NotEntitledJustification.MISSING_PERMISSION);
66
47
  };
67
48
 
68
49
  /**
69
50
  @param entitlements
70
- @param key feature key
71
- @param attributes entitlements query attributes including comnsumer and frontegg attributes
72
- @param isV2 true when need to use entitlements API V2
51
+ @param key
73
52
  @returns if the user is entitled to the given feature. Attaching the justification if not
74
53
  @throws when entitlement is not enabled via frontegg options
75
54
  */
76
- export const getFeatureEntitlements = (entitlements, key, attributes, isV2) => {
77
- var _features;
78
- guardEntitlementsUsage();
79
- if (isV2) {
80
- return evaluateIsEntitledToFeature(key, entitlements, attributes);
81
- }
82
- return getEntitlementsHelperV1(entitlements == null ? void 0 : (_features = entitlements.features) == null ? void 0 : _features[key], NotEntitledJustification.MISSING_FEATURE);
55
+ export const getFeatureEntitlements = (entitlements, key) => {
56
+ var _entitlements$feature;
57
+ return getEntitlementsHelper(entitlements == null ? void 0 : (_entitlements$feature = entitlements.features) == null ? void 0 : _entitlements$feature[key], NotEntitledJustification.MISSING_FEATURE);
83
58
  };
84
59
 
85
60
  /**
86
61
  @param entitlements
87
62
  @param options including permission or feature
88
- @param attributes entitlements query attributes including comnsumer and frontegg attributes
89
- @param isV2 true when need to use entitlements API V2
90
63
  @returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
91
64
  @throws when entitlement is not enabled via frontegg options
92
65
  */
93
- export const getEntitlements = (entitlements, options, attributes, isV2) => {
66
+ export const getEntitlements = (entitlements, options) => {
94
67
  if ('permissionKey' in options) {
95
- return getPermissionEntitlements(entitlements, options.permissionKey, attributes, isV2);
68
+ return getPermissionEntitlements(entitlements, options.permissionKey);
96
69
  }
97
- return getFeatureEntitlements(entitlements, options.featureKey, attributes, isV2);
70
+ return getFeatureEntitlements(entitlements, options.featureKey);
98
71
  };
package/auth/index.d.ts CHANGED
@@ -756,7 +756,7 @@ declare const _default: {
756
756
  resetState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
757
757
  setState: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<import("./interfaces").AuthState>, string>;
758
758
  setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("./interfaces").User, string>;
759
- setEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("@frontegg/entitlements-javascript-commons").UserEntitlementsContext>], Partial<import("@frontegg/entitlements-javascript-commons").UserEntitlementsContext>, string, never, never>;
759
+ setEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("@frontegg/rest-api").UserEntitlementsResponse>], Partial<import("@frontegg/rest-api").UserEntitlementsResponse>, string, never, never>;
760
760
  loadEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(import("./Entitlements/interfaces").LoadEntitlementsActionPayload | undefined)?], import("./Entitlements/interfaces").LoadEntitlementsActionPayload | undefined, string, never, never>;
761
761
  };
762
762
  };
package/auth/reducer.d.ts CHANGED
@@ -27,7 +27,7 @@ import { AllAccountsActions } from './MSP/AllAccountsState';
27
27
  import { AllAccountsDialogsActions } from './MSP/AllAccountsState/allAccountsDialogsState';
28
28
  import { SecurityCenterActions } from './Security/SecurityCenterState';
29
29
  import { SmsActions } from './SmsState';
30
- import { UserEntitlementsContext as UserEntitlementsResponseV2 } from '@frontegg/entitlements-javascript-commons';
30
+ import { UserEntitlementsResponse } from '@frontegg/rest-api';
31
31
  import { LoadEntitlementsActionPayload } from './Entitlements/interfaces';
32
32
  declare const reducer: import("redux").Reducer<AuthState, import("redux").AnyAction>;
33
33
  declare const actions: {
@@ -715,14 +715,14 @@ declare const actions: {
715
715
  resetState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
716
716
  setState: import("@reduxjs/toolkit").ActionCreatorWithPayload<Partial<AuthState>, string>;
717
717
  setUser: import("@reduxjs/toolkit").ActionCreatorWithPayload<User, string>;
718
- setEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<UserEntitlementsResponseV2>], Partial<UserEntitlementsResponseV2>, string, never, never>;
718
+ setEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<UserEntitlementsResponse>], Partial<UserEntitlementsResponse>, string, never, never>;
719
719
  loadEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(LoadEntitlementsActionPayload | undefined)?], LoadEntitlementsActionPayload | undefined, string, never, never>;
720
720
  };
721
721
  export declare type RootActions = {
722
722
  setState: (state: Partial<AuthState>) => void;
723
723
  resetState: () => void;
724
724
  setUser: (user: User) => void;
725
- setEntitlements: (entitlements: Partial<UserEntitlementsResponseV2>) => void;
725
+ setEntitlements: (entitlements: Partial<UserEntitlementsResponse>) => void;
726
726
  loadEntitlements: (payload?: LoadEntitlementsActionPayload) => void;
727
727
  };
728
728
  export declare type AuthActions = RootActions & LoginActions & SocialLoginActions & ActivateAccountActions & ImpersonateActions & AcceptInvitationActions & ForgotPasswordActions & ResetPhoneNumberActions & SignUpActions & ProfileActions & CustomLoginActions & SSOActions & MfaActions & TeamActions & GroupsActions & GroupsDialogsActions & ApiTokensActions & SecurityPolicyActions & AccountSettingsActions & TenantsActions & RolesActions & SessionsActions & RestrictionsActions & ProvisioningActions & PasskeysActions & AllAccountsActions & AllAccountsDialogsActions & SecurityCenterActions & SmsActions;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.148.0-alpha.0
1
+ /** @license Frontegg v6.148.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.
@@ -12,7 +12,6 @@ var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
12
12
  var _effects = require("redux-saga/effects");
13
13
  var _restApi = require("@frontegg/rest-api");
14
14
  var _reducer = require("../reducer");
15
- var _helpers = require("../../helpers");
16
15
  /**
17
16
  * @param oldEntitlements
18
17
  * @param newEntitlements
@@ -49,9 +48,8 @@ function* loadEntitlements({
49
48
  payload
50
49
  }) {
51
50
  const callback = payload == null ? void 0 : payload.callback;
52
- const [useEntitlementsV2] = yield (0, _effects.call)(_helpers.getFeatureFlags, [_restApi.USE_ENTITLEMENTS_V2_ENDPOINT_FF]);
53
51
  try {
54
- const entitlements = yield (0, _effects.call)(useEntitlementsV2 ? _restApi.api.entitlements.loadEntitlementsV2 : _restApi.api.entitlements.loadEntitlements);
52
+ const entitlements = yield (0, _effects.call)(_restApi.api.entitlements.loadEntitlements);
55
53
  yield handleFetchedEntitlements(entitlements);
56
54
  callback == null ? void 0 : callback(true);
57
55
  } catch (e) {
@@ -5,18 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getPermissionEntitlements = exports.getFeatureEntitlements = exports.getEntitlements = void 0;
7
7
  var _restApi = require("@frontegg/rest-api");
8
- var _entitlementsJavascriptCommons = require("@frontegg/entitlements-javascript-commons");
9
- /**
10
- * NOTE: This file including the usage of user entitlements API V1 and V2. The BE API response is diffrent.
11
- * V1 is the initial implementation.
12
- * V2 is using the entitlenents package for Rule Based entitlements.
13
- *
14
- * V1 is still supported with feature flag but it's depracated.
15
- *
16
- * The entitlements query functions supports both APIs by an optional argument of [isV2] to decide what version to choose.
17
- * The function returns the same type.
18
- */
19
-
20
8
  const ENTITLEMENTS_NOT_ENABLED_EXCEPTION_TEXT = 'You must first enable entitlements via Frontegg options to use this function';
21
9
 
22
10
  /**
@@ -29,14 +17,13 @@ const guardEntitlementsUsage = () => {
29
17
  };
30
18
 
31
19
  /**
32
- For user entitlements API V1
33
-
34
20
  @param keyEntitlements permission or feature data object
35
21
  @param missingKeyEnum missing key for scenario that the key does not exist in entitlementsValuePerKeys
36
22
  @returns if the user is entitled to the given key. Attaching the justification if not
37
23
  @throws when entitlement is not enabled via frontegg options
38
24
  */
39
- const getEntitlementsHelperV1 = (keyEntitlements, missingKeyEnum) => {
25
+ const getEntitlementsHelper = (keyEntitlements, missingKeyEnum) => {
26
+ guardEntitlementsUsage();
40
27
  if (!keyEntitlements) {
41
28
  return {
42
29
  isEntitled: false,
@@ -56,52 +43,38 @@ const getEntitlementsHelperV1 = (keyEntitlements, missingKeyEnum) => {
56
43
 
57
44
  /**
58
45
  @param entitlements
59
- @param key permission key
60
- @param attributes entitlements query attributes including comnsumer and frontegg attributes
61
- @param isV2 true when need to use entitlements API V2
46
+ @param key
62
47
  @returns if the user is entitled to the given permission. Attaching the justification if not
63
48
  @throws when entitlement is not enabled via frontegg options
64
49
  */
65
- const getPermissionEntitlements = (entitlements, key, attributes, isV2) => {
66
- var _permissions;
67
- guardEntitlementsUsage();
68
- if (isV2) {
69
- return (0, _entitlementsJavascriptCommons.evaluateIsEntitledToPermissions)(key, entitlements, attributes);
70
- }
71
- return getEntitlementsHelperV1(entitlements == null ? void 0 : (_permissions = entitlements.permissions) == null ? void 0 : _permissions[key], _restApi.NotEntitledJustification.MISSING_PERMISSION);
50
+ const getPermissionEntitlements = (entitlements, key) => {
51
+ var _entitlements$permiss;
52
+ return getEntitlementsHelper(entitlements == null ? void 0 : (_entitlements$permiss = entitlements.permissions) == null ? void 0 : _entitlements$permiss[key], _restApi.NotEntitledJustification.MISSING_PERMISSION);
72
53
  };
73
54
 
74
55
  /**
75
56
  @param entitlements
76
- @param key feature key
77
- @param attributes entitlements query attributes including comnsumer and frontegg attributes
78
- @param isV2 true when need to use entitlements API V2
57
+ @param key
79
58
  @returns if the user is entitled to the given feature. Attaching the justification if not
80
59
  @throws when entitlement is not enabled via frontegg options
81
60
  */
82
61
  exports.getPermissionEntitlements = getPermissionEntitlements;
83
- const getFeatureEntitlements = (entitlements, key, attributes, isV2) => {
84
- var _features;
85
- guardEntitlementsUsage();
86
- if (isV2) {
87
- return (0, _entitlementsJavascriptCommons.evaluateIsEntitledToFeature)(key, entitlements, attributes);
88
- }
89
- return getEntitlementsHelperV1(entitlements == null ? void 0 : (_features = entitlements.features) == null ? void 0 : _features[key], _restApi.NotEntitledJustification.MISSING_FEATURE);
62
+ const getFeatureEntitlements = (entitlements, key) => {
63
+ var _entitlements$feature;
64
+ return getEntitlementsHelper(entitlements == null ? void 0 : (_entitlements$feature = entitlements.features) == null ? void 0 : _entitlements$feature[key], _restApi.NotEntitledJustification.MISSING_FEATURE);
90
65
  };
91
66
 
92
67
  /**
93
68
  @param entitlements
94
69
  @param options including permission or feature
95
- @param attributes entitlements query attributes including comnsumer and frontegg attributes
96
- @param isV2 true when need to use entitlements API V2
97
70
  @returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
98
71
  @throws when entitlement is not enabled via frontegg options
99
72
  */
100
73
  exports.getFeatureEntitlements = getFeatureEntitlements;
101
- const getEntitlements = (entitlements, options, attributes, isV2) => {
74
+ const getEntitlements = (entitlements, options) => {
102
75
  if ('permissionKey' in options) {
103
- return getPermissionEntitlements(entitlements, options.permissionKey, attributes, isV2);
76
+ return getPermissionEntitlements(entitlements, options.permissionKey);
104
77
  }
105
- return getFeatureEntitlements(entitlements, options.featureKey, attributes, isV2);
78
+ return getFeatureEntitlements(entitlements, options.featureKey);
106
79
  };
107
80
  exports.getEntitlements = getEntitlements;
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.148.0-alpha.0
1
+ /** @license Frontegg v6.148.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,12 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
- "version": "6.148.0-alpha.0",
3
+ "version": "6.148.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
- "@frontegg/entitlements-javascript-commons": "1.0.0-alpha.13",
10
- "@frontegg/rest-api": "3.1.38",
9
+ "@frontegg/rest-api": "3.1.34",
11
10
  "@reduxjs/toolkit": "1.8.5",
12
11
  "fast-deep-equal": "3.1.3",
13
12
  "redux-saga": "^1.2.1",