@frontegg/react 4.0.23-alpha.2594518864 → 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.
- package/AuthorizedContent.d.ts +8 -8
- package/AuthorizedContent.js +48 -0
- package/CheckoutDialog.d.ts +8 -8
- package/CheckoutDialog.js +55 -0
- package/FronteggProvider.d.ts +18 -18
- package/FronteggProvider.js +89 -0
- package/index.d.ts +6 -6
- package/index.js +11 -241
- package/node/AuthorizedContent.js +61 -0
- package/node/CheckoutDialog.js +68 -0
- package/node/FronteggProvider.js +121 -0
- package/node/index.js +98 -0
- package/node/queryKeeper.js +46 -0
- package/node/routerProxy.js +50 -0
- package/package.json +10 -13
- package/queryKeeper.d.ts +9 -9
- package/queryKeeper.js +36 -0
- package/routerProxy.d.ts +19 -19
- package/routerProxy.js +34 -0
- package/README.md +0 -70
- package/index.js.map +0 -1
package/AuthorizedContent.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { FC, ReactNode } from 'react';
|
|
2
|
-
export interface AuthorizationProps {
|
|
3
|
-
requiredRoles?: string[];
|
|
4
|
-
requiredPermissions?: string[];
|
|
5
|
-
render?: (isAuthorized: boolean) => React.ReactNode | null;
|
|
6
|
-
children?: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare const AuthorizedContent: FC<AuthorizationProps>;
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
export interface AuthorizationProps {
|
|
3
|
+
requiredRoles?: string[];
|
|
4
|
+
requiredPermissions?: string[];
|
|
5
|
+
render?: (isAuthorized: boolean) => React.ReactNode | null;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const AuthorizedContent: FC<AuthorizationProps>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useAuthUserOrNull } from '@frontegg/react-hooks';
|
|
3
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export const AuthorizedContent = props => {
|
|
6
|
+
let isAuthorized = true;
|
|
7
|
+
const user = useAuthUserOrNull();
|
|
8
|
+
|
|
9
|
+
if (!(user != null && user.superUser)) {
|
|
10
|
+
if (props.requiredPermissions) {
|
|
11
|
+
isAuthorized = false;
|
|
12
|
+
|
|
13
|
+
for (const permission of props.requiredPermissions) {
|
|
14
|
+
var _user$permissions;
|
|
15
|
+
|
|
16
|
+
if (user != null && (_user$permissions = user.permissions) != null && _user$permissions.find(({
|
|
17
|
+
key
|
|
18
|
+
}) => key === permission)) {
|
|
19
|
+
isAuthorized = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (props.requiredRoles) {
|
|
25
|
+
isAuthorized = false;
|
|
26
|
+
|
|
27
|
+
for (const role of props.requiredRoles) {
|
|
28
|
+
var _user$roles;
|
|
29
|
+
|
|
30
|
+
if (user != null && (_user$roles = user.roles) != null && _user$roles.find(({
|
|
31
|
+
key
|
|
32
|
+
}) => key === role)) {
|
|
33
|
+
isAuthorized = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (typeof props.render === 'function') {
|
|
40
|
+
return _jsx(_Fragment, {
|
|
41
|
+
children: props.render(isAuthorized)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return isAuthorized ? _jsx(_Fragment, {
|
|
46
|
+
children: props.children
|
|
47
|
+
}) : null;
|
|
48
|
+
};
|
package/CheckoutDialog.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export interface CheckoutDialogHook {
|
|
2
|
-
showDialog: (plan: string) => void;
|
|
3
|
-
hideDialog: () => void;
|
|
4
|
-
open: boolean;
|
|
5
|
-
error: string | null;
|
|
6
|
-
success: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare const useCheckoutDialog: () => CheckoutDialogHook;
|
|
1
|
+
export interface CheckoutDialogHook {
|
|
2
|
+
showDialog: (plan: string) => void;
|
|
3
|
+
hideDialog: () => void;
|
|
4
|
+
open: boolean;
|
|
5
|
+
error: string | null;
|
|
6
|
+
success: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const useCheckoutDialog: () => CheckoutDialogHook;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { CheckoutDialog } from '@frontegg/js';
|
|
3
|
+
export const useCheckoutDialog = () => {
|
|
4
|
+
const [{
|
|
5
|
+
open,
|
|
6
|
+
error,
|
|
7
|
+
success
|
|
8
|
+
}, setState] = useState({
|
|
9
|
+
open: false,
|
|
10
|
+
error: null,
|
|
11
|
+
success: false
|
|
12
|
+
});
|
|
13
|
+
const handleError = useCallback(error => {
|
|
14
|
+
setState({
|
|
15
|
+
open: true,
|
|
16
|
+
success: false,
|
|
17
|
+
error
|
|
18
|
+
});
|
|
19
|
+
}, []);
|
|
20
|
+
const handleSuccess = useCallback(() => {
|
|
21
|
+
setState({
|
|
22
|
+
open: false,
|
|
23
|
+
success: true,
|
|
24
|
+
error: null
|
|
25
|
+
});
|
|
26
|
+
}, []);
|
|
27
|
+
const showDialog = useCallback(plan => {
|
|
28
|
+
CheckoutDialog.show({
|
|
29
|
+
plan,
|
|
30
|
+
onClose: hideDialog,
|
|
31
|
+
onError: handleError,
|
|
32
|
+
onSuccess: handleSuccess
|
|
33
|
+
});
|
|
34
|
+
setState({
|
|
35
|
+
open: true,
|
|
36
|
+
success: false,
|
|
37
|
+
error: null
|
|
38
|
+
});
|
|
39
|
+
}, []);
|
|
40
|
+
const hideDialog = useCallback(() => {
|
|
41
|
+
CheckoutDialog.hide();
|
|
42
|
+
setState({
|
|
43
|
+
open: false,
|
|
44
|
+
error: null,
|
|
45
|
+
success: false
|
|
46
|
+
});
|
|
47
|
+
}, []);
|
|
48
|
+
return useMemo(() => ({
|
|
49
|
+
open,
|
|
50
|
+
showDialog,
|
|
51
|
+
hideDialog,
|
|
52
|
+
error,
|
|
53
|
+
success
|
|
54
|
+
}), [open, showDialog, hideDialog, error, success]);
|
|
55
|
+
};
|
package/FronteggProvider.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react';
|
|
2
|
-
import { FronteggAppOptions } from '@frontegg/types';
|
|
3
|
-
import { UseHistory } from './routerProxy';
|
|
4
|
-
export declare type FronteggProviderProps = FronteggAppOptions & {
|
|
5
|
-
appName?: string;
|
|
6
|
-
history?: UseHistory;
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
};
|
|
9
|
-
declare type ConnectorProps = Omit<FronteggProviderProps, 'history'> & {
|
|
10
|
-
history: {
|
|
11
|
-
push: (path: string) => void;
|
|
12
|
-
replace: (path: string) => void;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare const ConnectorHistory: FC<Omit<ConnectorProps, 'history'>>;
|
|
16
|
-
export declare const Connector: FC<ConnectorProps>;
|
|
17
|
-
export declare const FronteggProvider: FC<FronteggProviderProps>;
|
|
18
|
-
export {};
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { FronteggAppOptions } from '@frontegg/types';
|
|
3
|
+
import { UseHistory } from './routerProxy';
|
|
4
|
+
export declare type FronteggProviderProps = FronteggAppOptions & {
|
|
5
|
+
appName?: string;
|
|
6
|
+
history?: UseHistory;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
declare type ConnectorProps = Omit<FronteggProviderProps, 'history'> & {
|
|
10
|
+
history: {
|
|
11
|
+
push: (path: string) => void;
|
|
12
|
+
replace: (path: string) => void;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const ConnectorHistory: FC<Omit<ConnectorProps, 'history'>>;
|
|
16
|
+
export declare const Connector: FC<ConnectorProps>;
|
|
17
|
+
export declare const FronteggProvider: FC<FronteggProviderProps>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["history", "appName"];
|
|
4
|
+
import React, { useCallback, useMemo } from 'react';
|
|
5
|
+
import { AppHolder, initialize } from '@frontegg/js';
|
|
6
|
+
import { FronteggStoreProvider } from '@frontegg/react-hooks';
|
|
7
|
+
import { BrowserRouter, useHistory } from './routerProxy';
|
|
8
|
+
import { ContextHolder } from '@frontegg/rest-api';
|
|
9
|
+
import { useQueryKeeper } from './queryKeeper';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export const ConnectorHistory = props => {
|
|
12
|
+
const history = useHistory();
|
|
13
|
+
return _jsx(Connector, _extends({
|
|
14
|
+
history: history
|
|
15
|
+
}, props));
|
|
16
|
+
};
|
|
17
|
+
export const Connector = _ref => {
|
|
18
|
+
var _props$basename;
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
history,
|
|
22
|
+
appName
|
|
23
|
+
} = _ref,
|
|
24
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
25
|
+
|
|
26
|
+
const isSSR = typeof window === 'undefined';
|
|
27
|
+
const baseName = (_props$basename = props.basename) != null ? _props$basename : '';
|
|
28
|
+
const onRedirectTo = useCallback((_path, opts) => {
|
|
29
|
+
let path = _path;
|
|
30
|
+
|
|
31
|
+
if (baseName && typeof baseName === 'string' && baseName.length > 0 && path.startsWith(baseName)) {
|
|
32
|
+
path = path.substring(baseName.length);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (opts != null && opts.preserveQueryParams) {
|
|
36
|
+
path = `${path}${window.location.search}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (opts != null && opts.refresh && !isSSR) {
|
|
40
|
+
window.Cypress ? history.push(path) : window.location.href = path;
|
|
41
|
+
} else {
|
|
42
|
+
opts != null && opts.replace ? history.replace(path) : history.push(path);
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
const app = useMemo(() => {
|
|
46
|
+
try {
|
|
47
|
+
return AppHolder.getInstance(appName != null ? appName : 'default');
|
|
48
|
+
} catch (e) {
|
|
49
|
+
var _props$basename2;
|
|
50
|
+
|
|
51
|
+
return initialize(_extends({}, props, {
|
|
52
|
+
basename: (_props$basename2 = props.basename) != null ? _props$basename2 : baseName,
|
|
53
|
+
contextOptions: _extends({
|
|
54
|
+
requestCredentials: 'include'
|
|
55
|
+
}, props.contextOptions),
|
|
56
|
+
onRedirectTo
|
|
57
|
+
}), appName != null ? appName : 'default');
|
|
58
|
+
}
|
|
59
|
+
}, []);
|
|
60
|
+
ContextHolder.setOnRedirectTo(onRedirectTo);
|
|
61
|
+
const signUpUrl = app.store.getState().auth.routes.signUpUrl;
|
|
62
|
+
useQueryKeeper({
|
|
63
|
+
routes: {
|
|
64
|
+
signUpUrl
|
|
65
|
+
},
|
|
66
|
+
history
|
|
67
|
+
});
|
|
68
|
+
return _jsx(FronteggStoreProvider, _extends({}, _extends({}, props, {
|
|
69
|
+
app
|
|
70
|
+
})));
|
|
71
|
+
};
|
|
72
|
+
export const FronteggProvider = props => {
|
|
73
|
+
const history = useHistory();
|
|
74
|
+
|
|
75
|
+
if (props.history || history) {
|
|
76
|
+
return _jsx(Connector, _extends({
|
|
77
|
+
history: props.history || history
|
|
78
|
+
}, props, {
|
|
79
|
+
children: props.children
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return _jsx(BrowserRouter, {
|
|
84
|
+
basename: props.basename,
|
|
85
|
+
children: _jsx(ConnectorHistory, _extends({}, props, {
|
|
86
|
+
children: props.children
|
|
87
|
+
}))
|
|
88
|
+
});
|
|
89
|
+
};
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './FronteggProvider';
|
|
2
|
-
export * from './AuthorizedContent';
|
|
3
|
-
export * from './CheckoutDialog';
|
|
4
|
-
export { AdminPortal, CheckoutDialog } from '@frontegg/
|
|
5
|
-
export * from '@frontegg/react-hooks';
|
|
6
|
-
export * from '@frontegg/types';
|
|
1
|
+
export * from './FronteggProvider';
|
|
2
|
+
export * from './AuthorizedContent';
|
|
3
|
+
export * from './CheckoutDialog';
|
|
4
|
+
export { AdminPortal, CheckoutDialog } from '@frontegg/js';
|
|
5
|
+
export * from '@frontegg/react-hooks';
|
|
6
|
+
export * from '@frontegg/types';
|
package/index.js
CHANGED
|
@@ -1,241 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var ReactRouterDom = require('react-router-dom');
|
|
13
|
-
var restApi = require('@frontegg/rest-api');
|
|
14
|
-
var AppHolder = require('@frontegg/admin-portal/AppHolder');
|
|
15
|
-
var types = require('@frontegg/types');
|
|
16
|
-
|
|
17
|
-
var BrowserRouter = ReactRouterDom.BrowserRouter;
|
|
18
|
-
var useHistory = function () {
|
|
19
|
-
var _a, _b, _c;
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
var navigate = ((_a = ReactRouterDom.useInRouterContext) === null || _a === void 0 ? void 0 : _a.call(ReactRouterDom)) ? (_b = ReactRouterDom.useNavigate) === null || _b === void 0 ? void 0 : _b.call(ReactRouterDom) : null;
|
|
22
|
-
var history = (_c = ReactRouterDom.useHistory) === null || _c === void 0 ? void 0 : _c.call(ReactRouterDom);
|
|
23
|
-
if (navigate) {
|
|
24
|
-
var push = function (path, state) {
|
|
25
|
-
if (state) {
|
|
26
|
-
navigate(path, { state: state });
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
navigate(path);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
var replace = function (path, state) {
|
|
33
|
-
navigate(path, { state: state, replace: true });
|
|
34
|
-
};
|
|
35
|
-
return { push: push, replace: replace };
|
|
36
|
-
}
|
|
37
|
-
return history;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
var removeRedirectUrlFromQuery = function (query) {
|
|
41
|
-
var q = new URLSearchParams(query);
|
|
42
|
-
q.delete('redirectUrl');
|
|
43
|
-
return q.toString();
|
|
44
|
-
};
|
|
45
|
-
var useQueryKeeper = function (_a) {
|
|
46
|
-
var routes = _a.routes, history = _a.history;
|
|
47
|
-
var queryParams = React.useRef();
|
|
48
|
-
var prevPathname = React.useRef();
|
|
49
|
-
var _b = ReactRouterDom.useLocation(), pathname = _b.pathname, search = _b.search;
|
|
50
|
-
React.useEffect(function () {
|
|
51
|
-
if (!!search) {
|
|
52
|
-
queryParams.current = search;
|
|
53
|
-
prevPathname.current = pathname;
|
|
54
|
-
}
|
|
55
|
-
}, []);
|
|
56
|
-
React.useEffect(function () {
|
|
57
|
-
var shouldKeepQuery = !!Object.values(routes).find(function (route) { return route === prevPathname.current; });
|
|
58
|
-
if (!search && !!queryParams.current && shouldKeepQuery) {
|
|
59
|
-
var query = removeRedirectUrlFromQuery(queryParams.current);
|
|
60
|
-
history.push(pathname + ("?" + query));
|
|
61
|
-
}
|
|
62
|
-
prevPathname.current = pathname;
|
|
63
|
-
}, [pathname, search, routes]);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
var ConnectorHistory = function (props) {
|
|
67
|
-
var history = useHistory();
|
|
68
|
-
return React__default.createElement(Connector, tslib.__assign({ history: history }, props));
|
|
69
|
-
};
|
|
70
|
-
var Connector = function (_a) {
|
|
71
|
-
var _b;
|
|
72
|
-
var history = _a.history, appName = _a.appName, props = tslib.__rest(_a, ["history", "appName"]);
|
|
73
|
-
var isSSR = typeof window === 'undefined';
|
|
74
|
-
// v6 or v5
|
|
75
|
-
var baseName = (_b = props.basename) !== null && _b !== void 0 ? _b : '';
|
|
76
|
-
var onRedirectTo = React.useCallback(function (_path, opts) {
|
|
77
|
-
var path = _path;
|
|
78
|
-
// noinspection SuspiciousTypeOfGuard
|
|
79
|
-
if (baseName && typeof baseName === 'string' && baseName.length > 0 && path.startsWith(baseName)) {
|
|
80
|
-
path = path.substring(baseName.length);
|
|
81
|
-
}
|
|
82
|
-
if (opts === null || opts === void 0 ? void 0 : opts.preserveQueryParams) {
|
|
83
|
-
path = "" + path + window.location.search;
|
|
84
|
-
}
|
|
85
|
-
if ((opts === null || opts === void 0 ? void 0 : opts.refresh) && !isSSR) {
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
window.Cypress ? history.push(path) : (window.location.href = path);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
(opts === null || opts === void 0 ? void 0 : opts.replace) ? history.replace(path) : history.push(path);
|
|
91
|
-
}
|
|
92
|
-
}, []);
|
|
93
|
-
var app = React.useMemo(function () {
|
|
94
|
-
var _a;
|
|
95
|
-
try {
|
|
96
|
-
return AppHolder.AppHolder.getInstance(appName !== null && appName !== void 0 ? appName : 'default');
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
return adminPortal.initialize(tslib.__assign(tslib.__assign({}, props), { basename: (_a = props.basename) !== null && _a !== void 0 ? _a : baseName, contextOptions: tslib.__assign({ requestCredentials: 'include' }, props.contextOptions), onRedirectTo: onRedirectTo }), appName !== null && appName !== void 0 ? appName : 'default');
|
|
100
|
-
}
|
|
101
|
-
}, []);
|
|
102
|
-
restApi.ContextHolder.setOnRedirectTo(onRedirectTo);
|
|
103
|
-
var signUpUrl = app.store.getState().auth.routes.signUpUrl;
|
|
104
|
-
useQueryKeeper({ routes: { signUpUrl: signUpUrl }, history: history });
|
|
105
|
-
return React__default.createElement(reactHooks.FronteggStoreProvider, tslib.__assign({}, tslib.__assign(tslib.__assign({}, props), { app: app })));
|
|
106
|
-
};
|
|
107
|
-
var FronteggProvider = function (props) {
|
|
108
|
-
var history = useHistory();
|
|
109
|
-
if (props.history || history) {
|
|
110
|
-
return (React__default.createElement(Connector, tslib.__assign({ history: props.history || history }, props), props.children));
|
|
111
|
-
}
|
|
112
|
-
return (React__default.createElement(BrowserRouter, { basename: props.basename },
|
|
113
|
-
React__default.createElement(ConnectorHistory, tslib.__assign({}, props), props.children)));
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
var AuthorizedContent = function (props) {
|
|
117
|
-
var _a, _b;
|
|
118
|
-
var isAuthorized = true; // Initially
|
|
119
|
-
var user = reactHooks.useAuthUserOrNull();
|
|
120
|
-
if (!(user === null || user === void 0 ? void 0 : user.superUser)) {
|
|
121
|
-
if (props.requiredPermissions) {
|
|
122
|
-
isAuthorized = false; // Reset - we are going to check that the user has at least one matching permission
|
|
123
|
-
var _loop_1 = function (permission) {
|
|
124
|
-
if ((_a = user === null || user === void 0 ? void 0 : user.permissions) === null || _a === void 0 ? void 0 : _a.find(function (_a) {
|
|
125
|
-
var key = _a.key;
|
|
126
|
-
return key === permission;
|
|
127
|
-
})) {
|
|
128
|
-
isAuthorized = true;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
for (var _i = 0, _c = props.requiredPermissions; _i < _c.length; _i++) {
|
|
132
|
-
var permission = _c[_i];
|
|
133
|
-
_loop_1(permission);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (props.requiredRoles) {
|
|
137
|
-
isAuthorized = false; // Reset - we are going to check that the user has at least one matching role
|
|
138
|
-
var _loop_2 = function (role) {
|
|
139
|
-
if ((_b = user === null || user === void 0 ? void 0 : user.roles) === null || _b === void 0 ? void 0 : _b.find(function (_a) {
|
|
140
|
-
var key = _a.key;
|
|
141
|
-
return key === role;
|
|
142
|
-
})) {
|
|
143
|
-
isAuthorized = true;
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
for (var _d = 0, _e = props.requiredRoles; _d < _e.length; _d++) {
|
|
147
|
-
var role = _e[_d];
|
|
148
|
-
_loop_2(role);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (typeof props.render === 'function') {
|
|
153
|
-
return React__default.createElement(React__default.Fragment, null, props.render(isAuthorized));
|
|
154
|
-
}
|
|
155
|
-
return isAuthorized ? React__default.createElement(React__default.Fragment, null, props.children) : null;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
var useCheckoutDialog = function () {
|
|
159
|
-
var _a = React.useState({
|
|
160
|
-
open: false,
|
|
161
|
-
error: null,
|
|
162
|
-
success: false,
|
|
163
|
-
}), _b = _a[0], open = _b.open, error = _b.error, success = _b.success, setState = _a[1];
|
|
164
|
-
var handleError = React.useCallback(function (error) {
|
|
165
|
-
setState({
|
|
166
|
-
open: true,
|
|
167
|
-
success: false,
|
|
168
|
-
error: error,
|
|
169
|
-
});
|
|
170
|
-
}, []);
|
|
171
|
-
var handleSuccess = React.useCallback(function () {
|
|
172
|
-
setState({
|
|
173
|
-
open: false,
|
|
174
|
-
success: true,
|
|
175
|
-
error: null,
|
|
176
|
-
});
|
|
177
|
-
}, []);
|
|
178
|
-
var showDialog = React.useCallback(function (plan) {
|
|
179
|
-
adminPortal.CheckoutDialog.show({
|
|
180
|
-
plan: plan,
|
|
181
|
-
onClose: hideDialog,
|
|
182
|
-
onError: handleError,
|
|
183
|
-
onSuccess: handleSuccess,
|
|
184
|
-
});
|
|
185
|
-
setState({
|
|
186
|
-
open: true,
|
|
187
|
-
success: false,
|
|
188
|
-
error: null,
|
|
189
|
-
});
|
|
190
|
-
}, []);
|
|
191
|
-
var hideDialog = React.useCallback(function () {
|
|
192
|
-
adminPortal.CheckoutDialog.hide();
|
|
193
|
-
setState({
|
|
194
|
-
open: false,
|
|
195
|
-
error: null,
|
|
196
|
-
success: false,
|
|
197
|
-
});
|
|
198
|
-
}, []);
|
|
199
|
-
return React.useMemo(function () { return ({
|
|
200
|
-
open: open,
|
|
201
|
-
showDialog: showDialog,
|
|
202
|
-
hideDialog: hideDialog,
|
|
203
|
-
error: error,
|
|
204
|
-
success: success,
|
|
205
|
-
}); }, [open, showDialog, hideDialog, error, success]);
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
Object.keys(reactHooks).forEach(function (k) {
|
|
209
|
-
if (k !== 'default') Object.defineProperty(exports, k, {
|
|
210
|
-
enumerable: true,
|
|
211
|
-
get: function () {
|
|
212
|
-
return reactHooks[k];
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
Object.keys(types).forEach(function (k) {
|
|
217
|
-
if (k !== 'default') Object.defineProperty(exports, k, {
|
|
218
|
-
enumerable: true,
|
|
219
|
-
get: function () {
|
|
220
|
-
return types[k];
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
Object.defineProperty(exports, 'AdminPortal', {
|
|
225
|
-
enumerable: true,
|
|
226
|
-
get: function () {
|
|
227
|
-
return adminPortal.AdminPortal;
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
Object.defineProperty(exports, 'CheckoutDialog', {
|
|
231
|
-
enumerable: true,
|
|
232
|
-
get: function () {
|
|
233
|
-
return adminPortal.CheckoutDialog;
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
exports.AuthorizedContent = AuthorizedContent;
|
|
237
|
-
exports.Connector = Connector;
|
|
238
|
-
exports.ConnectorHistory = ConnectorHistory;
|
|
239
|
-
exports.FronteggProvider = FronteggProvider;
|
|
240
|
-
exports.useCheckoutDialog = useCheckoutDialog;
|
|
241
|
-
//# sourceMappingURL=index.js.map
|
|
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 './FronteggProvider';
|
|
7
|
+
export * from './AuthorizedContent';
|
|
8
|
+
export * from './CheckoutDialog';
|
|
9
|
+
export { AdminPortal, CheckoutDialog } from '@frontegg/js';
|
|
10
|
+
export * from '@frontegg/react-hooks';
|
|
11
|
+
export * from '@frontegg/types';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.AuthorizedContent = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _reactHooks = require("@frontegg/react-hooks");
|
|
13
|
+
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
|
|
16
|
+
const AuthorizedContent = props => {
|
|
17
|
+
let isAuthorized = true;
|
|
18
|
+
const user = (0, _reactHooks.useAuthUserOrNull)();
|
|
19
|
+
|
|
20
|
+
if (!(user != null && user.superUser)) {
|
|
21
|
+
if (props.requiredPermissions) {
|
|
22
|
+
isAuthorized = false;
|
|
23
|
+
|
|
24
|
+
for (const permission of props.requiredPermissions) {
|
|
25
|
+
var _user$permissions;
|
|
26
|
+
|
|
27
|
+
if (user != null && (_user$permissions = user.permissions) != null && _user$permissions.find(({
|
|
28
|
+
key
|
|
29
|
+
}) => key === permission)) {
|
|
30
|
+
isAuthorized = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (props.requiredRoles) {
|
|
36
|
+
isAuthorized = false;
|
|
37
|
+
|
|
38
|
+
for (const role of props.requiredRoles) {
|
|
39
|
+
var _user$roles;
|
|
40
|
+
|
|
41
|
+
if (user != null && (_user$roles = user.roles) != null && _user$roles.find(({
|
|
42
|
+
key
|
|
43
|
+
}) => key === role)) {
|
|
44
|
+
isAuthorized = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (typeof props.render === 'function') {
|
|
51
|
+
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
52
|
+
children: props.render(isAuthorized)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return isAuthorized ? (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
57
|
+
children: props.children
|
|
58
|
+
}) : null;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.AuthorizedContent = AuthorizedContent;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCheckoutDialog = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _js = require("@frontegg/js");
|
|
11
|
+
|
|
12
|
+
const useCheckoutDialog = () => {
|
|
13
|
+
const [{
|
|
14
|
+
open,
|
|
15
|
+
error,
|
|
16
|
+
success
|
|
17
|
+
}, setState] = (0, _react.useState)({
|
|
18
|
+
open: false,
|
|
19
|
+
error: null,
|
|
20
|
+
success: false
|
|
21
|
+
});
|
|
22
|
+
const handleError = (0, _react.useCallback)(error => {
|
|
23
|
+
setState({
|
|
24
|
+
open: true,
|
|
25
|
+
success: false,
|
|
26
|
+
error
|
|
27
|
+
});
|
|
28
|
+
}, []);
|
|
29
|
+
const handleSuccess = (0, _react.useCallback)(() => {
|
|
30
|
+
setState({
|
|
31
|
+
open: false,
|
|
32
|
+
success: true,
|
|
33
|
+
error: null
|
|
34
|
+
});
|
|
35
|
+
}, []);
|
|
36
|
+
const showDialog = (0, _react.useCallback)(plan => {
|
|
37
|
+
_js.CheckoutDialog.show({
|
|
38
|
+
plan,
|
|
39
|
+
onClose: hideDialog,
|
|
40
|
+
onError: handleError,
|
|
41
|
+
onSuccess: handleSuccess
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
setState({
|
|
45
|
+
open: true,
|
|
46
|
+
success: false,
|
|
47
|
+
error: null
|
|
48
|
+
});
|
|
49
|
+
}, []);
|
|
50
|
+
const hideDialog = (0, _react.useCallback)(() => {
|
|
51
|
+
_js.CheckoutDialog.hide();
|
|
52
|
+
|
|
53
|
+
setState({
|
|
54
|
+
open: false,
|
|
55
|
+
error: null,
|
|
56
|
+
success: false
|
|
57
|
+
});
|
|
58
|
+
}, []);
|
|
59
|
+
return (0, _react.useMemo)(() => ({
|
|
60
|
+
open,
|
|
61
|
+
showDialog,
|
|
62
|
+
hideDialog,
|
|
63
|
+
error,
|
|
64
|
+
success
|
|
65
|
+
}), [open, showDialog, hideDialog, error, success]);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
exports.useCheckoutDialog = useCheckoutDialog;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.FronteggProvider = exports.ConnectorHistory = exports.Connector = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _js = require("@frontegg/js");
|
|
17
|
+
|
|
18
|
+
var _reactHooks = require("@frontegg/react-hooks");
|
|
19
|
+
|
|
20
|
+
var _routerProxy = require("./routerProxy");
|
|
21
|
+
|
|
22
|
+
var _restApi = require("@frontegg/rest-api");
|
|
23
|
+
|
|
24
|
+
var _queryKeeper = require("./queryKeeper");
|
|
25
|
+
|
|
26
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
|
+
|
|
28
|
+
const _excluded = ["history", "appName"];
|
|
29
|
+
|
|
30
|
+
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); }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
const ConnectorHistory = props => {
|
|
35
|
+
const history = (0, _routerProxy.useHistory)();
|
|
36
|
+
return (0, _jsxRuntime.jsx)(Connector, (0, _extends2.default)({
|
|
37
|
+
history: history
|
|
38
|
+
}, props));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.ConnectorHistory = ConnectorHistory;
|
|
42
|
+
|
|
43
|
+
const Connector = _ref => {
|
|
44
|
+
var _props$basename;
|
|
45
|
+
|
|
46
|
+
let {
|
|
47
|
+
history,
|
|
48
|
+
appName
|
|
49
|
+
} = _ref,
|
|
50
|
+
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
51
|
+
const isSSR = typeof window === 'undefined';
|
|
52
|
+
const baseName = (_props$basename = props.basename) != null ? _props$basename : '';
|
|
53
|
+
const onRedirectTo = (0, _react.useCallback)((_path, opts) => {
|
|
54
|
+
let path = _path;
|
|
55
|
+
|
|
56
|
+
if (baseName && typeof baseName === 'string' && baseName.length > 0 && path.startsWith(baseName)) {
|
|
57
|
+
path = path.substring(baseName.length);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (opts != null && opts.preserveQueryParams) {
|
|
61
|
+
path = `${path}${window.location.search}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (opts != null && opts.refresh && !isSSR) {
|
|
65
|
+
window.Cypress ? history.push(path) : window.location.href = path;
|
|
66
|
+
} else {
|
|
67
|
+
opts != null && opts.replace ? history.replace(path) : history.push(path);
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
const app = (0, _react.useMemo)(() => {
|
|
71
|
+
try {
|
|
72
|
+
return _js.AppHolder.getInstance(appName != null ? appName : 'default');
|
|
73
|
+
} catch (e) {
|
|
74
|
+
var _props$basename2;
|
|
75
|
+
|
|
76
|
+
return (0, _js.initialize)((0, _extends2.default)({}, props, {
|
|
77
|
+
basename: (_props$basename2 = props.basename) != null ? _props$basename2 : baseName,
|
|
78
|
+
contextOptions: (0, _extends2.default)({
|
|
79
|
+
requestCredentials: 'include'
|
|
80
|
+
}, props.contextOptions),
|
|
81
|
+
onRedirectTo
|
|
82
|
+
}), appName != null ? appName : 'default');
|
|
83
|
+
}
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
86
|
+
_restApi.ContextHolder.setOnRedirectTo(onRedirectTo);
|
|
87
|
+
|
|
88
|
+
const signUpUrl = app.store.getState().auth.routes.signUpUrl;
|
|
89
|
+
(0, _queryKeeper.useQueryKeeper)({
|
|
90
|
+
routes: {
|
|
91
|
+
signUpUrl
|
|
92
|
+
},
|
|
93
|
+
history
|
|
94
|
+
});
|
|
95
|
+
return (0, _jsxRuntime.jsx)(_reactHooks.FronteggStoreProvider, (0, _extends2.default)({}, (0, _extends2.default)({}, props, {
|
|
96
|
+
app
|
|
97
|
+
})));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
exports.Connector = Connector;
|
|
101
|
+
|
|
102
|
+
const FronteggProvider = props => {
|
|
103
|
+
const history = (0, _routerProxy.useHistory)();
|
|
104
|
+
|
|
105
|
+
if (props.history || history) {
|
|
106
|
+
return (0, _jsxRuntime.jsx)(Connector, (0, _extends2.default)({
|
|
107
|
+
history: props.history || history
|
|
108
|
+
}, props, {
|
|
109
|
+
children: props.children
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (0, _jsxRuntime.jsx)(_routerProxy.BrowserRouter, {
|
|
114
|
+
basename: props.basename,
|
|
115
|
+
children: (0, _jsxRuntime.jsx)(ConnectorHistory, (0, _extends2.default)({}, props, {
|
|
116
|
+
children: props.children
|
|
117
|
+
}))
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
exports.FronteggProvider = FronteggProvider;
|
package/node/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
var _exportNames = {
|
|
12
|
+
AdminPortal: true,
|
|
13
|
+
CheckoutDialog: true
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "AdminPortal", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () {
|
|
18
|
+
return _js.AdminPortal;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "CheckoutDialog", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _js.CheckoutDialog;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
var _FronteggProvider = require("./FronteggProvider");
|
|
29
|
+
|
|
30
|
+
Object.keys(_FronteggProvider).forEach(function (key) {
|
|
31
|
+
if (key === "default" || key === "__esModule") return;
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
33
|
+
if (key in exports && exports[key] === _FronteggProvider[key]) return;
|
|
34
|
+
Object.defineProperty(exports, key, {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return _FronteggProvider[key];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
var _AuthorizedContent = require("./AuthorizedContent");
|
|
43
|
+
|
|
44
|
+
Object.keys(_AuthorizedContent).forEach(function (key) {
|
|
45
|
+
if (key === "default" || key === "__esModule") return;
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
47
|
+
if (key in exports && exports[key] === _AuthorizedContent[key]) return;
|
|
48
|
+
Object.defineProperty(exports, key, {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _AuthorizedContent[key];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
var _CheckoutDialog = require("./CheckoutDialog");
|
|
57
|
+
|
|
58
|
+
Object.keys(_CheckoutDialog).forEach(function (key) {
|
|
59
|
+
if (key === "default" || key === "__esModule") return;
|
|
60
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
61
|
+
if (key in exports && exports[key] === _CheckoutDialog[key]) return;
|
|
62
|
+
Object.defineProperty(exports, key, {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () {
|
|
65
|
+
return _CheckoutDialog[key];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var _js = require("@frontegg/js");
|
|
71
|
+
|
|
72
|
+
var _reactHooks = require("@frontegg/react-hooks");
|
|
73
|
+
|
|
74
|
+
Object.keys(_reactHooks).forEach(function (key) {
|
|
75
|
+
if (key === "default" || key === "__esModule") return;
|
|
76
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
77
|
+
if (key in exports && exports[key] === _reactHooks[key]) return;
|
|
78
|
+
Object.defineProperty(exports, key, {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _reactHooks[key];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
var _types = require("@frontegg/types");
|
|
87
|
+
|
|
88
|
+
Object.keys(_types).forEach(function (key) {
|
|
89
|
+
if (key === "default" || key === "__esModule") return;
|
|
90
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
91
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
92
|
+
Object.defineProperty(exports, key, {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function () {
|
|
95
|
+
return _types[key];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useQueryKeeper = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _reactRouterDom = require("react-router-dom");
|
|
11
|
+
|
|
12
|
+
const removeRedirectUrlFromQuery = query => {
|
|
13
|
+
const q = new URLSearchParams(query);
|
|
14
|
+
q.delete('redirectUrl');
|
|
15
|
+
return q.toString();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const useQueryKeeper = ({
|
|
19
|
+
routes,
|
|
20
|
+
history
|
|
21
|
+
}) => {
|
|
22
|
+
const queryParams = (0, _react.useRef)();
|
|
23
|
+
const prevPathname = (0, _react.useRef)();
|
|
24
|
+
const {
|
|
25
|
+
pathname,
|
|
26
|
+
search
|
|
27
|
+
} = (0, _reactRouterDom.useLocation)();
|
|
28
|
+
(0, _react.useEffect)(() => {
|
|
29
|
+
if (!!search) {
|
|
30
|
+
queryParams.current = search;
|
|
31
|
+
prevPathname.current = pathname;
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
(0, _react.useEffect)(() => {
|
|
35
|
+
const shouldKeepQuery = !!Object.values(routes).find(route => route === prevPathname.current);
|
|
36
|
+
|
|
37
|
+
if (!search && !!queryParams.current && shouldKeepQuery) {
|
|
38
|
+
const query = removeRedirectUrlFromQuery(queryParams.current);
|
|
39
|
+
history.push(pathname + `?${query}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
prevPathname.current = pathname;
|
|
43
|
+
}, [pathname, search, routes]);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.useQueryKeeper = useQueryKeeper;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useHistory = exports.BrowserRouter = void 0;
|
|
7
|
+
|
|
8
|
+
var ReactRouterDom = _interopRequireWildcard(require("react-router-dom"));
|
|
9
|
+
|
|
10
|
+
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); }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
const BrowserRouter = ReactRouterDom.BrowserRouter;
|
|
15
|
+
exports.BrowserRouter = BrowserRouter;
|
|
16
|
+
|
|
17
|
+
const useHistory = () => {
|
|
18
|
+
var _ReactRouterDom$useIn, _ReactRouterDom$useNa, _ReactRouterDom$useHi;
|
|
19
|
+
|
|
20
|
+
const navigate = (_ReactRouterDom$useIn = ReactRouterDom.useInRouterContext) != null && _ReactRouterDom$useIn.call(ReactRouterDom) ? (_ReactRouterDom$useNa = ReactRouterDom.useNavigate) == null ? void 0 : _ReactRouterDom$useNa.call(ReactRouterDom) : null;
|
|
21
|
+
const history = (_ReactRouterDom$useHi = ReactRouterDom.useHistory) == null ? void 0 : _ReactRouterDom$useHi.call(ReactRouterDom);
|
|
22
|
+
|
|
23
|
+
if (navigate) {
|
|
24
|
+
const push = (path, state) => {
|
|
25
|
+
if (state) {
|
|
26
|
+
navigate(path, {
|
|
27
|
+
state
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
navigate(path);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const replace = (path, state) => {
|
|
35
|
+
navigate(path, {
|
|
36
|
+
state,
|
|
37
|
+
replace: true
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
push,
|
|
43
|
+
replace
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return history;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.useHistory = useHistory;
|
package/package.json
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/react",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"types": "index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build": "rm -rf dist && mkdir dist && rollup -c ./rollup.config.js",
|
|
10
|
-
"build:watch": "rm -rf dist && mkdir dist && rollup -w -c ./rollup.config.js",
|
|
11
|
-
"test": "jest --runInBand --passWithNoTests -c ../../scripts/jest.config.json --rootDir ."
|
|
12
|
-
},
|
|
3
|
+
"version": "6.0.1-alpha.0",
|
|
4
|
+
"main": "./node/index.js",
|
|
5
|
+
"license": "MIT",
|
|
13
6
|
"dependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"@frontegg/
|
|
7
|
+
"@babel/runtime": "^7.17.2",
|
|
8
|
+
"@frontegg/js": "6.0.1-alpha.0",
|
|
9
|
+
"@frontegg/react-hooks": "6.0.1-alpha.0"
|
|
16
10
|
},
|
|
17
11
|
"peerDependencies": {
|
|
18
12
|
"react": ">16.9.0",
|
|
19
13
|
"react-dom": ">16.9.0",
|
|
20
14
|
"react-router-dom": ">5.0.0"
|
|
21
15
|
},
|
|
22
|
-
"
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"private": false,
|
|
18
|
+
"module": "./index.js",
|
|
19
|
+
"types": "./index.d.ts"
|
|
23
20
|
}
|
package/queryKeeper.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { UseHistory } from './routerProxy';
|
|
2
|
-
interface UseQueryKeeperProps {
|
|
3
|
-
history: UseHistory;
|
|
4
|
-
routes: {
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
export declare const useQueryKeeper: ({ routes, history }: UseQueryKeeperProps) => void;
|
|
9
|
-
export {};
|
|
1
|
+
import { UseHistory } from './routerProxy';
|
|
2
|
+
interface UseQueryKeeperProps {
|
|
3
|
+
history: UseHistory;
|
|
4
|
+
routes: {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare const useQueryKeeper: ({ routes, history }: UseQueryKeeperProps) => void;
|
|
9
|
+
export {};
|
package/queryKeeper.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
const removeRedirectUrlFromQuery = query => {
|
|
5
|
+
const q = new URLSearchParams(query);
|
|
6
|
+
q.delete('redirectUrl');
|
|
7
|
+
return q.toString();
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const useQueryKeeper = ({
|
|
11
|
+
routes,
|
|
12
|
+
history
|
|
13
|
+
}) => {
|
|
14
|
+
const queryParams = useRef();
|
|
15
|
+
const prevPathname = useRef();
|
|
16
|
+
const {
|
|
17
|
+
pathname,
|
|
18
|
+
search
|
|
19
|
+
} = useLocation();
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!!search) {
|
|
22
|
+
queryParams.current = search;
|
|
23
|
+
prevPathname.current = pathname;
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const shouldKeepQuery = !!Object.values(routes).find(route => route === prevPathname.current);
|
|
28
|
+
|
|
29
|
+
if (!search && !!queryParams.current && shouldKeepQuery) {
|
|
30
|
+
const query = removeRedirectUrlFromQuery(queryParams.current);
|
|
31
|
+
history.push(pathname + `?${query}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
prevPathname.current = pathname;
|
|
35
|
+
}, [pathname, search, routes]);
|
|
36
|
+
};
|
package/routerProxy.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import * as ReactRouterDom from 'react-router-dom';
|
|
2
|
-
export declare type Path = string;
|
|
3
|
-
declare type Location = {
|
|
4
|
-
pathname: string;
|
|
5
|
-
search: string;
|
|
6
|
-
state: any;
|
|
7
|
-
hash: string;
|
|
8
|
-
key?: string;
|
|
9
|
-
};
|
|
10
|
-
declare type LocationDescriptor = string | Location;
|
|
11
|
-
export declare type UseHistory = {
|
|
12
|
-
push(path: Path, state?: any): void;
|
|
13
|
-
push(location: LocationDescriptor): void;
|
|
14
|
-
replace(path: Path, state?: any): void;
|
|
15
|
-
replace(location: LocationDescriptor): void;
|
|
16
|
-
};
|
|
17
|
-
export declare const BrowserRouter: typeof ReactRouterDom.BrowserRouter;
|
|
18
|
-
export declare const useHistory: () => UseHistory;
|
|
19
|
-
export {};
|
|
1
|
+
import * as ReactRouterDom from 'react-router-dom';
|
|
2
|
+
export declare type Path = string;
|
|
3
|
+
declare type Location = {
|
|
4
|
+
pathname: string;
|
|
5
|
+
search: string;
|
|
6
|
+
state: any;
|
|
7
|
+
hash: string;
|
|
8
|
+
key?: string;
|
|
9
|
+
};
|
|
10
|
+
declare type LocationDescriptor = string | Location;
|
|
11
|
+
export declare type UseHistory = {
|
|
12
|
+
push(path: Path, state?: any): void;
|
|
13
|
+
push(location: LocationDescriptor): void;
|
|
14
|
+
replace(path: Path, state?: any): void;
|
|
15
|
+
replace(location: LocationDescriptor): void;
|
|
16
|
+
};
|
|
17
|
+
export declare const BrowserRouter: typeof ReactRouterDom.BrowserRouter;
|
|
18
|
+
export declare const useHistory: () => UseHistory;
|
|
19
|
+
export {};
|
package/routerProxy.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as ReactRouterDom from 'react-router-dom';
|
|
2
|
+
export const BrowserRouter = ReactRouterDom.BrowserRouter;
|
|
3
|
+
export const useHistory = () => {
|
|
4
|
+
var _ReactRouterDom$useIn, _ReactRouterDom$useNa, _ReactRouterDom$useHi;
|
|
5
|
+
|
|
6
|
+
const navigate = (_ReactRouterDom$useIn = ReactRouterDom.useInRouterContext) != null && _ReactRouterDom$useIn.call(ReactRouterDom) ? (_ReactRouterDom$useNa = ReactRouterDom.useNavigate) == null ? void 0 : _ReactRouterDom$useNa.call(ReactRouterDom) : null;
|
|
7
|
+
const history = (_ReactRouterDom$useHi = ReactRouterDom.useHistory) == null ? void 0 : _ReactRouterDom$useHi.call(ReactRouterDom);
|
|
8
|
+
|
|
9
|
+
if (navigate) {
|
|
10
|
+
const push = (path, state) => {
|
|
11
|
+
if (state) {
|
|
12
|
+
navigate(path, {
|
|
13
|
+
state
|
|
14
|
+
});
|
|
15
|
+
} else {
|
|
16
|
+
navigate(path);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const replace = (path, state) => {
|
|
21
|
+
navigate(path, {
|
|
22
|
+
state,
|
|
23
|
+
replace: true
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
push,
|
|
29
|
+
replace
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return history;
|
|
34
|
+
};
|
package/README.md
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# Frontegg React
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
Frontegg is a web platform where SaaS companies can set up their fully managed, scalable and brand aware - SaaS features
|
|
6
|
-
and integrate them into their SaaS portals in up to 5 lines of code.
|
|
7
|
-
|
|
8
|
-
## BREAKING CHANGES SINCE VERSION 2.1.0
|
|
9
|
-
|
|
10
|
-
### The new @frontegg/react uses AdminPortal and LoginBox instead of multiple components.
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
Use the package manager [npm](https://www.npmjs.com/) to install frontegg React.JS library.
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install @frontegg/react
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Configuration
|
|
21
|
-
|
|
22
|
-
Wrap your application with `Frontegg Provider`:
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
import { FronteggProvider } from '@frontegg/react'
|
|
26
|
-
|
|
27
|
-
const contextOptions = {
|
|
28
|
-
baseUrl: 'https://{HOST}.frontegg.com', // Your backend base URL (frontegg will direct the requests to it)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const App = () => {
|
|
32
|
-
return <FronteggProvider contextOptions={contextOptions}>
|
|
33
|
-
{/*...*/}
|
|
34
|
-
</FronteggProvider>
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Usage
|
|
40
|
-
|
|
41
|
-
You can use React Hooks to access Frontegg store.
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
import { useAuthUser } from '@frontegg/react'
|
|
45
|
-
|
|
46
|
-
const HomePage = () => {
|
|
47
|
-
const user = useAuthUser();
|
|
48
|
-
|
|
49
|
-
return <div>
|
|
50
|
-
Logged In user: {user.email}
|
|
51
|
-
</div>
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Openning the Admin Portal is available via the following code snippet.
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
import { AdminPortal } from '@frontegg/react'
|
|
59
|
-
|
|
60
|
-
const Toolbar = () => {
|
|
61
|
-
|
|
62
|
-
return <nav>
|
|
63
|
-
{/*... your application tabs ...*/}
|
|
64
|
-
|
|
65
|
-
<button onClick={() => AdminPortal.show()}>
|
|
66
|
-
Open Admin Portal
|
|
67
|
-
</button>
|
|
68
|
-
</nav>
|
|
69
|
-
}
|
|
70
|
-
```
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/routerProxy.tsx","../src/queryKeeper.tsx","../src/FronteggProvider.tsx","../src/AuthorizedContent.tsx","../src/CheckoutDialog.tsx"],"sourcesContent":["import * as ReactRouterDom from 'react-router-dom';\n\nexport type Path = string;\n\ntype Location = {\n pathname: string;\n search: string;\n state: any;\n hash: string;\n key?: string;\n};\n\ntype LocationDescriptor = string | Location;\n\nexport type UseHistory = {\n push(path: Path, state?: any): void;\n push(location: LocationDescriptor): void;\n replace(path: Path, state?: any): void;\n replace(location: LocationDescriptor): void;\n};\n\nexport const BrowserRouter = ReactRouterDom.BrowserRouter;\n\nexport const useHistory = (): UseHistory => {\n // @ts-ignore\n const navigate = ReactRouterDom.useInRouterContext?.() ? ReactRouterDom.useNavigate?.() : null;\n const history = ReactRouterDom.useHistory?.();\n\n if (navigate) {\n const push = (path: Path, state?: any): void => {\n if (state) {\n navigate(path, { state });\n } else {\n navigate(path);\n }\n };\n\n const replace = (path: Path, state?: any): void => {\n navigate(path, { state, replace: true });\n };\n\n return { push, replace };\n }\n return history;\n};\n","import { useEffect, useRef } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport { UseHistory } from './routerProxy';\n\ninterface UseQueryKeeperProps {\n history: UseHistory;\n routes: {\n [key: string]: string;\n };\n}\n\nconst removeRedirectUrlFromQuery = (query: string) => {\n const q = new URLSearchParams(query);\n q.delete('redirectUrl');\n return q.toString();\n};\n\nexport const useQueryKeeper = ({ routes, history }: UseQueryKeeperProps): void => {\n const queryParams = useRef<string>();\n const prevPathname = useRef<string>();\n const { pathname, search } = useLocation();\n\n useEffect(() => {\n if (!!search) {\n queryParams.current = search;\n prevPathname.current = pathname;\n }\n }, []);\n\n useEffect(() => {\n const shouldKeepQuery = !!Object.values(routes).find((route) => route === prevPathname.current);\n\n if (!search && !!queryParams.current && shouldKeepQuery) {\n const query = removeRedirectUrlFromQuery(queryParams.current);\n history.push(pathname + `?${query}`);\n }\n\n prevPathname.current = pathname;\n }, [pathname, search, routes]);\n};\n","import React, { FC, ReactNode, useCallback, useMemo } from 'react';\nimport { initialize } from '@frontegg/admin-portal';\nimport { FronteggAppOptions } from '@frontegg/types';\nimport { FronteggStoreProvider } from '@frontegg/react-hooks';\nimport { BrowserRouter, useHistory, UseHistory } from './routerProxy';\nimport { ContextHolder, RedirectOptions } from '@frontegg/rest-api';\nimport { AppHolder } from '@frontegg/admin-portal/AppHolder';\nimport { useQueryKeeper } from './queryKeeper';\n\nexport type FronteggProviderProps = FronteggAppOptions & {\n appName?: string;\n history?: UseHistory;\n children?: ReactNode;\n};\ntype ConnectorProps = Omit<FronteggProviderProps, 'history'> & {\n history: {\n push: (path: string) => void;\n replace: (path: string) => void;\n };\n};\n\nexport const ConnectorHistory: FC<Omit<ConnectorProps, 'history'>> = (props) => {\n const history = useHistory();\n return <Connector history={history} {...props} />;\n};\n\nexport const Connector: FC<ConnectorProps> = ({ history, appName, ...props }) => {\n const isSSR = typeof window === 'undefined';\n\n // v6 or v5\n const baseName = props.basename ?? '';\n\n const onRedirectTo = useCallback((_path: string, opts?: RedirectOptions) => {\n let path = _path;\n // noinspection SuspiciousTypeOfGuard\n if (baseName && typeof baseName === 'string' && baseName.length > 0 && path.startsWith(baseName)) {\n path = path.substring(baseName.length);\n }\n if (opts?.preserveQueryParams) {\n path = `${path}${window.location.search}`;\n }\n if (opts?.refresh && !isSSR) {\n // @ts-ignore\n window.Cypress ? history.push(path) : (window.location.href = path);\n } else {\n opts?.replace ? history.replace(path) : history.push(path);\n }\n }, []);\n\n const app = useMemo(() => {\n try {\n return AppHolder.getInstance(appName ?? 'default');\n } catch (e) {\n return initialize(\n {\n ...props,\n basename: props.basename ?? baseName,\n contextOptions: {\n requestCredentials: 'include',\n ...props.contextOptions,\n },\n onRedirectTo,\n },\n appName ?? 'default'\n );\n }\n }, []);\n ContextHolder.setOnRedirectTo(onRedirectTo);\n\n const signUpUrl = app.store.getState().auth.routes.signUpUrl;\n useQueryKeeper({ routes: { signUpUrl }, history });\n\n return <FronteggStoreProvider {...({ ...props, app } as any)} />;\n};\n\nexport const FronteggProvider: FC<FronteggProviderProps> = (props) => {\n const history = useHistory();\n\n if (props.history || history) {\n return (\n <Connector history={props.history || history} {...props}>\n {props.children}\n </Connector>\n );\n }\n\n return (\n <BrowserRouter basename={props.basename}>\n <ConnectorHistory {...props}>{props.children}</ConnectorHistory>\n </BrowserRouter>\n );\n};\n","import React, { FC, ReactNode } from 'react';\nimport { useAuthUserOrNull } from '@frontegg/react-hooks';\n\nexport interface AuthorizationProps {\n requiredRoles?: string[];\n requiredPermissions?: string[];\n render?: (isAuthorized: boolean) => React.ReactNode | null;\n children?: ReactNode;\n}\n\nexport const AuthorizedContent: FC<AuthorizationProps> = (props) => {\n let isAuthorized = true; // Initially\n const user = useAuthUserOrNull();\n\n if (!user?.superUser) {\n if (props.requiredPermissions) {\n isAuthorized = false; // Reset - we are going to check that the user has at least one matching permission\n for (const permission of props.requiredPermissions) {\n if (user?.permissions?.find(({ key }) => key === permission)) {\n isAuthorized = true;\n }\n }\n }\n\n if (props.requiredRoles) {\n isAuthorized = false; // Reset - we are going to check that the user has at least one matching role\n for (const role of props.requiredRoles) {\n if (user?.roles?.find(({ key }) => key === role)) {\n isAuthorized = true;\n }\n }\n }\n }\n if (typeof props.render === 'function') {\n return <>{props.render(isAuthorized)}</>;\n }\n\n return isAuthorized ? <>{props.children}</> : null;\n};\n","import { useCallback, useMemo, useState } from 'react';\nimport { CheckoutDialog } from '@frontegg/admin-portal';\n\ninterface CheckoutDialogState {\n open: boolean;\n error: string | null;\n success: boolean;\n}\n\nexport interface CheckoutDialogHook {\n showDialog: (plan: string) => void;\n hideDialog: () => void;\n open: boolean;\n error: string | null;\n success: boolean;\n}\n\nexport const useCheckoutDialog = (): CheckoutDialogHook => {\n const [{ open, error, success }, setState] = useState<CheckoutDialogState>({\n open: false,\n error: null,\n success: false,\n });\n\n const handleError = useCallback((error: string) => {\n setState({\n open: true,\n success: false,\n error,\n });\n }, []);\n\n const handleSuccess = useCallback(() => {\n setState({\n open: false,\n success: true,\n error: null,\n });\n }, []);\n\n const showDialog = useCallback((plan: string) => {\n CheckoutDialog.show({\n plan,\n onClose: hideDialog,\n onError: handleError,\n onSuccess: handleSuccess,\n });\n setState({\n open: true,\n success: false,\n error: null,\n });\n }, []);\n\n const hideDialog = useCallback(() => {\n CheckoutDialog.hide();\n setState({\n open: false,\n error: null,\n success: false,\n });\n }, []);\n\n return useMemo(\n () => ({\n open,\n showDialog,\n hideDialog,\n error,\n success,\n }),\n [open, showDialog, hideDialog, error, success]\n );\n};\n"],"names":["ReactRouterDom.BrowserRouter","ReactRouterDom.useInRouterContext","ReactRouterDom.useNavigate","ReactRouterDom.useHistory","useRef","useLocation","useEffect","React","useCallback","useMemo","AppHolder","initialize","ContextHolder","FronteggStoreProvider","__assign","useAuthUserOrNull","useState","CheckoutDialog"],"mappings":";;;;;;;;;;;;;;;;AAqBO,IAAM,aAAa,GAAGA,4BAA4B,CAAC;AAEnD,IAAM,UAAU,GAAG;;;IAExB,IAAM,QAAQ,GAAG,OAAAC,iCAAiC,+CAAjC,cAAc,WAA0BC,0BAA0B,+CAA1B,cAAc,IAAmB,IAAI,CAAC;IAC/F,IAAM,OAAO,SAAGC,yBAAyB,+CAAzB,cAAc,CAAe,CAAC;IAE9C,IAAI,QAAQ,EAAE;QACZ,IAAM,IAAI,GAAG,UAAC,IAAU,EAAE,KAAW;YACnC,IAAI,KAAK,EAAE;gBACT,QAAQ,CAAC,IAAI,EAAE,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;aAC3B;iBAAM;gBACL,QAAQ,CAAC,IAAI,CAAC,CAAC;aAChB;SACF,CAAC;QAEF,IAAM,OAAO,GAAG,UAAC,IAAU,EAAE,KAAW;YACtC,QAAQ,CAAC,IAAI,EAAE,EAAE,KAAK,OAAA,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;SAC1C,CAAC;QAEF,OAAO,EAAE,IAAI,MAAA,EAAE,OAAO,SAAA,EAAE,CAAC;KAC1B;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;;ACjCD,IAAM,0BAA0B,GAAG,UAAC,KAAa;IAC/C,IAAM,CAAC,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACxB,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AACtB,CAAC,CAAC;AAEK,IAAM,cAAc,GAAG,UAAC,EAAwC;QAAtC,MAAM,YAAA,EAAE,OAAO,a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