@frontegg/react-hooks 5.59.1 → 6.0.1-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 (107) hide show
  1. package/FronteggProvider.d.ts +11 -10
  2. package/FronteggProvider.js +137 -0
  3. package/FronteggStoreContext.d.ts +8 -8
  4. package/FronteggStoreContext.js +13 -0
  5. package/audits/auditLogs.d.ts +5 -5
  6. package/audits/auditLogs.js +4 -0
  7. package/audits/auditsMetadata.d.ts +5 -5
  8. package/audits/auditsMetadata.js +4 -0
  9. package/audits/hooks.d.ts +12 -12
  10. package/audits/hooks.js +35 -0
  11. package/audits/index.d.ts +3 -3
  12. package/audits/index.js +3 -5
  13. package/auth/acceptInvitation.d.ts +5 -5
  14. package/auth/acceptInvitation.js +4 -0
  15. package/auth/activateAccount.d.ts +5 -5
  16. package/auth/activateAccount.js +4 -0
  17. package/auth/apiTokens.d.ts +5 -5
  18. package/auth/apiTokens.js +4 -0
  19. package/auth/forgotPassword.d.ts +5 -5
  20. package/auth/forgotPassword.js +4 -0
  21. package/auth/hooks.d.ts +62 -62
  22. package/auth/hooks.js +79 -0
  23. package/auth/index.d.ts +16 -16
  24. package/auth/index.js +16 -7
  25. package/auth/login.d.ts +5 -5
  26. package/auth/login.js +4 -0
  27. package/auth/mfa.d.ts +4 -4
  28. package/auth/mfa.js +4 -0
  29. package/auth/profile.d.ts +6 -6
  30. package/auth/profile.js +16 -0
  31. package/auth/resetPhoneNumber.d.ts +5 -5
  32. package/auth/resetPhoneNumber.js +4 -0
  33. package/auth/roles.d.ts +5 -5
  34. package/auth/roles.js +4 -0
  35. package/auth/securityPolicy.d.ts +11 -11
  36. package/auth/securityPolicy.js +25 -0
  37. package/auth/signup.d.ts +5 -5
  38. package/auth/signup.js +4 -0
  39. package/auth/socialLogin.d.ts +5 -5
  40. package/auth/socialLogin.js +4 -0
  41. package/auth/sso.d.ts +4 -4
  42. package/auth/sso.js +4 -0
  43. package/auth/team.d.ts +5 -5
  44. package/auth/team.js +4 -0
  45. package/auth/tenants.d.ts +5 -5
  46. package/auth/tenants.js +4 -0
  47. package/common/index.d.ts +17 -17
  48. package/common/index.js +30 -0
  49. package/common/package.json +6 -0
  50. package/connectivity/hooks.d.ts +5 -5
  51. package/connectivity/hooks.js +15 -0
  52. package/connectivity/index.d.ts +1 -1
  53. package/connectivity/index.js +1 -5
  54. package/index.d.ts +8 -8
  55. package/index.js +13 -93
  56. package/node/FronteggProvider.js +160 -0
  57. package/node/FronteggStoreContext.js +49 -0
  58. package/node/audits/auditLogs.js +18 -0
  59. package/node/audits/auditsMetadata.js +18 -0
  60. package/node/audits/hooks.js +62 -0
  61. package/node/audits/index.js +46 -13
  62. package/node/auth/acceptInvitation.js +18 -0
  63. package/node/auth/activateAccount.js +18 -0
  64. package/node/auth/apiTokens.js +18 -0
  65. package/node/auth/forgotPassword.js +18 -0
  66. package/node/auth/hooks.js +127 -0
  67. package/node/auth/index.js +275 -54
  68. package/node/auth/login.js +18 -0
  69. package/node/auth/mfa.js +18 -0
  70. package/node/auth/profile.js +34 -0
  71. package/node/auth/resetPhoneNumber.js +18 -0
  72. package/node/auth/roles.js +18 -0
  73. package/node/auth/securityPolicy.js +43 -0
  74. package/node/auth/signup.js +18 -0
  75. package/node/auth/socialLogin.js +18 -0
  76. package/node/auth/sso.js +18 -0
  77. package/node/auth/team.js +18 -0
  78. package/node/auth/tenants.js +18 -0
  79. package/node/common/index.js +44 -0
  80. package/node/connectivity/hooks.js +31 -0
  81. package/node/connectivity/index.js +17 -12
  82. package/node/index.js +111 -187
  83. package/node/subscriptions/hooks.js +131 -0
  84. package/node/subscriptions/index.js +15 -27
  85. package/node/vendor/hooks.js +31 -0
  86. package/node/vendor/index.js +17 -12
  87. package/package.json +12 -7
  88. package/subscriptions/hooks.d.ts +19 -19
  89. package/subscriptions/hooks.js +69 -0
  90. package/subscriptions/index.d.ts +1 -1
  91. package/subscriptions/index.js +1 -5
  92. package/vendor/hooks.d.ts +5 -5
  93. package/vendor/hooks.js +15 -0
  94. package/vendor/index.d.ts +1 -1
  95. package/vendor/index.js +1 -5
  96. package/FronteggStoreContext-d6c3b684.js +0 -9
  97. package/auditsMetadata-9ab88593.js +0 -35
  98. package/hooks-6400e233.js +0 -14
  99. package/hooks-7fc5d634.js +0 -64
  100. package/hooks-eaf879c9.js +0 -14
  101. package/node/FronteggStoreContext-6cfac56c.js +0 -18
  102. package/node/auditsMetadata-d15799a1.js +0 -42
  103. package/node/hooks-429ffd3a.js +0 -83
  104. package/node/hooks-5d5a445e.js +0 -17
  105. package/node/hooks-cf739b27.js +0 -17
  106. package/node/roles-f45dbc50.js +0 -215
  107. package/roles-f87bc6a0.js +0 -172
package/auth/index.js CHANGED
@@ -1,7 +1,16 @@
1
- export { w as reloadProfileIfNeeded, i as useAcceptInvitationActions, h as useAcceptInvitationState, k as useActivateAccountActions, j as useActivateAccountState, m as useApiTokensActions, l as useApiTokensState, u as useAuth, a as useAuthActions, c as useAuthRoutes, E as useAuthTeamActions, D as useAuthTeamState, e as useAuthUser, f as useAuthUserOrNull, o as useForgotPasswordActions, n as useForgotPasswordState, d as useIsAuthenticated, s as useLoginActions, r as useLoginState, g as useLoginWithRedirect, v as useMfaActions, t as useMfaState, b as useOnRedirectTo, y as useProfileActions, x as useProfileState, J as usePublicPolicySettings, q as useResetPhoneNumberActions, p as useResetPhoneNumberState, N as useRolesActions, M as useRolesState, G as useSSOActions, F as useSSOState, I as useSecurityPolicyActions, H as useSecurityPolicyState, A as useSignUpActions, z as useSignUpState, C as useSocialLoginActions, B as useSocialLoginState, L as useTenantsActions, K as useTenantsState } from '../roles-f87bc6a0.js';
2
- import '@frontegg/redux-store';
3
- import 'react';
4
- import 'react-redux';
5
- import '../FronteggStoreContext-d6c3b684.js';
6
- import '@frontegg/rest-api';
7
- import 'tslib';
1
+ export { useAuth, useAuthActions, useOnRedirectTo, useAuthRoutes, useIsAuthenticated, useAuthUser, useAuthUserOrNull, useLoginWithRedirect } from './hooks';
2
+ export * from './acceptInvitation';
3
+ export * from './activateAccount';
4
+ export * from './apiTokens';
5
+ export * from './forgotPassword';
6
+ export * from './resetPhoneNumber';
7
+ export * from './login';
8
+ export * from './mfa';
9
+ export * from './profile';
10
+ export * from './signup';
11
+ export * from './socialLogin';
12
+ export * from './team';
13
+ export * from './sso';
14
+ export * from './securityPolicy';
15
+ export * from './tenants';
16
+ export * from './roles';
package/auth/login.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { LoginState, LoginActions } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare type LoginStateMapper<S extends object> = (state: LoginState) => S;
4
- export declare const useLoginState: StateHookFunction<LoginState>;
5
- export declare const useLoginActions: () => LoginActions;
1
+ import { LoginState, LoginActions } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare type LoginStateMapper<S extends object> = (state: LoginState) => S;
4
+ export declare const useLoginState: StateHookFunction<LoginState>;
5
+ export declare const useLoginActions: () => LoginActions;
package/auth/login.js ADDED
@@ -0,0 +1,4 @@
1
+ import { loginReducers, loginActions } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useLoginState = stateMapper => stateHookGenerator(stateMapper, 'loginState');
4
+ export const useLoginActions = () => reducerActionsGenerator(loginActions, loginReducers);
package/auth/mfa.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MfaActions, MFAState } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare const useMfaState: StateHookFunction<MFAState>;
4
- export declare const useMfaActions: () => MfaActions;
1
+ import { MfaActions, MFAState } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare const useMfaState: StateHookFunction<MFAState>;
4
+ export declare const useMfaActions: () => MfaActions;
package/auth/mfa.js ADDED
@@ -0,0 +1,4 @@
1
+ import { mfaActions, mfaReducers } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useMfaState = stateMapper => stateHookGenerator(stateMapper, 'mfaState');
4
+ export const useMfaActions = () => reducerActionsGenerator(mfaActions, mfaReducers);
package/auth/profile.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ProfileActions, ProfileState } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare const reloadProfileIfNeeded: () => void;
4
- export declare type ProfileStateMapper<S extends object> = (state: ProfileState) => S;
5
- export declare const useProfileState: StateHookFunction<ProfileState>;
6
- export declare const useProfileActions: () => ProfileActions;
1
+ import { ProfileActions, ProfileState } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare const reloadProfileIfNeeded: () => void;
4
+ export declare type ProfileStateMapper<S extends object> = (state: ProfileState) => S;
5
+ export declare const useProfileState: StateHookFunction<ProfileState>;
6
+ export declare const useProfileActions: () => ProfileActions;
@@ -0,0 +1,16 @@
1
+ import { useEffect } from 'react';
2
+ import { profileActions, profileReducers } from '@frontegg/redux-store';
3
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
4
+ export const reloadProfileIfNeeded = () => {
5
+ const {
6
+ loading
7
+ } = useProfileState();
8
+ const {
9
+ loadProfile
10
+ } = useProfileActions();
11
+ useEffect(() => {
12
+ !loading && loadProfile();
13
+ }, []);
14
+ };
15
+ export const useProfileState = stateMapper => stateHookGenerator(stateMapper, 'profileState');
16
+ export const useProfileActions = () => reducerActionsGenerator(profileActions, profileReducers);
@@ -1,5 +1,5 @@
1
- import { ResetPhoneNumberState, ResetPhoneNumberActions } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare type ResetPhoneNumberStateMapper<S extends object> = (state: ResetPhoneNumberState) => S;
4
- export declare const useResetPhoneNumberState: StateHookFunction<ResetPhoneNumberState>;
5
- export declare const useResetPhoneNumberActions: () => ResetPhoneNumberActions;
1
+ import { ResetPhoneNumberState, ResetPhoneNumberActions } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare type ResetPhoneNumberStateMapper<S extends object> = (state: ResetPhoneNumberState) => S;
4
+ export declare const useResetPhoneNumberState: StateHookFunction<ResetPhoneNumberState>;
5
+ export declare const useResetPhoneNumberActions: () => ResetPhoneNumberActions;
@@ -0,0 +1,4 @@
1
+ import { resetPhoneNumberReducers, resetPhoneNumberActions } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useResetPhoneNumberState = stateMapper => stateHookGenerator(stateMapper, 'resetPhoneNumberState');
4
+ export const useResetPhoneNumberActions = () => reducerActionsGenerator(resetPhoneNumberActions, resetPhoneNumberReducers);
package/auth/roles.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { RolesActions, RolesState } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare type RolesStateMapper<S extends object> = (state: RolesState) => S;
4
- export declare const useRolesState: StateHookFunction<RolesState>;
5
- export declare const useRolesActions: () => RolesActions;
1
+ import { RolesActions, RolesState } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare type RolesStateMapper<S extends object> = (state: RolesState) => S;
4
+ export declare const useRolesState: StateHookFunction<RolesState>;
5
+ export declare const useRolesActions: () => RolesActions;
package/auth/roles.js ADDED
@@ -0,0 +1,4 @@
1
+ import { rolesReducers, rolesActions } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useRolesState = stateMapper => stateHookGenerator(stateMapper, 'rolesState');
4
+ export const useRolesActions = () => reducerActionsGenerator(rolesActions, rolesReducers);
@@ -1,11 +1,11 @@
1
- import { SecurityPolicyActions, SecurityPolicyState } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare type SecurityPolicyStateMapper<S extends object> = (state: SecurityPolicyState) => S;
4
- export declare const useSecurityPolicyState: StateHookFunction<SecurityPolicyState>;
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;
11
- };
1
+ import { SecurityPolicyActions, SecurityPolicyState } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare type SecurityPolicyStateMapper<S extends object> = (state: SecurityPolicyState) => S;
4
+ export declare const useSecurityPolicyState: StateHookFunction<SecurityPolicyState>;
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;
11
+ };
@@ -0,0 +1,25 @@
1
+ import { securityPolicyActions, securityPolicyReducers } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ import { useEffect } from 'react';
4
+ export const useSecurityPolicyState = stateMapper => stateHookGenerator(stateMapper, 'securityPolicyState');
5
+ export const useSecurityPolicyActions = () => reducerActionsGenerator(securityPolicyActions, securityPolicyReducers);
6
+ export const usePublicPolicySettings = (loadOnMount = false) => {
7
+ const {
8
+ loading,
9
+ policy,
10
+ saving,
11
+ error
12
+ } = useSecurityPolicyState(state => state.publicPolicy);
13
+ const {
14
+ loadPublicSecurityPolicy
15
+ } = useSecurityPolicyActions();
16
+ useEffect(() => {
17
+ (loadOnMount || !policy) && loadPublicSecurityPolicy();
18
+ }, [loadOnMount, loadPublicSecurityPolicy]);
19
+ return {
20
+ loading,
21
+ saving,
22
+ error,
23
+ policy
24
+ };
25
+ };
package/auth/signup.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { SignUpState, SignUpActions } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare type SignUpStateMapper<S extends object> = (state: SignUpState) => S;
4
- export declare const useSignUpState: StateHookFunction<SignUpState>;
5
- export declare const useSignUpActions: () => SignUpActions;
1
+ import { SignUpState, SignUpActions } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare type SignUpStateMapper<S extends object> = (state: SignUpState) => S;
4
+ export declare const useSignUpState: StateHookFunction<SignUpState>;
5
+ export declare const useSignUpActions: () => SignUpActions;
package/auth/signup.js ADDED
@@ -0,0 +1,4 @@
1
+ import { signUpReducers, signUpActions } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useSignUpState = stateMapper => stateHookGenerator(stateMapper, 'signUpState');
4
+ export const useSignUpActions = () => reducerActionsGenerator(signUpActions, signUpReducers);
@@ -1,5 +1,5 @@
1
- import { SocialLoginActions, SocialLoginState } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare type SocialLoginStateMapper<S extends object> = (state: SocialLoginState) => S;
4
- export declare const useSocialLoginState: StateHookFunction<SocialLoginState>;
5
- export declare const useSocialLoginActions: () => SocialLoginActions;
1
+ import { SocialLoginActions, SocialLoginState } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare type SocialLoginStateMapper<S extends object> = (state: SocialLoginState) => S;
4
+ export declare const useSocialLoginState: StateHookFunction<SocialLoginState>;
5
+ export declare const useSocialLoginActions: () => SocialLoginActions;
@@ -0,0 +1,4 @@
1
+ import { socialLoginsActions, socialLoginsReducer } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useSocialLoginState = stateMapper => stateHookGenerator(stateMapper, 'socialLoginState');
4
+ export const useSocialLoginActions = () => reducerActionsGenerator(socialLoginsActions, socialLoginsReducer);
package/auth/sso.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SSOState, SSOActions } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare const useSSOState: StateHookFunction<SSOState>;
4
- export declare const useSSOActions: () => SSOActions;
1
+ import { SSOState, SSOActions } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare const useSSOState: StateHookFunction<SSOState>;
4
+ export declare const useSSOActions: () => SSOActions;
package/auth/sso.js ADDED
@@ -0,0 +1,4 @@
1
+ import { ssoActions, ssoReducers } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useSSOState = stateMapper => stateHookGenerator(stateMapper, 'ssoState');
4
+ export const useSSOActions = () => reducerActionsGenerator(ssoActions, ssoReducers);
package/auth/team.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { TeamState, TeamActions } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare type AuthTeamStateMapper<S extends object> = (state: TeamState) => S;
4
- export declare const useAuthTeamState: StateHookFunction<TeamState>;
5
- export declare const useAuthTeamActions: () => TeamActions;
1
+ import { TeamState, TeamActions } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare type AuthTeamStateMapper<S extends object> = (state: TeamState) => S;
4
+ export declare const useAuthTeamState: StateHookFunction<TeamState>;
5
+ export declare const useAuthTeamActions: () => TeamActions;
package/auth/team.js ADDED
@@ -0,0 +1,4 @@
1
+ import { teamActions, teamReducers } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useAuthTeamState = stateMapper => stateHookGenerator(stateMapper, 'teamState');
4
+ export const useAuthTeamActions = () => reducerActionsGenerator(teamActions, teamReducers);
package/auth/tenants.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { TenantsState, TenantsActions } from '@frontegg/redux-store';
2
- import { StateHookFunction } from './hooks';
3
- export declare type TenantsStateMapper<S extends object> = (state: TenantsState) => S;
4
- export declare const useTenantsState: StateHookFunction<TenantsState>;
5
- export declare const useTenantsActions: () => TenantsActions;
1
+ import { TenantsState, TenantsActions } from '@frontegg/redux-store';
2
+ import { StateHookFunction } from './hooks';
3
+ export declare type TenantsStateMapper<S extends object> = (state: TenantsState) => S;
4
+ export declare const useTenantsState: StateHookFunction<TenantsState>;
5
+ export declare const useTenantsActions: () => TenantsActions;
@@ -0,0 +1,4 @@
1
+ import { tenantsActions, tenantsReducers } from '@frontegg/redux-store';
2
+ import { reducerActionsGenerator, stateHookGenerator } from './hooks';
3
+ export const useTenantsState = stateMapper => stateHookGenerator(stateMapper, 'tenantsState');
4
+ export const useTenantsActions = () => reducerActionsGenerator(tenantsActions, tenantsReducers);
package/common/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
- import { FronteggAppInstance, FronteggAppOptions } from '@frontegg/types';
3
- interface ShadowDomContextData extends FronteggAppOptions {
4
- injector: FronteggAppInstance;
5
- iframeRendering: boolean;
6
- renderByRoute?: boolean;
7
- slotsContainer: HTMLElement;
8
- rootEl: HTMLElement;
9
- staticRoute?: string;
10
- setStaticRouteSetter?: (action: Dispatch<SetStateAction<string | undefined>>) => void;
11
- }
12
- export interface DomContext extends ShadowDomContextData {
13
- isShadowDom: boolean;
14
- }
15
- export declare const ShadowDomContext: import("react").Context<ShadowDomContextData>;
16
- export declare const useShadowDom: () => DomContext;
17
- export {};
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { FronteggAppInstance, FronteggAppOptions } from '@frontegg/types';
3
+ interface ShadowDomContextData extends FronteggAppOptions {
4
+ injector: FronteggAppInstance;
5
+ iframeRendering: boolean;
6
+ renderByRoute?: boolean;
7
+ slotsContainer: HTMLElement;
8
+ rootEl: HTMLElement;
9
+ staticRoute?: string;
10
+ setStaticRouteSetter?: (action: Dispatch<SetStateAction<string | undefined>>) => void;
11
+ }
12
+ export interface DomContext extends ShadowDomContextData {
13
+ isShadowDom: boolean;
14
+ }
15
+ export declare const ShadowDomContext: import("react").Context<ShadowDomContextData>;
16
+ export declare const useShadowDom: () => DomContext;
17
+ export {};
@@ -0,0 +1,30 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["urlStrategy", "onRedirectTo", "renderByRoute", "customLoader", "customStyles", "contextOptions"];
4
+ import { createContext, useContext } from 'react';
5
+ export const ShadowDomContext = createContext({});
6
+ export const useShadowDom = () => {
7
+ const context = useContext(ShadowDomContext);
8
+
9
+ const {
10
+ urlStrategy = 'path',
11
+ onRedirectTo = urlStrategy === 'path' ? path => window.history.pushState(null, '', path) : path => window.history.pushState(null, '', `#${path}`),
12
+ renderByRoute = false,
13
+ customLoader = false,
14
+ customStyles,
15
+ contextOptions
16
+ } = context,
17
+ rest = _objectWithoutPropertiesLoose(context, _excluded);
18
+
19
+ return _extends({
20
+ isShadowDom: true,
21
+ onRedirectTo,
22
+ renderByRoute,
23
+ customLoader,
24
+ customStyles,
25
+ urlStrategy,
26
+ contextOptions: _extends({
27
+ requestCredentials: 'include'
28
+ }, contextOptions)
29
+ }, rest);
30
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/common/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -1,5 +1,5 @@
1
- import { ConnectivityActions, IConnectivityState } from '@frontegg/redux-store';
2
- export declare type AuthStateMapper<S extends object> = (state: IConnectivityState) => S;
3
- export declare type StateHookFunction<T> = (() => T) & (<S extends object>(mapper: (state: T) => S) => S);
4
- export declare const useConnectivityState: <S extends object>(stateMapper?: AuthStateMapper<S> | undefined) => S;
5
- export declare const useConnectivityActions: () => ConnectivityActions;
1
+ import { ConnectivityActions, IConnectivityState } from '@frontegg/redux-store';
2
+ export declare type AuthStateMapper<S extends object> = (state: IConnectivityState) => S;
3
+ export declare type StateHookFunction<T> = (() => T) & (<S extends object>(mapper: (state: T) => S) => S);
4
+ export declare const useConnectivityState: <S extends object>(stateMapper?: AuthStateMapper<S> | undefined) => S;
5
+ export declare const useConnectivityActions: () => ConnectivityActions;
@@ -0,0 +1,15 @@
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
+ export const useConnectivityState = stateMapper => {
6
+ return useSelector(state => {
7
+ var _stateMapper;
8
+
9
+ return (_stateMapper = stateMapper == null ? void 0 : stateMapper(state[connectivityStoreName])) != null ? _stateMapper : state[connectivityStoreName];
10
+ }, shallowEqual);
11
+ };
12
+ export const useConnectivityActions = () => {
13
+ const dispatch = useDispatch();
14
+ return useMemo(() => bindActionCreators(connectivityActions, dispatch), [connectivityActions]);
15
+ };
@@ -1 +1 @@
1
- export { useConnectivityActions, useConnectivityState } from './hooks';
1
+ export { useConnectivityActions, useConnectivityState } from './hooks';
@@ -1,5 +1 @@
1
- export { u as useConnectivityActions, a as useConnectivityState } from '../hooks-6400e233.js';
2
- import 'react';
3
- import 'react-redux';
4
- import '../FronteggStoreContext-d6c3b684.js';
5
- import '@frontegg/redux-store';
1
+ export { useConnectivityActions, useConnectivityState } from './hooks';
package/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export * from './common';
2
- export * from './audits';
3
- export * from './auth';
4
- export * from './connectivity';
5
- export * from './subscriptions';
6
- export * from './vendor';
7
- export * from './FronteggProvider';
8
- export * from './FronteggStoreContext';
1
+ export * from './common';
2
+ export * from './audits';
3
+ export * from './auth';
4
+ export * from './connectivity';
5
+ export * from './subscriptions';
6
+ export * from './vendor';
7
+ export * from './FronteggProvider';
8
+ export * from './FronteggStoreContext';
package/index.js CHANGED
@@ -1,93 +1,13 @@
1
- import { u as useAuth, c as useAuthRoutes } from './roles-f87bc6a0.js';
2
- export { S as ShadowDomContext, w as reloadProfileIfNeeded, i as useAcceptInvitationActions, h as useAcceptInvitationState, k as useActivateAccountActions, j as useActivateAccountState, m as useApiTokensActions, l as useApiTokensState, u as useAuth, a as useAuthActions, c as useAuthRoutes, E as useAuthTeamActions, D as useAuthTeamState, e as useAuthUser, f as useAuthUserOrNull, o as useForgotPasswordActions, n as useForgotPasswordState, d as useIsAuthenticated, s as useLoginActions, r as useLoginState, g as useLoginWithRedirect, v as useMfaActions, t as useMfaState, b as useOnRedirectTo, y as useProfileActions, x as useProfileState, J as usePublicPolicySettings, q as useResetPhoneNumberActions, p as useResetPhoneNumberState, N as useRolesActions, M as useRolesState, G as useSSOActions, F as useSSOState, I as useSecurityPolicyActions, H as useSecurityPolicyState, O as useShadowDom, A as useSignUpActions, z as useSignUpState, C as useSocialLoginActions, B as useSocialLoginState, L as useTenantsActions, K as useTenantsState } from './roles-f87bc6a0.js';
3
- import { __rest } from 'tslib';
4
- import React, { useMemo, useRef, useState, useEffect } from 'react';
5
- import { Provider } from 'react-redux';
6
- export { Provider, connectAdvanced, shallowEqual } from 'react-redux';
7
- import { createFronteggStore } from '@frontegg/redux-store';
8
- import { ContextHolder } from '@frontegg/rest-api';
9
- import { F as FronteggStoreContext } from './FronteggStoreContext-d6c3b684.js';
10
- export { F as FronteggStoreContext, a as useDispatch, u as useSelector, b as useStore } from './FronteggStoreContext-d6c3b684.js';
11
- export { c as useAuditLogsActions, b as useAuditLogsState, a as useAuditsActions, e as useAuditsMetadataActions, d as useAuditsMetadataState, u as useAuditsState } from './auditsMetadata-9ab88593.js';
12
- export { u as useConnectivityActions, a as useConnectivityState } from './hooks-6400e233.js';
13
- export { f as useBillingInformation, g as useBillingInformationActions, d as useCheckout, e as useCheckoutActions, j as useInvoices, k as useInvoicesActions, h as usePaymentMethod, i as usePaymentMethodActions, u as usePaymentProvider, a as usePaymentProviderActions, b as usePlans, c as usePlansActions, m as useStripeActions, l as useStripeState, p as useSubscription, q as useSubscriptionActions, n as useSubscriptionCancellation, o as useSubscriptionRenewal } from './hooks-7fc5d634.js';
14
- export { u as useVendorActions, a as useVendorState } from './hooks-eaf879c9.js';
15
-
16
- const setLoading = (loading) => {
17
- const isSSR = typeof document === 'undefined' || typeof window === 'undefined';
18
- if (!isSSR) {
19
- if (loading) {
20
- document.body.classList.add('frontegg-loading');
21
- }
22
- else {
23
- document.body.classList.remove('frontegg-loading');
24
- }
25
- }
26
- };
27
- const HideChildrenIfFronteggRoutes = ({ children, basename }) => {
28
- const routes = useAuthRoutes();
29
- const uriRef = useRef(window.location.pathname);
30
- const animationFrameRef = useRef(0);
31
- const [uri, setUri] = useState(window.location.pathname);
32
- const checker = () => {
33
- if (uriRef.current !== window.location.pathname) {
34
- uriRef.current = window.location.pathname;
35
- setUri(document.location.pathname);
36
- }
37
- animationFrameRef.current = window.requestAnimationFrame(checker);
38
- };
39
- useEffect(() => {
40
- document.addEventListener('frontegg_onRedirectTo_fired', () => {
41
- if (uriRef.current !== window.location.pathname) {
42
- uriRef.current = window.location.pathname;
43
- setUri(document.location.pathname);
44
- }
45
- });
46
- window.addEventListener('popstate', () => {
47
- if (uriRef.current !== window.location.pathname) {
48
- uriRef.current = window.location.pathname;
49
- setUri(document.location.pathname);
50
- }
51
- });
52
- animationFrameRef.current = window.requestAnimationFrame(checker);
53
- return () => {
54
- window.cancelAnimationFrame(animationFrameRef.current);
55
- };
56
- }, [setUri]);
57
- const calculatedBasename = basename ? (basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '') : '';
58
- const checkRoutes = __rest(routes, ["authenticatedUrl", "signUpSuccessUrl"]);
59
- if (Object.values(checkRoutes).map(url => `${calculatedBasename}${url}`).indexOf(uri) !== -1) {
60
- return null;
61
- }
62
- return React.createElement(React.Fragment, null, children);
63
- };
64
- const FronteggContent = ({ children, app, setLoading }) => {
65
- var _a, _b, _c;
66
- const { isLoading } = useAuth(({ isLoading }) => ({ isLoading }));
67
- const customLoginBox = !app || ((_a = app === null || app === void 0 ? void 0 : app.options) === null || _a === void 0 ? void 0 : _a.customLoginBox) === true;
68
- const alwaysShowChildren = customLoginBox || (((_b = app === null || app === void 0 ? void 0 : app.options) === null || _b === void 0 ? void 0 : _b.hostedLoginBox) === true && ((_c = app === null || app === void 0 ? void 0 : app.options) === null || _c === void 0 ? void 0 : _c.framework) === 'nextjs');
69
- const loadingRef = useRef(undefined);
70
- if (isLoading !== loadingRef.current) {
71
- loadingRef.current = isLoading;
72
- setLoading(isLoading);
73
- }
74
- if (isLoading) {
75
- return null;
76
- }
77
- if (alwaysShowChildren) {
78
- return React.createElement(React.Fragment, null, children);
79
- }
80
- return React.createElement(HideChildrenIfFronteggRoutes, { basename: app === null || app === void 0 ? void 0 : app.options.basename }, children);
81
- };
82
- const FronteggStoreProvider = ({ children, app, contextOptions, setLoading: setLoadingProps, }) => {
83
- var _a, _b, _c, _d, _e, _f;
84
- const context = (_b = (_a = app === null || app === void 0 ? void 0 : app.options) === null || _a === void 0 ? void 0 : _a.contextOptions) !== null && _b !== void 0 ? _b : contextOptions;
85
- const previewMode = (_d = (_c = app === null || app === void 0 ? void 0 : app.options) === null || _c === void 0 ? void 0 : _c.previewMode) !== null && _d !== void 0 ? _d : false;
86
- const authOptions = (_f = (_e = app === null || app === void 0 ? void 0 : app.options) === null || _e === void 0 ? void 0 : _e.authOptions) !== null && _f !== void 0 ? _f : {};
87
- ContextHolder.setContext(context);
88
- const store = useMemo(() => createFronteggStore({ context: context }, app, previewMode, authOptions), [app, previewMode]);
89
- return (React.createElement(Provider, { context: FronteggStoreContext, store: store },
90
- React.createElement(FronteggContent, { setLoading: setLoadingProps !== null && setLoadingProps !== void 0 ? setLoadingProps : setLoading, app: app }, children)));
91
- };
92
-
93
- export { FronteggStoreProvider };
1
+ /** @license Frontegg v6.0.1-alpha.0
2
+ *
3
+ * This source code is licensed under the MIT license found in the
4
+ * LICENSE file in the root directory of this source tree.
5
+ */
6
+ export * from './common';
7
+ export * from './audits';
8
+ export * from './auth';
9
+ export * from './connectivity';
10
+ export * from './subscriptions';
11
+ export * from './vendor';
12
+ export * from './FronteggProvider';
13
+ export * from './FronteggStoreContext';