@frontegg/react-hooks 7.0.0-alpha.1 → 7.0.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.
- package/FronteggProvider/FronteggProvider.d.ts +12 -0
- package/FronteggProvider/FronteggProvider.js +138 -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/customLogin.d.ts +2 -5
- package/auth/customLogin.js +10 -11
- package/auth/entitlements.d.ts +32 -13
- package/auth/entitlements.js +116 -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 +15 -16
- package/auth/index.js +16 -17
- 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.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 +146 -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/customLogin.js +11 -12
- package/node/auth/entitlements.js +119 -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 +103 -101
- 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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ContextOptions } from '@frontegg/rest-api';
|
|
3
|
+
import { FronteggAppInstance } from '@frontegg/types';
|
|
4
|
+
declare type FronteggProviderProps = {
|
|
5
|
+
app?: FronteggAppInstance;
|
|
6
|
+
contextOptions?: ContextOptions;
|
|
7
|
+
setLoading?: (loading: boolean) => void;
|
|
8
|
+
children?: ReactNode | undefined;
|
|
9
|
+
alwaysVisibleChildren?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
export declare const FronteggStoreProvider: FC<FronteggProviderProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["authenticatedUrl", "signUpSuccessUrl"];
|
|
4
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import { createStore } from '@frontegg/redux-store';
|
|
6
|
+
import { ContextHolder } from '@frontegg/rest-api';
|
|
7
|
+
import { Provider } from '../FronteggStoreContext';
|
|
8
|
+
import { useAuth, useAuthRoutes } from '../auth';
|
|
9
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
const defaultSetLoading = loading => {
|
|
13
|
+
if (loading) {
|
|
14
|
+
document.body.classList.add('frontegg-loading');
|
|
15
|
+
} else {
|
|
16
|
+
document.body.classList.remove('frontegg-loading');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const HideChildrenIfFronteggRoutes = ({
|
|
20
|
+
children,
|
|
21
|
+
basename
|
|
22
|
+
}) => {
|
|
23
|
+
const routes = useAuthRoutes();
|
|
24
|
+
const uriRef = useRef(window.location.pathname);
|
|
25
|
+
const animationFrameRef = useRef(0);
|
|
26
|
+
const [uri, setUri] = useState(window.location.pathname);
|
|
27
|
+
const checker = useCallback(() => {
|
|
28
|
+
if (uriRef.current !== window.location.pathname) {
|
|
29
|
+
uriRef.current = window.location.pathname;
|
|
30
|
+
setUri(document.location.pathname);
|
|
31
|
+
}
|
|
32
|
+
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
33
|
+
}, []);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
document.addEventListener('frontegg_onRedirectTo_fired', () => {
|
|
36
|
+
if (uriRef.current !== window.location.pathname) {
|
|
37
|
+
uriRef.current = window.location.pathname;
|
|
38
|
+
setUri(document.location.pathname);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
window.addEventListener('popstate', () => {
|
|
42
|
+
if (uriRef.current !== window.location.pathname) {
|
|
43
|
+
uriRef.current = window.location.pathname;
|
|
44
|
+
setUri(document.location.pathname);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
48
|
+
return () => {
|
|
49
|
+
window.cancelAnimationFrame(animationFrameRef.current);
|
|
50
|
+
};
|
|
51
|
+
}, [checker, setUri]);
|
|
52
|
+
const calculatedBasename = basename ? basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '' : '';
|
|
53
|
+
const checkRoutes = _objectWithoutPropertiesLoose(routes, _excluded);
|
|
54
|
+
if (Object.values(checkRoutes).map(url => `${calculatedBasename}${url}`).indexOf(uri) !== -1) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
58
|
+
children: children
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const FronteggContent = ({
|
|
62
|
+
children,
|
|
63
|
+
app,
|
|
64
|
+
setLoading
|
|
65
|
+
}) => {
|
|
66
|
+
var _app$options, _app$options2;
|
|
67
|
+
const {
|
|
68
|
+
isLoading
|
|
69
|
+
} = useAuth();
|
|
70
|
+
const customLoginBox = !app || (app == null ? void 0 : (_app$options = app.options) == null ? void 0 : _app$options.customLoginBox) === true;
|
|
71
|
+
const isNextJS = (app == null ? void 0 : (_app$options2 = app.options) == null ? void 0 : _app$options2.framework) === 'nextjs';
|
|
72
|
+
const alwaysShowChildren = customLoginBox || isNextJS;
|
|
73
|
+
const loadingRef = useRef(undefined);
|
|
74
|
+
if (isLoading !== loadingRef.current && !isNextJS) {
|
|
75
|
+
loadingRef.current = isLoading;
|
|
76
|
+
setLoading(isLoading);
|
|
77
|
+
}
|
|
78
|
+
if (alwaysShowChildren) {
|
|
79
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
80
|
+
children: children
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (isLoading && !isNextJS) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return /*#__PURE__*/_jsx(HideChildrenIfFronteggRoutes, {
|
|
87
|
+
basename: app == null ? void 0 : app.options.basename,
|
|
88
|
+
children: children
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
export const FronteggStoreProvider = props => {
|
|
92
|
+
var _app$options$contextO, _app$options3, _app$options$previewM, _app$options4, _app$options$builderM, _app$options5, _app$options6, _app$options7, _app$options8;
|
|
93
|
+
const {
|
|
94
|
+
children,
|
|
95
|
+
app,
|
|
96
|
+
contextOptions,
|
|
97
|
+
setLoading = defaultSetLoading,
|
|
98
|
+
alwaysVisibleChildren
|
|
99
|
+
} = props;
|
|
100
|
+
|
|
101
|
+
// TODO: make this optionals more readable
|
|
102
|
+
const context = (_app$options$contextO = app == null ? void 0 : (_app$options3 = app.options) == null ? void 0 : _app$options3.contextOptions) != null ? _app$options$contextO : contextOptions;
|
|
103
|
+
if (!context) {
|
|
104
|
+
throw Error('contextOptions must not be null or undefined');
|
|
105
|
+
}
|
|
106
|
+
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.previewMode) != null ? _app$options$previewM : false;
|
|
107
|
+
const builderMode = (_app$options$builderM = app == null ? void 0 : (_app$options5 = app.options) == null ? void 0 : _app$options5.builderMode) != null ? _app$options$builderM : false;
|
|
108
|
+
const auditsOptions = app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.auditsOptions;
|
|
109
|
+
const authOptions = app != null && (_app$options7 = app.options) != null && _app$options7.authOptions ? _extends({}, app.options.authOptions, {
|
|
110
|
+
hostedLoginBox: app.options.hostedLoginBox
|
|
111
|
+
}) : {
|
|
112
|
+
hostedLoginBox: app == null ? void 0 : (_app$options8 = app.options) == null ? void 0 : _app$options8.hostedLoginBox
|
|
113
|
+
};
|
|
114
|
+
ContextHolder.setContext(context);
|
|
115
|
+
const store = useMemo(() => {
|
|
116
|
+
var _app$name, _app$options9;
|
|
117
|
+
return createStore({
|
|
118
|
+
name: (_app$name = app == null ? void 0 : app.name) != null ? _app$name : 'default',
|
|
119
|
+
context,
|
|
120
|
+
previewMode,
|
|
121
|
+
builderMode,
|
|
122
|
+
initialState: {
|
|
123
|
+
auth: authOptions,
|
|
124
|
+
audits: auditsOptions
|
|
125
|
+
},
|
|
126
|
+
urlStrategy: app == null ? void 0 : (_app$options9 = app.options) == null ? void 0 : _app$options9.urlStrategy,
|
|
127
|
+
storeHolder: app
|
|
128
|
+
});
|
|
129
|
+
}, [app, previewMode]);
|
|
130
|
+
return /*#__PURE__*/_jsxs(Provider, {
|
|
131
|
+
store: store,
|
|
132
|
+
children: [alwaysVisibleChildren, /*#__PURE__*/_jsx(FronteggContent, {
|
|
133
|
+
setLoading: setLoading,
|
|
134
|
+
app: app,
|
|
135
|
+
children: children
|
|
136
|
+
})]
|
|
137
|
+
});
|
|
138
|
+
};
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ContextOptions } from '@frontegg/rest-api';
|
|
3
|
-
import { FronteggAppInstance } from '@frontegg/types';
|
|
4
|
-
declare type FronteggProviderProps = {
|
|
5
|
-
app?: FronteggAppInstance;
|
|
6
|
-
contextOptions?: ContextOptions;
|
|
7
|
-
setLoading?: (loading: boolean) => void;
|
|
8
|
-
children?: ReactNode | undefined;
|
|
9
|
-
alwaysVisibleChildren?: ReactNode;
|
|
10
|
-
};
|
|
11
|
-
export declare const FronteggStoreProvider: FC<FronteggProviderProps>;
|
|
12
|
-
export {};
|
|
1
|
+
export * from './FronteggProvider';
|
|
@@ -1,133 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["authenticatedUrl", "signUpSuccessUrl"];
|
|
4
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
-
import { createFronteggStore } from '@frontegg/redux-store';
|
|
6
|
-
import { ContextHolder } from '@frontegg/rest-api';
|
|
7
|
-
import { useAuth, useAuthRoutes } from '../auth';
|
|
8
|
-
import { Provider, FronteggStoreContext } from '../FronteggStoreContext';
|
|
9
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
const defaultSetLoading = loading => {
|
|
13
|
-
if (loading) {
|
|
14
|
-
document.body.classList.add('frontegg-loading');
|
|
15
|
-
} else {
|
|
16
|
-
document.body.classList.remove('frontegg-loading');
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const HideChildrenIfFronteggRoutes = ({
|
|
20
|
-
children,
|
|
21
|
-
basename
|
|
22
|
-
}) => {
|
|
23
|
-
const routes = useAuthRoutes();
|
|
24
|
-
const uriRef = useRef(window.location.pathname);
|
|
25
|
-
const animationFrameRef = useRef(0);
|
|
26
|
-
const [uri, setUri] = useState(window.location.pathname);
|
|
27
|
-
const checker = useCallback(() => {
|
|
28
|
-
if (uriRef.current !== window.location.pathname) {
|
|
29
|
-
uriRef.current = window.location.pathname;
|
|
30
|
-
setUri(document.location.pathname);
|
|
31
|
-
}
|
|
32
|
-
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
33
|
-
}, []);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
document.addEventListener('frontegg_onRedirectTo_fired', () => {
|
|
36
|
-
if (uriRef.current !== window.location.pathname) {
|
|
37
|
-
uriRef.current = window.location.pathname;
|
|
38
|
-
setUri(document.location.pathname);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
window.addEventListener('popstate', () => {
|
|
42
|
-
if (uriRef.current !== window.location.pathname) {
|
|
43
|
-
uriRef.current = window.location.pathname;
|
|
44
|
-
setUri(document.location.pathname);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
animationFrameRef.current = window.requestAnimationFrame(checker);
|
|
48
|
-
return () => {
|
|
49
|
-
window.cancelAnimationFrame(animationFrameRef.current);
|
|
50
|
-
};
|
|
51
|
-
}, [checker, setUri]);
|
|
52
|
-
const calculatedBasename = basename ? basename.endsWith('/') ? basename.substring(0, basename.length - 1) : '' : '';
|
|
53
|
-
const checkRoutes = _objectWithoutPropertiesLoose(routes, _excluded);
|
|
54
|
-
if (Object.values(checkRoutes).map(url => `${calculatedBasename}${url}`).indexOf(uri) !== -1) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
58
|
-
children: children
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
const FronteggContent = ({
|
|
62
|
-
children,
|
|
63
|
-
app,
|
|
64
|
-
setLoading
|
|
65
|
-
}) => {
|
|
66
|
-
var _app$options, _app$options2;
|
|
67
|
-
const {
|
|
68
|
-
isLoading
|
|
69
|
-
} = useAuth(({
|
|
70
|
-
isLoading
|
|
71
|
-
}) => ({
|
|
72
|
-
isLoading
|
|
73
|
-
}));
|
|
74
|
-
const customLoginBox = !app || (app == null ? void 0 : (_app$options = app.options) == null ? void 0 : _app$options.customLoginBox) === true;
|
|
75
|
-
const isNextJS = (app == null ? void 0 : (_app$options2 = app.options) == null ? void 0 : _app$options2.framework) === 'nextjs';
|
|
76
|
-
const alwaysShowChildren = customLoginBox || isNextJS;
|
|
77
|
-
const loadingRef = useRef(undefined);
|
|
78
|
-
if (isLoading !== loadingRef.current && !isNextJS) {
|
|
79
|
-
loadingRef.current = isLoading;
|
|
80
|
-
setLoading(isLoading);
|
|
81
|
-
}
|
|
82
|
-
if (alwaysShowChildren) {
|
|
83
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
84
|
-
children: children
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (isLoading && !isNextJS) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
return /*#__PURE__*/_jsx(HideChildrenIfFronteggRoutes, {
|
|
91
|
-
basename: app == null ? void 0 : app.options.basename,
|
|
92
|
-
children: children
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
export const FronteggStoreProvider = props => {
|
|
96
|
-
var _app$options$contextO, _app$options3, _app$options$previewM, _app$options4, _app$options5, _app$options6;
|
|
97
|
-
const {
|
|
98
|
-
children,
|
|
99
|
-
app,
|
|
100
|
-
contextOptions,
|
|
101
|
-
setLoading = defaultSetLoading,
|
|
102
|
-
alwaysVisibleChildren
|
|
103
|
-
} = props;
|
|
104
|
-
|
|
105
|
-
// TODO: make this optionals more readable
|
|
106
|
-
const context = (_app$options$contextO = app == null ? void 0 : (_app$options3 = app.options) == null ? void 0 : _app$options3.contextOptions) != null ? _app$options$contextO : contextOptions;
|
|
107
|
-
if (!context) {
|
|
108
|
-
throw Error('contextOptions must not be null or undefined');
|
|
109
|
-
}
|
|
110
|
-
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.previewMode) != null ? _app$options$previewM : false;
|
|
111
|
-
const authOptions = app != null && (_app$options5 = app.options) != null && _app$options5.authOptions ? _extends({}, app.options.authOptions, {
|
|
112
|
-
hostedLoginBox: app.options.hostedLoginBox
|
|
113
|
-
}) : {
|
|
114
|
-
hostedLoginBox: app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.hostedLoginBox
|
|
115
|
-
};
|
|
116
|
-
ContextHolder.setContext(context);
|
|
117
|
-
const store = useMemo(() => {
|
|
118
|
-
var _app$name, _app$options7;
|
|
119
|
-
return createFronteggStore({
|
|
120
|
-
context,
|
|
121
|
-
appName: (_app$name = app == null ? void 0 : app.name) != null ? _app$name : 'default'
|
|
122
|
-
}, app, previewMode, authOptions, undefined, false, app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.urlStrategy);
|
|
123
|
-
}, [app, previewMode]);
|
|
124
|
-
return /*#__PURE__*/_jsxs(Provider, {
|
|
125
|
-
context: FronteggStoreContext,
|
|
126
|
-
store: store,
|
|
127
|
-
children: [alwaysVisibleChildren, /*#__PURE__*/_jsx(FronteggContent, {
|
|
128
|
-
setLoading: setLoading,
|
|
129
|
-
app: app,
|
|
130
|
-
children: children
|
|
131
|
-
})]
|
|
132
|
-
});
|
|
133
|
-
};
|
|
1
|
+
export * from './FronteggProvider';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
import type { FronteggStore } from '@frontegg/redux-store';
|
|
3
|
+
export declare const FronteggStoreContext: React.Context<FronteggStore>;
|
|
4
|
+
export declare const useStore: () => FronteggStore;
|
|
5
|
+
export declare const Provider: FC<{
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
store: FronteggStore;
|
|
8
|
+
}>;
|
|
9
|
+
export default FronteggStoreContext;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { createContext, memo, useContext } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export const FronteggStoreContext = /*#__PURE__*/createContext(null);
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7
|
+
FronteggStoreContext.displayName = 'FronteggStoreContext';
|
|
8
|
+
}
|
|
9
|
+
export const useStore = () => useContext(FronteggStoreContext);
|
|
10
|
+
export const Provider = /*#__PURE__*/memo(props => {
|
|
11
|
+
return /*#__PURE__*/_jsx(FronteggStoreContext.Provider, {
|
|
12
|
+
value: props.store,
|
|
13
|
+
children: props.children
|
|
14
|
+
});
|
|
15
|
+
}, () => true);
|
|
16
|
+
export default FronteggStoreContext;
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ReactReduxContextValue, ProviderProps } from 'react-redux';
|
|
3
|
-
import type { Action, AnyAction } from '@frontegg/redux-store';
|
|
4
|
-
export declare const FronteggStoreContext: React.Context<ReactReduxContextValue<any, AnyAction>>;
|
|
5
|
-
export declare const useSelector: <Selected extends unknown>(selector: (state: any) => Selected, equalityFn?: ((previous: Selected, next: Selected) => boolean) | undefined) => Selected;
|
|
6
|
-
export declare const useDispatch: () => import("redux").Dispatch<AnyAction>;
|
|
7
|
-
export declare const useStore: () => import("redux").Store<any, AnyAction>;
|
|
8
|
-
export { shallowEqual, Provider as ReactReduxProvider } from 'react-redux';
|
|
9
|
-
declare type ProviderWithChildren<A extends Action = AnyAction> = FC<ProviderProps<A> & {
|
|
10
|
-
children?: ReactNode | undefined;
|
|
11
|
-
}>;
|
|
12
|
-
export declare const Provider: ProviderWithChildren;
|
|
13
|
-
export default FronteggStoreContext;
|
|
1
|
+
export * from './FronteggStoreContext';
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { createSelectorHook, createDispatchHook, createStoreHook, Provider as ReactReduxProvider } from 'react-redux';
|
|
3
|
-
export const FronteggStoreContext = /*#__PURE__*/React.createContext(null);
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7
|
-
FronteggStoreContext.displayName = 'FronteggStoreContext';
|
|
8
|
-
}
|
|
9
|
-
export const useSelector = createSelectorHook(FronteggStoreContext);
|
|
10
|
-
export const useDispatch = createDispatchHook(FronteggStoreContext);
|
|
11
|
-
export const useStore = createStoreHook(FronteggStoreContext);
|
|
12
|
-
export { shallowEqual, Provider as ReactReduxProvider } from 'react-redux';
|
|
13
|
-
export const Provider = ReactReduxProvider;
|
|
14
|
-
export default FronteggStoreContext;
|
|
1
|
+
export * from './FronteggStoreContext';
|
package/audits/auditLogs.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type AuditLogsStateMapper<S> = (state: AuditLogsState) => S;
|
|
1
|
+
import { AuditLogsState, AuditsActions } from '@frontegg/redux-store';
|
|
3
2
|
export declare function useAuditLogsState(): AuditLogsState;
|
|
4
|
-
export declare
|
|
5
|
-
export declare const useAuditLogsActions: () => AuditLogsActions;
|
|
3
|
+
export declare const useAuditLogsActions: () => AuditsActions;
|
package/audits/auditLogs.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 useAuditLogsState() {
|
|
4
|
+
const state = useStore().store.auditLogs.auditLogsState;
|
|
5
|
+
return useSnapshot(state);
|
|
6
6
|
}
|
|
7
|
-
export const useAuditLogsActions = () =>
|
|
7
|
+
export const useAuditLogsActions = () => {
|
|
8
|
+
return useStore().stateActions.auditLogs;
|
|
9
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare type AuditsMetadataStateMapper<S> = (state: AuditsMetadataState) => S;
|
|
1
|
+
import { AuditsActions, AuditsMetadataState } from '@frontegg/redux-store';
|
|
3
2
|
export declare function useAuditsMetadataState(): AuditsMetadataState;
|
|
4
|
-
export declare
|
|
5
|
-
export declare const useAuditsMetadataActions: () => AuditsMetadataActions;
|
|
3
|
+
export declare const useAuditsMetadataActions: () => AuditsActions;
|
package/audits/auditsMetadata.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 useAuditsMetadataState() {
|
|
4
|
+
const state = useStore().store.auditLogs.auditsMetadataState;
|
|
5
|
+
return useSnapshot(state);
|
|
6
6
|
}
|
|
7
|
-
export const useAuditsMetadataActions = () =>
|
|
7
|
+
export const useAuditsMetadataActions = () => {
|
|
8
|
+
return useStore().stateActions.auditLogs;
|
|
9
|
+
};
|
package/audits/hooks.d.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { CaseReducerActions, SliceCaseReducers } from '@frontegg/redux-store';
|
|
2
1
|
import { AuditsActions, AuditsState } from '@frontegg/redux-store';
|
|
3
2
|
export declare type AuditsMapper = {
|
|
4
3
|
state: (state: AuditsState) => any;
|
|
5
4
|
actions: (actions: AuditsActions) => any;
|
|
6
5
|
};
|
|
7
|
-
export declare type StateHookFunction<T> = (() => T) & (<S extends object>(mapper: (state: T) => S) => S);
|
|
8
6
|
export declare type AuditsStateMapper<S> = (state: AuditsState) => S;
|
|
9
7
|
export declare function useAuditsState(): AuditsState;
|
|
10
8
|
export declare function useAuditsState<S>(stateMapper: AuditsStateMapper<S>): S;
|
|
11
9
|
export declare const useAuditsActions: () => AuditsActions;
|
|
12
|
-
/**
|
|
13
|
-
* hooks helpers
|
|
14
|
-
*/
|
|
15
|
-
export declare const sliceReducerActionsBy: <T extends SliceCaseReducers<any>>(reducer: T) => CaseReducerActions<T>;
|
|
16
|
-
export declare const stateHookGenerator: (stateMapper: any, subState: keyof AuditsState) => any;
|
|
17
|
-
export declare const reducerActionsGenerator: (actions: any, reducers: SliceCaseReducers<any>) => any;
|
package/audits/hooks.js
CHANGED
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { bindActionCreators } from '@frontegg/redux-store';
|
|
4
|
-
import { shallowEqual } from 'react-redux';
|
|
5
|
-
import { useSelector, useDispatch } from '../FronteggStoreContext';
|
|
6
|
-
import { auditsActions, auditsStoreName } from '@frontegg/redux-store';
|
|
1
|
+
import { useStore } from '../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
7
3
|
const defaultMapper = {
|
|
8
4
|
state: state => state,
|
|
9
5
|
actions: actions => actions
|
|
10
6
|
};
|
|
11
7
|
export function useAuditsState(stateMapper = defaultMapper.state) {
|
|
12
|
-
|
|
8
|
+
const state = useStore().store.auditLogs;
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
return stateMapper(useSnapshot(state));
|
|
13
11
|
}
|
|
14
12
|
export const useAuditsActions = () => {
|
|
15
|
-
|
|
16
|
-
return useMemo(() => bindActionCreators(auditsActions, dispatch), [auditsActions]);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* hooks helpers
|
|
21
|
-
*/
|
|
22
|
-
export const sliceReducerActionsBy = reducer => {
|
|
23
|
-
const reducerKeys = Object.keys(reducer);
|
|
24
|
-
const reducerActions = reducerKeys.map(key => ({
|
|
25
|
-
[key]: auditsActions[key]
|
|
26
|
-
}));
|
|
27
|
-
return reducerActions.reduce((p, n) => _extends({}, p, n), {});
|
|
28
|
-
};
|
|
29
|
-
export const stateHookGenerator = (stateMapper, subState) => {
|
|
30
|
-
return useSelector(state => {
|
|
31
|
-
var _stateMapper;
|
|
32
|
-
return (_stateMapper = stateMapper == null ? void 0 : stateMapper(state[auditsStoreName][subState])) != null ? _stateMapper : state[auditsStoreName][subState];
|
|
33
|
-
}, shallowEqual);
|
|
34
|
-
};
|
|
35
|
-
export const reducerActionsGenerator = (actions, reducers) => {
|
|
36
|
-
const dispatch = useDispatch();
|
|
37
|
-
return useMemo(() => bindActionCreators(_extends({}, actions, sliceReducerActionsBy(reducers)), dispatch), [dispatch]);
|
|
13
|
+
return useStore().stateActions.auditLogs;
|
|
38
14
|
};
|
package/auth/acceptInvitation.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { useStore } from '../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
3
|
+
|
|
4
|
+
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
+
|
|
4
6
|
const defaultMapper = state => state;
|
|
5
7
|
export function useAcceptInvitationState(stateMapper = defaultMapper) {
|
|
6
|
-
|
|
8
|
+
const state = useStore().store.auth.acceptInvitationState;
|
|
9
|
+
return stateMapper(useSnapshot(state));
|
|
7
10
|
}
|
|
8
|
-
export const useAcceptInvitationActions = () =>
|
|
11
|
+
export const useAcceptInvitationActions = () => {
|
|
12
|
+
return useStore().stateActions.auth.acceptInvitationActions;
|
|
13
|
+
};
|
package/auth/activateAccount.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useStore } from '../FronteggStoreContext';
|
|
2
|
+
import { useSnapshot } from '../useSnapshot';
|
|
3
|
+
|
|
4
|
+
// TODO: remove useless stateMapper, valtio already does this
|
|
5
|
+
|
|
3
6
|
const defaultMapper = state => state;
|
|
4
7
|
export function useActivateAccountState(stateMapper = defaultMapper) {
|
|
5
|
-
|
|
8
|
+
const state = useStore().store.auth.activateAccountState;
|
|
9
|
+
return stateMapper(useSnapshot(state));
|
|
6
10
|
}
|
|
7
|
-
export const useActivateAccountActions = () =>
|
|
11
|
+
export const useActivateAccountActions = () => {
|
|
12
|
+
return useStore().stateActions.auth.activateAccountActions;
|
|
13
|
+
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { IAllAccountsState, AllAccountsActions, IAllAccountsDialogsState,
|
|
1
|
+
import { IAllAccountsState, AllAccountsActions, IAllAccountsDialogsState, AllAccountsDialogActions } from '@frontegg/redux-store';
|
|
2
2
|
export declare type AllAccountsStateMapper<S> = (state: IAllAccountsState) => S;
|
|
3
3
|
export declare function useAllAccountsState(): IAllAccountsState;
|
|
4
4
|
export declare function useAllAccountsState<S>(stateMapper: AllAccountsStateMapper<S>): S;
|
|
5
5
|
export declare const useAllAccountsActions: () => AllAccountsActions;
|
|
6
|
-
export declare type AllAccountsDialogsStateMapper<S> = (state: IAllAccountsDialogsState) => S;
|
|
7
6
|
export declare function useAllAccountsDialogsState(): IAllAccountsDialogsState;
|
|
8
|
-
export declare
|
|
9
|
-
export declare const useAllAccountsDialogsActions: () => AllAccountsDialogsActions;
|
|
7
|
+
export declare const useAllAccountsDialogsActions: () => AllAccountsDialogActions;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
};
|
package/auth/apiTokens.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { ApiTokensActions, ApiTokensState } from '@frontegg/redux-store';
|
|
2
|
-
export declare type ApiTokensStateMapper<S> = (state: ApiTokensState) => S;
|
|
3
2
|
export declare function useApiTokensState(): ApiTokensState;
|
|
4
|
-
export declare function useApiTokensState<S>(stateMapper: ApiTokensStateMapper<S>): S;
|
|
5
3
|
export declare const useApiTokensActions: () => ApiTokensActions;
|
package/auth/apiTokens.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 useApiTokensState() {
|
|
4
|
+
const state = useStore().store.auth.apiTokensState;
|
|
5
|
+
return useSnapshot(state);
|
|
6
6
|
}
|
|
7
|
-
export const useApiTokensActions = () =>
|
|
7
|
+
export const useApiTokensActions = () => {
|
|
8
|
+
return useStore().stateActions.auth.apiTokensActions;
|
|
9
|
+
};
|
package/auth/customLogin.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { CustomLoginActions } from '@frontegg/redux-store';
|
|
2
|
-
import { CustomLoginState } from '@frontegg/types';
|
|
3
|
-
export declare type CustomLoginStateMapper<S> = (state: CustomLoginState) => S;
|
|
1
|
+
import { CustomLoginState, CustomLoginActions } from '@frontegg/redux-store';
|
|
4
2
|
export declare function useCustomLoginState(): CustomLoginState;
|
|
5
|
-
export declare function useCustomLoginState<S>(stateMapper: CustomLoginStateMapper<S>): S;
|
|
6
3
|
export declare const useCustomLoginActions: () => CustomLoginActions;
|
|
7
4
|
export declare const useCustomLoginTheme: () => {
|
|
8
|
-
customLoginTheme:
|
|
5
|
+
customLoginTheme: any;
|
|
9
6
|
getCustomLoginThemeValue: (path?: string | undefined) => any;
|
|
10
7
|
};
|
package/auth/customLogin.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { customLoginActions, customLoginReducers } from '@frontegg/redux-store';
|
|
2
|
-
import { reducerActionsGenerator, stateHookGenerator } from './hooks';
|
|
3
|
-
import getValue from 'get-value';
|
|
4
1
|
import { useCallback } from 'react';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import getValue from 'get-value';
|
|
3
|
+
import { useStore } from '../FronteggStoreContext';
|
|
4
|
+
import { useSnapshot } from '../useSnapshot';
|
|
5
|
+
export function useCustomLoginState() {
|
|
6
|
+
const state = useStore().store.auth.customLoginState;
|
|
7
|
+
return useSnapshot(state);
|
|
8
8
|
}
|
|
9
|
-
export const useCustomLoginActions = () =>
|
|
10
|
-
|
|
11
|
-
var _state$tenantMetadata, _state$tenantMetadata2, _state$tenantMetadata3;
|
|
12
|
-
return (_state$tenantMetadata = state.tenantMetadata) == null ? void 0 : (_state$tenantMetadata2 = _state$tenantMetadata.configuration) == null ? void 0 : (_state$tenantMetadata3 = _state$tenantMetadata2.themeV2) == null ? void 0 : _state$tenantMetadata3.loginBox;
|
|
9
|
+
export const useCustomLoginActions = () => {
|
|
10
|
+
return useStore().stateActions.auth.customLoginActions;
|
|
13
11
|
};
|
|
14
12
|
export const useCustomLoginTheme = () => {
|
|
15
|
-
|
|
13
|
+
var _useCustomLoginState$, _useCustomLoginState$2, _useCustomLoginState$3;
|
|
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;
|
|
16
15
|
const getCustomLoginThemeValue = useCallback(path => {
|
|
17
16
|
return path && customLoginTheme ? getValue(customLoginTheme, path) : customLoginTheme;
|
|
18
17
|
}, [customLoginTheme]);
|