@frontegg/react-hooks 7.77.0 → 7.78.0-alpha.1

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 (120) hide show
  1. package/audits/auditLogs.d.ts +2 -3
  2. package/audits/auditLogs.js +8 -9
  3. package/audits/auditsMetadata.d.ts +2 -3
  4. package/audits/auditsMetadata.js +8 -9
  5. package/audits/hooks.d.ts +2 -9
  6. package/audits/hooks.js +10 -14
  7. package/auth/acceptInvitation.d.ts +7 -5
  8. package/auth/acceptInvitation.js +8 -13
  9. package/auth/activateAccount.d.ts +11 -5
  10. package/auth/activateAccount.js +8 -13
  11. package/auth/allAccounts.d.ts +47 -7
  12. package/auth/allAccounts.js +12 -20
  13. package/auth/apiTokens.d.ts +14 -3
  14. package/auth/apiTokens.js +8 -9
  15. package/auth/applications.d.ts +22 -3
  16. package/auth/applications.js +8 -9
  17. package/auth/customLogin.d.ts +9 -3
  18. package/auth/customLogin.js +9 -12
  19. package/auth/entitlements.d.ts +6 -25
  20. package/auth/entitlements.js +41 -73
  21. package/auth/forgotPassword.d.ts +12 -3
  22. package/auth/forgotPassword.js +10 -9
  23. package/auth/groups.d.ts +32 -5
  24. package/auth/groups.js +14 -14
  25. package/auth/impersonate.d.ts +6 -3
  26. package/auth/impersonate.js +8 -8
  27. package/auth/login.d.ts +74 -3
  28. package/auth/login.js +8 -8
  29. package/auth/passkeys.d.ts +10 -3
  30. package/auth/passkeys.js +8 -8
  31. package/auth/passwordRotation.d.ts +4 -3
  32. package/auth/passwordRotation.js +8 -9
  33. package/auth/profile.d.ts +19 -3
  34. package/auth/profile.js +17 -12
  35. package/auth/provisioning.d.ts +20 -3
  36. package/auth/provisioning.js +8 -8
  37. package/auth/resetPhoneNumber.d.ts +8 -3
  38. package/auth/resetPhoneNumber.js +8 -8
  39. package/auth/roles.d.ts +14 -3
  40. package/auth/roles.js +8 -8
  41. package/auth/security/restrictions.d.ts +21 -3
  42. package/auth/security/restrictions.js +20 -19
  43. package/auth/security/securityCenter.d.ts +15 -3
  44. package/auth/security/securityCenter.js +8 -9
  45. package/auth/security/securityPolicy.d.ts +35 -5
  46. package/auth/security/securityPolicy.js +16 -18
  47. package/auth/security/sessionsPolicy.d.ts +7 -3
  48. package/auth/security/sessionsPolicy.js +8 -9
  49. package/auth/sessions.d.ts +12 -3
  50. package/auth/sessions.js +8 -8
  51. package/auth/signup.d.ts +10 -5
  52. package/auth/signup.js +8 -16
  53. package/auth/sms.d.ts +13 -3
  54. package/auth/sms.js +8 -8
  55. package/auth/socialLogin.d.ts +9 -5
  56. package/auth/socialLogin.js +8 -13
  57. package/auth/sso.d.ts +31 -6
  58. package/auth/sso.js +8 -13
  59. package/auth/stepUp.d.ts +15 -14
  60. package/auth/stepUp.js +9 -22
  61. package/auth/team.d.ts +84 -13
  62. package/auth/team.js +12 -23
  63. package/auth/tenants.d.ts +9 -3
  64. package/auth/tenants.js +8 -9
  65. package/auth/unlockAccount.d.ts +6 -5
  66. package/auth/unlockAccount.js +8 -10
  67. package/auth/usernames.d.ts +7 -3
  68. package/auth/usernames.js +8 -8
  69. package/auth/usersEmailsPolicyState.d.ts +5 -5
  70. package/auth/usersEmailsPolicyState.js +8 -10
  71. package/connectivity/hooks.d.ts +41 -3
  72. package/connectivity/hooks.js +8 -9
  73. package/index.js +1 -1
  74. package/node/audits/auditLogs.js +11 -12
  75. package/node/audits/auditsMetadata.js +11 -12
  76. package/node/audits/hooks.js +13 -17
  77. package/node/auth/acceptInvitation.js +11 -13
  78. package/node/auth/activateAccount.js +11 -13
  79. package/node/auth/allAccounts.js +15 -20
  80. package/node/auth/apiTokens.js +11 -12
  81. package/node/auth/applications.js +11 -12
  82. package/node/auth/customLogin.js +11 -15
  83. package/node/auth/entitlements.js +41 -73
  84. package/node/auth/forgotPassword.js +13 -12
  85. package/node/auth/groups.js +17 -17
  86. package/node/auth/impersonate.js +11 -11
  87. package/node/auth/login.js +11 -11
  88. package/node/auth/passkeys.js +11 -11
  89. package/node/auth/passwordRotation.js +11 -12
  90. package/node/auth/profile.js +19 -13
  91. package/node/auth/provisioning.js +11 -11
  92. package/node/auth/resetPhoneNumber.js +11 -11
  93. package/node/auth/roles.js +11 -11
  94. package/node/auth/security/restrictions.js +22 -21
  95. package/node/auth/security/securityCenter.js +11 -12
  96. package/node/auth/security/securityPolicy.js +18 -17
  97. package/node/auth/security/sessionsPolicy.js +11 -12
  98. package/node/auth/sessions.js +11 -11
  99. package/node/auth/signup.js +11 -16
  100. package/node/auth/sms.js +11 -11
  101. package/node/auth/socialLogin.js +11 -13
  102. package/node/auth/sso.js +11 -13
  103. package/node/auth/stepUp.js +11 -24
  104. package/node/auth/team.js +16 -28
  105. package/node/auth/tenants.js +11 -12
  106. package/node/auth/unlockAccount.js +11 -13
  107. package/node/auth/usernames.js +11 -11
  108. package/node/auth/usersEmailsPolicyState.js +11 -13
  109. package/node/connectivity/hooks.js +11 -12
  110. package/node/index.js +1 -1
  111. package/node/subscriptions/hooks.js +86 -115
  112. package/node/useSnapshot/hookFactory.js +32 -0
  113. package/node/vendor/hooks.js +11 -14
  114. package/package.json +3 -3
  115. package/subscriptions/hooks.d.ts +48 -22
  116. package/subscriptions/hooks.js +77 -103
  117. package/useSnapshot/hookFactory.d.ts +18 -0
  118. package/useSnapshot/hookFactory.js +26 -0
  119. package/vendor/hooks.d.ts +2 -5
  120. package/vendor/hooks.js +8 -14
@@ -1,3 +1,2 @@
1
- import { AuditLogsState, AuditsActions } from '@frontegg/redux-store';
2
- export declare function useAuditLogsState(): AuditLogsState;
3
- export declare const useAuditLogsActions: () => AuditsActions;
1
+ import type { AuditLogsState, AuditsActions } from '@frontegg/redux-store';
2
+ export declare const useAuditLogsState: <S = AuditLogsState>(selector?: (s: AuditLogsState) => S) => S, useAuditLogsActions: () => AuditsActions;
@@ -1,9 +1,8 @@
1
- import { useStore } from '../FronteggStoreContext';
2
- import { useSnapshot } from '../useSnapshot';
3
- export function useAuditLogsState() {
4
- const state = useStore().store.auditLogs.auditLogsState;
5
- return useSnapshot(state);
6
- }
7
- export const useAuditLogsActions = () => {
8
- return useStore().stateActions.auditLogs;
9
- };
1
+ import { createSliceHooks } from '../useSnapshot/hookFactory';
2
+ export const {
3
+ useSliceState: useAuditLogsState,
4
+ useSliceActions: useAuditLogsActions
5
+ } = createSliceHooks({
6
+ getState: s => s.auditLogs.auditLogsState,
7
+ getActions: a => a.auditLogs
8
+ });
@@ -1,3 +1,2 @@
1
- import { AuditsActions, AuditsMetadataState } from '@frontegg/redux-store';
2
- export declare function useAuditsMetadataState(): AuditsMetadataState;
3
- export declare const useAuditsMetadataActions: () => AuditsActions;
1
+ import type { AuditsMetadataState, AuditsActions } from '@frontegg/redux-store';
2
+ export declare const useAuditsMetadataState: <S = AuditsMetadataState>(selector?: (s: AuditsMetadataState) => S) => S, useAuditsMetadataActions: () => AuditsActions;
@@ -1,9 +1,8 @@
1
- import { useStore } from '../FronteggStoreContext';
2
- import { useSnapshot } from '../useSnapshot';
3
- export function useAuditsMetadataState() {
4
- const state = useStore().store.auditLogs.auditsMetadataState;
5
- return useSnapshot(state);
6
- }
7
- export const useAuditsMetadataActions = () => {
8
- return useStore().stateActions.auditLogs;
9
- };
1
+ import { createSliceHooks } from '../useSnapshot/hookFactory';
2
+ export const {
3
+ useSliceState: useAuditsMetadataState,
4
+ useSliceActions: useAuditsMetadataActions
5
+ } = createSliceHooks({
6
+ getState: s => s.auditLogs.auditsMetadataState,
7
+ getActions: a => a.auditLogs
8
+ });
package/audits/hooks.d.ts CHANGED
@@ -1,9 +1,2 @@
1
- import { AuditsActions, AuditsState } from '@frontegg/redux-store';
2
- export type AuditsMapper = {
3
- state: (state: AuditsState) => any;
4
- actions: (actions: AuditsActions) => any;
5
- };
6
- export type AuditsStateMapper<S> = (state: AuditsState) => S;
7
- export declare function useAuditsState(): AuditsState;
8
- export declare function useAuditsState<S>(stateMapper: AuditsStateMapper<S>): S;
9
- export declare const useAuditsActions: () => AuditsActions;
1
+ import type { AuditsState, AuditsActions } from '@frontegg/redux-store';
2
+ export declare const useAuditsState: <S = AuditsState>(selector?: (s: AuditsState) => S) => S, useAuditsActions: () => AuditsActions;
package/audits/hooks.js CHANGED
@@ -1,14 +1,10 @@
1
- import { useStore } from '../FronteggStoreContext';
2
- import { useSnapshot } from '../useSnapshot';
3
- const defaultMapper = {
4
- state: state => state,
5
- actions: actions => actions
6
- };
7
- export function useAuditsState(stateMapper = defaultMapper.state) {
8
- const state = useStore().store.auditLogs;
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- return stateMapper(useSnapshot(state));
11
- }
12
- export const useAuditsActions = () => {
13
- return useStore().stateActions.auditLogs;
14
- };
1
+ import { createSliceHooks } from '../useSnapshot/hookFactory';
2
+ export const {
3
+ useSliceState: useAuditsState,
4
+ // supports optional selector
5
+ useSliceActions: useAuditsActions
6
+ } = createSliceHooks({
7
+ getState: s => s.auditLogs,
8
+ // whole audits slice
9
+ getActions: a => a.auditLogs
10
+ });
@@ -1,5 +1,7 @@
1
- import { AcceptInvitationState, AcceptInvitationActions } from '@frontegg/redux-store';
2
- export type AcceptInvitationStateMapper<S> = (state: AcceptInvitationState) => S;
3
- export declare function useAcceptInvitationState(): AcceptInvitationState;
4
- export declare function useAcceptInvitationState<S>(stateMapper: AcceptInvitationStateMapper<S>): S;
5
- export declare const useAcceptInvitationActions: () => AcceptInvitationActions;
1
+ import type { AcceptInvitationState } from '@frontegg/redux-store';
2
+ export declare const useAcceptInvitationState: <S = AcceptInvitationState>(selector?: (s: AcceptInvitationState) => S) => S, useAcceptInvitationActions: () => {
3
+ setAcceptInvitationState: (state: Partial<AcceptInvitationState>) => void;
4
+ resetAcceptInvitationState: () => void;
5
+ acceptInvitation: (payload: import("dist/@frontegg/rest-api").IAcceptInvitation) => Promise<void>;
6
+ acceptInvitationWithOTC: (payload: import("dist/@frontegg/rest-api").IAcceptInvitationWithOTC) => Promise<void>;
7
+ };
@@ -1,13 +1,8 @@
1
- import { useStore } from '../FronteggStoreContext';
2
- import { useSnapshot } from '../useSnapshot';
3
-
4
- // TODO: remove useless stateMapper, valtio already does this
5
-
6
- const defaultMapper = state => state;
7
- export function useAcceptInvitationState(stateMapper = defaultMapper) {
8
- const state = useStore().store.auth.acceptInvitationState;
9
- return stateMapper(useSnapshot(state));
10
- }
11
- export const useAcceptInvitationActions = () => {
12
- return useStore().stateActions.auth.acceptInvitationActions;
13
- };
1
+ import { createSliceHooks } from '../useSnapshot/hookFactory';
2
+ export const {
3
+ useSliceState: useAcceptInvitationState,
4
+ useSliceActions: useAcceptInvitationActions
5
+ } = createSliceHooks({
6
+ getState: s => s.auth.acceptInvitationState,
7
+ getActions: a => a.auth.acceptInvitationActions
8
+ });
@@ -1,5 +1,11 @@
1
- import { ActivateAccountState, ActivateAccountActions } from '@frontegg/redux-store';
2
- export type ActivateAccountStateMapper<S> = (state: ActivateAccountState) => S;
3
- export declare function useActivateAccountState(): ActivateAccountState;
4
- export declare function useActivateAccountState<S>(stateMapper: ActivateAccountStateMapper<S>): S;
5
- export declare const useActivateAccountActions: () => ActivateAccountActions;
1
+ import type { ActivateAccountState } from '@frontegg/redux-store';
2
+ export declare const useActivateAccountState: <S = ActivateAccountState>(selector?: (s: ActivateAccountState) => S) => S, useActivateAccountActions: () => {
3
+ setActivateState: (state: Partial<ActivateAccountState>) => void;
4
+ resetActivateState: () => void;
5
+ setActivateStrategyState: (state: Partial<ActivateAccountState["activationStrategy"]>) => void;
6
+ activateAccount: (_payload: import("@frontegg/redux-store").WithCallback<import("@frontegg/redux-store").IActivateAccountPayload>) => Promise<void>;
7
+ preActivateAccount: (payload: import("@frontegg/redux-store").IPreActivateAccount) => Promise<void>;
8
+ getActivateAccountStrategy: (payload: import("@frontegg/redux-store").WithCallback<import("dist/@frontegg/rest-api").IGetActivateAccountStrategy, import("dist/@frontegg/rest-api").IGetActivateAccountStrategyResponse>) => Promise<void>;
9
+ resendActivationEmail: (payload: import("@frontegg/redux-store").WithCallback<import("dist/@frontegg/rest-api").IResendActivationEmail>) => Promise<void>;
10
+ activateAccountWithCode: (_payload: import("@frontegg/redux-store").WithCallback<import("@frontegg/redux-store").IActivateAccountWithOTCPayload>) => Promise<void>;
11
+ };
@@ -1,13 +1,8 @@
1
- import { useStore } from '../FronteggStoreContext';
2
- import { useSnapshot } from '../useSnapshot';
3
-
4
- // TODO: remove useless stateMapper, valtio already does this
5
-
6
- const defaultMapper = state => state;
7
- export function useActivateAccountState(stateMapper = defaultMapper) {
8
- const state = useStore().store.auth.activateAccountState;
9
- return stateMapper(useSnapshot(state));
10
- }
11
- export const useActivateAccountActions = () => {
12
- return useStore().stateActions.auth.activateAccountActions;
13
- };
1
+ import { createSliceHooks } from '../useSnapshot/hookFactory';
2
+ export const {
3
+ useSliceState: useActivateAccountState,
4
+ useSliceActions: useActivateAccountActions
5
+ } = createSliceHooks({
6
+ getState: s => s.auth.activateAccountState,
7
+ getActions: a => a.auth.activateAccountActions
8
+ });
@@ -1,7 +1,47 @@
1
- import { IAllAccountsState, AllAccountsActions, IAllAccountsDialogsState, AllAccountsDialogActions } from '@frontegg/redux-store';
2
- export type AllAccountsStateMapper<S> = (state: IAllAccountsState) => S;
3
- export declare function useAllAccountsState(): IAllAccountsState;
4
- export declare function useAllAccountsState<S>(stateMapper: AllAccountsStateMapper<S>): S;
5
- export declare const useAllAccountsActions: () => AllAccountsActions;
6
- export declare function useAllAccountsDialogsState(): IAllAccountsDialogsState;
7
- export declare const useAllAccountsDialogsActions: () => AllAccountsDialogActions;
1
+ import { IAllAccountsState, IAllAccountsDialogsState } from '@frontegg/redux-store';
2
+ export declare const useAllAccountsState: <S = IAllAccountsState>(selector?: (s: IAllAccountsState) => S) => S, useAllAccountsActions: () => {
3
+ setAllAccountsLoader: (payload: import("@frontegg/redux-store").AllAccountsStateIndicator) => void;
4
+ setAllAccountsError: (payload: import("@frontegg/redux-store").AllAccountsStateIndicator) => void;
5
+ setAllAccountsState: (state: Partial<IAllAccountsState>) => void;
6
+ setSelectedAccountState: (payload: Partial<IAllAccountsState["selectedAccount"]>) => void;
7
+ resetAllAccountsState: () => void;
8
+ clearSelectedAccount: () => void;
9
+ loadAccounts: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["loadAccounts"]) => Promise<void>;
10
+ searchAccounts: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["searchAccounts"]) => Promise<void>;
11
+ updateSubAccountAccessForUser: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["updateSubAccountAccessForUser"]) => Promise<void>;
12
+ createSubAccount: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["createSubAccount"]) => Promise<void>;
13
+ updateSubAccount: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["updateSubAccount"]) => Promise<void>;
14
+ deleteSubAccount: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["deleteSubAccount"]) => Promise<void>;
15
+ updateSubAccountSettings: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["updateSubAccountSettings"]) => Promise<void>;
16
+ updateSubAccountManagement: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["updateSubAccountManagement"]) => Promise<void>;
17
+ updateSubAccountHierarchySettings: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["updateSubAccountHierarchySettings"]) => Promise<void>;
18
+ addUsersToAccount: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["addUsersToAccount"]) => Promise<void>;
19
+ getAccountUsers: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["getAccountUsers"]) => Promise<void>;
20
+ deleteUsersFromAccount: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["deleteUsersFromAccount"]) => Promise<void>;
21
+ setUserRolesForSubAccount: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["setUserRolesForSubAccount"]) => Promise<void>;
22
+ getUserJwtForSubAccount: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["getUserJwtForSubAccount"]) => Promise<void>;
23
+ setRootAccountData: () => Promise<void>;
24
+ setSelectedSubAccountData: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["setSelectedSubAccountData"]) => Promise<void>;
25
+ loadNumberOfUsersForSelectedSubAccount: (payload: import("@frontegg/redux-store").IAllAccountsStateActionsPayloads["loadNumberOfUsersForSelectedSubAccount"]) => Promise<void>;
26
+ }, useAllAccountsDialogsState: () => IAllAccountsDialogsState, useAllAccountsDialogsActions: () => {
27
+ setAllAccountDialogsState: (payload: Partial<IAllAccountsDialogsState>) => void;
28
+ resetAllAccountDialogsState: () => void;
29
+ openCreateSubAccountDialog: (payload: Partial<import("@frontegg/redux-store").TCreateSubAccountDialogState>) => void;
30
+ closeCreateSubAccountDialog: () => void;
31
+ openUpdateSubAccountDialog: (payload: Partial<import("@frontegg/redux-store").TUpdateAccountDialogState>) => void;
32
+ closeUpdateSubAccountDialog: () => void;
33
+ openEnableSubAccountManagementDialog: (payload: Partial<import("@frontegg/redux-store").TUpdateSubAccountManagementState>) => void;
34
+ closeEnableSubAccountManagementDialog: () => void;
35
+ openUpdateSubAccountHierarchySettingsDialog: (payload: Partial<import("@frontegg/redux-store").TUpdateSubAccountHierarchySettingsDialogState>) => void;
36
+ closeUpdateSubAccountHierarchySettingsDialog: () => void;
37
+ openDisableSubAccountManagementDialog: (payload: Partial<import("@frontegg/redux-store").TUpdateSubAccountManagementState>) => void;
38
+ closeDisableSubAccountManagementDialog: () => void;
39
+ openDeleteSubAccountDialog: (payload: Partial<import("@frontegg/redux-store").TDeleteSubAccountDialogState>) => void;
40
+ closeDeleteSubAccountDialog: () => void;
41
+ openAddUsersToAccountDialog: (payload: Partial<import("@frontegg/redux-store").TAddUsersToSubAccountDialogState>) => void;
42
+ closeAddUsersToAccountDialog: () => void;
43
+ openDeleteUserFromAccountDialog: (payload: Partial<import("@frontegg/redux-store").TDeleteUserFromSubAccountDialogState>) => void;
44
+ closeDeleteUserFromAccountDialog: () => void;
45
+ openEditUserRolesDialog: (payload: Partial<import("@frontegg/redux-store").TEditUserRolesDialogState>) => void;
46
+ closeEditUserRolesDialog: () => void;
47
+ };
@@ -1,20 +1,12 @@
1
- import { useStore } from '../FronteggStoreContext';
2
- import { useSnapshot } from '../useSnapshot';
3
-
4
- // TODO: remove useless stateMapper, valtio already does this
5
-
6
- const defaultMapper = state => state;
7
- export function useAllAccountsState(stateMapper = defaultMapper) {
8
- const state = useStore().store.auth.allAccountsState;
9
- return stateMapper(useSnapshot(state));
10
- }
11
- export const useAllAccountsActions = () => {
12
- return useStore().stateActions.auth.allAccountsActions;
13
- };
14
- export function useAllAccountsDialogsState() {
15
- const state = useStore().store.auth.allAccountsDialogsState;
16
- return useSnapshot(state);
17
- }
18
- export const useAllAccountsDialogsActions = () => {
19
- return useStore().stateActions.auth.allAccountsDialogActions;
20
- };
1
+ import { createSliceHooks } from '../useSnapshot/hookFactory';
2
+ export const {
3
+ useSliceState: useAllAccountsState,
4
+ useSliceActions: useAllAccountsActions,
5
+ useSliceDialogsState: useAllAccountsDialogsState,
6
+ useSliceDialogsActions: useAllAccountsDialogsActions
7
+ } = createSliceHooks({
8
+ getState: s => s.auth.allAccountsState,
9
+ getActions: a => a.auth.allAccountsActions,
10
+ getDialogsState: s => s.auth.allAccountsDialogsState,
11
+ getDialogsActions: a => a.auth.allAccountsDialogActions
12
+ });
@@ -1,3 +1,14 @@
1
- import { ApiTokensActions, ApiTokensState } from '@frontegg/redux-store';
2
- export declare function useApiTokensState(): ApiTokensState;
3
- export declare const useApiTokensActions: () => ApiTokensActions;
1
+ import type { ApiTokensState } from '@frontegg/redux-store';
2
+ export declare const useApiTokensState: <S = ApiTokensState>(selector?: (s: ApiTokensState) => S) => S, useApiTokensActions: () => {
3
+ setApiTokensLoader: (payload: import("@frontegg/redux-store").ApiStateIndicator) => void;
4
+ setApiTokensError: (payload: import("@frontegg/redux-store").ApiStateIndicator) => void;
5
+ setApiTokensState: (state: Partial<ApiTokensState>) => void;
6
+ resetApiTokensState: () => void;
7
+ loadApiTokens: (payload?: import("@frontegg/redux-store").WithSilentLoad<import("@frontegg/redux-store").WithCallback>) => Promise<void>;
8
+ loadUserApiTokens: (payload?: import("@frontegg/redux-store").WithRetryConfig<import("@frontegg/redux-store").WithSilentLoad<import("@frontegg/redux-store").WithCallback>>) => Promise<void>;
9
+ loadTenantApiTokens: (payload?: import("@frontegg/redux-store").WithRetryConfig<import("@frontegg/redux-store").WithSilentLoad<import("@frontegg/redux-store").WithCallback>>) => Promise<void>;
10
+ addTenantApiToken: (payload: import("@frontegg/redux-store").AddTenantApiTokenPayload) => Promise<void>;
11
+ addUserApiToken: (payload: import("@frontegg/redux-store").AddUserApiTokenPayload) => Promise<void>;
12
+ deleteUserApiToken: (payload: string) => Promise<void>;
13
+ deleteTenantApiToken: (payload: string) => Promise<void>;
14
+ };
package/auth/apiTokens.js CHANGED
@@ -1,9 +1,8 @@
1
- import { useStore } from '../FronteggStoreContext';
2
- import { useSnapshot } from '../useSnapshot';
3
- export function useApiTokensState() {
4
- const state = useStore().store.auth.apiTokensState;
5
- return useSnapshot(state);
6
- }
7
- export const useApiTokensActions = () => {
8
- return useStore().stateActions.auth.apiTokensActions;
9
- };
1
+ import { createSliceHooks } from '../useSnapshot/hookFactory';
2
+ export const {
3
+ useSliceState: useApiTokensState,
4
+ useSliceActions: useApiTokensActions
5
+ } = createSliceHooks({
6
+ getState: s => s.auth.apiTokensState,
7
+ getActions: a => a.auth.apiTokensActions
8
+ });
@@ -1,3 +1,22 @@
1
- import { ApplicationsActions, ApplicationsState } from '@frontegg/redux-store';
2
- export declare function useApplicationsState(): ApplicationsState;
3
- export declare const useApplicationsActions: () => ApplicationsActions;
1
+ import type { ApplicationsState } from '@frontegg/redux-store';
2
+ export declare const useApplicationsState: <S = ApplicationsState>(selector?: (s: ApplicationsState) => S) => S, useApplicationsActions: () => {
3
+ setApplicationsState: (payload: Partial<ApplicationsState>) => void;
4
+ resetApplicationsState: () => void;
5
+ loadUserApplications: (payload?: import("@frontegg/redux-store").WithRetryConfig<{}>) => Promise<void>;
6
+ loadAccountApplications: (payload?: import("@frontegg/redux-store").WithRetryConfig<{}>) => Promise<void>;
7
+ loadMultipleUsersApplications: ({ userIds, retryConfig }: import("@frontegg/redux-store").WithRetryConfig<{
8
+ userIds: string[];
9
+ }>) => Promise<Record<string, import("dist/@frontegg/rest-api").IApplicationsResponse[]> | undefined>;
10
+ assignUserToApps: (payload: import("@frontegg/redux-store").WithCallback<import("@frontegg/redux-store").UserAppsAssignmentPayload>) => Promise<void>;
11
+ unassignUserFromApps: (payload: import("@frontegg/redux-store").WithCallback<import("@frontegg/redux-store").UserAppsAssignmentPayload>) => Promise<void>;
12
+ assignNewUserToApps: ({ appIds, user }: {
13
+ appIds?: string[];
14
+ user: import("dist/@frontegg/rest-api").ITeamUser;
15
+ }) => Promise<((import("dist/@frontegg/rest-api").IApplicationsResponse & {
16
+ userIds?: string[];
17
+ }) | never[])[] | undefined>;
18
+ mapUsersWithApplicationData: ({ shouldLoadApps, users, retryConfig, }: import("@frontegg/redux-store").WithRetryConfig<{
19
+ shouldLoadApps?: boolean;
20
+ users: import("dist/@frontegg/rest-api").ITeamUser[];
21
+ }>) => Promise<import("dist/@frontegg/rest-api").ITeamUser[]>;
22
+ };
@@ -1,9 +1,8 @@
1
- import { useStore } from '../FronteggStoreContext';
2
- import { useSnapshot } from '../useSnapshot';
3
- export function useApplicationsState() {
4
- const state = useStore().store.auth.applicationsState;
5
- return useSnapshot(state);
6
- }
7
- export const useApplicationsActions = () => {
8
- return useStore().stateActions.auth.applicationsActions;
9
- };
1
+ import { createSliceHooks } from '../useSnapshot/hookFactory';
2
+ export const {
3
+ useSliceState: useApplicationsState,
4
+ useSliceActions: useApplicationsActions
5
+ } = createSliceHooks({
6
+ getState: s => s.auth.applicationsState,
7
+ getActions: a => a.auth.applicationsActions
8
+ });
@@ -1,6 +1,12 @@
1
- import { CustomLoginState, CustomLoginActions } from '@frontegg/redux-store';
2
- export declare function useCustomLoginState(): CustomLoginState;
3
- export declare const useCustomLoginActions: () => CustomLoginActions;
1
+ import type { CustomLoginState } from '@frontegg/redux-store';
2
+ export declare const useCustomLoginState: <S = CustomLoginState>(selector?: (s: CustomLoginState) => S) => S, useCustomLoginActions: () => {
3
+ setCustomLoginState: (payload: Partial<CustomLoginState>) => void;
4
+ resetCustomLoginState: () => void;
5
+ loadTenantMetadata: () => Promise<void>;
6
+ updateTenantMetadata: (payload: import("@frontegg/redux-store").WithCallback<Partial<import("@frontegg/redux-store").UpdateTenantMetadataRequest>>) => Promise<void>;
7
+ customLoginEnabled: () => Promise<boolean>;
8
+ loadCustomLoginRoutes: (payload?: import("@frontegg/redux-store").WithCallback<import("@frontegg/redux-store").WithRetryConfig<{}>>) => Promise<void>;
9
+ };
4
10
  export declare const useCustomLoginTheme: () => {
5
11
  customLoginTheme: any;
6
12
  getCustomLoginThemeValue: (path?: string) => any;
@@ -1,20 +1,17 @@
1
1
  import { useCallback } from 'react';
2
2
  import getValue from 'get-value';
3
- import { useStore } from '../FronteggStoreContext';
4
- import { useSnapshot } from '../useSnapshot';
5
- export function useCustomLoginState() {
6
- const state = useStore().store.auth.customLoginState;
7
- return useSnapshot(state);
8
- }
9
- export const useCustomLoginActions = () => {
10
- return useStore().stateActions.auth.customLoginActions;
11
- };
3
+ import { createSliceHooks } from '../useSnapshot/hookFactory';
4
+ export const {
5
+ useSliceState: useCustomLoginState,
6
+ useSliceActions: useCustomLoginActions
7
+ } = createSliceHooks({
8
+ getState: s => s.auth.customLoginState,
9
+ getActions: a => a.auth.customLoginActions
10
+ });
12
11
  export const useCustomLoginTheme = () => {
13
12
  var _useCustomLoginState$, _useCustomLoginState$2, _useCustomLoginState$3;
14
13
  const customLoginTheme = (_useCustomLoginState$ = useCustomLoginState().tenantMetadata) == null ? void 0 : (_useCustomLoginState$2 = _useCustomLoginState$.configuration) == null ? void 0 : (_useCustomLoginState$3 = _useCustomLoginState$2.themeV2) == null ? void 0 : _useCustomLoginState$3.loginBox;
15
- const getCustomLoginThemeValue = useCallback(path => {
16
- return path && customLoginTheme ? getValue(customLoginTheme, path) : customLoginTheme;
17
- }, [customLoginTheme]);
14
+ const getCustomLoginThemeValue = useCallback(path => path && customLoginTheme ? getValue(customLoginTheme, path) : customLoginTheme, [customLoginTheme]);
18
15
  return {
19
16
  customLoginTheme,
20
17
  getCustomLoginThemeValue
@@ -1,35 +1,16 @@
1
- import { CustomAttributes } from '@frontegg/entitlements-javascript-commons';
1
+ import type { CustomAttributes } from '@frontegg/entitlements-javascript-commons';
2
2
  import { EntitledToOptions, Entitlement } from '@frontegg/redux-store';
3
- /**
4
- @param key feature key
5
- @param customAttributes user attributes
6
- @returns if the user is entitled to the given feature and attributes. Attaching the justification if not
7
- */
8
- export declare const useFeatureEntitlements: (key: string, customAttributes?: CustomAttributes) => Entitlement;
9
- /**
10
- @param key permission key
11
- @param customAttributes user attributes
12
- @returns if the user is entitled to the given permission and attributes. Attaching the justification if not
13
- */
14
- export declare const usePermissionEntitlements: (key: string, customAttributes?: CustomAttributes) => Entitlement;
15
- /**
16
- @param options
17
- @param customAttributes user attributes
18
- @returns if the user is entitled to the given feature or permission and attributes (check only one). Attaching the justification if not
19
- */
20
- export declare const useEntitlements: (options: EntitledToOptions, customAttributes?: CustomAttributes) => Entitlement;
21
- /**
22
- @returns an action your can use to detect if the user is entitled to the given feature or permission (check only one).
23
- Attaching the justification if not
24
- */
3
+ export declare const useFeatureEntitlements: (key: string, custom?: CustomAttributes) => Entitlement;
4
+ export declare const usePermissionEntitlements: (key: string, custom?: CustomAttributes) => Entitlement;
5
+ export declare const useEntitlements: (opts: EntitledToOptions, custom?: CustomAttributes) => Entitlement;
25
6
  export declare const useEntitlementsActions: () => {
26
- isEntitledTo: (options: EntitledToOptions, customAttributes?: CustomAttributes) => Entitlement;
7
+ isEntitledTo: (options: EntitledToOptions, custom?: CustomAttributes) => Entitlement;
27
8
  };
28
9
  /**
29
10
  @returns if the option to use entitlements is enabled
30
11
  */
31
12
  export declare const useEntitlementsOptions: () => {
32
13
  isEntitlementsEnabled: boolean;
33
- isEntitledTo: (options: EntitledToOptions, customAttributes?: CustomAttributes) => Entitlement;
14
+ isEntitledTo: (o: EntitledToOptions, c?: CustomAttributes) => Entitlement;
34
15
  verifyIsEntitledFF: boolean;
35
16
  };
@@ -1,112 +1,80 @@
1
- import { useAuthUserOrNull } from './hooks';
2
1
  import { useMemo } from 'react';
2
+ import { getEntitlements, getFeatureEntitlements, getPermissionEntitlements } from '@frontegg/redux-store';
3
+ import { useAuthUserOrNull } from './hooks';
3
4
  import { useRootState, useShadowDom } from '../common';
4
5
  import { useFeatureFlags } from '../flags';
5
6
  import { useStore } from '../FronteggStoreContext';
6
7
  import { useSnapshot } from '../useSnapshot';
7
- import { getEntitlements, getFeatureEntitlements, getPermissionEntitlements } from '@frontegg/redux-store';
8
8
 
9
- /**
10
- * @returns entitlements state as stored in the user
11
- */
9
+ /** Current entitlements object (or empty) */
12
10
  const useEntitlementsState = () => {
13
11
  var _useSnapshot$user$ent, _useSnapshot$user;
14
- const state = useStore().store.auth;
15
- return (_useSnapshot$user$ent = (_useSnapshot$user = useSnapshot(state).user) == null ? void 0 : _useSnapshot$user.entitlements) != null ? _useSnapshot$user$ent : {};
12
+ return (_useSnapshot$user$ent = (_useSnapshot$user = useSnapshot(useStore().store.auth).user) == null ? void 0 : _useSnapshot$user.entitlements) != null ? _useSnapshot$user$ent : {};
16
13
  };
17
14
 
18
- /**
19
- * @returns user state
20
- */
21
- const useUserState = () => {
22
- return useAuthUserOrNull() || undefined;
23
- };
15
+ /** Currently logged-in user claims (or undefined) */
16
+ const useUserState = () => useAuthUserOrNull() || undefined;
24
17
 
25
- /**
26
- * @param customAttributes user attributes
27
- * @returns is entitled query data including entitlement state and final attributes (consumer and frontegg)
28
- */
29
- const useEntitlementsQueryData = customAttributes => {
18
+ /** Shared attributes object passed to the entitlement engine */
19
+ const useAttributes = custom => {
30
20
  const user = useUserState();
31
- const entitlements = useEntitlementsState();
32
- const attributes = {
33
- custom: customAttributes,
21
+ return useMemo(() => ({
22
+ custom,
34
23
  jwt: user
35
- };
36
- return {
37
- entitlements,
38
- attributes
39
- };
24
+ }), [custom, user]);
40
25
  };
41
26
 
42
- /**
43
- @param key feature key
44
- @param customAttributes user attributes
45
- @returns if the user is entitled to the given feature and attributes. Attaching the justification if not
46
- */
47
- export const useFeatureEntitlements = (key, customAttributes) => {
48
- const {
49
- entitlements,
50
- attributes
51
- } = useEntitlementsQueryData(customAttributes);
27
+ /** Single resolver so we don’t repeat switch-cases in every hook */
28
+ const resolveEntitlement = (variant, keyOrOpts, entitlements, attrs, appName) => {
29
+ switch (variant) {
30
+ case 'feature':
31
+ return getFeatureEntitlements(entitlements, keyOrOpts, attrs, undefined, appName);
32
+ case 'permission':
33
+ return getPermissionEntitlements(entitlements, keyOrOpts, attrs, undefined, appName);
34
+ default:
35
+ return getEntitlements(entitlements, keyOrOpts, attrs, undefined, appName);
36
+ }
37
+ };
38
+ export const useFeatureEntitlements = (key, custom) => {
39
+ const entitlements = useEntitlementsState();
40
+ const attrs = useAttributes(custom);
52
41
  const {
53
42
  appName
54
43
  } = useRootState();
55
- return getFeatureEntitlements(entitlements, key, attributes, undefined, appName);
44
+ return resolveEntitlement('feature', key, entitlements, attrs, appName);
56
45
  };
57
-
58
- /**
59
- @param key permission key
60
- @param customAttributes user attributes
61
- @returns if the user is entitled to the given permission and attributes. Attaching the justification if not
62
- */
63
- export const usePermissionEntitlements = (key, customAttributes) => {
64
- const {
65
- entitlements,
66
- attributes
67
- } = useEntitlementsQueryData(customAttributes);
46
+ export const usePermissionEntitlements = (key, custom) => {
47
+ const entitlements = useEntitlementsState();
48
+ const attrs = useAttributes(custom);
68
49
  const {
69
50
  appName
70
51
  } = useRootState();
71
- return getPermissionEntitlements(entitlements, key, attributes, undefined, appName);
52
+ return resolveEntitlement('permission', key, entitlements, attrs, appName);
72
53
  };
73
-
74
- /**
75
- @param options
76
- @param customAttributes user attributes
77
- @returns if the user is entitled to the given feature or permission and attributes (check only one). Attaching the justification if not
78
- */
79
- export const useEntitlements = (options, customAttributes) => {
80
- const {
81
- entitlements,
82
- attributes
83
- } = useEntitlementsQueryData(customAttributes);
54
+ export const useEntitlements = (opts, custom) => {
55
+ const entitlements = useEntitlementsState();
56
+ const attrs = useAttributes(custom);
84
57
  const {
85
58
  appName
86
59
  } = useRootState();
87
- return getEntitlements(entitlements, options, attributes, undefined, appName);
60
+ return resolveEntitlement('any', opts, entitlements, attrs, appName);
88
61
  };
89
-
90
- /**
91
- @returns an action your can use to detect if the user is entitled to the given feature or permission (check only one).
92
- Attaching the justification if not
93
- */
94
62
  export const useEntitlementsActions = () => {
95
- // this code is duplicated because React is yelling when using useEntitlementsQueryData inside the isEntitledTo function because it's not a hook
96
- const user = useUserState();
97
63
  const entitlements = useEntitlementsState();
98
64
  const {
99
65
  appName
100
66
  } = useRootState();
67
+ const user = useUserState(); // stable referentially via useAuthUserOrNull
68
+ // Pre-compute attrs once so callers don’t need to worry
101
69
  return useMemo(() => ({
102
- isEntitledTo: (options, customAttributes) => {
103
- const attributes = {
104
- custom: customAttributes,
70
+ isEntitledTo: (options, custom) => {
71
+ const attrs = {
72
+ custom,
105
73
  jwt: user
106
74
  };
107
- return getEntitlements(entitlements, options, attributes, undefined, appName);
75
+ return getEntitlements(entitlements, options, attrs, undefined, appName);
108
76
  }
109
- }), [user, entitlements]);
77
+ }), [entitlements, user, appName]);
110
78
  };
111
79
 
112
80
  /**
@@ -1,3 +1,12 @@
1
- import { ForgotPasswordState, ForgotPasswordActions } from '@frontegg/redux-store';
2
- export declare function useForgotPasswordState(): ForgotPasswordState;
3
- export declare const useForgotPasswordActions: () => ForgotPasswordActions;
1
+ import type { ForgotPasswordState } from '@frontegg/redux-store';
2
+ export declare const useForgotPasswordState: <S = ForgotPasswordState>(selector?: (s: ForgotPasswordState) => S) => S, useForgotPasswordActions: () => {
3
+ setForgotPasswordState: (payload: Partial<ForgotPasswordState>) => void;
4
+ resetForgotPasswordState: () => void;
5
+ forgotPassword: (payload: import("@frontegg/redux-store").IForgotPasswordPayload) => Promise<void>;
6
+ resetPassword: (payload: import("@frontegg/redux-store").IResetPasswordPayload) => Promise<void>;
7
+ loadPasswordConfig: (payload?: import("dist/@frontegg/rest-api").IGetUserPasswordConfig) => Promise<void>;
8
+ determinePasswordRecoveryStrategy: (payload: import("@frontegg/redux-store").IDeterminePasswordRecoveryStrategyPayload) => Promise<void>;
9
+ sendPasswordRecoveryEmail: () => Promise<void>;
10
+ sendPasswordRecoverySms: () => Promise<void>;
11
+ verifyPasswordViaSms: (payload: import("@frontegg/redux-store").IVerifyPasswordViaSmsPayload) => Promise<void>;
12
+ };