@frontegg/react-hooks 7.0.0-alpha.0 → 7.0.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/FronteggProvider/FronteggProvider.d.ts +12 -0
- package/FronteggProvider/FronteggProvider.js +138 -0
- package/FronteggProvider/index.d.ts +1 -12
- package/FronteggProvider/index.js +1 -133
- package/FronteggStoreContext/FronteggStoreContext.d.ts +9 -0
- package/FronteggStoreContext/FronteggStoreContext.js +16 -0
- package/FronteggStoreContext/index.d.ts +1 -13
- package/FronteggStoreContext/index.js +1 -14
- package/audits/auditLogs.d.ts +2 -4
- package/audits/auditLogs.js +8 -6
- package/audits/auditsMetadata.d.ts +2 -4
- package/audits/auditsMetadata.js +8 -6
- package/audits/hooks.d.ts +0 -8
- package/audits/hooks.js +6 -30
- package/auth/acceptInvitation.js +10 -5
- package/auth/activateAccount.js +10 -4
- package/auth/{MSP/allAccounts.d.ts → allAccounts.d.ts} +2 -4
- package/auth/allAccounts.js +20 -0
- package/auth/apiTokens.d.ts +0 -2
- package/auth/apiTokens.js +8 -6
- package/auth/customLogin.d.ts +2 -5
- package/auth/customLogin.js +10 -11
- package/auth/entitlements.d.ts +32 -13
- package/auth/entitlements.js +116 -21
- package/auth/forgotPassword.d.ts +0 -2
- package/auth/forgotPassword.js +8 -6
- package/auth/groups.d.ts +0 -4
- package/auth/groups.js +12 -13
- package/auth/hooks.d.ts +44 -12
- package/auth/hooks.js +73 -62
- package/auth/impersonate.d.ts +0 -2
- package/auth/impersonate.js +7 -6
- package/auth/index.d.ts +15 -16
- package/auth/index.js +16 -17
- package/auth/login.d.ts +1 -3
- package/auth/login.js +7 -6
- package/auth/mfa.d.ts +1 -1
- package/auth/mfa.js +13 -4
- package/auth/passkeys.d.ts +1 -4
- package/auth/passkeys.js +7 -6
- package/auth/profile.d.ts +2 -4
- package/auth/profile.js +9 -8
- package/auth/provisioning.d.ts +1 -3
- package/auth/provisioning.js +7 -6
- package/auth/resetPhoneNumber.d.ts +1 -3
- package/auth/resetPhoneNumber.js +7 -6
- package/auth/roles.d.ts +1 -3
- package/auth/roles.js +7 -6
- package/auth/security/index.d.ts +4 -0
- package/auth/security/index.js +4 -0
- package/auth/security/restrictions.d.ts +0 -2
- package/auth/security/restrictions.js +10 -10
- package/auth/security/securityCenter.d.ts +1 -4
- package/auth/security/securityCenter.js +8 -6
- package/auth/security/securityPolicy.d.ts +5 -11
- package/auth/security/securityPolicy.js +19 -30
- package/auth/security/sessionsPolicy.d.ts +1 -3
- package/auth/security/sessionsPolicy.js +8 -6
- package/auth/sessions.d.ts +1 -3
- package/auth/sessions.js +7 -6
- package/auth/signup.d.ts +1 -1
- package/auth/signup.js +13 -4
- package/auth/sms.d.ts +3 -0
- package/auth/sms.js +8 -0
- package/auth/socialLogin.d.ts +1 -1
- package/auth/socialLogin.js +10 -4
- package/auth/sso.d.ts +1 -1
- package/auth/sso.js +10 -4
- package/auth/stepUp.d.ts +16 -0
- package/auth/stepUp.js +51 -0
- package/auth/team.d.ts +9 -1
- package/auth/team.js +22 -4
- package/auth/tenants.d.ts +1 -3
- package/auth/tenants.js +8 -6
- package/common/CustomComponentHolder.js +3 -1
- package/common/index.js +3 -3
- package/connectivity/hooks.d.ts +2 -5
- package/connectivity/hooks.js +6 -9
- package/index.d.ts +2 -2
- package/index.js +3 -3
- package/node/FronteggProvider/FronteggProvider.js +146 -0
- package/node/FronteggProvider/index.js +9 -134
- package/node/FronteggStoreContext/FronteggStoreContext.js +28 -0
- package/node/FronteggStoreContext/index.js +11 -35
- package/node/audits/auditLogs.js +8 -6
- package/node/audits/auditsMetadata.js +8 -6
- package/node/audits/hooks.js +7 -34
- package/node/auth/acceptInvitation.js +7 -5
- package/node/auth/activateAccount.js +7 -4
- package/node/auth/allAccounts.js +27 -0
- package/node/auth/apiTokens.js +8 -6
- package/node/auth/customLogin.js +11 -12
- package/node/auth/entitlements.js +119 -22
- package/node/auth/forgotPassword.js +8 -6
- package/node/auth/groups.js +12 -12
- package/node/auth/hooks.js +77 -67
- package/node/auth/impersonate.js +7 -6
- package/node/auth/index.js +103 -101
- package/node/auth/login.js +7 -6
- package/node/auth/mfa.js +10 -4
- package/node/auth/passkeys.js +7 -6
- package/node/auth/profile.js +10 -9
- package/node/auth/provisioning.js +7 -6
- package/node/auth/resetPhoneNumber.js +7 -6
- package/node/auth/roles.js +7 -6
- package/node/auth/security/index.js +49 -0
- package/node/auth/security/restrictions.js +10 -10
- package/node/auth/security/securityCenter.js +8 -6
- package/node/auth/security/securityPolicy.js +16 -30
- package/node/auth/security/sessionsPolicy.js +8 -6
- package/node/auth/sessions.js +7 -6
- package/node/auth/signup.js +10 -4
- package/node/auth/sms.js +16 -0
- package/node/auth/socialLogin.js +7 -4
- package/node/auth/sso.js +7 -4
- package/node/auth/stepUp.js +62 -0
- package/node/auth/team.js +25 -4
- package/node/auth/tenants.js +8 -6
- package/node/common/CustomComponentHolder.js +3 -1
- package/node/common/index.js +2 -2
- package/node/connectivity/hooks.js +5 -8
- package/node/index.js +16 -16
- package/node/subscriptions/hooks.js +84 -51
- package/node/tests/hooks.tsc-test.js +339 -0
- package/node/useSnapshot/index.js +137 -0
- package/node/vendor/hooks.js +5 -6
- package/package.json +3 -3
- package/subscriptions/hooks.d.ts +32 -10
- package/subscriptions/hooks.js +81 -49
- package/tests/hooks.tsc-test.js +338 -0
- package/useSnapshot/index.d.ts +78 -0
- package/useSnapshot/index.js +128 -0
- package/useSnapshot/package.json +6 -0
- package/vendor/hooks.d.ts +0 -1
- package/vendor/hooks.js +9 -7
- package/auth/MSP/allAccounts.js +0 -15
- package/node/auth/MSP/allAccounts.js +0 -24
package/auth/login.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return stateHookGenerator(stateMapper, 'loginState');
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
export function useLoginState() {
|
|
4
|
+
return useSnapshot(useStore().store.auth.loginState);
|
|
6
5
|
}
|
|
7
|
-
export const useLoginActions = () =>
|
|
6
|
+
export const useLoginActions = () => {
|
|
7
|
+
return useStore().stateActions.auth.loginActions;
|
|
8
|
+
};
|
package/auth/mfa.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MfaActions, MFAState } from '@frontegg/redux-store';
|
|
1
|
+
import type { 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,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
|
|
4
|
+
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
+
|
|
3
6
|
const defaultMapper = state => state;
|
|
7
|
+
// @deprecated use useMfaState() instead
|
|
4
8
|
export function useMfaState(stateMapper = defaultMapper) {
|
|
5
|
-
|
|
9
|
+
const {
|
|
10
|
+
mfaState
|
|
11
|
+
} = useStore().store.auth;
|
|
12
|
+
return stateMapper(useSnapshot(mfaState));
|
|
6
13
|
}
|
|
7
|
-
export const useMfaActions = () =>
|
|
14
|
+
export const useMfaActions = () => {
|
|
15
|
+
return useStore().stateActions.auth.mfaActions;
|
|
16
|
+
};
|
package/auth/passkeys.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { PasskeysActions, PasskeysState } from '@frontegg/redux-store';
|
|
2
|
-
declare type AuthPasskeysStateMapper<S> = (state: PasskeysState) => S;
|
|
1
|
+
import type { PasskeysActions, PasskeysState } from '@frontegg/redux-store';
|
|
3
2
|
export declare function usePasskeysState(): PasskeysState;
|
|
4
|
-
export declare function usePasskeysState<S>(stateMapper: AuthPasskeysStateMapper<S>): S;
|
|
5
3
|
export declare const usePasskeysActions: () => PasskeysActions;
|
|
6
|
-
export {};
|
package/auth/passkeys.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return stateHookGenerator(stateMapper, 'passkeysState');
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
export function usePasskeysState() {
|
|
4
|
+
return useSnapshot(useStore().store.auth.passkeysState);
|
|
6
5
|
}
|
|
7
|
-
export const usePasskeysActions = () =>
|
|
6
|
+
export const usePasskeysActions = () => {
|
|
7
|
+
return useStore().stateActions.auth.passkeysActions;
|
|
8
|
+
};
|
package/auth/profile.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { ProfileActions, ProfileState } from '@frontegg/redux-store';
|
|
2
|
-
export declare const reloadProfileIfNeeded: () => void;
|
|
3
|
-
export declare type ProfileStateMapper<S> = (state: ProfileState) => S;
|
|
1
|
+
import type { ProfileActions, ProfileState } from '@frontegg/redux-store';
|
|
4
2
|
export declare function useProfileState(): ProfileState;
|
|
5
|
-
export declare function useProfileState<S>(stateMapper: ProfileStateMapper<S>): S;
|
|
6
3
|
export declare const useProfileActions: () => ProfileActions;
|
|
4
|
+
export declare const reloadProfileIfNeeded: () => void;
|
package/auth/profile.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
3
|
+
import { useStore } from '../FronteggStoreContext';
|
|
4
|
+
export function useProfileState() {
|
|
5
|
+
return useSnapshot(useStore().store.auth.profileState);
|
|
6
|
+
}
|
|
7
|
+
export const useProfileActions = () => {
|
|
8
|
+
return useStore().stateActions.auth.profileActions;
|
|
9
|
+
};
|
|
4
10
|
export const reloadProfileIfNeeded = () => {
|
|
5
11
|
const {
|
|
6
12
|
loading
|
|
@@ -11,9 +17,4 @@ export const reloadProfileIfNeeded = () => {
|
|
|
11
17
|
useEffect(() => {
|
|
12
18
|
!loading && loadProfile();
|
|
13
19
|
}, []);
|
|
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);
|
|
20
|
+
};
|
package/auth/provisioning.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ProvisioningActions, ProvisioningState } from '@frontegg/redux-store';
|
|
2
|
-
export declare type ProvisioningStateMapper<S> = (state: ProvisioningState) => S;
|
|
1
|
+
import type { ProvisioningActions, ProvisioningState } from '@frontegg/redux-store';
|
|
3
2
|
export declare function useProvisioningState(): ProvisioningState;
|
|
4
|
-
export declare function useProvisioningState<S>(stateMapper: ProvisioningStateMapper<S>): S;
|
|
5
3
|
export declare const useProvisioningActions: () => ProvisioningActions;
|
package/auth/provisioning.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return stateHookGenerator(stateMapper, 'provisioningState');
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
export function useProvisioningState() {
|
|
4
|
+
return useSnapshot(useStore().store.auth.provisioningState);
|
|
6
5
|
}
|
|
7
|
-
export const useProvisioningActions = () =>
|
|
6
|
+
export const useProvisioningActions = () => {
|
|
7
|
+
return useStore().stateActions.auth.provisioningActions;
|
|
8
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ResetPhoneNumberState, ResetPhoneNumberActions } from '@frontegg/redux-store';
|
|
2
|
-
export declare type ResetPhoneNumberStateMapper<S> = (state: ResetPhoneNumberState) => S;
|
|
1
|
+
import type { ResetPhoneNumberState, ResetPhoneNumberActions } from '@frontegg/redux-store';
|
|
3
2
|
export declare function useResetPhoneNumberState(): ResetPhoneNumberState;
|
|
4
|
-
export declare function useResetPhoneNumberState<S>(stateMapper: ResetPhoneNumberStateMapper<S>): S;
|
|
5
3
|
export declare const useResetPhoneNumberActions: () => ResetPhoneNumberActions;
|
package/auth/resetPhoneNumber.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return stateHookGenerator(stateMapper, 'resetPhoneNumberState');
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
export function useResetPhoneNumberState() {
|
|
4
|
+
return useSnapshot(useStore().store.auth.resetPhoneNumberState);
|
|
6
5
|
}
|
|
7
|
-
export const useResetPhoneNumberActions = () =>
|
|
6
|
+
export const useResetPhoneNumberActions = () => {
|
|
7
|
+
return useStore().stateActions.auth.resetPhoneNumberActions;
|
|
8
|
+
};
|
package/auth/roles.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { RolesActions, RolesState } from '@frontegg/redux-store';
|
|
2
|
-
export declare type RolesStateMapper<S> = (state: RolesState) => S;
|
|
1
|
+
import type { RolesActions, RolesState } from '@frontegg/redux-store';
|
|
3
2
|
export declare function useRolesState(): RolesState;
|
|
4
|
-
export declare function useRolesState<S>(stateMapper: RolesStateMapper<S>): S;
|
|
5
3
|
export declare const useRolesActions: () => RolesActions;
|
package/auth/roles.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return stateHookGenerator(stateMapper, 'rolesState');
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
export function useRolesState() {
|
|
4
|
+
return useSnapshot(useStore().store.auth.rolesState);
|
|
6
5
|
}
|
|
7
|
-
export const useRolesActions = () =>
|
|
6
|
+
export const useRolesActions = () => {
|
|
7
|
+
return useStore().stateActions.auth.rolesActions;
|
|
8
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RestrictionsActions, RestrictionsState } from '@frontegg/redux-store';
|
|
2
|
-
export declare type RestrictionsStateMapper<S> = (state: RestrictionsState) => S;
|
|
3
2
|
export declare function useRestrictionsState(): RestrictionsState;
|
|
4
|
-
export declare function useRestrictionsState<S>(stateMapper: RestrictionsStateMapper<S>): S;
|
|
5
3
|
export declare const useRestrictionsActions: () => RestrictionsActions;
|
|
6
4
|
export declare const useIpRestrictions: (loadOnMount?: boolean) => {
|
|
7
5
|
loading: boolean;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { restrictionsReducers, restrictionsActions } from '@frontegg/redux-store';
|
|
2
1
|
import { useEffect } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export function useRestrictionsState(
|
|
6
|
-
|
|
2
|
+
import { useStore } from '../../FronteggStoreContext';
|
|
3
|
+
import { useSnapshot } from '../../useSnapshot';
|
|
4
|
+
export function useRestrictionsState() {
|
|
5
|
+
const state = useStore().store.auth.restrictionsState;
|
|
6
|
+
return useSnapshot(state);
|
|
7
7
|
}
|
|
8
|
-
export const useRestrictionsActions = () =>
|
|
8
|
+
export const useRestrictionsActions = () => {
|
|
9
|
+
return useStore().stateActions.auth.restrictionsActions;
|
|
10
|
+
};
|
|
9
11
|
export const useIpRestrictions = (loadOnMount = false) => {
|
|
10
12
|
const {
|
|
11
13
|
loading,
|
|
@@ -15,13 +17,12 @@ export const useIpRestrictions = (loadOnMount = false) => {
|
|
|
15
17
|
pagination,
|
|
16
18
|
totalPages,
|
|
17
19
|
userIpValid
|
|
18
|
-
} = useRestrictionsState(
|
|
20
|
+
} = useRestrictionsState().ipRestrictions;
|
|
19
21
|
const {
|
|
20
22
|
loadIpRestrictions
|
|
21
23
|
} = useRestrictionsActions();
|
|
22
24
|
useEffect(() => {
|
|
23
25
|
(loadOnMount || !data) && loadIpRestrictions();
|
|
24
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
26
|
}, [loadOnMount, loadIpRestrictions]);
|
|
26
27
|
return {
|
|
27
28
|
loading,
|
|
@@ -39,13 +40,12 @@ export const useEmailDomainRestrictions = (loadOnMount = false) => {
|
|
|
39
40
|
data,
|
|
40
41
|
saving,
|
|
41
42
|
error
|
|
42
|
-
} = useRestrictionsState(
|
|
43
|
+
} = useRestrictionsState().emailDomainRestrictions;
|
|
43
44
|
const {
|
|
44
45
|
loadEmailDomainRestrictions
|
|
45
46
|
} = useRestrictionsActions();
|
|
46
47
|
useEffect(() => {
|
|
47
48
|
(loadOnMount || !data) && loadEmailDomainRestrictions();
|
|
48
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
49
|
}, [loadOnMount, loadEmailDomainRestrictions]);
|
|
50
50
|
return {
|
|
51
51
|
loading,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { SecurityCenterActions, SecurityCenterState } from '@frontegg/redux-store';
|
|
2
|
-
declare type AuthSecurityCenterStateMapper<S> = (state: SecurityCenterState) => S;
|
|
1
|
+
import type { SecurityCenterActions, SecurityCenterState } from '@frontegg/redux-store';
|
|
3
2
|
export declare function useSecurityCenterState(): SecurityCenterState;
|
|
4
|
-
export declare function useSecurityCenterState<S>(stateMapper: AuthSecurityCenterStateMapper<S>): S;
|
|
5
3
|
export declare const useSecurityCenterActions: () => SecurityCenterActions;
|
|
6
|
-
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
1
|
+
import { useStore } from '../../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../../useSnapshot';
|
|
3
|
+
export function useSecurityCenterState() {
|
|
4
|
+
const state = useStore().store.auth.securityCenterState;
|
|
5
|
+
return useSnapshot(state);
|
|
6
6
|
}
|
|
7
|
-
export const useSecurityCenterActions = () =>
|
|
7
|
+
export const useSecurityCenterActions = () => {
|
|
8
|
+
return useStore().stateActions.auth.securityCenterActions;
|
|
9
|
+
};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import { SecurityPolicyActions, SecurityPolicyState } from '@frontegg/redux-store';
|
|
1
|
+
import type { 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
|
-
|
|
8
|
-
saving: boolean | undefined;
|
|
9
|
-
error: any;
|
|
10
|
-
policy: import("@frontegg/rest-api").IVendorConfig | undefined;
|
|
6
|
+
export declare const usePublicPolicySettings: (loadOnMount?: boolean) => import("@frontegg/redux-store").WithStatus & {
|
|
7
|
+
policy?: import("@frontegg/rest-api").IVendorConfig | undefined;
|
|
11
8
|
};
|
|
12
|
-
export declare const usePublicAuthStrategiesPolicySettings: (loadOnMount?: boolean) => {
|
|
13
|
-
|
|
14
|
-
saving: boolean | undefined;
|
|
15
|
-
error: any;
|
|
16
|
-
policy: import("@frontegg/rest-api").IAuthStrategiesConfig | undefined;
|
|
9
|
+
export declare const usePublicAuthStrategiesPolicySettings: (loadOnMount?: boolean) => import("@frontegg/redux-store").WithStatus & {
|
|
10
|
+
policy?: import("@frontegg/rest-api").IAuthStrategiesConfig | undefined;
|
|
17
11
|
};
|
|
@@ -1,50 +1,39 @@
|
|
|
1
|
-
import { securityPolicyActions, securityPolicyReducers } from '@frontegg/redux-store';
|
|
2
|
-
import { reducerActionsGenerator, stateHookGenerator } from '../hooks';
|
|
3
1
|
import { useEffect } from 'react';
|
|
2
|
+
import { useStore } from '../../FronteggStoreContext';
|
|
3
|
+
import { useSnapshot } from '../../useSnapshot';
|
|
4
|
+
|
|
5
|
+
// TODO: remove useless stateMapper, valtio already does this
|
|
6
|
+
|
|
4
7
|
const defaultMapper = state => state;
|
|
8
|
+
// @deprecated use useSecurityPolicyState() instead
|
|
5
9
|
export function useSecurityPolicyState(stateMapper = defaultMapper) {
|
|
6
|
-
|
|
10
|
+
const state = useStore().store.auth.securityPolicyState;
|
|
11
|
+
return stateMapper(useSnapshot(state));
|
|
7
12
|
}
|
|
8
|
-
export const useSecurityPolicyActions = () =>
|
|
13
|
+
export const useSecurityPolicyActions = () => {
|
|
14
|
+
return useStore().stateActions.auth.securityPolicyActions;
|
|
15
|
+
};
|
|
9
16
|
export const usePublicPolicySettings = (loadOnMount = false) => {
|
|
10
17
|
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
saving,
|
|
14
|
-
error
|
|
15
|
-
} = useSecurityPolicyState(state => state.publicPolicy);
|
|
18
|
+
publicPolicy
|
|
19
|
+
} = useSecurityPolicyState();
|
|
16
20
|
const {
|
|
17
21
|
loadPublicSecurityPolicy
|
|
18
22
|
} = useSecurityPolicyActions();
|
|
19
23
|
useEffect(() => {
|
|
20
|
-
(loadOnMount || !policy) && loadPublicSecurityPolicy();
|
|
21
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
(loadOnMount || !publicPolicy.policy) && loadPublicSecurityPolicy();
|
|
22
25
|
}, [loadOnMount, loadPublicSecurityPolicy]);
|
|
23
|
-
return
|
|
24
|
-
loading,
|
|
25
|
-
saving,
|
|
26
|
-
error,
|
|
27
|
-
policy
|
|
28
|
-
};
|
|
26
|
+
return publicPolicy;
|
|
29
27
|
};
|
|
30
28
|
export const usePublicAuthStrategiesPolicySettings = (loadOnMount = false) => {
|
|
31
29
|
const {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
saving,
|
|
35
|
-
error
|
|
36
|
-
} = useSecurityPolicyState(state => state.publicAuthStrategyPolicy);
|
|
30
|
+
publicAuthStrategyPolicy
|
|
31
|
+
} = useSecurityPolicyState();
|
|
37
32
|
const {
|
|
38
33
|
loadPublicAuthStrategiesPolicy
|
|
39
34
|
} = useSecurityPolicyActions();
|
|
40
35
|
useEffect(() => {
|
|
41
|
-
(loadOnMount || !policy) && loadPublicAuthStrategiesPolicy();
|
|
42
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
(loadOnMount || !publicAuthStrategyPolicy.policy) && loadPublicAuthStrategiesPolicy();
|
|
43
37
|
}, [loadOnMount, loadPublicAuthStrategiesPolicy]);
|
|
44
|
-
return
|
|
45
|
-
loading,
|
|
46
|
-
saving,
|
|
47
|
-
error,
|
|
48
|
-
policy
|
|
49
|
-
};
|
|
38
|
+
return publicAuthStrategyPolicy;
|
|
50
39
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { SessionsPolicyState, SessionsPolicyActions } from '@frontegg/redux-store';
|
|
2
|
-
export declare type SessionsPolicyStateMapper<S> = (state: SessionsPolicyState) => S;
|
|
1
|
+
import type { SessionsPolicyState, SessionsPolicyActions } from '@frontegg/redux-store';
|
|
3
2
|
export declare function useSessionsPolicyState(): SessionsPolicyState;
|
|
4
|
-
export declare function useSessionsPolicyState<S>(stateMapper: SessionsPolicyStateMapper<S>): S;
|
|
5
3
|
export declare const useSessionsPolicyActions: () => SessionsPolicyActions;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
1
|
+
import { useStore } from '../../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../../useSnapshot';
|
|
3
|
+
export function useSessionsPolicyState() {
|
|
4
|
+
const state = useStore().store.auth.sessionsPolicyState;
|
|
5
|
+
return useSnapshot(state);
|
|
6
6
|
}
|
|
7
|
-
export const useSessionsPolicyActions = () =>
|
|
7
|
+
export const useSessionsPolicyActions = () => {
|
|
8
|
+
return useStore().stateActions.auth.sessionsPolicyActions;
|
|
9
|
+
};
|
package/auth/sessions.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { SessionsState, SessionsActions } from '@frontegg/redux-store';
|
|
2
|
-
export declare type SessionsStateMapper<S> = (state: SessionsState) => S;
|
|
1
|
+
import type { SessionsState, SessionsActions } from '@frontegg/redux-store';
|
|
3
2
|
export declare function useSessionsState(): SessionsState;
|
|
4
|
-
export declare function useSessionsState<S>(stateMapper: SessionsStateMapper<S>): S;
|
|
5
3
|
export declare const useSessionsActions: () => SessionsActions;
|
package/auth/sessions.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return stateHookGenerator(stateMapper, 'sessionsState');
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
export function useSessionsState() {
|
|
4
|
+
return useSnapshot(useStore().store.auth.sessionsState);
|
|
6
5
|
}
|
|
7
|
-
export const useSessionsActions = () =>
|
|
6
|
+
export const useSessionsActions = () => {
|
|
7
|
+
return useStore().stateActions.auth.sessionsActions;
|
|
8
|
+
};
|
package/auth/signup.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SignUpState, SignUpActions } from '@frontegg/redux-store';
|
|
1
|
+
import type { SignUpState, SignUpActions } from '@frontegg/redux-store';
|
|
2
2
|
export declare type SignUpStateMapper<S> = (state: SignUpState) => S;
|
|
3
3
|
export declare function useSignUpState(): SignUpState;
|
|
4
4
|
export declare function useSignUpState<S>(stateMapper: SignUpStateMapper<S>): S;
|
package/auth/signup.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
|
|
4
|
+
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
+
|
|
3
6
|
const defaultMapper = state => state;
|
|
7
|
+
// @deprecated use useSignUpState() instead
|
|
4
8
|
export function useSignUpState(stateMapper = defaultMapper) {
|
|
5
|
-
|
|
9
|
+
const {
|
|
10
|
+
signUpState
|
|
11
|
+
} = useStore().store.auth;
|
|
12
|
+
return stateMapper(useSnapshot(signUpState));
|
|
6
13
|
}
|
|
7
|
-
export const useSignUpActions = () =>
|
|
14
|
+
export const useSignUpActions = () => {
|
|
15
|
+
return useStore().stateActions.auth.signUpActions;
|
|
16
|
+
};
|
package/auth/sms.d.ts
ADDED
package/auth/sms.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useStore } from '../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
3
|
+
export function useSmsState() {
|
|
4
|
+
return useSnapshot(useStore().store.auth.smsState);
|
|
5
|
+
}
|
|
6
|
+
export const useSmsActions = () => {
|
|
7
|
+
return useStore().stateActions.auth.smsActions;
|
|
8
|
+
};
|
package/auth/socialLogin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SocialLoginActions, SocialLoginState } from '@frontegg/redux-store';
|
|
1
|
+
import type { SocialLoginActions, SocialLoginState } from '@frontegg/redux-store';
|
|
2
2
|
export declare type SocialLoginStateMapper<S> = (state: SocialLoginState) => S;
|
|
3
3
|
export declare function useSocialLoginState(): SocialLoginState;
|
|
4
4
|
export declare function useSocialLoginState<S>(stateMapper: SocialLoginStateMapper<S>): S;
|
package/auth/socialLogin.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useStore } from '../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
3
|
+
|
|
4
|
+
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
+
|
|
3
6
|
const defaultMapper = state => state;
|
|
7
|
+
// @deprecated use useSocialLoginState() instead
|
|
4
8
|
export function useSocialLoginState(stateMapper = defaultMapper) {
|
|
5
|
-
return
|
|
9
|
+
return stateMapper(useSnapshot(useStore().store.auth.socialLoginState));
|
|
6
10
|
}
|
|
7
|
-
export const useSocialLoginActions = () =>
|
|
11
|
+
export const useSocialLoginActions = () => {
|
|
12
|
+
return useStore().stateActions.auth.socialLoginActions;
|
|
13
|
+
};
|
package/auth/sso.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SSOState, SSOActions } from '@frontegg/redux-store';
|
|
1
|
+
import type { SSOState, SSOActions } from '@frontegg/redux-store';
|
|
2
2
|
declare type AuthSSOStateMapper<S> = (state: SSOState) => S;
|
|
3
3
|
export declare function useSSOState(): SSOState;
|
|
4
4
|
export declare function useSSOState<S>(stateMapper: AuthSSOStateMapper<S>): S;
|
package/auth/sso.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
|
|
4
|
+
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
+
|
|
3
6
|
const defaultMapper = state => state;
|
|
7
|
+
// @deprecated use useSSOState() instead
|
|
4
8
|
export function useSSOState(stateMapper = defaultMapper) {
|
|
5
|
-
return
|
|
9
|
+
return stateMapper(useSnapshot(useStore().store.auth.ssoState));
|
|
6
10
|
}
|
|
7
|
-
export const useSSOActions = () =>
|
|
11
|
+
export const useSSOActions = () => {
|
|
12
|
+
return useStore().stateActions.auth.ssoActions;
|
|
13
|
+
};
|
package/auth/stepUp.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StepUpState, StepUpActions, IsSteppedUpOptions } from '@frontegg/redux-store';
|
|
2
|
+
export declare function useStepUpState(): StepUpState;
|
|
3
|
+
export declare const useStepUpActions: () => StepUpActions;
|
|
4
|
+
/**
|
|
5
|
+
* @returns max age from the query param as a number or null if not exists
|
|
6
|
+
*/
|
|
7
|
+
export declare const getMaxAgeFromQueryParam: () => number | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* @returns step up function that redirects to the step up url with the max age param and set the redirect url in the local storage
|
|
10
|
+
*/
|
|
11
|
+
export declare const useStepUp: () => any;
|
|
12
|
+
/**
|
|
13
|
+
* @param options.maxAge - max age of step up
|
|
14
|
+
* @returns true when the user is stepped up, false otherwise
|
|
15
|
+
*/
|
|
16
|
+
export declare const useIsSteppedUp: (options?: IsSteppedUpOptions) => boolean;
|
package/auth/stepUp.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { STEP_UP_MAX_AGE_PARAM_NAME, getSearchParam, redirectByStepUpUrl, isSteppedUp } from '@frontegg/redux-store';
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
3
|
+
import { useStore } from '../FronteggStoreContext';
|
|
4
|
+
import { useAuth, useAuthRoutes, useAuthUserOrNull, useOnRedirectTo } from './hooks';
|
|
5
|
+
import { useCallback } from 'react';
|
|
6
|
+
export function useStepUpState() {
|
|
7
|
+
return useSnapshot(useStore().store.auth.stepUpState);
|
|
8
|
+
}
|
|
9
|
+
export const useStepUpActions = () => {
|
|
10
|
+
return useStore().stateActions.auth.stepUpActions;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @returns max age from the query param as a number or null if not exists
|
|
15
|
+
*/
|
|
16
|
+
export const getMaxAgeFromQueryParam = () => {
|
|
17
|
+
const str = getSearchParam(STEP_UP_MAX_AGE_PARAM_NAME);
|
|
18
|
+
return str === undefined ? undefined : +str;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @returns step up function that redirects to the step up url with the max age param and set the redirect url in the local storage
|
|
23
|
+
*/
|
|
24
|
+
export const useStepUp = () => {
|
|
25
|
+
const {
|
|
26
|
+
stepUpUrl
|
|
27
|
+
} = useAuthRoutes();
|
|
28
|
+
const {
|
|
29
|
+
hostedLoginBox
|
|
30
|
+
} = useAuth();
|
|
31
|
+
const {
|
|
32
|
+
stepUpHostedLogin
|
|
33
|
+
} = useStepUpActions();
|
|
34
|
+
const onRedirectTo = useOnRedirectTo();
|
|
35
|
+
return useCallback(options => {
|
|
36
|
+
if (hostedLoginBox) {
|
|
37
|
+
stepUpHostedLogin(options || {});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
redirectByStepUpUrl(stepUpUrl, onRedirectTo, options == null ? void 0 : options.maxAge);
|
|
41
|
+
}, [stepUpUrl, onRedirectTo, stepUpHostedLogin, hostedLoginBox]);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param options.maxAge - max age of step up
|
|
46
|
+
* @returns true when the user is stepped up, false otherwise
|
|
47
|
+
*/
|
|
48
|
+
export const useIsSteppedUp = (options = {}) => {
|
|
49
|
+
const user = useAuthUserOrNull();
|
|
50
|
+
return isSteppedUp(user, options);
|
|
51
|
+
};
|
package/auth/team.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TeamActions, TeamState } from '@frontegg/redux-store';
|
|
2
|
+
export declare function useTeamState(): TeamState;
|
|
3
|
+
export declare const useTeamActions: () => TeamActions;
|
|
2
4
|
export declare type AuthTeamStateMapper<S> = (state: TeamState) => S;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use useTeamState instead
|
|
7
|
+
*/
|
|
3
8
|
export declare function useAuthTeamState(): TeamState;
|
|
4
9
|
export declare function useAuthTeamState<S>(stateMapper: AuthTeamStateMapper<S>): S;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated use useTeamActions instead
|
|
12
|
+
*/
|
|
5
13
|
export declare const useAuthTeamActions: () => TeamActions;
|