@frontegg/react 3.0.9-alpha.1277668777 → 3.0.10-alpha.1311417090
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/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -62,7 +62,7 @@ var Connector = function (_a) {
|
|
|
62
62
|
}
|
|
63
63
|
catch (e) { }
|
|
64
64
|
}; }, []);
|
|
65
|
-
return React__default.createElement(reactHooks.FronteggStoreProvider, tslib.__assign({}, { app: app })
|
|
65
|
+
return React__default.createElement(reactHooks.FronteggStoreProvider, tslib.__assign({}, tslib.__assign(tslib.__assign({}, props), { app: app })));
|
|
66
66
|
};
|
|
67
67
|
var FronteggProvider = function (props) {
|
|
68
68
|
var history = reactRouter.useHistory();
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/FronteggProvider.tsx","../src/AuthorizedContent.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useMemo } from 'react';\nimport { initialize } from '@frontegg/admin-portal';\nimport { FronteggAppOptions } from '@frontegg/types';\nimport { FronteggStoreProvider } from '@frontegg/react-hooks';\nimport { BrowserRouter } from 'react-router-dom';\nimport { useHistory } from 'react-router';\nimport { ContextHolder, RedirectOptions } from '@frontegg/rest-api';\n\nexport type FronteggProviderProps = FronteggAppOptions & {\n appName?: string;\n history?: {\n push: (path: string) => void;\n replace: (path: string) => void;\n };\n};\ntype ConnectorProps = Omit<FronteggProviderProps, 'history'> & {\n history: {\n push: (path: string) => void;\n replace: (path: string) => void;\n };\n};\n\nconst getBasename = (history: any) => {\n let basename = '';\n if (history.createHref) {\n basename = history.createHref({ pathname: '/url' });\n } else {\n basename = history.createPath(history.parsePath('/url'));\n }\n return basename.substring(0, basename.length - '/url'.length);\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 ?? getBasename(history);\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 ? 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 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 ContextHolder.setOnRedirectTo(onRedirectTo);\n\n useEffect(\n () => () => {\n try {\n (app.store as any)?.destroy?.();\n } catch (e) {}\n },\n []\n );\n return <FronteggStoreProvider {...({ app } as any)}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/FronteggProvider.tsx","../src/AuthorizedContent.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, useMemo } from 'react';\nimport { initialize } from '@frontegg/admin-portal';\nimport { FronteggAppOptions } from '@frontegg/types';\nimport { FronteggStoreProvider } from '@frontegg/react-hooks';\nimport { BrowserRouter } from 'react-router-dom';\nimport { useHistory } from 'react-router';\nimport { ContextHolder, RedirectOptions } from '@frontegg/rest-api';\n\nexport type FronteggProviderProps = FronteggAppOptions & {\n appName?: string;\n history?: {\n push: (path: string) => void;\n replace: (path: string) => void;\n };\n};\ntype ConnectorProps = Omit<FronteggProviderProps, 'history'> & {\n history: {\n push: (path: string) => void;\n replace: (path: string) => void;\n };\n};\n\nconst getBasename = (history: any) => {\n let basename = '';\n if (history.createHref) {\n basename = history.createHref({ pathname: '/url' });\n } else {\n basename = history.createPath(history.parsePath('/url'));\n }\n return basename.substring(0, basename.length - '/url'.length);\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 ?? getBasename(history);\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 ? 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 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 ContextHolder.setOnRedirectTo(onRedirectTo);\n\n useEffect(\n () => () => {\n try {\n (app.store as any)?.destroy?.();\n } catch (e) {}\n },\n []\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>\n <ConnectorHistory {...props}>{props.children}</ConnectorHistory>\n </BrowserRouter>\n );\n};\n","import React, { FC } 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}\n\nexport const AuthorizedContent: FC<AuthorizationProps> = (props) => {\n let isAuthorized = true; // Initially\n const user = useAuthUserOrNull();\n\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 if (typeof props.render === 'function') {\n return <>{props.render(isAuthorized)}</>;\n }\n\n return isAuthorized ? <>{props.children}</> : null;\n};\n"],"names":["useHistory","React","useCallback","useMemo","initialize","ContextHolder","useEffect","FronteggStoreProvider","__assign","BrowserRouter","useAuthUserOrNull"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAM,WAAW,GAAG,UAAC,OAAY;IAC/B,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAI,OAAO,CAAC,UAAU,EAAE;QACtB,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;KACrD;SAAM;QACL,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;KAC1D;IACD,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAChE,CAAC,CAAC;IAEW,gBAAgB,GAAwC,UAAC,KAAK;IACzE,IAAM,OAAO,GAAGA,sBAAU,EAAE,CAAC;IAC7B,OAAOC,6BAAC,SAAS,mBAAC,OAAO,EAAE,OAAO,IAAM,KAAK,EAAI,CAAC;AACpD,EAAE;IAEW,SAAS,GAAuB,UAAC,EAA8B;;IAA5B,IAAA,OAAO,aAAA,EAAE,OAAO,aAAA,EAAK,KAAK,oBAA5B,sBAA8B,CAAF;IACxE,IAAM,KAAK,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;;IAG5C,IAAM,QAAQ,SAAG,KAAK,CAAC,Q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AAyB;YAA7C,IAAM,UAAU,SAAA;oBAAV,UAAU;SAIpB;KACF;IAED,IAAI,KAAK,CAAC,aAAa,EAAE;QACvB,IAAI,EAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAA,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,MAAM,MAAK,CAAC,EAAE;YAC5C,YAAY,GAAG,KAAK,CAAC;SACtB;gCAEU,IAAI;YACb,IAAI,QAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,IAAI,CAAC,UAAC,EAAO;oBAAL,GAAG,SAAA;gBAAO,OAAA,GAAG,KAAK,IAAI;aAAA,EAAC,EAAE;gBACjD,YAAY,GAAG,KAAK,CAAC;aACtB;;QAHH,KAAmB,UAAmB,EAAnB,KAAA,KAAK,CAAC,aAAa,EAAnB,cAAmB,EAAnB,IAAmB;YAAjC,IAAM,IAAI,SAAA;oBAAJ,IAAI;SAId;KACF;IAED,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU,EAAE;QACtC,OAAOT,4DAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAI,CAAC;KAC1C;IAED,OAAO,YAAY,GAAGA,4DAAG,KAAK,CAAC,QAAQ,CAAI,GAAG,IAAI,CAAC;AACrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/react",
|
|
3
3
|
"libName": "FronteggReact",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.10-alpha.1311417090",
|
|
5
5
|
"author": "Frontegg LTD",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "index.d.ts",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"test": "jest --runInBand --passWithNoTests -c ../../scripts/jest.config.json --rootDir ."
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@frontegg/admin-portal": "4.
|
|
15
|
-
"@frontegg/react-hooks": "4.
|
|
14
|
+
"@frontegg/admin-portal": "4.22.0",
|
|
15
|
+
"@frontegg/react-hooks": "4.22.0",
|
|
16
16
|
"react-router-dom": ">5.0.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|