@frontegg/redux-store 6.149.0 → 6.150.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.
- package/auth/Entitlements/saga.d.ts +6 -9
- package/auth/Entitlements/saga.js +5 -2
- package/auth/Entitlements/utils.d.ts +13 -5
- package/auth/Entitlements/utils.js +40 -13
- package/auth/index.d.ts +1 -1
- package/auth/reducer.d.ts +3 -3
- package/index.js +1 -1
- package/node/auth/Entitlements/saga.js +3 -1
- package/node/auth/Entitlements/utils.js +40 -13
- package/node/index.js +1 -1
- package/package.json +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UserEntitlementsContext as UserEntitlementsResponseV2 } from '@frontegg/entitlements-javascript-commons';
|
|
2
2
|
import { PayloadAction } from '@reduxjs/toolkit';
|
|
3
3
|
import { LoadEntitlementsActionPayload } from './interfaces';
|
|
4
4
|
/**
|
|
@@ -6,25 +6,22 @@ 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:
|
|
9
|
+
export declare function isEntitlementsDeeplyEqual(oldEntitlements: UserEntitlementsResponseV2 | undefined, newEntitlements: UserEntitlementsResponseV2 | 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:
|
|
17
|
-
payload: Partial<
|
|
16
|
+
export declare function handleFetchedEntitlements(newEntitlementsResponse: UserEntitlementsResponseV2): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").PutEffect<{
|
|
17
|
+
payload: Partial<UserEntitlementsResponseV2>;
|
|
18
18
|
type: string;
|
|
19
|
-
}>, void,
|
|
19
|
+
}>, void, UserEntitlementsResponseV2>;
|
|
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>):
|
|
27
|
-
payload: Partial<UserEntitlementsResponse>;
|
|
28
|
-
type: string;
|
|
29
|
-
}>, void, UserEntitlementsResponse> | import("redux-saga/effects").CallEffect<UserEntitlementsResponse>, void, UserEntitlementsResponse>;
|
|
26
|
+
export declare function loadEntitlements({ payload }: PayloadAction<LoadEntitlementsActionPayload>): any;
|
|
30
27
|
export declare function entitlementsSagas(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import isEqual from 'fast-deep-equal';
|
|
2
2
|
import { call, put, takeLeading, select } from 'redux-saga/effects';
|
|
3
|
-
import { api } from '@frontegg/rest-api';
|
|
3
|
+
import { USE_ENTITLEMENTS_V2_ENDPOINT_FF, api } from '@frontegg/rest-api';
|
|
4
4
|
import { actions } from '../reducer';
|
|
5
|
+
import { getFeatureFlags } from '../../helpers';
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* @param oldEntitlements
|
|
7
9
|
* @param newEntitlements
|
|
@@ -38,8 +40,9 @@ export function* loadEntitlements({
|
|
|
38
40
|
payload
|
|
39
41
|
}) {
|
|
40
42
|
const callback = payload == null ? void 0 : payload.callback;
|
|
43
|
+
const [useEntitlementsV2] = yield call(getFeatureFlags, [USE_ENTITLEMENTS_V2_ENDPOINT_FF]);
|
|
41
44
|
try {
|
|
42
|
-
const entitlements = yield call(api.entitlements.loadEntitlements);
|
|
45
|
+
const entitlements = yield call(useEntitlementsV2 ? api.entitlements.loadEntitlementsV2 : api.entitlements.loadEntitlements);
|
|
43
46
|
yield handleFetchedEntitlements(entitlements);
|
|
44
47
|
callback == null ? void 0 : callback(true);
|
|
45
48
|
} catch (e) {
|
|
@@ -1,23 +1,31 @@
|
|
|
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';
|
|
3
5
|
/**
|
|
4
6
|
@param entitlements
|
|
5
|
-
@param key
|
|
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
|
|
6
10
|
@returns if the user is entitled to the given permission. Attaching the justification if not
|
|
7
11
|
@throws when entitlement is not enabled via frontegg options
|
|
8
12
|
*/
|
|
9
|
-
export declare const getPermissionEntitlements: (entitlements: UserEntitlementsResponse | undefined, key: string) => Entitlement;
|
|
13
|
+
export declare const getPermissionEntitlements: (entitlements: UserEntitlementsResponseV2 | UserEntitlementsResponse | undefined, key: string, attributes?: Attributes | undefined, isV2?: boolean | undefined) => Entitlement;
|
|
10
14
|
/**
|
|
11
15
|
@param entitlements
|
|
12
|
-
@param key
|
|
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
|
|
13
19
|
@returns if the user is entitled to the given feature. Attaching the justification if not
|
|
14
20
|
@throws when entitlement is not enabled via frontegg options
|
|
15
21
|
*/
|
|
16
|
-
export declare const getFeatureEntitlements: (entitlements: UserEntitlementsResponse | undefined, key: string) => Entitlement;
|
|
22
|
+
export declare const getFeatureEntitlements: (entitlements: UserEntitlementsResponseV2 | UserEntitlementsResponse | undefined, key: string, attributes?: Attributes | undefined, isV2?: boolean | undefined) => Entitlement;
|
|
17
23
|
/**
|
|
18
24
|
@param entitlements
|
|
19
25
|
@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
|
|
20
28
|
@returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
|
|
21
29
|
@throws when entitlement is not enabled via frontegg options
|
|
22
30
|
*/
|
|
23
|
-
export declare const getEntitlements: (entitlements: UserEntitlementsResponse | undefined, options: EntitledToOptions) => Entitlement;
|
|
31
|
+
export declare const getEntitlements: (entitlements: UserEntitlementsResponseV2 | UserEntitlementsResponse | undefined, options: EntitledToOptions, attributes?: Attributes | undefined, isV2?: boolean | undefined) => Entitlement;
|
|
@@ -1,4 +1,16 @@
|
|
|
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
|
+
|
|
2
14
|
const ENTITLEMENTS_NOT_ENABLED_EXCEPTION_TEXT = 'You must first enable entitlements via Frontegg options to use this function';
|
|
3
15
|
|
|
4
16
|
/**
|
|
@@ -11,13 +23,14 @@ const guardEntitlementsUsage = () => {
|
|
|
11
23
|
};
|
|
12
24
|
|
|
13
25
|
/**
|
|
26
|
+
For user entitlements API V1
|
|
27
|
+
|
|
14
28
|
@param keyEntitlements permission or feature data object
|
|
15
29
|
@param missingKeyEnum missing key for scenario that the key does not exist in entitlementsValuePerKeys
|
|
16
30
|
@returns if the user is entitled to the given key. Attaching the justification if not
|
|
17
31
|
@throws when entitlement is not enabled via frontegg options
|
|
18
32
|
*/
|
|
19
|
-
const
|
|
20
|
-
guardEntitlementsUsage();
|
|
33
|
+
const getEntitlementsHelperV1 = (keyEntitlements, missingKeyEnum) => {
|
|
21
34
|
if (!keyEntitlements) {
|
|
22
35
|
return {
|
|
23
36
|
isEntitled: false,
|
|
@@ -37,35 +50,49 @@ const getEntitlementsHelper = (keyEntitlements, missingKeyEnum) => {
|
|
|
37
50
|
|
|
38
51
|
/**
|
|
39
52
|
@param entitlements
|
|
40
|
-
@param key
|
|
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
|
|
41
56
|
@returns if the user is entitled to the given permission. Attaching the justification if not
|
|
42
57
|
@throws when entitlement is not enabled via frontegg options
|
|
43
58
|
*/
|
|
44
|
-
export const getPermissionEntitlements = (entitlements, key) => {
|
|
45
|
-
var
|
|
46
|
-
|
|
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);
|
|
47
66
|
};
|
|
48
67
|
|
|
49
68
|
/**
|
|
50
69
|
@param entitlements
|
|
51
|
-
@param key
|
|
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
|
|
52
73
|
@returns if the user is entitled to the given feature. Attaching the justification if not
|
|
53
74
|
@throws when entitlement is not enabled via frontegg options
|
|
54
75
|
*/
|
|
55
|
-
export const getFeatureEntitlements = (entitlements, key) => {
|
|
56
|
-
var
|
|
57
|
-
|
|
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);
|
|
58
83
|
};
|
|
59
84
|
|
|
60
85
|
/**
|
|
61
86
|
@param entitlements
|
|
62
87
|
@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
|
|
63
90
|
@returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
|
|
64
91
|
@throws when entitlement is not enabled via frontegg options
|
|
65
92
|
*/
|
|
66
|
-
export const getEntitlements = (entitlements, options) => {
|
|
93
|
+
export const getEntitlements = (entitlements, options, attributes, isV2) => {
|
|
67
94
|
if ('permissionKey' in options) {
|
|
68
|
-
return getPermissionEntitlements(entitlements, options.permissionKey);
|
|
95
|
+
return getPermissionEntitlements(entitlements, options.permissionKey, attributes, isV2);
|
|
69
96
|
}
|
|
70
|
-
return getFeatureEntitlements(entitlements, options.featureKey);
|
|
97
|
+
return getFeatureEntitlements(entitlements, options.featureKey, attributes, isV2);
|
|
71
98
|
};
|
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/
|
|
759
|
+
setEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("@frontegg/entitlements-javascript-commons").UserEntitlementsContext>], Partial<import("@frontegg/entitlements-javascript-commons").UserEntitlementsContext>, 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 {
|
|
30
|
+
import { UserEntitlementsContext as UserEntitlementsResponseV2 } from '@frontegg/entitlements-javascript-commons';
|
|
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<
|
|
718
|
+
setEntitlements: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<UserEntitlementsResponseV2>], Partial<UserEntitlementsResponseV2>, 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<
|
|
725
|
+
setEntitlements: (entitlements: Partial<UserEntitlementsResponseV2>) => 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
|
@@ -12,6 +12,7 @@ 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");
|
|
15
16
|
/**
|
|
16
17
|
* @param oldEntitlements
|
|
17
18
|
* @param newEntitlements
|
|
@@ -48,8 +49,9 @@ function* loadEntitlements({
|
|
|
48
49
|
payload
|
|
49
50
|
}) {
|
|
50
51
|
const callback = payload == null ? void 0 : payload.callback;
|
|
52
|
+
const [useEntitlementsV2] = yield (0, _effects.call)(_helpers.getFeatureFlags, [_restApi.USE_ENTITLEMENTS_V2_ENDPOINT_FF]);
|
|
51
53
|
try {
|
|
52
|
-
const entitlements = yield (0, _effects.call)(_restApi.api.entitlements.loadEntitlements);
|
|
54
|
+
const entitlements = yield (0, _effects.call)(useEntitlementsV2 ? _restApi.api.entitlements.loadEntitlementsV2 : _restApi.api.entitlements.loadEntitlements);
|
|
53
55
|
yield handleFetchedEntitlements(entitlements);
|
|
54
56
|
callback == null ? void 0 : callback(true);
|
|
55
57
|
} catch (e) {
|
|
@@ -5,6 +5,18 @@ 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
|
+
|
|
8
20
|
const ENTITLEMENTS_NOT_ENABLED_EXCEPTION_TEXT = 'You must first enable entitlements via Frontegg options to use this function';
|
|
9
21
|
|
|
10
22
|
/**
|
|
@@ -17,13 +29,14 @@ const guardEntitlementsUsage = () => {
|
|
|
17
29
|
};
|
|
18
30
|
|
|
19
31
|
/**
|
|
32
|
+
For user entitlements API V1
|
|
33
|
+
|
|
20
34
|
@param keyEntitlements permission or feature data object
|
|
21
35
|
@param missingKeyEnum missing key for scenario that the key does not exist in entitlementsValuePerKeys
|
|
22
36
|
@returns if the user is entitled to the given key. Attaching the justification if not
|
|
23
37
|
@throws when entitlement is not enabled via frontegg options
|
|
24
38
|
*/
|
|
25
|
-
const
|
|
26
|
-
guardEntitlementsUsage();
|
|
39
|
+
const getEntitlementsHelperV1 = (keyEntitlements, missingKeyEnum) => {
|
|
27
40
|
if (!keyEntitlements) {
|
|
28
41
|
return {
|
|
29
42
|
isEntitled: false,
|
|
@@ -43,38 +56,52 @@ const getEntitlementsHelper = (keyEntitlements, missingKeyEnum) => {
|
|
|
43
56
|
|
|
44
57
|
/**
|
|
45
58
|
@param entitlements
|
|
46
|
-
@param key
|
|
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
|
|
47
62
|
@returns if the user is entitled to the given permission. Attaching the justification if not
|
|
48
63
|
@throws when entitlement is not enabled via frontegg options
|
|
49
64
|
*/
|
|
50
|
-
const getPermissionEntitlements = (entitlements, key) => {
|
|
51
|
-
var
|
|
52
|
-
|
|
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);
|
|
53
72
|
};
|
|
54
73
|
|
|
55
74
|
/**
|
|
56
75
|
@param entitlements
|
|
57
|
-
@param key
|
|
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
|
|
58
79
|
@returns if the user is entitled to the given feature. Attaching the justification if not
|
|
59
80
|
@throws when entitlement is not enabled via frontegg options
|
|
60
81
|
*/
|
|
61
82
|
exports.getPermissionEntitlements = getPermissionEntitlements;
|
|
62
|
-
const getFeatureEntitlements = (entitlements, key) => {
|
|
63
|
-
var
|
|
64
|
-
|
|
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);
|
|
65
90
|
};
|
|
66
91
|
|
|
67
92
|
/**
|
|
68
93
|
@param entitlements
|
|
69
94
|
@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
|
|
70
97
|
@returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
|
|
71
98
|
@throws when entitlement is not enabled via frontegg options
|
|
72
99
|
*/
|
|
73
100
|
exports.getFeatureEntitlements = getFeatureEntitlements;
|
|
74
|
-
const getEntitlements = (entitlements, options) => {
|
|
101
|
+
const getEntitlements = (entitlements, options, attributes, isV2) => {
|
|
75
102
|
if ('permissionKey' in options) {
|
|
76
|
-
return getPermissionEntitlements(entitlements, options.permissionKey);
|
|
103
|
+
return getPermissionEntitlements(entitlements, options.permissionKey, attributes, isV2);
|
|
77
104
|
}
|
|
78
|
-
return getFeatureEntitlements(entitlements, options.featureKey);
|
|
105
|
+
return getFeatureEntitlements(entitlements, options.featureKey, attributes, isV2);
|
|
79
106
|
};
|
|
80
107
|
exports.getEntitlements = getEntitlements;
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/redux-store",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.150.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/rest-api": "3.1.
|
|
9
|
+
"@frontegg/rest-api": "3.1.41",
|
|
10
|
+
"@frontegg/entitlements-javascript-commons": "1.0.0-alpha.15",
|
|
10
11
|
"@reduxjs/toolkit": "1.8.5",
|
|
11
12
|
"fast-deep-equal": "3.1.3",
|
|
12
13
|
"redux-saga": "^1.2.1",
|