@frontegg/react-hooks 7.78.0-alpha.1 → 7.78.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.
Files changed (120) hide show
  1. package/audits/auditLogs.d.ts +3 -2
  2. package/audits/auditLogs.js +9 -8
  3. package/audits/auditsMetadata.d.ts +3 -2
  4. package/audits/auditsMetadata.js +9 -8
  5. package/audits/hooks.d.ts +9 -2
  6. package/audits/hooks.js +14 -10
  7. package/auth/acceptInvitation.d.ts +5 -7
  8. package/auth/acceptInvitation.js +13 -8
  9. package/auth/activateAccount.d.ts +5 -11
  10. package/auth/activateAccount.js +13 -8
  11. package/auth/allAccounts.d.ts +7 -47
  12. package/auth/allAccounts.js +20 -12
  13. package/auth/apiTokens.d.ts +3 -14
  14. package/auth/apiTokens.js +9 -8
  15. package/auth/applications.d.ts +3 -22
  16. package/auth/applications.js +9 -8
  17. package/auth/customLogin.d.ts +3 -9
  18. package/auth/customLogin.js +12 -9
  19. package/auth/entitlements.d.ts +25 -6
  20. package/auth/entitlements.js +73 -41
  21. package/auth/forgotPassword.d.ts +3 -12
  22. package/auth/forgotPassword.js +9 -10
  23. package/auth/groups.d.ts +5 -32
  24. package/auth/groups.js +14 -14
  25. package/auth/impersonate.d.ts +3 -6
  26. package/auth/impersonate.js +8 -8
  27. package/auth/login.d.ts +3 -74
  28. package/auth/login.js +8 -8
  29. package/auth/passkeys.d.ts +3 -10
  30. package/auth/passkeys.js +8 -8
  31. package/auth/passwordRotation.d.ts +3 -4
  32. package/auth/passwordRotation.js +9 -8
  33. package/auth/profile.d.ts +3 -19
  34. package/auth/profile.js +12 -17
  35. package/auth/provisioning.d.ts +3 -20
  36. package/auth/provisioning.js +8 -8
  37. package/auth/resetPhoneNumber.d.ts +3 -8
  38. package/auth/resetPhoneNumber.js +8 -8
  39. package/auth/roles.d.ts +3 -14
  40. package/auth/roles.js +8 -8
  41. package/auth/security/restrictions.d.ts +3 -21
  42. package/auth/security/restrictions.js +19 -20
  43. package/auth/security/securityCenter.d.ts +3 -15
  44. package/auth/security/securityCenter.js +9 -8
  45. package/auth/security/securityPolicy.d.ts +5 -35
  46. package/auth/security/securityPolicy.js +18 -16
  47. package/auth/security/sessionsPolicy.d.ts +3 -7
  48. package/auth/security/sessionsPolicy.js +9 -8
  49. package/auth/sessions.d.ts +3 -12
  50. package/auth/sessions.js +8 -8
  51. package/auth/signup.d.ts +5 -10
  52. package/auth/signup.js +16 -8
  53. package/auth/sms.d.ts +3 -13
  54. package/auth/sms.js +8 -8
  55. package/auth/socialLogin.d.ts +5 -9
  56. package/auth/socialLogin.js +13 -8
  57. package/auth/sso.d.ts +6 -31
  58. package/auth/sso.js +13 -8
  59. package/auth/stepUp.d.ts +14 -15
  60. package/auth/stepUp.js +22 -9
  61. package/auth/team.d.ts +13 -84
  62. package/auth/team.js +23 -12
  63. package/auth/tenants.d.ts +3 -9
  64. package/auth/tenants.js +9 -8
  65. package/auth/unlockAccount.d.ts +5 -6
  66. package/auth/unlockAccount.js +10 -8
  67. package/auth/usernames.d.ts +3 -7
  68. package/auth/usernames.js +8 -8
  69. package/auth/usersEmailsPolicyState.d.ts +5 -5
  70. package/auth/usersEmailsPolicyState.js +10 -8
  71. package/connectivity/hooks.d.ts +3 -41
  72. package/connectivity/hooks.js +9 -8
  73. package/index.js +1 -1
  74. package/node/audits/auditLogs.js +12 -11
  75. package/node/audits/auditsMetadata.js +12 -11
  76. package/node/audits/hooks.js +17 -13
  77. package/node/auth/acceptInvitation.js +13 -11
  78. package/node/auth/activateAccount.js +13 -11
  79. package/node/auth/allAccounts.js +20 -15
  80. package/node/auth/apiTokens.js +12 -11
  81. package/node/auth/applications.js +12 -11
  82. package/node/auth/customLogin.js +15 -11
  83. package/node/auth/entitlements.js +73 -41
  84. package/node/auth/forgotPassword.js +12 -13
  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 +12 -11
  90. package/node/auth/profile.js +13 -19
  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 +21 -22
  95. package/node/auth/security/securityCenter.js +12 -11
  96. package/node/auth/security/securityPolicy.js +17 -18
  97. package/node/auth/security/sessionsPolicy.js +12 -11
  98. package/node/auth/sessions.js +11 -11
  99. package/node/auth/signup.js +16 -11
  100. package/node/auth/sms.js +11 -11
  101. package/node/auth/socialLogin.js +13 -11
  102. package/node/auth/sso.js +13 -11
  103. package/node/auth/stepUp.js +24 -11
  104. package/node/auth/team.js +28 -16
  105. package/node/auth/tenants.js +12 -11
  106. package/node/auth/unlockAccount.js +13 -11
  107. package/node/auth/usernames.js +11 -11
  108. package/node/auth/usersEmailsPolicyState.js +13 -11
  109. package/node/connectivity/hooks.js +12 -11
  110. package/node/index.js +1 -1
  111. package/node/subscriptions/hooks.js +115 -86
  112. package/node/vendor/hooks.js +14 -11
  113. package/package.json +3 -3
  114. package/subscriptions/hooks.d.ts +22 -48
  115. package/subscriptions/hooks.js +103 -77
  116. package/vendor/hooks.d.ts +5 -2
  117. package/vendor/hooks.js +14 -8
  118. package/node/useSnapshot/hookFactory.js +0 -32
  119. package/useSnapshot/hookFactory.d.ts +0 -18
  120. package/useSnapshot/hookFactory.js +0 -26
@@ -1,2 +1,3 @@
1
- import type { AuditLogsState, AuditsActions } from '@frontegg/redux-store';
2
- export declare const useAuditLogsState: <S = AuditLogsState>(selector?: (s: AuditLogsState) => S) => S, useAuditLogsActions: () => AuditsActions;
1
+ import { AuditLogsState, AuditsActions } from '@frontegg/redux-store';
2
+ export declare function useAuditLogsState(): AuditLogsState;
3
+ export declare const useAuditLogsActions: () => AuditsActions;
@@ -1,8 +1,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
+ 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,2 +1,3 @@
1
- import type { AuditsMetadataState, AuditsActions } from '@frontegg/redux-store';
2
- export declare const useAuditsMetadataState: <S = AuditsMetadataState>(selector?: (s: AuditsMetadataState) => S) => S, useAuditsMetadataActions: () => AuditsActions;
1
+ import { AuditsActions, AuditsMetadataState } from '@frontegg/redux-store';
2
+ export declare function useAuditsMetadataState(): AuditsMetadataState;
3
+ export declare const useAuditsMetadataActions: () => AuditsActions;
@@ -1,8 +1,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
- });
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
+ };
package/audits/hooks.d.ts CHANGED
@@ -1,2 +1,9 @@
1
- import type { AuditsState, AuditsActions } from '@frontegg/redux-store';
2
- export declare const useAuditsState: <S = AuditsState>(selector?: (s: AuditsState) => S) => S, useAuditsActions: () => AuditsActions;
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;
package/audits/hooks.js CHANGED
@@ -1,10 +1,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
+ 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,7 +1,5 @@
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
+ 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,8 +1,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
+ 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,11 +1,5 @@
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
+ 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,8 +1,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
+ 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,47 +1,7 @@
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
+ 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,12 +1,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
+ 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,14 +1,3 @@
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
- };
1
+ import { ApiTokensActions, ApiTokensState } from '@frontegg/redux-store';
2
+ export declare function useApiTokensState(): ApiTokensState;
3
+ export declare const useApiTokensActions: () => ApiTokensActions;
package/auth/apiTokens.js CHANGED
@@ -1,8 +1,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
+ 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,22 +1,3 @@
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
+ import { ApplicationsActions, ApplicationsState } from '@frontegg/redux-store';
2
+ export declare function useApplicationsState(): ApplicationsState;
3
+ export declare const useApplicationsActions: () => ApplicationsActions;
@@ -1,8 +1,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
+ 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,12 +1,6 @@
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
- };
1
+ import { CustomLoginState, CustomLoginActions } from '@frontegg/redux-store';
2
+ export declare function useCustomLoginState(): CustomLoginState;
3
+ export declare const useCustomLoginActions: () => CustomLoginActions;
10
4
  export declare const useCustomLoginTheme: () => {
11
5
  customLoginTheme: any;
12
6
  getCustomLoginThemeValue: (path?: string) => any;
@@ -1,17 +1,20 @@
1
1
  import { useCallback } from 'react';
2
2
  import getValue from 'get-value';
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
- });
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
+ };
11
12
  export const useCustomLoginTheme = () => {
12
13
  var _useCustomLoginState$, _useCustomLoginState$2, _useCustomLoginState$3;
13
14
  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;
14
- const getCustomLoginThemeValue = useCallback(path => path && customLoginTheme ? getValue(customLoginTheme, path) : customLoginTheme, [customLoginTheme]);
15
+ const getCustomLoginThemeValue = useCallback(path => {
16
+ return path && customLoginTheme ? getValue(customLoginTheme, path) : customLoginTheme;
17
+ }, [customLoginTheme]);
15
18
  return {
16
19
  customLoginTheme,
17
20
  getCustomLoginThemeValue
@@ -1,16 +1,35 @@
1
- import type { CustomAttributes } from '@frontegg/entitlements-javascript-commons';
1
+ import { CustomAttributes } from '@frontegg/entitlements-javascript-commons';
2
2
  import { EntitledToOptions, Entitlement } from '@frontegg/redux-store';
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;
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
+ */
6
25
  export declare const useEntitlementsActions: () => {
7
- isEntitledTo: (options: EntitledToOptions, custom?: CustomAttributes) => Entitlement;
26
+ isEntitledTo: (options: EntitledToOptions, customAttributes?: CustomAttributes) => Entitlement;
8
27
  };
9
28
  /**
10
29
  @returns if the option to use entitlements is enabled
11
30
  */
12
31
  export declare const useEntitlementsOptions: () => {
13
32
  isEntitlementsEnabled: boolean;
14
- isEntitledTo: (o: EntitledToOptions, c?: CustomAttributes) => Entitlement;
33
+ isEntitledTo: (options: EntitledToOptions, customAttributes?: CustomAttributes) => Entitlement;
15
34
  verifyIsEntitledFF: boolean;
16
35
  };
@@ -1,80 +1,112 @@
1
- import { useMemo } from 'react';
2
- import { getEntitlements, getFeatureEntitlements, getPermissionEntitlements } from '@frontegg/redux-store';
3
1
  import { useAuthUserOrNull } from './hooks';
2
+ import { useMemo } from 'react';
4
3
  import { useRootState, useShadowDom } from '../common';
5
4
  import { useFeatureFlags } from '../flags';
6
5
  import { useStore } from '../FronteggStoreContext';
7
6
  import { useSnapshot } from '../useSnapshot';
7
+ import { getEntitlements, getFeatureEntitlements, getPermissionEntitlements } from '@frontegg/redux-store';
8
8
 
9
- /** Current entitlements object (or empty) */
9
+ /**
10
+ * @returns entitlements state as stored in the user
11
+ */
10
12
  const useEntitlementsState = () => {
11
13
  var _useSnapshot$user$ent, _useSnapshot$user;
12
- return (_useSnapshot$user$ent = (_useSnapshot$user = useSnapshot(useStore().store.auth).user) == null ? void 0 : _useSnapshot$user.entitlements) != null ? _useSnapshot$user$ent : {};
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 : {};
13
16
  };
14
17
 
15
- /** Currently logged-in user claims (or undefined) */
16
- const useUserState = () => useAuthUserOrNull() || undefined;
18
+ /**
19
+ * @returns user state
20
+ */
21
+ const useUserState = () => {
22
+ return useAuthUserOrNull() || undefined;
23
+ };
17
24
 
18
- /** Shared attributes object passed to the entitlement engine */
19
- const useAttributes = custom => {
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 => {
20
30
  const user = useUserState();
21
- return useMemo(() => ({
22
- custom,
31
+ const entitlements = useEntitlementsState();
32
+ const attributes = {
33
+ custom: customAttributes,
23
34
  jwt: user
24
- }), [custom, user]);
35
+ };
36
+ return {
37
+ entitlements,
38
+ attributes
39
+ };
25
40
  };
26
41
 
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);
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);
41
52
  const {
42
53
  appName
43
54
  } = useRootState();
44
- return resolveEntitlement('feature', key, entitlements, attrs, appName);
55
+ return getFeatureEntitlements(entitlements, key, attributes, undefined, appName);
45
56
  };
46
- export const usePermissionEntitlements = (key, custom) => {
47
- const entitlements = useEntitlementsState();
48
- const attrs = useAttributes(custom);
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);
49
68
  const {
50
69
  appName
51
70
  } = useRootState();
52
- return resolveEntitlement('permission', key, entitlements, attrs, appName);
71
+ return getPermissionEntitlements(entitlements, key, attributes, undefined, appName);
53
72
  };
54
- export const useEntitlements = (opts, custom) => {
55
- const entitlements = useEntitlementsState();
56
- const attrs = useAttributes(custom);
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);
57
84
  const {
58
85
  appName
59
86
  } = useRootState();
60
- return resolveEntitlement('any', opts, entitlements, attrs, appName);
87
+ return getEntitlements(entitlements, options, attributes, undefined, appName);
61
88
  };
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
+ */
62
94
  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();
63
97
  const entitlements = useEntitlementsState();
64
98
  const {
65
99
  appName
66
100
  } = useRootState();
67
- const user = useUserState(); // stable referentially via useAuthUserOrNull
68
- // Pre-compute attrs once so callers don’t need to worry
69
101
  return useMemo(() => ({
70
- isEntitledTo: (options, custom) => {
71
- const attrs = {
72
- custom,
102
+ isEntitledTo: (options, customAttributes) => {
103
+ const attributes = {
104
+ custom: customAttributes,
73
105
  jwt: user
74
106
  };
75
- return getEntitlements(entitlements, options, attrs, undefined, appName);
107
+ return getEntitlements(entitlements, options, attributes, undefined, appName);
76
108
  }
77
- }), [entitlements, user, appName]);
109
+ }), [user, entitlements]);
78
110
  };
79
111
 
80
112
  /**
@@ -1,12 +1,3 @@
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
- };
1
+ import { ForgotPasswordState, ForgotPasswordActions } from '@frontegg/redux-store';
2
+ export declare function useForgotPasswordState(): ForgotPasswordState;
3
+ export declare const useForgotPasswordActions: () => ForgotPasswordActions;