@frontegg/react-hooks 7.0.0-alpha.1 → 7.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FronteggProvider/FronteggProvider.d.ts +12 -0
- package/FronteggProvider/FronteggProvider.js +140 -0
- package/FronteggProvider/index.d.ts +1 -12
- package/FronteggProvider/index.js +1 -133
- package/FronteggStoreContext/FronteggStoreContext.d.ts +9 -0
- package/FronteggStoreContext/FronteggStoreContext.js +16 -0
- package/FronteggStoreContext/index.d.ts +1 -13
- package/FronteggStoreContext/index.js +1 -14
- package/audits/auditLogs.d.ts +2 -4
- package/audits/auditLogs.js +8 -6
- package/audits/auditsMetadata.d.ts +2 -4
- package/audits/auditsMetadata.js +8 -6
- package/audits/hooks.d.ts +0 -8
- package/audits/hooks.js +6 -30
- package/auth/acceptInvitation.js +10 -5
- package/auth/activateAccount.js +10 -4
- package/auth/{MSP/allAccounts.d.ts → allAccounts.d.ts} +2 -4
- package/auth/allAccounts.js +20 -0
- package/auth/apiTokens.d.ts +0 -2
- package/auth/apiTokens.js +8 -6
- package/auth/applications.d.ts +3 -0
- package/auth/applications.js +9 -0
- package/auth/customLogin.d.ts +2 -5
- package/auth/customLogin.js +10 -11
- package/auth/entitlements.d.ts +32 -13
- package/auth/entitlements.js +103 -21
- package/auth/forgotPassword.d.ts +0 -2
- package/auth/forgotPassword.js +8 -6
- package/auth/groups.d.ts +0 -4
- package/auth/groups.js +12 -13
- package/auth/hooks.d.ts +44 -12
- package/auth/hooks.js +73 -62
- package/auth/impersonate.d.ts +0 -2
- package/auth/impersonate.js +7 -6
- package/auth/index.d.ts +16 -16
- package/auth/index.js +16 -16
- package/auth/login.d.ts +1 -3
- package/auth/login.js +7 -6
- package/auth/mfa.d.ts +1 -1
- package/auth/mfa.js +13 -4
- package/auth/passkeys.d.ts +1 -4
- package/auth/passkeys.js +7 -6
- package/auth/profile.d.ts +2 -4
- package/auth/profile.js +9 -8
- package/auth/provisioning.d.ts +1 -3
- package/auth/provisioning.js +7 -6
- package/auth/resetPhoneNumber.d.ts +1 -3
- package/auth/resetPhoneNumber.js +7 -6
- package/auth/roles.d.ts +1 -3
- package/auth/roles.js +7 -6
- package/auth/security/index.d.ts +4 -0
- package/auth/security/index.js +4 -0
- package/auth/security/restrictions.d.ts +0 -2
- package/auth/security/restrictions.js +10 -10
- package/auth/security/securityCenter.d.ts +1 -4
- package/auth/security/securityCenter.js +8 -6
- package/auth/security/securityPolicy.d.ts +5 -11
- package/auth/security/securityPolicy.js +19 -30
- package/auth/security/sessionsPolicy.d.ts +1 -3
- package/auth/security/sessionsPolicy.js +8 -6
- package/auth/sessions.d.ts +1 -3
- package/auth/sessions.js +7 -6
- package/auth/signup.d.ts +1 -1
- package/auth/signup.js +13 -4
- package/auth/sms.d.ts +3 -0
- package/auth/sms.js +8 -0
- package/auth/socialLogin.d.ts +1 -1
- package/auth/socialLogin.js +10 -4
- package/auth/sso.d.ts +1 -1
- package/auth/sso.js +10 -4
- package/auth/stepUp.d.ts +16 -0
- package/auth/stepUp.js +51 -0
- package/auth/team.d.ts +9 -1
- package/auth/team.js +22 -4
- package/auth/tenants.d.ts +1 -3
- package/auth/tenants.js +8 -6
- package/common/CustomComponentHolder.js +3 -1
- package/common/index.d.ts +1 -0
- package/common/index.js +3 -3
- package/connectivity/hooks.d.ts +2 -5
- package/connectivity/hooks.js +6 -9
- package/index.d.ts +2 -2
- package/index.js +3 -3
- package/node/FronteggProvider/FronteggProvider.js +148 -0
- package/node/FronteggProvider/index.js +9 -134
- package/node/FronteggStoreContext/FronteggStoreContext.js +28 -0
- package/node/FronteggStoreContext/index.js +11 -35
- package/node/audits/auditLogs.js +8 -6
- package/node/audits/auditsMetadata.js +8 -6
- package/node/audits/hooks.js +7 -34
- package/node/auth/acceptInvitation.js +7 -5
- package/node/auth/activateAccount.js +7 -4
- package/node/auth/allAccounts.js +27 -0
- package/node/auth/apiTokens.js +8 -6
- package/node/auth/applications.js +17 -0
- package/node/auth/customLogin.js +11 -12
- package/node/auth/entitlements.js +106 -22
- package/node/auth/forgotPassword.js +8 -6
- package/node/auth/groups.js +12 -12
- package/node/auth/hooks.js +77 -67
- package/node/auth/impersonate.js +7 -6
- package/node/auth/index.js +107 -93
- package/node/auth/login.js +7 -6
- package/node/auth/mfa.js +10 -4
- package/node/auth/passkeys.js +7 -6
- package/node/auth/profile.js +10 -9
- package/node/auth/provisioning.js +7 -6
- package/node/auth/resetPhoneNumber.js +7 -6
- package/node/auth/roles.js +7 -6
- package/node/auth/security/index.js +49 -0
- package/node/auth/security/restrictions.js +10 -10
- package/node/auth/security/securityCenter.js +8 -6
- package/node/auth/security/securityPolicy.js +16 -30
- package/node/auth/security/sessionsPolicy.js +8 -6
- package/node/auth/sessions.js +7 -6
- package/node/auth/signup.js +10 -4
- package/node/auth/sms.js +16 -0
- package/node/auth/socialLogin.js +7 -4
- package/node/auth/sso.js +7 -4
- package/node/auth/stepUp.js +62 -0
- package/node/auth/team.js +25 -4
- package/node/auth/tenants.js +8 -6
- package/node/common/CustomComponentHolder.js +3 -1
- package/node/common/index.js +2 -2
- package/node/connectivity/hooks.js +5 -8
- package/node/index.js +16 -16
- package/node/subscriptions/hooks.js +84 -51
- package/node/tests/hooks.tsc-test.js +339 -0
- package/node/useSnapshot/index.js +137 -0
- package/node/vendor/hooks.js +5 -6
- package/package.json +3 -3
- package/subscriptions/hooks.d.ts +32 -10
- package/subscriptions/hooks.js +81 -49
- package/tests/hooks.tsc-test.js +338 -0
- package/useSnapshot/index.d.ts +78 -0
- package/useSnapshot/index.js +128 -0
- package/useSnapshot/package.json +6 -0
- package/vendor/hooks.d.ts +0 -1
- package/vendor/hooks.js +9 -7
- package/auth/MSP/allAccounts.js +0 -15
- package/node/auth/MSP/allAccounts.js +0 -24
package/auth/team.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useSnapshot } from '../useSnapshot';
|
|
2
|
+
import { useStore } from '../FronteggStoreContext';
|
|
3
|
+
export function useTeamState() {
|
|
4
|
+
const state = useStore().store.auth.teamState;
|
|
5
|
+
return useSnapshot(state);
|
|
6
|
+
}
|
|
7
|
+
export const useTeamActions = () => {
|
|
8
|
+
return useStore().stateActions.auth.teamActions;
|
|
9
|
+
};
|
|
3
10
|
const defaultMapper = state => state;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated use useTeamState instead
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// @deprecated use useTeamState() instead
|
|
4
16
|
export function useAuthTeamState(stateMapper = defaultMapper) {
|
|
5
|
-
return
|
|
17
|
+
return stateMapper(useTeamState());
|
|
6
18
|
}
|
|
7
|
-
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated use useTeamActions instead
|
|
22
|
+
*/
|
|
23
|
+
export const useAuthTeamActions = () => {
|
|
24
|
+
return useTeamActions();
|
|
25
|
+
};
|
package/auth/tenants.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { TenantsState, TenantsActions } from '@frontegg/redux-store';
|
|
2
|
-
export declare type TenantsStateMapper<S> = (state: TenantsState) => S;
|
|
1
|
+
import type { TenantsState, TenantsActions } from '@frontegg/redux-store';
|
|
3
2
|
export declare function useTenantsState(): TenantsState;
|
|
4
|
-
export declare function useTenantsState<S>(stateMapper: TenantsStateMapper<S>): S;
|
|
5
3
|
export declare const useTenantsActions: () => TenantsActions;
|
package/auth/tenants.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
1
|
+
import { useStore } from '../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
3
|
+
export function useTenantsState() {
|
|
4
|
+
const state = useStore().store.auth.tenantsState;
|
|
5
|
+
return useSnapshot(state);
|
|
6
6
|
}
|
|
7
|
-
export const useTenantsActions = () =>
|
|
7
|
+
export const useTenantsActions = () => {
|
|
8
|
+
return useStore().stateActions.auth.tenantsActions;
|
|
9
|
+
};
|
|
@@ -80,7 +80,9 @@ export const CustomComponentRegister = ({
|
|
|
80
80
|
CustomComponentHolder.set(generatedKey, obj);
|
|
81
81
|
return [generatedKey];
|
|
82
82
|
}
|
|
83
|
-
} catch (e) {
|
|
83
|
+
} catch (e) {
|
|
84
|
+
/* empty */
|
|
85
|
+
}
|
|
84
86
|
}
|
|
85
87
|
if ( /*#__PURE__*/isValidElement(obj) || isElement(obj) || obj === null) {
|
|
86
88
|
const generatedKey = `${keyPath}.${key}`;
|
package/common/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ interface ShadowDomContextData extends FronteggAppOptions {
|
|
|
9
9
|
rootEl: HTMLElement;
|
|
10
10
|
staticRoute?: string;
|
|
11
11
|
setStaticRouteSetter?: (action: Dispatch<SetStateAction<string | undefined>>) => void;
|
|
12
|
+
isMultiApp?: boolean;
|
|
12
13
|
}
|
|
13
14
|
export interface DomContext extends ShadowDomContextData {
|
|
14
15
|
isShadowDom: boolean;
|
package/common/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["urlStrategy", "onRedirectTo", "renderByRoute", "customLoader", "customStyles", "contextOptions"];
|
|
4
4
|
import { createContext, useContext } from 'react';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { useStore } from '../FronteggStoreContext';
|
|
6
|
+
import { useSnapshot } from '../useSnapshot';
|
|
7
7
|
export const ShadowDomContext = /*#__PURE__*/createContext({});
|
|
8
8
|
export const useShadowDom = () => {
|
|
9
9
|
const context = useContext(ShadowDomContext);
|
|
@@ -29,6 +29,6 @@ export const useShadowDom = () => {
|
|
|
29
29
|
}, rest);
|
|
30
30
|
};
|
|
31
31
|
export const useRootState = () => {
|
|
32
|
-
return
|
|
32
|
+
return useSnapshot(useStore().store.root);
|
|
33
33
|
};
|
|
34
34
|
export * from './CustomComponentHolder';
|
package/connectivity/hooks.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
3
|
-
export declare type StateHookFunction<T> = (() => T) & (<S extends object>(mapper: (state: T) => S) => S);
|
|
4
|
-
export declare function useConnectivityState(): IConnectivityState;
|
|
5
|
-
export declare function useConnectivityState<S>(stateMapper: ConnectivityStateMapper<S>): S;
|
|
1
|
+
import { ConnectivityState, ConnectivityActions } from '@frontegg/redux-store';
|
|
2
|
+
export declare function useConnectivityState(): ConnectivityState;
|
|
6
3
|
export declare const useConnectivityActions: () => ConnectivityActions;
|
package/connectivity/hooks.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function useConnectivityState(stateMapper = defaultMapper) {
|
|
7
|
-
return useSelector(state => stateMapper(state[connectivityStoreName]), shallowEqual);
|
|
1
|
+
import { useStore } from '../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
3
|
+
export function useConnectivityState() {
|
|
4
|
+
const state = useStore().store.connectivity;
|
|
5
|
+
return useSnapshot(state);
|
|
8
6
|
}
|
|
9
7
|
export const useConnectivityActions = () => {
|
|
10
|
-
|
|
11
|
-
return useMemo(() => bindActionCreators(connectivityActions, dispatch), [connectivityActions]);
|
|
8
|
+
return useStore().stateActions.connectivity;
|
|
12
9
|
};
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './common';
|
|
2
|
-
export * from './audits';
|
|
3
1
|
export * from './auth';
|
|
2
|
+
export * from './audits';
|
|
4
3
|
export * from './connectivity';
|
|
5
4
|
export * from './subscriptions';
|
|
6
5
|
export * from './vendor';
|
|
6
|
+
export * from './common';
|
|
7
7
|
export * from './flags';
|
|
8
8
|
export * from './FronteggProvider';
|
|
9
9
|
export * from './FronteggStoreContext';
|
package/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/** @license Frontegg v7.0.0-alpha.
|
|
1
|
+
/** @license Frontegg v7.0.0-alpha.3
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
5
5
|
*/
|
|
6
|
-
export * from './common';
|
|
7
|
-
export * from './audits';
|
|
8
6
|
export * from './auth';
|
|
7
|
+
export * from './audits';
|
|
9
8
|
export * from './connectivity';
|
|
10
9
|
export * from './subscriptions';
|
|
11
10
|
export * from './vendor';
|
|
11
|
+
export * from './common';
|
|
12
12
|
export * from './flags';
|
|
13
13
|
export * from './FronteggProvider';
|
|
14
14
|
export * from './FronteggStoreContext';
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.FronteggStoreProvider = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _reduxStore = require("@frontegg/redux-store");
|
|
12
|
+
var _restApi = require("@frontegg/rest-api");
|
|
13
|
+
var _FronteggStoreContext = require("../FronteggStoreContext");
|
|
14
|
+
var _auth = require("../auth");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
const _excluded = ["authenticatedUrl", "signUpSuccessUrl"];
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
const defaultSetLoading = loading => {
|
|
20
|
+
if (loading) {
|
|
21
|
+
document.body.classList.add('frontegg-loading');
|
|
22
|
+
} else {
|
|
23
|
+
document.body.classList.remove('frontegg-loading');
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const HideChildrenIfFronteggRoutes = ({
|
|
27
|
+
children,
|
|
28
|
+
basename
|
|
29
|
+
}) => {
|
|
30
|
+
const routes = (0, _auth.useAuthRoutes)();
|
|
31
|
+
const uriRef = (0, _react.useRef)(window.location.pathname);
|
|
32
|
+
const animationFrameRef = (0, _react.useRef)(0);
|
|
33
|
+
const [uri, setUri] = (0, _react.useState)(window.location.pathname);
|
|
34
|
+
const checker = (0, _react.useCallback)(() => {
|
|
35
|
+
if (uriRef.current !== window.location.pathname) {
|
|
36
|
+
uriRef.current = window.location.pathname;
|
|
37
|
+
setUri(document.location.pathname);
|
|
38
|
+
}
|
|
39
|
+
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
40
|
+
}, []);
|
|
41
|
+
(0, _react.useEffect)(() => {
|
|
42
|
+
document.addEventListener('frontegg_onRedirectTo_fired', () => {
|
|
43
|
+
if (uriRef.current !== window.location.pathname) {
|
|
44
|
+
uriRef.current = window.location.pathname;
|
|
45
|
+
setUri(document.location.pathname);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
window.addEventListener('popstate', () => {
|
|
49
|
+
if (uriRef.current !== window.location.pathname) {
|
|
50
|
+
uriRef.current = window.location.pathname;
|
|
51
|
+
setUri(document.location.pathname);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
55
|
+
return () => {
|
|
56
|
+
window.cancelAnimationFrame(animationFrameRef.current);
|
|
57
|
+
};
|
|
58
|
+
}, [checker, setUri]);
|
|
59
|
+
const calculatedBasename = basename ? basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '' : '';
|
|
60
|
+
const checkRoutes = (0, _objectWithoutPropertiesLoose2.default)(routes, _excluded);
|
|
61
|
+
if (Object.values(checkRoutes).map(url => `${calculatedBasename}${url}`).indexOf(uri) !== -1) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
65
|
+
children: children
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const FronteggContent = ({
|
|
69
|
+
children,
|
|
70
|
+
app,
|
|
71
|
+
setLoading
|
|
72
|
+
}) => {
|
|
73
|
+
var _app$options, _app$options2;
|
|
74
|
+
const {
|
|
75
|
+
isLoading
|
|
76
|
+
} = (0, _auth.useAuth)();
|
|
77
|
+
const customLoginBox = !app || (app == null ? void 0 : (_app$options = app.options) == null ? void 0 : _app$options.customLoginBox) === true;
|
|
78
|
+
const isNextJS = (app == null ? void 0 : (_app$options2 = app.options) == null ? void 0 : _app$options2.framework) === 'nextjs';
|
|
79
|
+
const alwaysShowChildren = customLoginBox || isNextJS;
|
|
80
|
+
const loadingRef = (0, _react.useRef)(undefined);
|
|
81
|
+
if (isLoading !== loadingRef.current && !isNextJS) {
|
|
82
|
+
loadingRef.current = isLoading;
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
setLoading(isLoading);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (alwaysShowChildren) {
|
|
88
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
89
|
+
children: children
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (isLoading && !isNextJS) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HideChildrenIfFronteggRoutes, {
|
|
96
|
+
basename: app == null ? void 0 : app.options.basename,
|
|
97
|
+
children: children
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
const FronteggStoreProvider = props => {
|
|
101
|
+
var _app$options$contextO, _app$options3, _app$options$previewM, _app$options4, _app$options$builderM, _app$options5, _app$options6, _app$options7, _app$options8;
|
|
102
|
+
const {
|
|
103
|
+
children,
|
|
104
|
+
app,
|
|
105
|
+
contextOptions,
|
|
106
|
+
setLoading = defaultSetLoading,
|
|
107
|
+
alwaysVisibleChildren
|
|
108
|
+
} = props;
|
|
109
|
+
|
|
110
|
+
// TODO: make this optionals more readable
|
|
111
|
+
const context = (_app$options$contextO = app == null ? void 0 : (_app$options3 = app.options) == null ? void 0 : _app$options3.contextOptions) != null ? _app$options$contextO : contextOptions;
|
|
112
|
+
if (!context) {
|
|
113
|
+
throw Error('contextOptions must not be null or undefined');
|
|
114
|
+
}
|
|
115
|
+
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.previewMode) != null ? _app$options$previewM : false;
|
|
116
|
+
const builderMode = (_app$options$builderM = app == null ? void 0 : (_app$options5 = app.options) == null ? void 0 : _app$options5.builderMode) != null ? _app$options$builderM : false;
|
|
117
|
+
const auditsOptions = app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.auditsOptions;
|
|
118
|
+
const authOptions = app != null && (_app$options7 = app.options) != null && _app$options7.authOptions ? (0, _extends2.default)({}, app.options.authOptions, {
|
|
119
|
+
hostedLoginBox: app.options.hostedLoginBox
|
|
120
|
+
}) : {
|
|
121
|
+
hostedLoginBox: app == null ? void 0 : (_app$options8 = app.options) == null ? void 0 : _app$options8.hostedLoginBox
|
|
122
|
+
};
|
|
123
|
+
_restApi.ContextHolder.setContext(context);
|
|
124
|
+
const store = (0, _react.useMemo)(() => {
|
|
125
|
+
var _app$name, _app$options9;
|
|
126
|
+
return (0, _reduxStore.createStore)({
|
|
127
|
+
name: (_app$name = app == null ? void 0 : app.name) != null ? _app$name : 'default',
|
|
128
|
+
context,
|
|
129
|
+
previewMode,
|
|
130
|
+
builderMode,
|
|
131
|
+
initialState: {
|
|
132
|
+
auth: authOptions,
|
|
133
|
+
audits: auditsOptions
|
|
134
|
+
},
|
|
135
|
+
urlStrategy: app == null ? void 0 : (_app$options9 = app.options) == null ? void 0 : _app$options9.urlStrategy,
|
|
136
|
+
storeHolder: app
|
|
137
|
+
});
|
|
138
|
+
}, [app, previewMode]);
|
|
139
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_FronteggStoreContext.Provider, {
|
|
140
|
+
store: store,
|
|
141
|
+
children: [alwaysVisibleChildren, /*#__PURE__*/(0, _jsxRuntime.jsx)(FronteggContent, {
|
|
142
|
+
setLoading: setLoading,
|
|
143
|
+
app: app,
|
|
144
|
+
children: children
|
|
145
|
+
})]
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
exports.FronteggStoreProvider = FronteggStoreProvider;
|
|
@@ -1,141 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
const _excluded = ["authenticatedUrl", "signUpSuccessUrl"];
|
|
17
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
const defaultSetLoading = loading => {
|
|
20
|
-
if (loading) {
|
|
21
|
-
document.body.classList.add('frontegg-loading');
|
|
22
|
-
} else {
|
|
23
|
-
document.body.classList.remove('frontegg-loading');
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const HideChildrenIfFronteggRoutes = ({
|
|
27
|
-
children,
|
|
28
|
-
basename
|
|
29
|
-
}) => {
|
|
30
|
-
const routes = (0, _auth.useAuthRoutes)();
|
|
31
|
-
const uriRef = (0, _react.useRef)(window.location.pathname);
|
|
32
|
-
const animationFrameRef = (0, _react.useRef)(0);
|
|
33
|
-
const [uri, setUri] = (0, _react.useState)(window.location.pathname);
|
|
34
|
-
const checker = (0, _react.useCallback)(() => {
|
|
35
|
-
if (uriRef.current !== window.location.pathname) {
|
|
36
|
-
uriRef.current = window.location.pathname;
|
|
37
|
-
setUri(document.location.pathname);
|
|
6
|
+
var _FronteggProvider = require("./FronteggProvider");
|
|
7
|
+
Object.keys(_FronteggProvider).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _FronteggProvider[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _FronteggProvider[key];
|
|
38
14
|
}
|
|
39
|
-
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
40
|
-
}, []);
|
|
41
|
-
(0, _react.useEffect)(() => {
|
|
42
|
-
document.addEventListener('frontegg_onRedirectTo_fired', () => {
|
|
43
|
-
if (uriRef.current !== window.location.pathname) {
|
|
44
|
-
uriRef.current = window.location.pathname;
|
|
45
|
-
setUri(document.location.pathname);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
window.addEventListener('popstate', () => {
|
|
49
|
-
if (uriRef.current !== window.location.pathname) {
|
|
50
|
-
uriRef.current = window.location.pathname;
|
|
51
|
-
setUri(document.location.pathname);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
55
|
-
return () => {
|
|
56
|
-
window.cancelAnimationFrame(animationFrameRef.current);
|
|
57
|
-
};
|
|
58
|
-
}, [checker, setUri]);
|
|
59
|
-
const calculatedBasename = basename ? basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '' : '';
|
|
60
|
-
const checkRoutes = (0, _objectWithoutPropertiesLoose2.default)(routes, _excluded);
|
|
61
|
-
if (Object.values(checkRoutes).map(url => `${calculatedBasename}${url}`).indexOf(uri) !== -1) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
65
|
-
children: children
|
|
66
15
|
});
|
|
67
|
-
};
|
|
68
|
-
const FronteggContent = ({
|
|
69
|
-
children,
|
|
70
|
-
app,
|
|
71
|
-
setLoading
|
|
72
|
-
}) => {
|
|
73
|
-
var _app$options, _app$options2;
|
|
74
|
-
const {
|
|
75
|
-
isLoading
|
|
76
|
-
} = (0, _auth.useAuth)(({
|
|
77
|
-
isLoading
|
|
78
|
-
}) => ({
|
|
79
|
-
isLoading
|
|
80
|
-
}));
|
|
81
|
-
const customLoginBox = !app || (app == null ? void 0 : (_app$options = app.options) == null ? void 0 : _app$options.customLoginBox) === true;
|
|
82
|
-
const isNextJS = (app == null ? void 0 : (_app$options2 = app.options) == null ? void 0 : _app$options2.framework) === 'nextjs';
|
|
83
|
-
const alwaysShowChildren = customLoginBox || isNextJS;
|
|
84
|
-
const loadingRef = (0, _react.useRef)(undefined);
|
|
85
|
-
if (isLoading !== loadingRef.current && !isNextJS) {
|
|
86
|
-
loadingRef.current = isLoading;
|
|
87
|
-
setLoading(isLoading);
|
|
88
|
-
}
|
|
89
|
-
if (alwaysShowChildren) {
|
|
90
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
91
|
-
children: children
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
if (isLoading && !isNextJS) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HideChildrenIfFronteggRoutes, {
|
|
98
|
-
basename: app == null ? void 0 : app.options.basename,
|
|
99
|
-
children: children
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
const FronteggStoreProvider = props => {
|
|
103
|
-
var _app$options$contextO, _app$options3, _app$options$previewM, _app$options4, _app$options5, _app$options6;
|
|
104
|
-
const {
|
|
105
|
-
children,
|
|
106
|
-
app,
|
|
107
|
-
contextOptions,
|
|
108
|
-
setLoading = defaultSetLoading,
|
|
109
|
-
alwaysVisibleChildren
|
|
110
|
-
} = props;
|
|
111
|
-
|
|
112
|
-
// TODO: make this optionals more readable
|
|
113
|
-
const context = (_app$options$contextO = app == null ? void 0 : (_app$options3 = app.options) == null ? void 0 : _app$options3.contextOptions) != null ? _app$options$contextO : contextOptions;
|
|
114
|
-
if (!context) {
|
|
115
|
-
throw Error('contextOptions must not be null or undefined');
|
|
116
|
-
}
|
|
117
|
-
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.previewMode) != null ? _app$options$previewM : false;
|
|
118
|
-
const authOptions = app != null && (_app$options5 = app.options) != null && _app$options5.authOptions ? (0, _extends2.default)({}, app.options.authOptions, {
|
|
119
|
-
hostedLoginBox: app.options.hostedLoginBox
|
|
120
|
-
}) : {
|
|
121
|
-
hostedLoginBox: app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.hostedLoginBox
|
|
122
|
-
};
|
|
123
|
-
_restApi.ContextHolder.setContext(context);
|
|
124
|
-
const store = (0, _react.useMemo)(() => {
|
|
125
|
-
var _app$name, _app$options7;
|
|
126
|
-
return (0, _reduxStore.createFronteggStore)({
|
|
127
|
-
context,
|
|
128
|
-
appName: (_app$name = app == null ? void 0 : app.name) != null ? _app$name : 'default'
|
|
129
|
-
}, app, previewMode, authOptions, undefined, false, app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.urlStrategy);
|
|
130
|
-
}, [app, previewMode]);
|
|
131
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_FronteggStoreContext.Provider, {
|
|
132
|
-
context: _FronteggStoreContext.FronteggStoreContext,
|
|
133
|
-
store: store,
|
|
134
|
-
children: [alwaysVisibleChildren, /*#__PURE__*/(0, _jsxRuntime.jsx)(FronteggContent, {
|
|
135
|
-
setLoading: setLoading,
|
|
136
|
-
app: app,
|
|
137
|
-
children: children
|
|
138
|
-
})]
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
exports.FronteggStoreProvider = FronteggStoreProvider;
|
|
16
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useStore = exports.default = exports.Provider = exports.FronteggStoreContext = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
const FronteggStoreContext = /*#__PURE__*/(0, _react.createContext)(null);
|
|
12
|
+
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
exports.FronteggStoreContext = FronteggStoreContext;
|
|
15
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
16
|
+
FronteggStoreContext.displayName = 'FronteggStoreContext';
|
|
17
|
+
}
|
|
18
|
+
const useStore = () => (0, _react.useContext)(FronteggStoreContext);
|
|
19
|
+
exports.useStore = useStore;
|
|
20
|
+
const Provider = /*#__PURE__*/(0, _react.memo)(props => {
|
|
21
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(FronteggStoreContext.Provider, {
|
|
22
|
+
value: props.store,
|
|
23
|
+
children: props.children
|
|
24
|
+
});
|
|
25
|
+
}, () => true);
|
|
26
|
+
exports.Provider = Provider;
|
|
27
|
+
var _default = FronteggStoreContext;
|
|
28
|
+
exports.default = _default;
|
|
@@ -1,40 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
|
|
8
|
-
Object.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return _reactRedux.shallowEqual;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
exports.useStore = exports.useSelector = exports.useDispatch = void 0;
|
|
22
|
-
var _react = _interopRequireDefault(require("react"));
|
|
23
|
-
var _reactRedux = require("react-redux");
|
|
24
|
-
const FronteggStoreContext = /*#__PURE__*/_react.default.createContext(null);
|
|
25
|
-
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
exports.FronteggStoreContext = FronteggStoreContext;
|
|
28
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
29
|
-
FronteggStoreContext.displayName = 'FronteggStoreContext';
|
|
30
|
-
}
|
|
31
|
-
const useSelector = (0, _reactRedux.createSelectorHook)(FronteggStoreContext);
|
|
32
|
-
exports.useSelector = useSelector;
|
|
33
|
-
const useDispatch = (0, _reactRedux.createDispatchHook)(FronteggStoreContext);
|
|
34
|
-
exports.useDispatch = useDispatch;
|
|
35
|
-
const useStore = (0, _reactRedux.createStoreHook)(FronteggStoreContext);
|
|
36
|
-
exports.useStore = useStore;
|
|
37
|
-
const Provider = _reactRedux.Provider;
|
|
38
|
-
exports.Provider = Provider;
|
|
39
|
-
var _default = FronteggStoreContext;
|
|
40
|
-
exports.default = _default;
|
|
6
|
+
var _FronteggStoreContext = require("./FronteggStoreContext");
|
|
7
|
+
Object.keys(_FronteggStoreContext).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _FronteggStoreContext[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _FronteggStoreContext[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
package/node/audits/auditLogs.js
CHANGED
|
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useAuditLogsActions = void 0;
|
|
7
7
|
exports.useAuditLogsState = useAuditLogsState;
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return (0,
|
|
8
|
+
var _FronteggStoreContext = require("../FronteggStoreContext");
|
|
9
|
+
var _useSnapshot = require("../useSnapshot");
|
|
10
|
+
function useAuditLogsState() {
|
|
11
|
+
const state = (0, _FronteggStoreContext.useStore)().store.auditLogs.auditLogsState;
|
|
12
|
+
return (0, _useSnapshot.useSnapshot)(state);
|
|
13
13
|
}
|
|
14
|
-
const useAuditLogsActions = () =>
|
|
14
|
+
const useAuditLogsActions = () => {
|
|
15
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.auditLogs;
|
|
16
|
+
};
|
|
15
17
|
exports.useAuditLogsActions = useAuditLogsActions;
|
|
@@ -5,11 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useAuditsMetadataActions = void 0;
|
|
7
7
|
exports.useAuditsMetadataState = useAuditsMetadataState;
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return (0,
|
|
8
|
+
var _FronteggStoreContext = require("../FronteggStoreContext");
|
|
9
|
+
var _useSnapshot = require("../useSnapshot");
|
|
10
|
+
function useAuditsMetadataState() {
|
|
11
|
+
const state = (0, _FronteggStoreContext.useStore)().store.auditLogs.auditsMetadataState;
|
|
12
|
+
return (0, _useSnapshot.useSnapshot)(state);
|
|
13
13
|
}
|
|
14
|
-
const useAuditsMetadataActions = () =>
|
|
14
|
+
const useAuditsMetadataActions = () => {
|
|
15
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.auditLogs;
|
|
16
|
+
};
|
|
15
17
|
exports.useAuditsMetadataActions = useAuditsMetadataActions;
|
package/node/audits/hooks.js
CHANGED
|
@@ -1,49 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.useAuditsActions =
|
|
6
|
+
exports.useAuditsActions = void 0;
|
|
8
7
|
exports.useAuditsState = useAuditsState;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
var _reduxStore = require("@frontegg/redux-store");
|
|
12
|
-
var _reactRedux = require("react-redux");
|
|
13
8
|
var _FronteggStoreContext = require("../FronteggStoreContext");
|
|
9
|
+
var _useSnapshot = require("../useSnapshot");
|
|
14
10
|
const defaultMapper = {
|
|
15
11
|
state: state => state,
|
|
16
12
|
actions: actions => actions
|
|
17
13
|
};
|
|
18
14
|
function useAuditsState(stateMapper = defaultMapper.state) {
|
|
19
|
-
|
|
15
|
+
const state = (0, _FronteggStoreContext.useStore)().store.auditLogs;
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
return stateMapper((0, _useSnapshot.useSnapshot)(state));
|
|
20
18
|
}
|
|
21
19
|
const useAuditsActions = () => {
|
|
22
|
-
|
|
23
|
-
return (0, _react.useMemo)(() => (0, _reduxStore.bindActionCreators)(_reduxStore.auditsActions, dispatch), [_reduxStore.auditsActions]);
|
|
20
|
+
return (0, _FronteggStoreContext.useStore)().stateActions.auditLogs;
|
|
24
21
|
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* hooks helpers
|
|
28
|
-
*/
|
|
29
|
-
exports.useAuditsActions = useAuditsActions;
|
|
30
|
-
const sliceReducerActionsBy = reducer => {
|
|
31
|
-
const reducerKeys = Object.keys(reducer);
|
|
32
|
-
const reducerActions = reducerKeys.map(key => ({
|
|
33
|
-
[key]: _reduxStore.auditsActions[key]
|
|
34
|
-
}));
|
|
35
|
-
return reducerActions.reduce((p, n) => (0, _extends2.default)({}, p, n), {});
|
|
36
|
-
};
|
|
37
|
-
exports.sliceReducerActionsBy = sliceReducerActionsBy;
|
|
38
|
-
const stateHookGenerator = (stateMapper, subState) => {
|
|
39
|
-
return (0, _FronteggStoreContext.useSelector)(state => {
|
|
40
|
-
var _stateMapper;
|
|
41
|
-
return (_stateMapper = stateMapper == null ? void 0 : stateMapper(state[_reduxStore.auditsStoreName][subState])) != null ? _stateMapper : state[_reduxStore.auditsStoreName][subState];
|
|
42
|
-
}, _reactRedux.shallowEqual);
|
|
43
|
-
};
|
|
44
|
-
exports.stateHookGenerator = stateHookGenerator;
|
|
45
|
-
const reducerActionsGenerator = (actions, reducers) => {
|
|
46
|
-
const dispatch = (0, _FronteggStoreContext.useDispatch)();
|
|
47
|
-
return (0, _react.useMemo)(() => (0, _reduxStore.bindActionCreators)((0, _extends2.default)({}, actions, sliceReducerActionsBy(reducers)), dispatch), [dispatch]);
|
|
48
|
-
};
|
|
49
|
-
exports.reducerActionsGenerator = reducerActionsGenerator;
|
|
22
|
+
exports.useAuditsActions = useAuditsActions;
|