@frontegg/nextjs 4.0.14 → 4.0.15-alpha.2201525149
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 +2 -1
- package/FronteggProvider.d.ts +6 -2
- package/index.d.ts +2 -3
- package/index.js +5 -22
- package/index.js.map +1 -1
- package/package.json +3 -3
package/AuthorizedContent.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
2
|
export interface AuthorizationProps {
|
|
3
3
|
requiredRoles?: string[];
|
|
4
4
|
requiredPermissions?: string[];
|
|
5
5
|
render?: (isAuthorized: boolean) => React.ReactNode | null;
|
|
6
|
+
children?: ReactNode;
|
|
6
7
|
}
|
|
7
8
|
export declare const AuthorizedContent: FC<AuthorizationProps>;
|
package/FronteggProvider.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { FronteggAppOptions } from '@frontegg/types';
|
|
3
3
|
import { NextRouter } from 'next/router';
|
|
4
|
+
export declare type FronteggProviderProps = FronteggAppOptions & {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
};
|
|
4
7
|
declare type ConnectorProps = FronteggAppOptions & {
|
|
5
8
|
router: NextRouter;
|
|
6
9
|
appName?: string;
|
|
10
|
+
children?: ReactNode;
|
|
7
11
|
};
|
|
8
12
|
export declare const Connector: FC<ConnectorProps>;
|
|
9
|
-
export declare const FronteggProvider: FC<
|
|
13
|
+
export declare const FronteggProvider: FC<FronteggProviderProps>;
|
|
10
14
|
export {};
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './FronteggProvider';
|
|
2
2
|
export * from './AuthorizedContent';
|
|
3
3
|
export { AdminPortal } from '@frontegg/admin-portal';
|
|
4
|
-
export * from '@frontegg/react-hooks
|
|
5
|
-
export * from '@frontegg/
|
|
6
|
-
export * from '@frontegg/react-hooks/connectivity';
|
|
4
|
+
export * from '@frontegg/react-hooks';
|
|
5
|
+
export * from '@frontegg/types';
|
package/index.js
CHANGED
|
@@ -11,9 +11,7 @@ var adminPortal = require('@frontegg/admin-portal');
|
|
|
11
11
|
var reactHooks = require('@frontegg/react-hooks');
|
|
12
12
|
var restApi = require('@frontegg/rest-api');
|
|
13
13
|
var router = require('next/router');
|
|
14
|
-
var
|
|
15
|
-
var audits = require('@frontegg/react-hooks/audits');
|
|
16
|
-
var connectivity = require('@frontegg/react-hooks/connectivity');
|
|
14
|
+
var types = require('@frontegg/types');
|
|
17
15
|
|
|
18
16
|
var Connector = function (_a) {
|
|
19
17
|
var _b;
|
|
@@ -47,13 +45,6 @@ var Connector = function (_a) {
|
|
|
47
45
|
}
|
|
48
46
|
}, [onRedirectTo]);
|
|
49
47
|
restApi.ContextHolder.setOnRedirectTo(onRedirectTo);
|
|
50
|
-
React.useEffect(function () { return function () {
|
|
51
|
-
var _a, _b;
|
|
52
|
-
try {
|
|
53
|
-
(_b = (_a = app.store) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
54
|
-
}
|
|
55
|
-
catch (e) { }
|
|
56
|
-
}; }, []);
|
|
57
48
|
return React__default.createElement(reactHooks.FronteggStoreProvider, tslib.__assign({}, tslib.__assign(tslib.__assign({}, props), { app: app })), props.children);
|
|
58
49
|
};
|
|
59
50
|
var FronteggProvider = function (props) {
|
|
@@ -107,27 +98,19 @@ var AuthorizedContent = function (props) {
|
|
|
107
98
|
return isAuthorized ? React__default.createElement(React__default.Fragment, null, props.children) : null;
|
|
108
99
|
};
|
|
109
100
|
|
|
110
|
-
Object.keys(
|
|
111
|
-
if (k !== 'default') Object.defineProperty(exports, k, {
|
|
112
|
-
enumerable: true,
|
|
113
|
-
get: function () {
|
|
114
|
-
return auth[k];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
Object.keys(audits).forEach(function (k) {
|
|
101
|
+
Object.keys(reactHooks).forEach(function (k) {
|
|
119
102
|
if (k !== 'default') Object.defineProperty(exports, k, {
|
|
120
103
|
enumerable: true,
|
|
121
104
|
get: function () {
|
|
122
|
-
return
|
|
105
|
+
return reactHooks[k];
|
|
123
106
|
}
|
|
124
107
|
});
|
|
125
108
|
});
|
|
126
|
-
Object.keys(
|
|
109
|
+
Object.keys(types).forEach(function (k) {
|
|
127
110
|
if (k !== 'default') Object.defineProperty(exports, k, {
|
|
128
111
|
enumerable: true,
|
|
129
112
|
get: function () {
|
|
130
|
-
return
|
|
113
|
+
return types[k];
|
|
131
114
|
}
|
|
132
115
|
});
|
|
133
116
|
});
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/FronteggProvider.tsx","../src/AuthorizedContent.tsx"],"sourcesContent":["import React, { FC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/FronteggProvider.tsx","../src/AuthorizedContent.tsx"],"sourcesContent":["import React, { FC, ReactNode, useCallback, useMemo } from 'react';\nimport { initialize, AppHolder } from '@frontegg/admin-portal';\nimport { FronteggAppOptions } from '@frontegg/types';\nimport { FronteggStoreProvider } from '@frontegg/react-hooks';\nimport { ContextHolder, RedirectOptions } from '@frontegg/rest-api';\nimport { NextRouter, useRouter } from 'next/router';\n\nexport type FronteggProviderProps = FronteggAppOptions & {\n children?: ReactNode;\n};\n\ntype ConnectorProps = FronteggAppOptions & {\n router: NextRouter;\n appName?: string;\n children?: ReactNode;\n};\n\nexport const Connector: FC<ConnectorProps> = ({ router, appName, ...props }) => {\n const isSSR = typeof window === 'undefined';\n\n // v6 or v5\n const baseName = props.basename ?? router.basePath;\n\n const onRedirectTo = useCallback((_path: string, opts?: RedirectOptions) => {\n let path = _path;\n if (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 ? router.push(path) : (window.location.href = path);\n } else {\n opts?.replace ? router.replace(path) : router.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 }, [onRedirectTo]);\n ContextHolder.setOnRedirectTo(onRedirectTo);\n\n return <FronteggStoreProvider {...({ ...props, app } as any)}>{props.children}</FronteggStoreProvider>;\n};\n\nexport const FronteggProvider: FC<FronteggProviderProps> = (props) => {\n const router = useRouter();\n\n return (\n <Connector {...props} router={router}>\n {props.children}\n </Connector>\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 if (!user?.permissions || user?.permissions.length === 0) {\n isAuthorized = false;\n }\n\n for (const permission of props.requiredPermissions) {\n if (!user?.permissions?.find(({ key }) => key === permission)) {\n isAuthorized = false;\n }\n }\n }\n\n if (props.requiredRoles) {\n if (!user?.roles || user?.roles.length === 0) {\n isAuthorized = false;\n }\n\n for (const role of props.requiredRoles) {\n if (!user?.roles?.find(({ key }) => key === role)) {\n isAuthorized = false;\n }\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"],"names":["useCallback","useMemo","AppHolder","initialize","ContextHolder","React","FronteggStore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.2201525149",
|
|
5
5
|
"author": "Frontegg LTD",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@frontegg/admin-portal": "5.
|
|
9
|
-
"@frontegg/react-hooks": "5.
|
|
8
|
+
"@frontegg/admin-portal": "5.43.0",
|
|
9
|
+
"@frontegg/react-hooks": "5.43.0"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"next": ">10.0.0",
|