@frontegg/react-hooks 6.121.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.
@@ -1,8 +1,4 @@
1
- import { EntitlementsState, EntitlementsActions, Entitlement, EntitledToOptions } from '@frontegg/redux-store';
2
- export declare type EntitlementsStateMapper<S> = (state: EntitlementsState) => S;
3
- export declare function useEntitlementsState(): EntitlementsState;
4
- export declare function useEntitlementsState<S>(stateMapper: EntitlementsStateMapper<S>): S;
5
- export declare const useEntitlementsActions: () => EntitlementsActions;
1
+ import { Entitlement, EntitledToOptions } from '@frontegg/redux-store';
6
2
  /**
7
3
  @param keys
8
4
  @returns if the user is entitled to the given feature. Attaching the justification if not
@@ -1,27 +1,20 @@
1
- import { entitlementsActions, entitlementsReducers, getPermissionEntitlements, getFeatureEntitlements, getEntitlements } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
- const defaultMapper = state => state;
4
- export function useEntitlementsState(stateMapper = defaultMapper) {
5
- return stateHookGenerator(stateMapper, 'entitlementsState', true);
6
- }
7
- export const useEntitlementsActions = () => reducerActionsGenerator(entitlementsActions, entitlementsReducers);
1
+ import { getPermissionEntitlements, getFeatureEntitlements, getEntitlements } from '@frontegg/redux-store';
2
+ import { useAuth } from './hooks';
3
+
4
+ /**
5
+ * @returns entitlemenets state as stored in the user
6
+ */
7
+ const useEntitlementsState = () => useAuth(({
8
+ user
9
+ }) => user == null ? void 0 : user.entitlements);
8
10
 
9
11
  /**
10
12
  @param keys
11
13
  @returns if the user is entitled to the given feature. Attaching the justification if not
12
14
  */
13
15
  export const useFeatureEntitlements = keys => {
14
- const {
15
- entitlements,
16
- options
17
- } = useEntitlementsState(({
18
- entitlements,
19
- options
20
- }) => ({
21
- entitlements,
22
- options
23
- }));
24
- return getFeatureEntitlements(entitlements, keys, options);
16
+ const entitlements = useEntitlementsState();
17
+ return getFeatureEntitlements(entitlements, keys);
25
18
  };
26
19
 
27
20
  /**
@@ -29,17 +22,8 @@ export const useFeatureEntitlements = keys => {
29
22
  @returns if the user is entitled to the given permission. Attaching the justification if not
30
23
  */
31
24
  export const usePermissionEntitlements = key => {
32
- const {
33
- entitlements,
34
- options
35
- } = useEntitlementsState(({
36
- entitlements,
37
- options
38
- }) => ({
39
- entitlements,
40
- options
41
- }));
42
- return getPermissionEntitlements(entitlements, key, options);
25
+ const entitlements = useEntitlementsState();
26
+ return getPermissionEntitlements(entitlements, key);
43
27
  };
44
28
 
45
29
  /**
@@ -47,15 +31,6 @@ export const usePermissionEntitlements = key => {
47
31
  @returns if the user is entitled to the given feature or permission (check only one). Attaching the justification if not
48
32
  */
49
33
  export const useEntitlements = options => {
50
- const {
51
- entitlements,
52
- options: entitlementsVendorConfig
53
- } = useEntitlementsState(({
54
- entitlements,
55
- options
56
- }) => ({
57
- entitlements,
58
- options
59
- }));
60
- return getEntitlements(entitlements, options, entitlementsVendorConfig);
34
+ const entitlements = useEntitlementsState();
35
+ return getEntitlements(entitlements, options);
61
36
  };
package/auth/index.d.ts CHANGED
@@ -24,3 +24,4 @@ export * from './groups';
24
24
  export * from './customLogin';
25
25
  export * from './MSP/allAccounts';
26
26
  export * from './entitlements';
27
+ export * from './securityCenter';
package/auth/index.js CHANGED
@@ -23,4 +23,5 @@ export * from './passkeys';
23
23
  export * from './groups';
24
24
  export * from './customLogin';
25
25
  export * from './MSP/allAccounts';
26
- export * from './entitlements';
26
+ export * from './entitlements';
27
+ export * from './securityCenter';
@@ -0,0 +1,6 @@
1
+ import { SecurityCenterActions, SecurityCenterState } from '@frontegg/redux-store';
2
+ declare type AuthSecurityCenterStateMapper<S> = (state: SecurityCenterState) => S;
3
+ export declare function useSecurityCenterState(): SecurityCenterState;
4
+ export declare function useSecurityCenterState<S>(stateMapper: AuthSecurityCenterStateMapper<S>): S;
5
+ export declare const useSecurityCenterActions: () => SecurityCenterActions;
6
+ export {};
@@ -0,0 +1,7 @@
1
+ import { securityCenterActions, securityCenterReducers } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ const defaultMapper = state => state;
4
+ export function useSecurityCenterState(stateMapper = defaultMapper) {
5
+ return stateHookGenerator(stateMapper, 'securityCenterState');
6
+ }
7
+ export const useSecurityCenterActions = () => reducerActionsGenerator(securityCenterActions, securityCenterReducers);
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.121.0
1
+ /** @license Frontegg v6.123.0-alpha.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.
@@ -3,34 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useEntitlementsActions = exports.useEntitlements = void 0;
7
- exports.useEntitlementsState = useEntitlementsState;
8
- exports.usePermissionEntitlements = exports.useFeatureEntitlements = void 0;
6
+ exports.usePermissionEntitlements = exports.useFeatureEntitlements = exports.useEntitlements = void 0;
9
7
  var _reduxStore = require("@frontegg/redux-store");
10
8
  var _hooks = require("./hooks");
11
- const defaultMapper = state => state;
12
- function useEntitlementsState(stateMapper = defaultMapper) {
13
- return (0, _hooks.stateHookGenerator)(stateMapper, 'entitlementsState', true);
14
- }
15
- const useEntitlementsActions = () => (0, _hooks.reducerActionsGenerator)(_reduxStore.entitlementsActions, _reduxStore.entitlementsReducers);
9
+ /**
10
+ * @returns entitlemenets state as stored in the user
11
+ */
12
+ const useEntitlementsState = () => (0, _hooks.useAuth)(({
13
+ user
14
+ }) => user == null ? void 0 : user.entitlements);
16
15
 
17
16
  /**
18
17
  @param keys
19
18
  @returns if the user is entitled to the given feature. Attaching the justification if not
20
19
  */
21
- exports.useEntitlementsActions = useEntitlementsActions;
22
20
  const useFeatureEntitlements = keys => {
23
- const {
24
- entitlements,
25
- options
26
- } = useEntitlementsState(({
27
- entitlements,
28
- options
29
- }) => ({
30
- entitlements,
31
- options
32
- }));
33
- return (0, _reduxStore.getFeatureEntitlements)(entitlements, keys, options);
21
+ const entitlements = useEntitlementsState();
22
+ return (0, _reduxStore.getFeatureEntitlements)(entitlements, keys);
34
23
  };
35
24
 
36
25
  /**
@@ -39,17 +28,8 @@ const useFeatureEntitlements = keys => {
39
28
  */
40
29
  exports.useFeatureEntitlements = useFeatureEntitlements;
41
30
  const usePermissionEntitlements = key => {
42
- const {
43
- entitlements,
44
- options
45
- } = useEntitlementsState(({
46
- entitlements,
47
- options
48
- }) => ({
49
- entitlements,
50
- options
51
- }));
52
- return (0, _reduxStore.getPermissionEntitlements)(entitlements, key, options);
31
+ const entitlements = useEntitlementsState();
32
+ return (0, _reduxStore.getPermissionEntitlements)(entitlements, key);
53
33
  };
54
34
 
55
35
  /**
@@ -58,16 +38,7 @@ const usePermissionEntitlements = key => {
58
38
  */
59
39
  exports.usePermissionEntitlements = usePermissionEntitlements;
60
40
  const useEntitlements = options => {
61
- const {
62
- entitlements,
63
- options: entitlementsVendorConfig
64
- } = useEntitlementsState(({
65
- entitlements,
66
- options
67
- }) => ({
68
- entitlements,
69
- options
70
- }));
71
- return (0, _reduxStore.getEntitlements)(entitlements, options, entitlementsVendorConfig);
41
+ const entitlements = useEntitlementsState();
42
+ return (0, _reduxStore.getEntitlements)(entitlements, options);
72
43
  };
73
44
  exports.useEntitlements = useEntitlements;
@@ -361,4 +361,16 @@ Object.keys(_entitlements).forEach(function (key) {
361
361
  return _entitlements[key];
362
362
  }
363
363
  });
364
+ });
365
+ var _securityCenter = require("./securityCenter");
366
+ Object.keys(_securityCenter).forEach(function (key) {
367
+ if (key === "default" || key === "__esModule") return;
368
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
369
+ if (key in exports && exports[key] === _securityCenter[key]) return;
370
+ Object.defineProperty(exports, key, {
371
+ enumerable: true,
372
+ get: function () {
373
+ return _securityCenter[key];
374
+ }
375
+ });
364
376
  });
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSecurityCenterActions = void 0;
7
+ exports.useSecurityCenterState = useSecurityCenterState;
8
+ var _reduxStore = require("@frontegg/redux-store");
9
+ var _hooks = require("./hooks");
10
+ const defaultMapper = state => state;
11
+ function useSecurityCenterState(stateMapper = defaultMapper) {
12
+ return (0, _hooks.stateHookGenerator)(stateMapper, 'securityCenterState');
13
+ }
14
+ const useSecurityCenterActions = () => (0, _hooks.reducerActionsGenerator)(_reduxStore.securityCenterActions, _reduxStore.securityCenterReducers);
15
+ exports.useSecurityCenterActions = useSecurityCenterActions;
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.121.0
1
+ /** @license Frontegg v6.123.0-alpha.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,13 @@
1
1
  {
2
2
  "name": "@frontegg/react-hooks",
3
- "version": "6.121.0",
3
+ "version": "6.123.0-alpha.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/redux-store": "6.121.0",
10
- "@frontegg/types": "6.121.0",
9
+ "@frontegg/redux-store": "6.123.0-alpha.0",
10
+ "@frontegg/types": "6.123.0-alpha.0",
11
11
  "@types/react": "*",
12
12
  "get-value": "^3.0.1",
13
13
  "react-redux": "^7.x"