@frontegg/react-hooks 7.13.0 → 7.14.0-alpha.1
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.js +17 -5
- package/index.js +1 -1
- package/node/auth/entitlements.js +16 -4
- package/node/index.js +1 -1
- package/package.json +3 -3
package/auth/entitlements.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useAuthUserOrNull } from './hooks';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { useShadowDom } from '../common';
|
|
3
|
+
import { useRootState, useShadowDom } from '../common';
|
|
4
4
|
import { useFeatureFlags } from '../flags';
|
|
5
5
|
import { useStore } from '../FronteggStoreContext';
|
|
6
6
|
import { useSnapshot } from '../useSnapshot';
|
|
@@ -49,7 +49,10 @@ export const useFeatureEntitlements = (key, customAttributes) => {
|
|
|
49
49
|
entitlements,
|
|
50
50
|
attributes
|
|
51
51
|
} = useEntitlementsQueryData(customAttributes);
|
|
52
|
-
|
|
52
|
+
const {
|
|
53
|
+
appName
|
|
54
|
+
} = useRootState();
|
|
55
|
+
return getFeatureEntitlements(entitlements, key, attributes, undefined, appName);
|
|
53
56
|
};
|
|
54
57
|
|
|
55
58
|
/**
|
|
@@ -62,7 +65,10 @@ export const usePermissionEntitlements = (key, customAttributes) => {
|
|
|
62
65
|
entitlements,
|
|
63
66
|
attributes
|
|
64
67
|
} = useEntitlementsQueryData(customAttributes);
|
|
65
|
-
|
|
68
|
+
const {
|
|
69
|
+
appName
|
|
70
|
+
} = useRootState();
|
|
71
|
+
return getPermissionEntitlements(entitlements, key, attributes, undefined, appName);
|
|
66
72
|
};
|
|
67
73
|
|
|
68
74
|
/**
|
|
@@ -75,7 +81,10 @@ export const useEntitlements = (options, customAttributes) => {
|
|
|
75
81
|
entitlements,
|
|
76
82
|
attributes
|
|
77
83
|
} = useEntitlementsQueryData(customAttributes);
|
|
78
|
-
|
|
84
|
+
const {
|
|
85
|
+
appName
|
|
86
|
+
} = useRootState();
|
|
87
|
+
return getEntitlements(entitlements, options, attributes, undefined, appName);
|
|
79
88
|
};
|
|
80
89
|
|
|
81
90
|
/**
|
|
@@ -86,13 +95,16 @@ export const useEntitlementsActions = () => {
|
|
|
86
95
|
// this code is duplicated because React is yelling when using useEntitlementsQueryData inside the isEntitledTo function because it's not a hook
|
|
87
96
|
const user = useUserState();
|
|
88
97
|
const entitlements = useEntitlementsState();
|
|
98
|
+
const {
|
|
99
|
+
appName
|
|
100
|
+
} = useRootState();
|
|
89
101
|
return useMemo(() => ({
|
|
90
102
|
isEntitledTo: (options, customAttributes) => {
|
|
91
103
|
const attributes = {
|
|
92
104
|
custom: customAttributes,
|
|
93
105
|
jwt: user
|
|
94
106
|
};
|
|
95
|
-
return getEntitlements(entitlements, options, attributes);
|
|
107
|
+
return getEntitlements(entitlements, options, attributes, undefined, appName);
|
|
96
108
|
}
|
|
97
109
|
}), [user, entitlements]);
|
|
98
110
|
};
|
package/index.js
CHANGED
|
@@ -54,7 +54,10 @@ const useFeatureEntitlements = (key, customAttributes) => {
|
|
|
54
54
|
entitlements,
|
|
55
55
|
attributes
|
|
56
56
|
} = useEntitlementsQueryData(customAttributes);
|
|
57
|
-
|
|
57
|
+
const {
|
|
58
|
+
appName
|
|
59
|
+
} = (0, _common.useRootState)();
|
|
60
|
+
return (0, _reduxStore.getFeatureEntitlements)(entitlements, key, attributes, undefined, appName);
|
|
58
61
|
};
|
|
59
62
|
|
|
60
63
|
/**
|
|
@@ -68,7 +71,10 @@ const usePermissionEntitlements = (key, customAttributes) => {
|
|
|
68
71
|
entitlements,
|
|
69
72
|
attributes
|
|
70
73
|
} = useEntitlementsQueryData(customAttributes);
|
|
71
|
-
|
|
74
|
+
const {
|
|
75
|
+
appName
|
|
76
|
+
} = (0, _common.useRootState)();
|
|
77
|
+
return (0, _reduxStore.getPermissionEntitlements)(entitlements, key, attributes, undefined, appName);
|
|
72
78
|
};
|
|
73
79
|
|
|
74
80
|
/**
|
|
@@ -82,7 +88,10 @@ const useEntitlements = (options, customAttributes) => {
|
|
|
82
88
|
entitlements,
|
|
83
89
|
attributes
|
|
84
90
|
} = useEntitlementsQueryData(customAttributes);
|
|
85
|
-
|
|
91
|
+
const {
|
|
92
|
+
appName
|
|
93
|
+
} = (0, _common.useRootState)();
|
|
94
|
+
return (0, _reduxStore.getEntitlements)(entitlements, options, attributes, undefined, appName);
|
|
86
95
|
};
|
|
87
96
|
|
|
88
97
|
/**
|
|
@@ -94,13 +103,16 @@ const useEntitlementsActions = () => {
|
|
|
94
103
|
// this code is duplicated because React is yelling when using useEntitlementsQueryData inside the isEntitledTo function because it's not a hook
|
|
95
104
|
const user = useUserState();
|
|
96
105
|
const entitlements = useEntitlementsState();
|
|
106
|
+
const {
|
|
107
|
+
appName
|
|
108
|
+
} = (0, _common.useRootState)();
|
|
97
109
|
return (0, _react.useMemo)(() => ({
|
|
98
110
|
isEntitledTo: (options, customAttributes) => {
|
|
99
111
|
const attributes = {
|
|
100
112
|
custom: customAttributes,
|
|
101
113
|
jwt: user
|
|
102
114
|
};
|
|
103
|
-
return (0, _reduxStore.getEntitlements)(entitlements, options, attributes);
|
|
115
|
+
return (0, _reduxStore.getEntitlements)(entitlements, options, attributes, undefined, appName);
|
|
104
116
|
}
|
|
105
117
|
}), [user, entitlements]);
|
|
106
118
|
};
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/react-hooks",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.14.0-alpha.1",
|
|
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/redux-store": "7.
|
|
10
|
-
"@frontegg/types": "7.
|
|
9
|
+
"@frontegg/redux-store": "7.14.0-alpha.1",
|
|
10
|
+
"@frontegg/types": "7.14.0-alpha.1",
|
|
11
11
|
"@types/react": "*",
|
|
12
12
|
"@types/react-is": "^17.0.7",
|
|
13
13
|
"get-value": "^3.0.1",
|