@frontegg/react-hooks 6.178.0-alpha.2 → 6.178.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.d.ts +12 -1
- package/FronteggProvider/index.js +133 -1
- package/FronteggStoreContext/index.d.ts +13 -1
- package/FronteggStoreContext/index.js +14 -1
- package/audits/auditLogs.d.ts +4 -2
- package/audits/auditLogs.js +6 -8
- package/audits/auditsMetadata.d.ts +4 -2
- package/audits/auditsMetadata.js +6 -8
- package/audits/hooks.d.ts +8 -0
- package/audits/hooks.js +30 -6
- package/auth/{allAccounts.d.ts → MSP/allAccounts.d.ts} +4 -2
- package/auth/MSP/allAccounts.js +15 -0
- package/auth/acceptInvitation.js +5 -10
- package/auth/activateAccount.js +4 -10
- package/auth/apiTokens.d.ts +2 -0
- package/auth/apiTokens.js +6 -8
- package/auth/customLogin.d.ts +5 -2
- package/auth/customLogin.js +11 -10
- package/auth/entitlements.d.ts +14 -14
- package/auth/entitlements.js +21 -25
- package/auth/forgotPassword.d.ts +2 -0
- package/auth/forgotPassword.js +6 -8
- package/auth/groups.d.ts +4 -0
- package/auth/groups.js +13 -12
- package/auth/hooks.d.ts +11 -10
- package/auth/hooks.js +58 -30
- package/auth/impersonate.d.ts +2 -0
- package/auth/impersonate.js +6 -7
- package/auth/index.d.ts +18 -15
- package/auth/index.js +19 -16
- package/auth/login.d.ts +1 -1
- package/auth/login.js +4 -13
- package/auth/mfa.d.ts +1 -1
- package/auth/mfa.js +4 -13
- package/auth/passkeys.d.ts +4 -1
- package/auth/passkeys.js +6 -7
- package/auth/profile.d.ts +4 -2
- package/auth/profile.js +8 -9
- package/auth/provisioning.d.ts +3 -1
- package/auth/provisioning.js +6 -7
- package/auth/resetPhoneNumber.d.ts +3 -1
- package/auth/resetPhoneNumber.js +6 -7
- package/auth/roles.d.ts +3 -1
- package/auth/roles.js +6 -7
- package/auth/security/restrictions.d.ts +2 -0
- package/auth/security/restrictions.js +10 -10
- package/auth/security/securityCenter.d.ts +4 -1
- package/auth/security/securityCenter.js +6 -8
- package/auth/security/securityPolicy.d.ts +11 -5
- package/auth/security/securityPolicy.js +30 -19
- package/auth/security/sessionsPolicy.d.ts +3 -1
- package/auth/security/sessionsPolicy.js +6 -8
- package/auth/sessions.d.ts +3 -1
- package/auth/sessions.js +6 -7
- package/auth/signup.d.ts +1 -1
- package/auth/signup.js +4 -13
- package/auth/sms.d.ts +4 -1
- package/auth/sms.js +6 -7
- package/auth/socialLogin.d.ts +1 -1
- package/auth/socialLogin.js +4 -10
- package/auth/sso.d.ts +1 -1
- package/auth/sso.js +4 -10
- package/auth/stepUp/index.d.ts +2 -0
- package/auth/stepUp/index.js +2 -0
- package/auth/stepUp/interfaces.d.ts +2 -0
- package/auth/stepUp/interfaces.js +1 -0
- package/auth/{stepUp.d.ts → stepUp/stepUp.d.ts} +2 -0
- package/auth/{stepUp.js → stepUp/stepUp.js} +6 -9
- package/auth/team.d.ts +1 -9
- package/auth/team.js +4 -22
- package/auth/tenants.d.ts +3 -1
- package/auth/tenants.js +6 -8
- package/common/CustomComponentHolder.js +1 -3
- package/common/index.js +3 -3
- package/connectivity/hooks.d.ts +5 -2
- package/connectivity/hooks.js +9 -6
- package/index.d.ts +2 -2
- package/index.js +3 -3
- package/node/FronteggProvider/index.js +134 -9
- package/node/FronteggStoreContext/index.js +35 -11
- package/node/audits/auditLogs.js +6 -8
- package/node/audits/auditsMetadata.js +6 -8
- package/node/audits/hooks.js +34 -7
- package/node/auth/MSP/allAccounts.js +24 -0
- package/node/auth/acceptInvitation.js +5 -7
- package/node/auth/activateAccount.js +4 -7
- package/node/auth/apiTokens.js +6 -8
- package/node/auth/customLogin.js +12 -11
- package/node/auth/entitlements.js +20 -24
- package/node/auth/forgotPassword.js +6 -8
- package/node/auth/groups.js +12 -12
- package/node/auth/hooks.js +62 -33
- package/node/auth/impersonate.js +6 -7
- package/node/auth/index.js +120 -91
- package/node/auth/login.js +4 -10
- package/node/auth/mfa.js +4 -10
- package/node/auth/passkeys.js +6 -7
- package/node/auth/profile.js +9 -10
- package/node/auth/provisioning.js +6 -7
- package/node/auth/resetPhoneNumber.js +6 -7
- package/node/auth/roles.js +6 -7
- package/node/auth/security/restrictions.js +10 -10
- package/node/auth/security/securityCenter.js +6 -8
- package/node/auth/security/securityPolicy.js +30 -16
- package/node/auth/security/sessionsPolicy.js +6 -8
- package/node/auth/sessions.js +6 -7
- package/node/auth/signup.js +4 -10
- package/node/auth/sms.js +6 -7
- package/node/auth/socialLogin.js +4 -7
- package/node/auth/sso.js +4 -7
- package/node/auth/stepUp/index.js +27 -0
- package/node/auth/stepUp/interfaces.js +5 -0
- package/node/auth/{stepUp.js → stepUp/stepUp.js} +7 -10
- package/node/auth/team.js +4 -25
- package/node/auth/tenants.js +6 -8
- package/node/common/CustomComponentHolder.js +1 -3
- package/node/common/index.js +2 -2
- package/node/connectivity/hooks.js +8 -5
- package/node/index.js +16 -16
- package/node/subscriptions/hooks.js +51 -84
- package/node/tests/hooks.tsc-test.js +318 -0
- package/node/vendor/hooks.js +6 -5
- package/package.json +3 -3
- package/subscriptions/hooks.d.ts +10 -32
- package/subscriptions/hooks.js +49 -81
- package/tests/hooks.tsc-test.js +317 -0
- package/vendor/hooks.d.ts +1 -0
- package/vendor/hooks.js +7 -9
- package/FronteggProvider/FronteggProvider.d.ts +0 -12
- package/FronteggProvider/FronteggProvider.js +0 -134
- package/FronteggStoreContext/FronteggStoreContext.d.ts +0 -9
- package/FronteggStoreContext/FronteggStoreContext.js +0 -16
- package/auth/allAccounts.js +0 -20
- package/auth/security/index.d.ts +0 -4
- package/auth/security/index.js +0 -4
- package/node/FronteggProvider/FronteggProvider.js +0 -140
- package/node/FronteggStoreContext/FronteggStoreContext.js +0 -26
- package/node/auth/allAccounts.js +0 -27
- package/node/auth/security/index.js +0 -49
package/auth/hooks.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CaseReducerActions, SliceCaseReducers } from '@frontegg/redux-store';
|
|
2
|
+
import { AuthActions, AuthPageRoutes, AuthState, User } from '@frontegg/redux-store';
|
|
2
3
|
import { RedirectOptions } from '@frontegg/rest-api';
|
|
3
|
-
import { AuthPageRoutes, User } from '@frontegg/redux-store';
|
|
4
4
|
export declare type AuthMapper = {
|
|
5
5
|
state: (state: AuthState) => any;
|
|
6
6
|
actions: (actions: AuthActions) => any;
|
|
7
7
|
};
|
|
8
|
+
export declare type StateHookFunction<T> = (() => T) & (<S extends {}>(mapper: (state: T) => S) => S);
|
|
8
9
|
export declare type AuthStateMapper<S> = (state: AuthState) => S;
|
|
9
10
|
/**
|
|
10
11
|
* Use this `frontegg` hook function to obtain the complete authentication state, if it exists.
|
|
@@ -21,7 +22,6 @@ export declare type AuthStateMapper<S> = (state: AuthState) => S;
|
|
|
21
22
|
*/
|
|
22
23
|
export declare function useAuth(): AuthState;
|
|
23
24
|
export declare function useAuth<S>(stateMapper: AuthStateMapper<S>): S;
|
|
24
|
-
export declare function useAuthState(): AuthState;
|
|
25
25
|
/**
|
|
26
26
|
* ```jsx
|
|
27
27
|
* export const MyFunctionComponent = () => {
|
|
@@ -48,13 +48,8 @@ export declare function useAuthState(): AuthState;
|
|
|
48
48
|
*
|
|
49
49
|
* When using this option, you can have the user on the first load, and you can control when the user is redirected to the login page by using `loginWithRedirect`.
|
|
50
50
|
*/
|
|
51
|
-
export declare const useLoginWithRedirect: () =>
|
|
52
|
-
export declare const useLoginWithRedirectV2: () =>
|
|
53
|
-
additionalParams?: Record<string, string> | undefined;
|
|
54
|
-
shouldRedirectToLogin?: boolean | undefined;
|
|
55
|
-
firstTime?: boolean | undefined;
|
|
56
|
-
loginDirectAction?: import("@frontegg/redux-store").LoginDirectAction | undefined;
|
|
57
|
-
} | undefined) => Promise<void>;
|
|
51
|
+
export declare const useLoginWithRedirect: () => AuthActions['requestHostedLoginAuthorize'];
|
|
52
|
+
export declare const useLoginWithRedirectV2: () => AuthActions['requestHostedLoginAuthorizeV2'];
|
|
58
53
|
export declare const useAuthActions: () => AuthActions;
|
|
59
54
|
export declare const useOnRedirectTo: () => (path: string, opts?: RedirectOptions | undefined) => void;
|
|
60
55
|
export declare const useAuthRoutes: () => AuthPageRoutes;
|
|
@@ -92,3 +87,9 @@ export declare const useAuthUser: () => User;
|
|
|
92
87
|
* Use this `frontegg` hook function to retrieve the authenticated user. If the user is not authenticated, this hook will return null. To redirect the user to the login page in case they are not authenticated, use the `useAuthUser` method.
|
|
93
88
|
*/
|
|
94
89
|
export declare const useAuthUserOrNull: () => User | null;
|
|
90
|
+
/**
|
|
91
|
+
* hooks helpers
|
|
92
|
+
*/
|
|
93
|
+
export declare const sliceReducerActionsBy: <T extends SliceCaseReducers<any>>(reducer: T) => CaseReducerActions<T>;
|
|
94
|
+
export declare const stateHookGenerator: (stateMapper: any, subState: keyof AuthState, enableMapperFalsyReturnValue?: boolean) => any;
|
|
95
|
+
export declare const reducerActionsGenerator: (actions: any, reducers: SliceCaseReducers<any>) => any;
|
package/auth/hooks.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { useContext } from 'react';
|
|
2
|
+
import { useContext, useMemo } from 'react';
|
|
3
|
+
import { bindActionCreators } from '@frontegg/redux-store';
|
|
4
|
+
import { authActions, authStoreName } from '@frontegg/redux-store';
|
|
5
|
+
import { shallowEqual } from 'react-redux';
|
|
6
|
+
import { useSelector, useDispatch } from '../FronteggStoreContext';
|
|
3
7
|
import { ContextHolder } from '@frontegg/rest-api';
|
|
4
|
-
import {
|
|
5
|
-
import { useSnapshot } from 'valtio/react';
|
|
8
|
+
import { ShadowDomContext } from '../common';
|
|
6
9
|
const defaultMapper = {
|
|
7
10
|
state: state => state,
|
|
8
11
|
actions: actions => actions
|
|
@@ -23,14 +26,7 @@ const defaultMapper = {
|
|
|
23
26
|
*/
|
|
24
27
|
|
|
25
28
|
export function useAuth(stateMapper = defaultMapper.state) {
|
|
26
|
-
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
return stateMapper(useSnapshot(state));
|
|
29
|
-
}
|
|
30
|
-
export function useAuthState() {
|
|
31
|
-
return useSnapshot(useStore().store.auth, {
|
|
32
|
-
sync: true
|
|
33
|
-
});
|
|
29
|
+
return useSelector(state => stateMapper(state[authStoreName]), shallowEqual);
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
/**
|
|
@@ -60,25 +56,21 @@ export function useAuthState() {
|
|
|
60
56
|
* When using this option, you can have the user on the first load, and you can control when the user is redirected to the login page by using `loginWithRedirect`.
|
|
61
57
|
*/
|
|
62
58
|
export const useLoginWithRedirect = () => {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
} = useContext(FronteggStoreContext);
|
|
66
|
-
return actions.requestHostedLoginAuthorize;
|
|
59
|
+
const dispatch = useDispatch();
|
|
60
|
+
return useMemo(() => bindActionCreators(authActions.requestHostedLoginAuthorize, dispatch), [authActions.requestHostedLoginAuthorize]);
|
|
67
61
|
};
|
|
68
62
|
export const useLoginWithRedirectV2 = () => {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
} = useContext(FronteggStoreContext);
|
|
72
|
-
return actions.requestHostedLoginAuthorizeV2;
|
|
63
|
+
const dispatch = useDispatch();
|
|
64
|
+
return useMemo(() => bindActionCreators(authActions.requestHostedLoginAuthorizeV2, dispatch), [authActions.requestHostedLoginAuthorizeV2]);
|
|
73
65
|
};
|
|
74
66
|
export const useAuthActions = () => {
|
|
75
|
-
|
|
67
|
+
const dispatch = useDispatch();
|
|
68
|
+
return useMemo(() => bindActionCreators(authActions, dispatch), [authActions]);
|
|
76
69
|
};
|
|
77
70
|
export const useOnRedirectTo = () => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return onRedirectTo != null ? onRedirectTo : ContextHolder.onRedirectTo;
|
|
71
|
+
var _context$onRedirectTo;
|
|
72
|
+
const context = useContext(ShadowDomContext);
|
|
73
|
+
return (_context$onRedirectTo = context == null ? void 0 : context.onRedirectTo) != null ? _context$onRedirectTo : ContextHolder.onRedirectTo;
|
|
82
74
|
};
|
|
83
75
|
export const useAuthRoutes = () => useAuth(state => _extends({}, state.routes));
|
|
84
76
|
|
|
@@ -92,12 +84,11 @@ export const useAuthRoutes = () => useAuth(state => _extends({}, state.routes));
|
|
|
92
84
|
*
|
|
93
85
|
* use this frontegg hook function to get if user is "Authenticated"
|
|
94
86
|
*/
|
|
95
|
-
export const useIsAuthenticated = () => {
|
|
96
|
-
|
|
87
|
+
export const useIsAuthenticated = () => useSelector(({
|
|
88
|
+
[authStoreName]: {
|
|
97
89
|
isAuthenticated
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
};
|
|
90
|
+
}
|
|
91
|
+
}) => isAuthenticated, shallowEqual);
|
|
101
92
|
|
|
102
93
|
/**
|
|
103
94
|
* ```jsx
|
|
@@ -141,6 +132,43 @@ export const useAuthUser = () => {
|
|
|
141
132
|
export const useAuthUserOrNull = () => {
|
|
142
133
|
const {
|
|
143
134
|
user
|
|
144
|
-
} =
|
|
135
|
+
} = useSelector(({
|
|
136
|
+
[authStoreName]: {
|
|
137
|
+
user
|
|
138
|
+
}
|
|
139
|
+
}) => ({
|
|
140
|
+
user
|
|
141
|
+
}), shallowEqual);
|
|
145
142
|
return user || null;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* hooks helpers
|
|
147
|
+
*/
|
|
148
|
+
export const sliceReducerActionsBy = reducer => {
|
|
149
|
+
const reducerKeys = Object.keys(reducer);
|
|
150
|
+
const reducerActions = reducerKeys.map(key => ({
|
|
151
|
+
[key]: authActions[key]
|
|
152
|
+
}));
|
|
153
|
+
return reducerActions.reduce((p, n) => _extends({}, p, n), {});
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/*
|
|
157
|
+
* enableMapperFalsyReturnValue was added to be backward compatible with all usages
|
|
158
|
+
* the scenario that require enableMapperFalsyReturnValue of true is when the
|
|
159
|
+
* mapper function returns a falsy value then we want to return it as is - it's a valid case like in entitlements (when it's undefined)
|
|
160
|
+
* IMO all usages should be like that
|
|
161
|
+
*/
|
|
162
|
+
export const stateHookGenerator = (stateMapper, subState, enableMapperFalsyReturnValue = false) => {
|
|
163
|
+
return useSelector(state => {
|
|
164
|
+
const mapperValue = stateMapper == null ? void 0 : stateMapper(state[authStoreName][subState]);
|
|
165
|
+
if (enableMapperFalsyReturnValue && stateMapper) {
|
|
166
|
+
return mapperValue;
|
|
167
|
+
}
|
|
168
|
+
return mapperValue != null ? mapperValue : state[authStoreName][subState];
|
|
169
|
+
}, shallowEqual);
|
|
170
|
+
};
|
|
171
|
+
export const reducerActionsGenerator = (actions, reducers) => {
|
|
172
|
+
const dispatch = useDispatch();
|
|
173
|
+
return useMemo(() => bindActionCreators(_extends({}, actions, sliceReducerActionsBy(reducers)), dispatch), [dispatch]);
|
|
146
174
|
};
|
package/auth/impersonate.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { ImpersonateState, ImpersonateActions } from '@frontegg/redux-store';
|
|
2
|
+
export declare type ImpersonateStateMapper<S> = (state: ImpersonateState) => S;
|
|
2
3
|
export declare function useImpersonateState(): ImpersonateState;
|
|
4
|
+
export declare function useImpersonateState<S>(stateMapper: ImpersonateStateMapper<S>): S;
|
|
3
5
|
export declare const useImpersonateActions: () => ImpersonateActions;
|
package/auth/impersonate.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { impersonateActions, impersonateReducers } from '@frontegg/redux-store';
|
|
2
|
+
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
+
const defaultMapper = state => state;
|
|
4
|
+
export function useImpersonateState(stateMapper = defaultMapper) {
|
|
5
|
+
return stateHookGenerator(stateMapper, 'impersonateState');
|
|
5
6
|
}
|
|
6
|
-
export const useImpersonateActions = () =>
|
|
7
|
-
return useStore().stateActions.auth.impersonateActions;
|
|
8
|
-
};
|
|
7
|
+
export const useImpersonateActions = () => reducerActionsGenerator(impersonateActions, impersonateReducers);
|
package/auth/index.d.ts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { useAuth, useAuthActions, useOnRedirectTo, useAuthRoutes, useIsAuthenticated, useAuthUser, useAuthUserOrNull, useLoginWithRedirect, useLoginWithRedirectV2, } from './hooks';
|
|
2
2
|
export * from './acceptInvitation';
|
|
3
3
|
export * from './activateAccount';
|
|
4
|
-
export * from './allAccounts';
|
|
5
4
|
export * from './apiTokens';
|
|
6
|
-
export * from './customLogin';
|
|
7
|
-
export * from './entitlements';
|
|
8
5
|
export * from './forgotPassword';
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './impersonate';
|
|
6
|
+
export * from './resetPhoneNumber';
|
|
11
7
|
export * from './login';
|
|
8
|
+
export * from './stepUp';
|
|
12
9
|
export * from './mfa';
|
|
13
|
-
export * from './passkeys';
|
|
14
10
|
export * from './profile';
|
|
15
|
-
export * from './provisioning';
|
|
16
|
-
export * from './resetPhoneNumber';
|
|
17
|
-
export * from './roles';
|
|
18
|
-
export * from './sessions';
|
|
19
11
|
export * from './signup';
|
|
20
|
-
export * from './sms';
|
|
21
12
|
export * from './socialLogin';
|
|
22
|
-
export * from './sso';
|
|
23
|
-
export * from './stepUp';
|
|
24
13
|
export * from './team';
|
|
25
|
-
export * from './
|
|
14
|
+
export * from './sso';
|
|
15
|
+
export * from './security/securityPolicy';
|
|
26
16
|
export * from './tenants';
|
|
17
|
+
export * from './roles';
|
|
18
|
+
export * from './sessions';
|
|
19
|
+
export * from './security/sessionsPolicy';
|
|
20
|
+
export * from './security/restrictions';
|
|
21
|
+
export * from './provisioning';
|
|
22
|
+
export * from './impersonate';
|
|
23
|
+
export * from './passkeys';
|
|
24
|
+
export * from './groups';
|
|
25
|
+
export * from './customLogin';
|
|
26
|
+
export * from './MSP/allAccounts';
|
|
27
|
+
export * from './entitlements';
|
|
28
|
+
export * from './security/securityCenter';
|
|
29
|
+
export * from './sms';
|
package/auth/index.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { useAuth, useAuthActions, useOnRedirectTo, useAuthRoutes, useIsAuthenticated, useAuthUser, useAuthUserOrNull, useLoginWithRedirect, useLoginWithRedirectV2 } from './hooks';
|
|
2
2
|
export * from './acceptInvitation';
|
|
3
3
|
export * from './activateAccount';
|
|
4
|
-
export * from './allAccounts';
|
|
5
4
|
export * from './apiTokens';
|
|
6
|
-
export * from './customLogin';
|
|
7
|
-
export * from './entitlements';
|
|
8
5
|
export * from './forgotPassword';
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './impersonate';
|
|
6
|
+
export * from './resetPhoneNumber';
|
|
11
7
|
export * from './login';
|
|
8
|
+
export * from './stepUp';
|
|
12
9
|
export * from './mfa';
|
|
13
|
-
export * from './passkeys';
|
|
14
10
|
export * from './profile';
|
|
15
|
-
export * from './provisioning';
|
|
16
|
-
export * from './resetPhoneNumber';
|
|
17
|
-
export * from './roles';
|
|
18
|
-
export * from './sessions';
|
|
19
11
|
export * from './signup';
|
|
20
|
-
export * from './sms';
|
|
21
12
|
export * from './socialLogin';
|
|
22
|
-
export * from './sso';
|
|
23
|
-
export * from './stepUp';
|
|
24
13
|
export * from './team';
|
|
25
|
-
export * from './
|
|
26
|
-
export * from './
|
|
14
|
+
export * from './sso';
|
|
15
|
+
export * from './security/securityPolicy';
|
|
16
|
+
export * from './tenants';
|
|
17
|
+
export * from './roles';
|
|
18
|
+
export * from './sessions';
|
|
19
|
+
export * from './security/sessionsPolicy';
|
|
20
|
+
export * from './security/restrictions';
|
|
21
|
+
export * from './provisioning';
|
|
22
|
+
export * from './impersonate';
|
|
23
|
+
export * from './passkeys';
|
|
24
|
+
export * from './groups';
|
|
25
|
+
export * from './customLogin';
|
|
26
|
+
export * from './MSP/allAccounts';
|
|
27
|
+
export * from './entitlements';
|
|
28
|
+
export * from './security/securityCenter';
|
|
29
|
+
export * from './sms';
|
package/auth/login.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { LoginState, LoginActions } from '@frontegg/redux-store';
|
|
2
2
|
export declare type LoginStateMapper<S> = (state: LoginState) => S;
|
|
3
3
|
export declare function useLoginState(): LoginState;
|
|
4
4
|
export declare function useLoginState<S>(stateMapper: LoginStateMapper<S>): S;
|
package/auth/login.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
-
|
|
1
|
+
import { loginReducers, loginActions } from '@frontegg/redux-store';
|
|
2
|
+
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
6
3
|
const defaultMapper = state => state;
|
|
7
|
-
// @deprecated use useLoginState() instead
|
|
8
4
|
export function useLoginState(stateMapper = defaultMapper) {
|
|
9
|
-
|
|
10
|
-
loginState
|
|
11
|
-
} = useStore().store.auth;
|
|
12
|
-
return stateMapper(useSnapshot(loginState));
|
|
5
|
+
return stateHookGenerator(stateMapper, 'loginState');
|
|
13
6
|
}
|
|
14
|
-
export const useLoginActions = () =>
|
|
15
|
-
return useStore().stateActions.auth.loginActions;
|
|
16
|
-
};
|
|
7
|
+
export const useLoginActions = () => reducerActionsGenerator(loginActions, loginReducers);
|
package/auth/mfa.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MfaActions, MFAState } from '@frontegg/redux-store';
|
|
2
2
|
declare type AuthMfaStateMapper<S> = (state: MFAState) => S;
|
|
3
3
|
export declare function useMfaState(): MFAState;
|
|
4
4
|
export declare function useMfaState<S>(stateMapper: AuthMfaStateMapper<S>): S;
|
package/auth/mfa.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
-
|
|
1
|
+
import { mfaActions, mfaReducers } from '@frontegg/redux-store';
|
|
2
|
+
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
6
3
|
const defaultMapper = state => state;
|
|
7
|
-
// @deprecated use useMfaState() instead
|
|
8
4
|
export function useMfaState(stateMapper = defaultMapper) {
|
|
9
|
-
|
|
10
|
-
mfaState
|
|
11
|
-
} = useStore().store.auth;
|
|
12
|
-
return stateMapper(useSnapshot(mfaState));
|
|
5
|
+
return stateHookGenerator(stateMapper, 'mfaState');
|
|
13
6
|
}
|
|
14
|
-
export const useMfaActions = () =>
|
|
15
|
-
return useStore().stateActions.auth.mfaActions;
|
|
16
|
-
};
|
|
7
|
+
export const useMfaActions = () => reducerActionsGenerator(mfaActions, mfaReducers);
|
package/auth/passkeys.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PasskeysActions, PasskeysState } from '@frontegg/redux-store';
|
|
2
|
+
declare type AuthPasskeysStateMapper<S> = (state: PasskeysState) => S;
|
|
2
3
|
export declare function usePasskeysState(): PasskeysState;
|
|
4
|
+
export declare function usePasskeysState<S>(stateMapper: AuthPasskeysStateMapper<S>): S;
|
|
3
5
|
export declare const usePasskeysActions: () => PasskeysActions;
|
|
6
|
+
export {};
|
package/auth/passkeys.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { passkeysActions, passkeysReducers } from '@frontegg/redux-store';
|
|
2
|
+
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
+
const defaultMapper = state => state;
|
|
4
|
+
export function usePasskeysState(stateMapper = defaultMapper) {
|
|
5
|
+
return stateHookGenerator(stateMapper, 'passkeysState');
|
|
5
6
|
}
|
|
6
|
-
export const usePasskeysActions = () =>
|
|
7
|
-
return useStore().stateActions.auth.passkeysActions;
|
|
8
|
-
};
|
|
7
|
+
export const usePasskeysActions = () => reducerActionsGenerator(passkeysActions, passkeysReducers);
|
package/auth/profile.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ProfileActions, ProfileState } from '@frontegg/redux-store';
|
|
2
|
+
export declare const reloadProfileIfNeeded: () => void;
|
|
3
|
+
export declare type ProfileStateMapper<S> = (state: ProfileState) => S;
|
|
2
4
|
export declare function useProfileState(): ProfileState;
|
|
5
|
+
export declare function useProfileState<S>(stateMapper: ProfileStateMapper<S>): S;
|
|
3
6
|
export declare const useProfileActions: () => ProfileActions;
|
|
4
|
-
export declare const reloadProfileIfNeeded: () => void;
|
package/auth/profile.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export function useProfileState() {
|
|
5
|
-
return useSnapshot(useStore().store.auth.profileState);
|
|
6
|
-
}
|
|
7
|
-
export const useProfileActions = () => {
|
|
8
|
-
return useStore().stateActions.auth.profileActions;
|
|
9
|
-
};
|
|
2
|
+
import { profileActions, profileReducers } from '@frontegg/redux-store';
|
|
3
|
+
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
10
4
|
export const reloadProfileIfNeeded = () => {
|
|
11
5
|
const {
|
|
12
6
|
loading
|
|
@@ -17,4 +11,9 @@ export const reloadProfileIfNeeded = () => {
|
|
|
17
11
|
useEffect(() => {
|
|
18
12
|
!loading && loadProfile();
|
|
19
13
|
}, []);
|
|
20
|
-
};
|
|
14
|
+
};
|
|
15
|
+
const defaultMapper = state => state;
|
|
16
|
+
export function useProfileState(stateMapper = defaultMapper) {
|
|
17
|
+
return stateHookGenerator(stateMapper, 'profileState');
|
|
18
|
+
}
|
|
19
|
+
export const useProfileActions = () => reducerActionsGenerator(profileActions, profileReducers);
|
package/auth/provisioning.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ProvisioningActions, ProvisioningState } from '@frontegg/redux-store';
|
|
2
|
+
export declare type ProvisioningStateMapper<S> = (state: ProvisioningState) => S;
|
|
2
3
|
export declare function useProvisioningState(): ProvisioningState;
|
|
4
|
+
export declare function useProvisioningState<S>(stateMapper: ProvisioningStateMapper<S>): S;
|
|
3
5
|
export declare const useProvisioningActions: () => ProvisioningActions;
|
package/auth/provisioning.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { provisioningActions, provisioningReducers } from '@frontegg/redux-store';
|
|
2
|
+
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
+
const defaultMapper = state => state;
|
|
4
|
+
export function useProvisioningState(stateMapper = defaultMapper) {
|
|
5
|
+
return stateHookGenerator(stateMapper, 'provisioningState');
|
|
5
6
|
}
|
|
6
|
-
export const useProvisioningActions = () =>
|
|
7
|
-
return useStore().stateActions.auth.provisioningActions;
|
|
8
|
-
};
|
|
7
|
+
export const useProvisioningActions = () => reducerActionsGenerator(provisioningActions, provisioningReducers);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ResetPhoneNumberState, ResetPhoneNumberActions } from '@frontegg/redux-store';
|
|
2
|
+
export declare type ResetPhoneNumberStateMapper<S> = (state: ResetPhoneNumberState) => S;
|
|
2
3
|
export declare function useResetPhoneNumberState(): ResetPhoneNumberState;
|
|
4
|
+
export declare function useResetPhoneNumberState<S>(stateMapper: ResetPhoneNumberStateMapper<S>): S;
|
|
3
5
|
export declare const useResetPhoneNumberActions: () => ResetPhoneNumberActions;
|
package/auth/resetPhoneNumber.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { resetPhoneNumberReducers, resetPhoneNumberActions } from '@frontegg/redux-store';
|
|
2
|
+
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
+
const defaultMapper = state => state;
|
|
4
|
+
export function useResetPhoneNumberState(stateMapper = defaultMapper) {
|
|
5
|
+
return stateHookGenerator(stateMapper, 'resetPhoneNumberState');
|
|
5
6
|
}
|
|
6
|
-
export const useResetPhoneNumberActions = () =>
|
|
7
|
-
return useStore().stateActions.auth.resetPhoneNumberActions;
|
|
8
|
-
};
|
|
7
|
+
export const useResetPhoneNumberActions = () => reducerActionsGenerator(resetPhoneNumberActions, resetPhoneNumberReducers);
|
package/auth/roles.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RolesActions, RolesState } from '@frontegg/redux-store';
|
|
2
|
+
export declare type RolesStateMapper<S> = (state: RolesState) => S;
|
|
2
3
|
export declare function useRolesState(): RolesState;
|
|
4
|
+
export declare function useRolesState<S>(stateMapper: RolesStateMapper<S>): S;
|
|
3
5
|
export declare const useRolesActions: () => RolesActions;
|
package/auth/roles.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { rolesReducers, rolesActions } from '@frontegg/redux-store';
|
|
2
|
+
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
+
const defaultMapper = state => state;
|
|
4
|
+
export function useRolesState(stateMapper = defaultMapper) {
|
|
5
|
+
return stateHookGenerator(stateMapper, 'rolesState');
|
|
5
6
|
}
|
|
6
|
-
export const useRolesActions = () =>
|
|
7
|
-
return useStore().stateActions.auth.rolesActions;
|
|
8
|
-
};
|
|
7
|
+
export const useRolesActions = () => reducerActionsGenerator(rolesActions, rolesReducers);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { RestrictionsActions, RestrictionsState } from '@frontegg/redux-store';
|
|
2
|
+
export declare type RestrictionsStateMapper<S> = (state: RestrictionsState) => S;
|
|
2
3
|
export declare function useRestrictionsState(): RestrictionsState;
|
|
4
|
+
export declare function useRestrictionsState<S>(stateMapper: RestrictionsStateMapper<S>): S;
|
|
3
5
|
export declare const useRestrictionsActions: () => RestrictionsActions;
|
|
4
6
|
export declare const useIpRestrictions: (loadOnMount?: boolean) => {
|
|
5
7
|
loading: boolean;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { restrictionsReducers, restrictionsActions } from '@frontegg/redux-store';
|
|
1
2
|
import { useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export function useRestrictionsState() {
|
|
5
|
-
|
|
6
|
-
return useSnapshot(state);
|
|
3
|
+
import { reducerActionsGenerator, stateHookGenerator } from '../hooks';
|
|
4
|
+
const defaultMapper = state => state;
|
|
5
|
+
export function useRestrictionsState(stateMapper = defaultMapper) {
|
|
6
|
+
return stateHookGenerator(stateMapper, 'restrictionsState');
|
|
7
7
|
}
|
|
8
|
-
export const useRestrictionsActions = () =>
|
|
9
|
-
return useStore().stateActions.auth.restrictionsActions;
|
|
10
|
-
};
|
|
8
|
+
export const useRestrictionsActions = () => reducerActionsGenerator(restrictionsActions, restrictionsReducers);
|
|
11
9
|
export const useIpRestrictions = (loadOnMount = false) => {
|
|
12
10
|
const {
|
|
13
11
|
loading,
|
|
@@ -17,12 +15,13 @@ export const useIpRestrictions = (loadOnMount = false) => {
|
|
|
17
15
|
pagination,
|
|
18
16
|
totalPages,
|
|
19
17
|
userIpValid
|
|
20
|
-
} = useRestrictionsState(
|
|
18
|
+
} = useRestrictionsState(state => state.ipRestrictions);
|
|
21
19
|
const {
|
|
22
20
|
loadIpRestrictions
|
|
23
21
|
} = useRestrictionsActions();
|
|
24
22
|
useEffect(() => {
|
|
25
23
|
(loadOnMount || !data) && loadIpRestrictions();
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
25
|
}, [loadOnMount, loadIpRestrictions]);
|
|
27
26
|
return {
|
|
28
27
|
loading,
|
|
@@ -40,12 +39,13 @@ export const useEmailDomainRestrictions = (loadOnMount = false) => {
|
|
|
40
39
|
data,
|
|
41
40
|
saving,
|
|
42
41
|
error
|
|
43
|
-
} = useRestrictionsState(
|
|
42
|
+
} = useRestrictionsState(state => state.emailDomainRestrictions);
|
|
44
43
|
const {
|
|
45
44
|
loadEmailDomainRestrictions
|
|
46
45
|
} = useRestrictionsActions();
|
|
47
46
|
useEffect(() => {
|
|
48
47
|
(loadOnMount || !data) && loadEmailDomainRestrictions();
|
|
48
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
49
|
}, [loadOnMount, loadEmailDomainRestrictions]);
|
|
50
50
|
return {
|
|
51
51
|
loading,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SecurityCenterActions, SecurityCenterState } from '@frontegg/redux-store';
|
|
2
|
+
declare type AuthSecurityCenterStateMapper<S> = (state: SecurityCenterState) => S;
|
|
2
3
|
export declare function useSecurityCenterState(): SecurityCenterState;
|
|
4
|
+
export declare function useSecurityCenterState<S>(stateMapper: AuthSecurityCenterStateMapper<S>): S;
|
|
3
5
|
export declare const useSecurityCenterActions: () => SecurityCenterActions;
|
|
6
|
+
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
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
6
|
}
|
|
7
|
-
export const useSecurityCenterActions = () =>
|
|
8
|
-
return useStore().stateActions.auth.securityCenterActions;
|
|
9
|
-
};
|
|
7
|
+
export const useSecurityCenterActions = () => reducerActionsGenerator(securityCenterActions, securityCenterReducers);
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SecurityPolicyActions, SecurityPolicyState } from '@frontegg/redux-store';
|
|
2
2
|
export declare type SecurityPolicyStateMapper<S> = (state: SecurityPolicyState) => S;
|
|
3
3
|
export declare function useSecurityPolicyState(): SecurityPolicyState;
|
|
4
4
|
export declare function useSecurityPolicyState<S>(stateMapper: SecurityPolicyStateMapper<S>): S;
|
|
5
5
|
export declare const useSecurityPolicyActions: () => SecurityPolicyActions;
|
|
6
|
-
export declare const usePublicPolicySettings: (loadOnMount?: boolean) =>
|
|
7
|
-
|
|
6
|
+
export declare const usePublicPolicySettings: (loadOnMount?: boolean) => {
|
|
7
|
+
loading: boolean;
|
|
8
|
+
saving: boolean | undefined;
|
|
9
|
+
error: any;
|
|
10
|
+
policy: import("@frontegg/rest-api").IVendorConfig | undefined;
|
|
8
11
|
};
|
|
9
|
-
export declare const usePublicAuthStrategiesPolicySettings: (loadOnMount?: boolean) =>
|
|
10
|
-
|
|
12
|
+
export declare const usePublicAuthStrategiesPolicySettings: (loadOnMount?: boolean) => {
|
|
13
|
+
loading: boolean;
|
|
14
|
+
saving: boolean | undefined;
|
|
15
|
+
error: any;
|
|
16
|
+
policy: import("@frontegg/rest-api").IAuthStrategiesConfig | undefined;
|
|
11
17
|
};
|