@frontegg/react-hooks 6.69.0 → 6.70.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/FronteggProvider/index.js +2 -18
- package/FronteggStoreContext/index.js +2 -2
- package/audits/auditLogs.js +0 -2
- package/audits/auditsMetadata.js +0 -2
- package/audits/hooks.js +1 -2
- package/auth/acceptInvitation.js +1 -2
- package/auth/activateAccount.js +0 -2
- package/auth/apiTokens.js +0 -2
- package/auth/forgotPassword.js +0 -2
- package/auth/hooks.js +4 -8
- package/auth/impersonate.js +0 -2
- package/auth/login.js +0 -2
- package/auth/mfa.js +0 -2
- package/auth/profile.js +0 -2
- package/auth/provisioning.js +0 -2
- package/auth/resetPhoneNumber.js +0 -2
- package/auth/restrictions.js +4 -4
- package/auth/roles.js +0 -2
- package/auth/securityPolicy.js +4 -4
- package/auth/sessions.js +0 -2
- package/auth/sessionsPolicy.js +0 -2
- package/auth/signup.js +0 -2
- package/auth/socialLogin.js +0 -2
- package/auth/sso.js +0 -2
- package/auth/team.js +0 -2
- package/auth/tenants.js +0 -2
- package/common/index.d.ts +1 -1
- package/common/index.js +8 -10
- package/connectivity/hooks.js +0 -2
- package/flags/useFeatureFlags.js +0 -1
- package/index.js +1 -1
- package/node/FronteggProvider/index.js +2 -32
- package/node/FronteggStoreContext/index.js +2 -8
- package/node/audits/auditLogs.js +0 -6
- package/node/audits/auditsMetadata.js +0 -6
- package/node/audits/hooks.js +1 -18
- package/node/audits/index.js +0 -5
- package/node/auth/acceptInvitation.js +1 -6
- package/node/auth/activateAccount.js +0 -6
- package/node/auth/apiTokens.js +0 -6
- package/node/auth/forgotPassword.js +0 -6
- package/node/auth/hooks.js +4 -38
- package/node/auth/impersonate.js +0 -6
- package/node/auth/index.js +0 -41
- package/node/auth/login.js +0 -6
- package/node/auth/mfa.js +0 -6
- package/node/auth/profile.js +0 -9
- package/node/auth/provisioning.js +0 -6
- package/node/auth/resetPhoneNumber.js +0 -6
- package/node/auth/restrictions.js +4 -13
- package/node/auth/roles.js +0 -6
- package/node/auth/securityPolicy.js +4 -13
- package/node/auth/sessions.js +0 -6
- package/node/auth/sessionsPolicy.js +0 -6
- package/node/auth/signup.js +0 -6
- package/node/auth/socialLogin.js +0 -6
- package/node/auth/sso.js +0 -6
- package/node/auth/team.js +0 -6
- package/node/auth/tenants.js +0 -6
- package/node/common/index.js +8 -19
- package/node/connectivity/hooks.js +0 -8
- package/node/connectivity/index.js +0 -1
- package/node/flags/index.js +0 -2
- package/node/flags/useFeatureFlags.js +0 -4
- package/node/index.js +1 -19
- package/node/subscriptions/hooks.js +0 -46
- package/node/subscriptions/index.js +0 -2
- package/node/vendor/hooks.js +0 -8
- package/node/vendor/index.js +0 -1
- package/package.json +3 -3
- package/subscriptions/hooks.js +0 -4
- package/vendor/hooks.js +0 -2
|
@@ -8,7 +8,6 @@ import { useAuth, useAuthRoutes } from '../auth';
|
|
|
8
8
|
import { Provider, FronteggStoreContext } from '../FronteggStoreContext';
|
|
9
9
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
|
|
12
11
|
const defaultSetLoading = loading => {
|
|
13
12
|
if (loading) {
|
|
14
13
|
document.body.classList.add('frontegg-loading');
|
|
@@ -16,7 +15,6 @@ const defaultSetLoading = loading => {
|
|
|
16
15
|
document.body.classList.remove('frontegg-loading');
|
|
17
16
|
}
|
|
18
17
|
};
|
|
19
|
-
|
|
20
18
|
const HideChildrenIfFronteggRoutes = ({
|
|
21
19
|
children,
|
|
22
20
|
basename
|
|
@@ -30,7 +28,6 @@ const HideChildrenIfFronteggRoutes = ({
|
|
|
30
28
|
uriRef.current = window.location.pathname;
|
|
31
29
|
setUri(document.location.pathname);
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
35
32
|
}, []);
|
|
36
33
|
useEffect(() => {
|
|
@@ -52,25 +49,20 @@ const HideChildrenIfFronteggRoutes = ({
|
|
|
52
49
|
};
|
|
53
50
|
}, [checker, setUri]);
|
|
54
51
|
const calculatedBasename = basename ? basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '' : '';
|
|
55
|
-
|
|
56
52
|
const checkRoutes = _objectWithoutPropertiesLoose(routes, _excluded);
|
|
57
|
-
|
|
58
53
|
if (Object.values(checkRoutes).map(url => `${calculatedBasename}${url}`).indexOf(uri) !== -1) {
|
|
59
54
|
return null;
|
|
60
55
|
}
|
|
61
|
-
|
|
62
56
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
63
57
|
children: children
|
|
64
58
|
});
|
|
65
59
|
};
|
|
66
|
-
|
|
67
60
|
const FronteggContent = ({
|
|
68
61
|
children,
|
|
69
62
|
app,
|
|
70
63
|
setLoading
|
|
71
64
|
}) => {
|
|
72
65
|
var _app$options, _app$options2;
|
|
73
|
-
|
|
74
66
|
const {
|
|
75
67
|
isLoading
|
|
76
68
|
} = useAuth(({
|
|
@@ -82,44 +74,37 @@ const FronteggContent = ({
|
|
|
82
74
|
const isNextJS = (app == null ? void 0 : (_app$options2 = app.options) == null ? void 0 : _app$options2.framework) === 'nextjs';
|
|
83
75
|
const alwaysShowChildren = customLoginBox || isNextJS;
|
|
84
76
|
const loadingRef = useRef(undefined);
|
|
85
|
-
|
|
86
77
|
if (isLoading !== loadingRef.current && !isNextJS) {
|
|
87
78
|
loadingRef.current = isLoading;
|
|
88
79
|
setLoading(isLoading);
|
|
89
80
|
}
|
|
90
|
-
|
|
91
81
|
if (isLoading && !isNextJS) {
|
|
92
82
|
return null;
|
|
93
83
|
}
|
|
94
|
-
|
|
95
84
|
if (alwaysShowChildren) {
|
|
96
85
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
97
86
|
children: children
|
|
98
87
|
});
|
|
99
88
|
}
|
|
100
|
-
|
|
101
89
|
return /*#__PURE__*/_jsx(HideChildrenIfFronteggRoutes, {
|
|
102
90
|
basename: app == null ? void 0 : app.options.basename,
|
|
103
91
|
children: children
|
|
104
92
|
});
|
|
105
93
|
};
|
|
106
|
-
|
|
107
94
|
export const FronteggStoreProvider = props => {
|
|
108
95
|
var _app$options$contextO, _app$options3, _app$options$previewM, _app$options4, _app$options5, _app$options6;
|
|
109
|
-
|
|
110
96
|
const {
|
|
111
97
|
children,
|
|
112
98
|
app,
|
|
113
99
|
contextOptions,
|
|
114
100
|
setLoading = defaultSetLoading
|
|
115
|
-
} = props;
|
|
101
|
+
} = props;
|
|
116
102
|
|
|
103
|
+
// TODO: make this optionals more readable
|
|
117
104
|
const context = (_app$options$contextO = app == null ? void 0 : (_app$options3 = app.options) == null ? void 0 : _app$options3.contextOptions) != null ? _app$options$contextO : contextOptions;
|
|
118
|
-
|
|
119
105
|
if (!context) {
|
|
120
106
|
throw Error('contextOptions must not be null or undefined');
|
|
121
107
|
}
|
|
122
|
-
|
|
123
108
|
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.previewMode) != null ? _app$options$previewM : false;
|
|
124
109
|
const authOptions = app != null && (_app$options5 = app.options) != null && _app$options5.authOptions ? _extends({}, app.options.authOptions, {
|
|
125
110
|
hostedLoginBox: app.options.hostedLoginBox
|
|
@@ -129,7 +114,6 @@ export const FronteggStoreProvider = props => {
|
|
|
129
114
|
ContextHolder.setContext(context);
|
|
130
115
|
const store = useMemo(() => {
|
|
131
116
|
var _app$options7;
|
|
132
|
-
|
|
133
117
|
return createFronteggStore({
|
|
134
118
|
context
|
|
135
119
|
}, app, previewMode, authOptions, undefined, false, app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.urlStrategy);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { createSelectorHook, createDispatchHook, createStoreHook, Provider as ReactReduxProvider } from 'react-redux';
|
|
3
|
-
export const FronteggStoreContext = /*#__PURE__*/React.createContext(null);
|
|
3
|
+
export const FronteggStoreContext = /*#__PURE__*/React.createContext(null);
|
|
4
4
|
|
|
5
|
+
// @ts-ignore
|
|
5
6
|
if (process.env.NODE_ENV !== 'production') {
|
|
6
7
|
FronteggStoreContext.displayName = 'FronteggStoreContext';
|
|
7
8
|
}
|
|
8
|
-
|
|
9
9
|
export const useSelector = createSelectorHook(FronteggStoreContext);
|
|
10
10
|
export const useDispatch = createDispatchHook(FronteggStoreContext);
|
|
11
11
|
export const useStore = createStoreHook(FronteggStoreContext);
|
package/audits/auditLogs.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
2
2
|
import { auditLogsActions, auditLogsReducers } from '@frontegg/redux-store';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useAuditLogsState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'auditLogsState');
|
|
8
6
|
}
|
package/audits/auditsMetadata.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { auditsMetadataActions, auditsMetadataReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useAuditsMetadataState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'auditsMetadataState');
|
|
8
6
|
}
|
package/audits/hooks.js
CHANGED
|
@@ -15,10 +15,10 @@ export const useAuditsActions = () => {
|
|
|
15
15
|
const dispatch = useDispatch();
|
|
16
16
|
return useMemo(() => bindActionCreators(auditsActions, dispatch), [auditsActions]);
|
|
17
17
|
};
|
|
18
|
+
|
|
18
19
|
/**
|
|
19
20
|
* hooks helpers
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
22
|
export const sliceReducerActionsBy = reducer => {
|
|
23
23
|
const reducerKeys = Object.keys(reducer);
|
|
24
24
|
const reducerActions = reducerKeys.map(key => ({
|
|
@@ -29,7 +29,6 @@ export const sliceReducerActionsBy = reducer => {
|
|
|
29
29
|
export const stateHookGenerator = (stateMapper, subState) => {
|
|
30
30
|
return useSelector(state => {
|
|
31
31
|
var _stateMapper;
|
|
32
|
-
|
|
33
32
|
return (_stateMapper = stateMapper == null ? void 0 : stateMapper(state[auditsStoreName][subState])) != null ? _stateMapper : state[auditsStoreName][subState];
|
|
34
33
|
}, shallowEqual);
|
|
35
34
|
};
|
package/auth/acceptInvitation.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { acceptInvitationReducers, acceptInvitationActions } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
4
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
5
|
export function useAcceptInvitationState(stateMapper = defaultMapper) {
|
|
7
6
|
return stateHookGenerator(stateMapper, 'acceptInvitationState');
|
|
8
7
|
}
|
package/auth/activateAccount.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { activateAccountReducers, activateAccountActions } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useActivateAccountState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'activateState');
|
|
8
6
|
}
|
package/auth/apiTokens.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { apiTokensActions, apiTokensReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useApiTokensState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'apiTokensState');
|
|
8
6
|
}
|
package/auth/forgotPassword.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { forgotPasswordReducers, forgotPasswordActions } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useForgotPasswordState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'forgotPasswordState');
|
|
8
6
|
}
|
package/auth/hooks.js
CHANGED
|
@@ -13,6 +13,7 @@ const defaultMapper = {
|
|
|
13
13
|
export function useAuth(stateMapper = defaultMapper.state) {
|
|
14
14
|
return useSelector(state => stateMapper(state[authStoreName]), shallowEqual);
|
|
15
15
|
}
|
|
16
|
+
|
|
16
17
|
/**
|
|
17
18
|
* ```jsx
|
|
18
19
|
* export const MyFunctionComponent = () => {
|
|
@@ -30,7 +31,6 @@ export function useAuth(stateMapper = defaultMapper.state) {
|
|
|
30
31
|
*
|
|
31
32
|
* use this frontegg hook function to get if user is "Authenticated"
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
34
|
export const useLoginWithRedirect = () => {
|
|
35
35
|
const dispatch = useDispatch();
|
|
36
36
|
return useMemo(() => bindActionCreators(authActions.requestHostedLoginAuthorize, dispatch), [authActions.requestHostedLoginAuthorize]);
|
|
@@ -41,11 +41,11 @@ export const useAuthActions = () => {
|
|
|
41
41
|
};
|
|
42
42
|
export const useOnRedirectTo = () => {
|
|
43
43
|
var _context$onRedirectTo;
|
|
44
|
-
|
|
45
44
|
const context = useContext(ShadowDomContext);
|
|
46
45
|
return (_context$onRedirectTo = context == null ? void 0 : context.onRedirectTo) != null ? _context$onRedirectTo : ContextHolder.onRedirectTo;
|
|
47
46
|
};
|
|
48
47
|
export const useAuthRoutes = () => useAuth(state => _extends({}, state.routes));
|
|
48
|
+
|
|
49
49
|
/**
|
|
50
50
|
* ```jsx
|
|
51
51
|
* export const MyFunctionComponent = () => {
|
|
@@ -56,12 +56,12 @@ export const useAuthRoutes = () => useAuth(state => _extends({}, state.routes));
|
|
|
56
56
|
*
|
|
57
57
|
* use this frontegg hook function to get if user is "Authenticated"
|
|
58
58
|
*/
|
|
59
|
-
|
|
60
59
|
export const useIsAuthenticated = () => useSelector(({
|
|
61
60
|
[authStoreName]: {
|
|
62
61
|
isAuthenticated
|
|
63
62
|
}
|
|
64
63
|
}) => isAuthenticated, shallowEqual);
|
|
64
|
+
|
|
65
65
|
/**
|
|
66
66
|
* ```jsx
|
|
67
67
|
* export const MyFunctionComponent = () => {
|
|
@@ -73,21 +73,18 @@ export const useIsAuthenticated = () => useSelector(({
|
|
|
73
73
|
* use this frontegg hook function to get the authenticated user
|
|
74
74
|
* the return user is null if not authenticated
|
|
75
75
|
*/
|
|
76
|
-
|
|
77
76
|
export const useAuthUser = () => {
|
|
78
77
|
const routes = useAuthRoutes();
|
|
79
78
|
const onRedirectTo = useOnRedirectTo();
|
|
80
79
|
const user = useAuthUserOrNull();
|
|
81
80
|
const isSSR = typeof window === 'undefined';
|
|
82
81
|
const noUser = {};
|
|
83
|
-
|
|
84
82
|
if (user == null && !isSSR) {
|
|
85
83
|
onRedirectTo(routes.loginUrl, {
|
|
86
84
|
refresh: true
|
|
87
85
|
});
|
|
88
86
|
return noUser;
|
|
89
87
|
}
|
|
90
|
-
|
|
91
88
|
return user || noUser;
|
|
92
89
|
};
|
|
93
90
|
export const useAuthUserOrNull = () => {
|
|
@@ -102,10 +99,10 @@ export const useAuthUserOrNull = () => {
|
|
|
102
99
|
}), shallowEqual);
|
|
103
100
|
return user || null;
|
|
104
101
|
};
|
|
102
|
+
|
|
105
103
|
/**
|
|
106
104
|
* hooks helpers
|
|
107
105
|
*/
|
|
108
|
-
|
|
109
106
|
export const sliceReducerActionsBy = reducer => {
|
|
110
107
|
const reducerKeys = Object.keys(reducer);
|
|
111
108
|
const reducerActions = reducerKeys.map(key => ({
|
|
@@ -116,7 +113,6 @@ export const sliceReducerActionsBy = reducer => {
|
|
|
116
113
|
export const stateHookGenerator = (stateMapper, subState) => {
|
|
117
114
|
return useSelector(state => {
|
|
118
115
|
var _stateMapper;
|
|
119
|
-
|
|
120
116
|
return (_stateMapper = stateMapper == null ? void 0 : stateMapper(state[authStoreName][subState])) != null ? _stateMapper : state[authStoreName][subState];
|
|
121
117
|
}, shallowEqual);
|
|
122
118
|
};
|
package/auth/impersonate.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { impersonateActions, impersonateReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useImpersonateState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'impersonateState');
|
|
8
6
|
}
|
package/auth/login.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { loginReducers, loginActions } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useLoginState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'loginState');
|
|
8
6
|
}
|
package/auth/mfa.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { mfaActions, mfaReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useMfaState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'mfaState');
|
|
8
6
|
}
|
package/auth/profile.js
CHANGED
|
@@ -12,9 +12,7 @@ export const reloadProfileIfNeeded = () => {
|
|
|
12
12
|
!loading && loadProfile();
|
|
13
13
|
}, []);
|
|
14
14
|
};
|
|
15
|
-
|
|
16
15
|
const defaultMapper = state => state;
|
|
17
|
-
|
|
18
16
|
export function useProfileState(stateMapper = defaultMapper) {
|
|
19
17
|
return stateHookGenerator(stateMapper, 'profileState');
|
|
20
18
|
}
|
package/auth/provisioning.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { provisioningActions, provisioningReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useProvisioningState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'provisioningState');
|
|
8
6
|
}
|
package/auth/resetPhoneNumber.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { resetPhoneNumberReducers, resetPhoneNumberActions } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useResetPhoneNumberState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'resetPhoneNumberState');
|
|
8
6
|
}
|
package/auth/restrictions.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { restrictionsReducers, restrictionsActions } from '@frontegg/redux-store';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
4
|
-
|
|
5
4
|
const defaultMapper = state => state;
|
|
6
|
-
|
|
7
5
|
export function useRestrictionsState(stateMapper = defaultMapper) {
|
|
8
6
|
return stateHookGenerator(stateMapper, 'restrictionsState');
|
|
9
7
|
}
|
|
@@ -22,7 +20,8 @@ export const useIpRestrictions = (loadOnMount = false) => {
|
|
|
22
20
|
loadIpRestrictions
|
|
23
21
|
} = useRestrictionsActions();
|
|
24
22
|
useEffect(() => {
|
|
25
|
-
(loadOnMount || !data) && loadIpRestrictions();
|
|
23
|
+
(loadOnMount || !data) && loadIpRestrictions();
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
25
|
}, [loadOnMount, loadIpRestrictions]);
|
|
27
26
|
return {
|
|
28
27
|
loading,
|
|
@@ -45,7 +44,8 @@ export const useEmailDomainRestrictions = (loadOnMount = false) => {
|
|
|
45
44
|
loadEmailDomainRestrictions
|
|
46
45
|
} = useRestrictionsActions();
|
|
47
46
|
useEffect(() => {
|
|
48
|
-
(loadOnMount || !data) && loadEmailDomainRestrictions();
|
|
47
|
+
(loadOnMount || !data) && loadEmailDomainRestrictions();
|
|
48
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
49
|
}, [loadOnMount, loadEmailDomainRestrictions]);
|
|
50
50
|
return {
|
|
51
51
|
loading,
|
package/auth/roles.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { rolesReducers, rolesActions } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useRolesState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'rolesState');
|
|
8
6
|
}
|
package/auth/securityPolicy.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { securityPolicyActions, securityPolicyReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
|
-
|
|
5
4
|
const defaultMapper = state => state;
|
|
6
|
-
|
|
7
5
|
export function useSecurityPolicyState(stateMapper = defaultMapper) {
|
|
8
6
|
return stateHookGenerator(stateMapper, 'securityPolicyState');
|
|
9
7
|
}
|
|
@@ -19,7 +17,8 @@ export const usePublicPolicySettings = (loadOnMount = false) => {
|
|
|
19
17
|
loadPublicSecurityPolicy
|
|
20
18
|
} = useSecurityPolicyActions();
|
|
21
19
|
useEffect(() => {
|
|
22
|
-
(loadOnMount || !policy) && loadPublicSecurityPolicy();
|
|
20
|
+
(loadOnMount || !policy) && loadPublicSecurityPolicy();
|
|
21
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
22
|
}, [loadOnMount, loadPublicSecurityPolicy]);
|
|
24
23
|
return {
|
|
25
24
|
loading,
|
|
@@ -39,7 +38,8 @@ export const usePublicAuthStrategiesPolicySettings = (loadOnMount = false) => {
|
|
|
39
38
|
loadPublicAuthStrategiesPolicy
|
|
40
39
|
} = useSecurityPolicyActions();
|
|
41
40
|
useEffect(() => {
|
|
42
|
-
(loadOnMount || !policy) && loadPublicAuthStrategiesPolicy();
|
|
41
|
+
(loadOnMount || !policy) && loadPublicAuthStrategiesPolicy();
|
|
42
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
43
|
}, [loadOnMount, loadPublicAuthStrategiesPolicy]);
|
|
44
44
|
return {
|
|
45
45
|
loading,
|
package/auth/sessions.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { sessionsActions, sessionsReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useSessionsState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'sessionsState');
|
|
8
6
|
}
|
package/auth/sessionsPolicy.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { sessionsPolicyActions, sessionsPolicyReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useSessionsPolicyState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'sessionsPolicyState');
|
|
8
6
|
}
|
package/auth/signup.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { signUpReducers, signUpActions } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useSignUpState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'signUpState');
|
|
8
6
|
}
|
package/auth/socialLogin.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { socialLoginsActions, socialLoginsReducer } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useSocialLoginState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'socialLoginState');
|
|
8
6
|
}
|
package/auth/sso.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ssoActions, ssoReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useSSOState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'ssoState');
|
|
8
6
|
}
|
package/auth/team.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { teamActions, teamReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useAuthTeamState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'teamState');
|
|
8
6
|
}
|
package/auth/tenants.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { tenantsActions, tenantsReducers } from '@frontegg/redux-store';
|
|
2
2
|
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
|
|
4
3
|
const defaultMapper = state => state;
|
|
5
|
-
|
|
6
4
|
export function useTenantsState(stateMapper = defaultMapper) {
|
|
7
5
|
return stateHookGenerator(stateMapper, 'tenantsState');
|
|
8
6
|
}
|
package/common/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { FronteggAppInstance, FronteggAppOptions } from '@frontegg/types';
|
|
3
|
-
import { FronteggState } from '@frontegg/redux-store';
|
|
3
|
+
import type { FronteggState } from '@frontegg/redux-store';
|
|
4
4
|
interface ShadowDomContextData extends FronteggAppOptions {
|
|
5
5
|
injector: FronteggAppInstance;
|
|
6
6
|
iframeRendering: boolean;
|
package/common/index.js
CHANGED
|
@@ -7,17 +7,15 @@ import { shallowEqual } from 'react-redux';
|
|
|
7
7
|
export const ShadowDomContext = /*#__PURE__*/createContext({});
|
|
8
8
|
export const useShadowDom = () => {
|
|
9
9
|
const context = useContext(ShadowDomContext);
|
|
10
|
-
|
|
11
10
|
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
urlStrategy = 'path',
|
|
12
|
+
onRedirectTo = urlStrategy === 'path' ? path => window.history.pushState(null, '', path) : path => window.history.pushState(null, '', `#${path}`),
|
|
13
|
+
renderByRoute = false,
|
|
14
|
+
customLoader = false,
|
|
15
|
+
customStyles,
|
|
16
|
+
contextOptions
|
|
17
|
+
} = context,
|
|
18
|
+
rest = _objectWithoutPropertiesLoose(context, _excluded);
|
|
21
19
|
return _extends({
|
|
22
20
|
isShadowDom: true,
|
|
23
21
|
onRedirectTo,
|
package/connectivity/hooks.js
CHANGED
|
@@ -2,9 +2,7 @@ import { useMemo } from 'react';
|
|
|
2
2
|
import { shallowEqual } from 'react-redux';
|
|
3
3
|
import { useSelector, useDispatch } from '../FronteggStoreContext';
|
|
4
4
|
import { bindActionCreators, connectivityActions, connectivityStoreName } from '@frontegg/redux-store';
|
|
5
|
-
|
|
6
5
|
const defaultMapper = state => state;
|
|
7
|
-
|
|
8
6
|
export function useConnectivityState(stateMapper = defaultMapper) {
|
|
9
7
|
return useSelector(state => stateMapper(state[connectivityStoreName]), shallowEqual);
|
|
10
8
|
}
|
package/flags/useFeatureFlags.js
CHANGED
package/index.js
CHANGED