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