@frontegg/react-hooks 6.176.0 → 6.178.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/FronteggProvider/FronteggProvider.d.ts +12 -0
  2. package/FronteggProvider/FronteggProvider.js +134 -0
  3. package/FronteggProvider/index.d.ts +1 -12
  4. package/FronteggProvider/index.js +1 -133
  5. package/FronteggStoreContext/FronteggStoreContext.d.ts +9 -0
  6. package/FronteggStoreContext/FronteggStoreContext.js +16 -0
  7. package/FronteggStoreContext/index.d.ts +1 -13
  8. package/FronteggStoreContext/index.js +1 -14
  9. package/audits/auditLogs.d.ts +2 -4
  10. package/audits/auditLogs.js +8 -6
  11. package/audits/auditsMetadata.d.ts +2 -4
  12. package/audits/auditsMetadata.js +8 -6
  13. package/audits/hooks.d.ts +0 -8
  14. package/audits/hooks.js +6 -30
  15. package/auth/acceptInvitation.js +10 -5
  16. package/auth/activateAccount.js +10 -4
  17. package/auth/{MSP/allAccounts.d.ts → allAccounts.d.ts} +2 -4
  18. package/auth/allAccounts.js +20 -0
  19. package/auth/apiTokens.d.ts +0 -2
  20. package/auth/apiTokens.js +8 -6
  21. package/auth/customLogin.d.ts +2 -5
  22. package/auth/customLogin.js +10 -11
  23. package/auth/entitlements.d.ts +14 -14
  24. package/auth/entitlements.js +25 -21
  25. package/auth/forgotPassword.d.ts +0 -2
  26. package/auth/forgotPassword.js +8 -6
  27. package/auth/groups.d.ts +0 -4
  28. package/auth/groups.js +12 -13
  29. package/auth/hooks.d.ts +9 -11
  30. package/auth/hooks.js +27 -58
  31. package/auth/impersonate.d.ts +0 -2
  32. package/auth/impersonate.js +7 -6
  33. package/auth/index.d.ts +14 -17
  34. package/auth/index.js +15 -18
  35. package/auth/login.d.ts +1 -1
  36. package/auth/login.js +13 -4
  37. package/auth/mfa.d.ts +1 -1
  38. package/auth/mfa.js +13 -4
  39. package/auth/passkeys.d.ts +1 -4
  40. package/auth/passkeys.js +7 -6
  41. package/auth/profile.d.ts +2 -4
  42. package/auth/profile.js +9 -8
  43. package/auth/provisioning.d.ts +1 -3
  44. package/auth/provisioning.js +7 -6
  45. package/auth/resetPhoneNumber.d.ts +1 -3
  46. package/auth/resetPhoneNumber.js +7 -6
  47. package/auth/roles.d.ts +1 -3
  48. package/auth/roles.js +7 -6
  49. package/auth/security/index.d.ts +4 -0
  50. package/auth/security/index.js +4 -0
  51. package/auth/security/restrictions.d.ts +0 -2
  52. package/auth/security/restrictions.js +10 -10
  53. package/auth/security/securityCenter.d.ts +1 -4
  54. package/auth/security/securityCenter.js +8 -6
  55. package/auth/security/securityPolicy.d.ts +5 -11
  56. package/auth/security/securityPolicy.js +19 -30
  57. package/auth/security/sessionsPolicy.d.ts +1 -3
  58. package/auth/security/sessionsPolicy.js +8 -6
  59. package/auth/sessions.d.ts +1 -3
  60. package/auth/sessions.js +7 -6
  61. package/auth/signup.d.ts +1 -1
  62. package/auth/signup.js +13 -4
  63. package/auth/sms.d.ts +1 -4
  64. package/auth/sms.js +7 -6
  65. package/auth/socialLogin.d.ts +1 -1
  66. package/auth/socialLogin.js +10 -4
  67. package/auth/sso.d.ts +1 -1
  68. package/auth/sso.js +10 -4
  69. package/auth/{stepUp/stepUp.d.ts → stepUp.d.ts} +0 -2
  70. package/auth/{stepUp/stepUp.js → stepUp.js} +9 -6
  71. package/auth/team.d.ts +9 -1
  72. package/auth/team.js +22 -4
  73. package/auth/tenants.d.ts +1 -3
  74. package/auth/tenants.js +8 -6
  75. package/common/CustomComponentHolder.js +3 -1
  76. package/common/index.js +3 -3
  77. package/connectivity/hooks.d.ts +2 -5
  78. package/connectivity/hooks.js +6 -9
  79. package/index.d.ts +2 -2
  80. package/index.js +3 -3
  81. package/node/FronteggProvider/FronteggProvider.js +140 -0
  82. package/node/FronteggProvider/index.js +9 -134
  83. package/node/FronteggStoreContext/FronteggStoreContext.js +26 -0
  84. package/node/FronteggStoreContext/index.js +11 -35
  85. package/node/audits/auditLogs.js +8 -6
  86. package/node/audits/auditsMetadata.js +8 -6
  87. package/node/audits/hooks.js +7 -34
  88. package/node/auth/acceptInvitation.js +7 -5
  89. package/node/auth/activateAccount.js +7 -4
  90. package/node/auth/allAccounts.js +27 -0
  91. package/node/auth/apiTokens.js +8 -6
  92. package/node/auth/customLogin.js +11 -12
  93. package/node/auth/entitlements.js +24 -20
  94. package/node/auth/forgotPassword.js +8 -6
  95. package/node/auth/groups.js +12 -12
  96. package/node/auth/hooks.js +27 -61
  97. package/node/auth/impersonate.js +7 -6
  98. package/node/auth/index.js +84 -120
  99. package/node/auth/login.js +10 -4
  100. package/node/auth/mfa.js +10 -4
  101. package/node/auth/passkeys.js +7 -6
  102. package/node/auth/profile.js +10 -9
  103. package/node/auth/provisioning.js +7 -6
  104. package/node/auth/resetPhoneNumber.js +7 -6
  105. package/node/auth/roles.js +7 -6
  106. package/node/auth/security/index.js +49 -0
  107. package/node/auth/security/restrictions.js +10 -10
  108. package/node/auth/security/securityCenter.js +8 -6
  109. package/node/auth/security/securityPolicy.js +16 -30
  110. package/node/auth/security/sessionsPolicy.js +8 -6
  111. package/node/auth/sessions.js +7 -6
  112. package/node/auth/signup.js +10 -4
  113. package/node/auth/sms.js +7 -6
  114. package/node/auth/socialLogin.js +7 -4
  115. package/node/auth/sso.js +7 -4
  116. package/node/auth/{stepUp/stepUp.js → stepUp.js} +10 -7
  117. package/node/auth/team.js +25 -4
  118. package/node/auth/tenants.js +8 -6
  119. package/node/common/CustomComponentHolder.js +3 -1
  120. package/node/common/index.js +2 -2
  121. package/node/connectivity/hooks.js +5 -8
  122. package/node/index.js +16 -16
  123. package/node/subscriptions/hooks.js +84 -51
  124. package/node/vendor/hooks.js +5 -6
  125. package/package.json +3 -3
  126. package/subscriptions/hooks.d.ts +32 -10
  127. package/subscriptions/hooks.js +81 -49
  128. package/vendor/hooks.d.ts +0 -1
  129. package/vendor/hooks.js +9 -7
  130. package/auth/MSP/allAccounts.js +0 -15
  131. package/auth/stepUp/index.d.ts +0 -2
  132. package/auth/stepUp/index.js +0 -2
  133. package/auth/stepUp/interfaces.d.ts +0 -2
  134. package/auth/stepUp/interfaces.js +0 -1
  135. package/node/auth/MSP/allAccounts.js +0 -24
  136. package/node/auth/stepUp/index.js +0 -27
  137. package/node/auth/stepUp/interfaces.js +0 -5
  138. package/node/tests/hooks.tsc-test.js +0 -318
  139. package/tests/hooks.tsc-test.js +0 -317
@@ -1,7 +1,8 @@
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');
1
+ import { useSnapshot } from 'valtio/react';
2
+ import { useStore } from '../FronteggStoreContext';
3
+ export function useResetPhoneNumberState() {
4
+ return useSnapshot(useStore().store.auth.resetPhoneNumberState);
6
5
  }
7
- export const useResetPhoneNumberActions = () => reducerActionsGenerator(resetPhoneNumberActions, resetPhoneNumberReducers);
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 { 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');
1
+ import { useSnapshot } from 'valtio/react';
2
+ import { useStore } from '../FronteggStoreContext';
3
+ export function useRolesState() {
4
+ return useSnapshot(useStore().store.auth.rolesState);
6
5
  }
7
- export const useRolesActions = () => reducerActionsGenerator(rolesActions, rolesReducers);
6
+ export const useRolesActions = () => {
7
+ return useStore().stateActions.auth.rolesActions;
8
+ };
@@ -0,0 +1,4 @@
1
+ export * from './restrictions';
2
+ export * from './securityCenter';
3
+ export * from './securityPolicy';
4
+ export * from './sessionsPolicy';
@@ -0,0 +1,4 @@
1
+ export * from './restrictions';
2
+ export * from './securityCenter';
3
+ export * from './securityPolicy';
4
+ export * from './sessionsPolicy';
@@ -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 { reducerActionsGenerator, stateHookGenerator } from '../hooks';
4
- const defaultMapper = state => state;
5
- export function useRestrictionsState(stateMapper = defaultMapper) {
6
- return stateHookGenerator(stateMapper, 'restrictionsState');
2
+ import { useStore } from '../../FronteggStoreContext';
3
+ import { useSnapshot } from 'valtio/react';
4
+ export function useRestrictionsState() {
5
+ const state = useStore().store.auth.restrictionsState;
6
+ return useSnapshot(state);
7
7
  }
8
- export const useRestrictionsActions = () => reducerActionsGenerator(restrictionsActions, restrictionsReducers);
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(state => state.ipRestrictions);
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(state => state.emailDomainRestrictions);
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 { 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');
1
+ import { useStore } from '../../FronteggStoreContext';
2
+ import { useSnapshot } from 'valtio/react';
3
+ export function useSecurityCenterState() {
4
+ const state = useStore().store.auth.securityCenterState;
5
+ return useSnapshot(state);
6
6
  }
7
- export const useSecurityCenterActions = () => reducerActionsGenerator(securityCenterActions, securityCenterReducers);
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
- loading: boolean;
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
- loading: boolean;
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 'valtio/react';
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
- return stateHookGenerator(stateMapper, 'securityPolicyState');
10
+ const state = useStore().store.auth.securityPolicyState;
11
+ return stateMapper(useSnapshot(state));
7
12
  }
8
- export const useSecurityPolicyActions = () => reducerActionsGenerator(securityPolicyActions, securityPolicyReducers);
13
+ export const useSecurityPolicyActions = () => {
14
+ return useStore().stateActions.auth.securityPolicyActions;
15
+ };
9
16
  export const usePublicPolicySettings = (loadOnMount = false) => {
10
17
  const {
11
- loading,
12
- policy,
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
- loading,
33
- policy,
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 { sessionsPolicyActions, sessionsPolicyReducers } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator } from '../hooks';
3
- const defaultMapper = state => state;
4
- export function useSessionsPolicyState(stateMapper = defaultMapper) {
5
- return stateHookGenerator(stateMapper, 'sessionsPolicyState');
1
+ import { useStore } from '../../FronteggStoreContext';
2
+ import { useSnapshot } from 'valtio/react';
3
+ export function useSessionsPolicyState() {
4
+ const state = useStore().store.auth.sessionsPolicyState;
5
+ return useSnapshot(state);
6
6
  }
7
- export const useSessionsPolicyActions = () => reducerActionsGenerator(sessionsPolicyActions, sessionsPolicyReducers);
7
+ export const useSessionsPolicyActions = () => {
8
+ return useStore().stateActions.auth.sessionsPolicyActions;
9
+ };
@@ -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 { sessionsActions, sessionsReducers } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
- const defaultMapper = state => state;
4
- export function useSessionsState(stateMapper = defaultMapper) {
5
- return stateHookGenerator(stateMapper, 'sessionsState');
1
+ import { useSnapshot } from 'valtio/react';
2
+ import { useStore } from '../FronteggStoreContext';
3
+ export function useSessionsState() {
4
+ return useSnapshot(useStore().store.auth.sessionsState);
6
5
  }
7
- export const useSessionsActions = () => reducerActionsGenerator(sessionsActions, sessionsReducers);
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 { signUpReducers, signUpActions } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator } from './hooks';
1
+ import { useSnapshot } from 'valtio/react';
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
- return stateHookGenerator(stateMapper, 'signUpState');
9
+ const {
10
+ signUpState
11
+ } = useStore().store.auth;
12
+ return stateMapper(useSnapshot(signUpState));
6
13
  }
7
- export const useSignUpActions = () => reducerActionsGenerator(signUpActions, signUpReducers);
14
+ export const useSignUpActions = () => {
15
+ return useStore().stateActions.auth.signUpActions;
16
+ };
package/auth/sms.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- import { SmsActions, SmsState } from '@frontegg/redux-store';
2
- declare type AuthSmsStateMapper<S> = (state: SmsState) => S;
1
+ import type { SmsActions, SmsState } from '@frontegg/redux-store';
3
2
  export declare function useSmsState(): SmsState;
4
- export declare function useSmsState<S>(stateMapper: AuthSmsStateMapper<S>): S;
5
3
  export declare const useSmsActions: () => SmsActions;
6
- export {};
package/auth/sms.js CHANGED
@@ -1,7 +1,8 @@
1
- import { smsActions, smsReducers } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
- const defaultMapper = state => state;
4
- export function useSmsState(stateMapper = defaultMapper) {
5
- return stateHookGenerator(stateMapper, 'smsState');
1
+ import { useSnapshot } from 'valtio/react';
2
+ import { useStore } from '../FronteggStoreContext';
3
+ export function useSmsState() {
4
+ return useSnapshot(useStore().store.auth.smsState);
6
5
  }
7
- export const useSmsActions = () => reducerActionsGenerator(smsActions, smsReducers);
6
+ export const useSmsActions = () => {
7
+ return useStore().stateActions.auth.smsActions;
8
+ };
@@ -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;
@@ -1,7 +1,13 @@
1
- import { socialLoginsActions, socialLoginsReducer } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator } from './hooks';
1
+ import { useStore } from '../FronteggStoreContext';
2
+ import { useSnapshot } from 'valtio/react';
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 stateHookGenerator(stateMapper, 'socialLoginState');
9
+ return stateMapper(useSnapshot(useStore().store.auth.socialLoginState));
6
10
  }
7
- export const useSocialLoginActions = () => reducerActionsGenerator(socialLoginsActions, socialLoginsReducer);
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 { ssoActions, ssoReducers } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator } from './hooks';
1
+ import { useSnapshot } from 'valtio/react';
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 stateHookGenerator(stateMapper, 'ssoState');
9
+ return stateMapper(useSnapshot(useStore().store.auth.ssoState));
6
10
  }
7
- export const useSSOActions = () => reducerActionsGenerator(ssoActions, ssoReducers);
11
+ export const useSSOActions = () => {
12
+ return useStore().stateActions.auth.ssoActions;
13
+ };
@@ -1,7 +1,5 @@
1
1
  import { StepUpState, StepUpActions, IsSteppedUpOptions } from '@frontegg/redux-store';
2
- import { StepUpStateMapper } from './interfaces';
3
2
  export declare function useStepUpState(): StepUpState;
4
- export declare function useStepUpState<S>(stateMapper: StepUpStateMapper<S>): S;
5
3
  export declare const useStepUpActions: () => StepUpActions;
6
4
  /**
7
5
  * @returns max age from the query param as a number or null if not exists
@@ -1,11 +1,14 @@
1
- import { stepUpReducers, stepUpActions, getSearchParam, isSteppedUp, STEP_UP_MAX_AGE_PARAM_NAME, redirectByStepUpUrl } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator, useAuth, useAuthRoutes, useAuthUserOrNull, useOnRedirectTo } from '../hooks';
1
+ import { STEP_UP_MAX_AGE_PARAM_NAME, getSearchParam, redirectByStepUpUrl, isSteppedUp } from '@frontegg/redux-store';
2
+ import { useSnapshot } from 'valtio/react';
3
+ import { useStore } from '../FronteggStoreContext';
4
+ import { useAuth, useAuthRoutes, useAuthUserOrNull, useOnRedirectTo } from './hooks';
3
5
  import { useCallback } from 'react';
4
- const defaultMapper = state => state;
5
- export function useStepUpState(stateMapper = defaultMapper) {
6
- return stateHookGenerator(stateMapper, 'stepUpState');
6
+ export function useStepUpState() {
7
+ return useSnapshot(useStore().store.auth.stepUpState);
7
8
  }
8
- export const useStepUpActions = () => reducerActionsGenerator(stepUpActions, stepUpReducers);
9
+ export const useStepUpActions = () => {
10
+ return useStore().stateActions.auth.stepUpActions;
11
+ };
9
12
 
10
13
  /**
11
14
  * @returns max age from the query param as a number or null if not exists
package/auth/team.d.ts CHANGED
@@ -1,5 +1,13 @@
1
- import { TeamState, TeamActions } from '@frontegg/redux-store';
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;
package/auth/team.js CHANGED
@@ -1,7 +1,25 @@
1
- import { teamActions, teamReducers } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator } from './hooks';
1
+ import { useSnapshot } from 'valtio/react';
2
+ import { useStore } from '../FronteggStoreContext';
3
+ export function useTeamState() {
4
+ const state = useStore().store.auth.teamState;
5
+ return useSnapshot(state);
6
+ }
7
+ export const useTeamActions = () => {
8
+ return useStore().stateActions.auth.teamActions;
9
+ };
3
10
  const defaultMapper = state => state;
11
+ /**
12
+ * @deprecated use useTeamState instead
13
+ */
14
+
15
+ // @deprecated use useTeamState() instead
4
16
  export function useAuthTeamState(stateMapper = defaultMapper) {
5
- return stateHookGenerator(stateMapper, 'teamState');
17
+ return stateMapper(useTeamState());
6
18
  }
7
- export const useAuthTeamActions = () => reducerActionsGenerator(teamActions, teamReducers);
19
+
20
+ /**
21
+ * @deprecated use useTeamActions instead
22
+ */
23
+ export const useAuthTeamActions = () => {
24
+ return useTeamActions();
25
+ };
package/auth/tenants.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { TenantsState, TenantsActions } from '@frontegg/redux-store';
2
- export declare type TenantsStateMapper<S> = (state: TenantsState) => S;
1
+ import type { TenantsState, TenantsActions } from '@frontegg/redux-store';
3
2
  export declare function useTenantsState(): TenantsState;
4
- export declare function useTenantsState<S>(stateMapper: TenantsStateMapper<S>): S;
5
3
  export declare const useTenantsActions: () => TenantsActions;
package/auth/tenants.js CHANGED
@@ -1,7 +1,9 @@
1
- import { tenantsActions, tenantsReducers } from '@frontegg/redux-store';
2
- import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
- const defaultMapper = state => state;
4
- export function useTenantsState(stateMapper = defaultMapper) {
5
- return stateHookGenerator(stateMapper, 'tenantsState');
1
+ import { useStore } from '../FronteggStoreContext';
2
+ import { useSnapshot } from 'valtio/react';
3
+ export function useTenantsState() {
4
+ const state = useStore().store.auth.tenantsState;
5
+ return useSnapshot(state);
6
6
  }
7
- export const useTenantsActions = () => reducerActionsGenerator(tenantsActions, tenantsReducers);
7
+ export const useTenantsActions = () => {
8
+ return useStore().stateActions.auth.tenantsActions;
9
+ };
@@ -80,7 +80,9 @@ export const CustomComponentRegister = ({
80
80
  CustomComponentHolder.set(generatedKey, obj);
81
81
  return [generatedKey];
82
82
  }
83
- } catch (e) {}
83
+ } catch (e) {
84
+ /* empty */
85
+ }
84
86
  }
85
87
  if ( /*#__PURE__*/isValidElement(obj) || isElement(obj) || obj === null) {
86
88
  const generatedKey = `${keyPath}.${key}`;
package/common/index.js CHANGED
@@ -2,8 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["urlStrategy", "onRedirectTo", "renderByRoute", "customLoader", "customStyles", "contextOptions"];
4
4
  import { createContext, useContext } from 'react';
5
- import { useSelector } from '../FronteggStoreContext';
6
- import { shallowEqual } from 'react-redux';
5
+ import { useStore } from '../FronteggStoreContext';
6
+ import { useSnapshot } from 'valtio/react';
7
7
  export const ShadowDomContext = /*#__PURE__*/createContext({});
8
8
  export const useShadowDom = () => {
9
9
  const context = useContext(ShadowDomContext);
@@ -29,6 +29,6 @@ export const useShadowDom = () => {
29
29
  }, rest);
30
30
  };
31
31
  export const useRootState = () => {
32
- return useSelector(state => state.root, shallowEqual);
32
+ return useSnapshot(useStore().store.root);
33
33
  };
34
34
  export * from './CustomComponentHolder';
@@ -1,6 +1,3 @@
1
- import { ConnectivityActions, IConnectivityState } from '@frontegg/redux-store';
2
- export declare type ConnectivityStateMapper<S> = (state: IConnectivityState) => S;
3
- export declare type StateHookFunction<T> = (() => T) & (<S extends object>(mapper: (state: T) => S) => S);
4
- export declare function useConnectivityState(): IConnectivityState;
5
- export declare function useConnectivityState<S>(stateMapper: ConnectivityStateMapper<S>): S;
1
+ import { ConnectivityState, ConnectivityActions } from '@frontegg/redux-store';
2
+ export declare function useConnectivityState(): ConnectivityState;
6
3
  export declare const useConnectivityActions: () => ConnectivityActions;
@@ -1,12 +1,9 @@
1
- import { useMemo } from 'react';
2
- import { shallowEqual } from 'react-redux';
3
- import { useSelector, useDispatch } from '../FronteggStoreContext';
4
- import { bindActionCreators, connectivityActions, connectivityStoreName } from '@frontegg/redux-store';
5
- const defaultMapper = state => state;
6
- export function useConnectivityState(stateMapper = defaultMapper) {
7
- return useSelector(state => stateMapper(state[connectivityStoreName]), shallowEqual);
1
+ import { useStore } from '../FronteggStoreContext';
2
+ import { useSnapshot } from 'valtio/react';
3
+ export function useConnectivityState() {
4
+ const state = useStore().store.connectivity;
5
+ return useSnapshot(state);
8
6
  }
9
7
  export const useConnectivityActions = () => {
10
- const dispatch = useDispatch();
11
- return useMemo(() => bindActionCreators(connectivityActions, dispatch), [connectivityActions]);
8
+ return useStore().stateActions.connectivity;
12
9
  };
package/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export * from './common';
2
- export * from './audits';
3
1
  export * from './auth';
2
+ export * from './audits';
4
3
  export * from './connectivity';
5
4
  export * from './subscriptions';
6
5
  export * from './vendor';
6
+ export * from './common';
7
7
  export * from './flags';
8
8
  export * from './FronteggProvider';
9
9
  export * from './FronteggStoreContext';
package/index.js CHANGED
@@ -1,14 +1,14 @@
1
- /** @license Frontegg v6.176.0
1
+ /** @license Frontegg v6.178.0-alpha.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
5
5
  */
6
- export * from './common';
7
- export * from './audits';
8
6
  export * from './auth';
7
+ export * from './audits';
9
8
  export * from './connectivity';
10
9
  export * from './subscriptions';
11
10
  export * from './vendor';
11
+ export * from './common';
12
12
  export * from './flags';
13
13
  export * from './FronteggProvider';
14
14
  export * from './FronteggStoreContext';