@frontegg/nextjs 4.0.9 → 4.0.10-alpha.2025557145

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 CHANGED
@@ -38,7 +38,13 @@ var Connector = function (_a) {
38
38
  }
39
39
  }, []);
40
40
  var app = React.useMemo(function () {
41
- return adminPortal.initialize(tslib.__assign(tslib.__assign({}, props), { contextOptions: tslib.__assign({ requestCredentials: 'include' }, props.contextOptions), onRedirectTo: onRedirectTo }), appName !== null && appName !== void 0 ? appName : 'default');
41
+ var _a;
42
+ try {
43
+ return adminPortal.AppHolder.getInstance(appName !== null && appName !== void 0 ? appName : 'default');
44
+ }
45
+ catch (e) {
46
+ 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');
47
+ }
42
48
  }, [onRedirectTo]);
43
49
  restApi.ContextHolder.setOnRedirectTo(onRedirectTo);
44
50
  React.useEffect(function () { return function () {
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 { ContextHolder, RedirectOptions } from '@frontegg/rest-api';\nimport { NextRouter, useRouter } from 'next/router';\n\ntype ConnectorProps = FronteggAppOptions & {\n router: NextRouter;\n appName?: string;\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 return initialize(\n {\n ...props,\n contextOptions: {\n requestCredentials: 'include',\n ...props.contextOptions,\n },\n onRedirectTo,\n },\n appName ?? 'default'\n );\n }, [onRedirectTo]);\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)}>{props.children}</FronteggStoreProvider>;\n};\n\nexport const FronteggProvider: FC<FronteggAppOptions> = (props) => {\n const router = useRouter();\n return (\n <Connector {...props} router={router}>\n {props.children}\n </Connector>\n );\n};\n","import React, { FC } from 'react';\nimport { useAuthUserOrNull } from '@frontegg/react-hooks';\nimport { User } from '@frontegg/redux-store';\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 (!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};\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AC,EAAO;wBAAL,GAAG,SAAA;oBAAO,OAAA,GAAG,KAAK,UAAU;iBAAA,EAAC,EAAE;oBAC7D,YAAY,GAAG,KAAK,CAAC;iBACtB;;YAHH,KAAyB,UAAyB,EAAzB,KAAA,KAAK,CAAC,mBAAmB,EAAzB,cAAyB,EAAzB,IAAyB;gBAA7C,IAAM,UAAU,SAAA;wBAAV,UAAU;aAIpB;SACF;QAED,IAAI,KAAK,CAAC,aAAa,EAAE;YACvB,IAAI,EAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAA,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,MAAM,MAAK,CAAC,EAAE;gBAC5C,YAAY,GAAG,KAAK,CAAC;aACtB;oCAEU,IAAI;gBACb,IAAI,QAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,IAAI,CAAC,UAAC,EAAO;wBAAL,GAAG,SAAA;oBAAO,OAAA,GAAG,KAAK,IAAI;iBAAA,EAAC,EAAE;oBACjD,YAAY,GAAG,KAAK,CAAC;iBACtB;;YAHH,KAAmB,UAAmB,EAAnB,KAAA,KAAK,CAAC,aAAa,EAAnB,cAAmB,EAAnB,IAAmB;gBAAjC,IAAM,IAAI,SAAA;wBAAJ,IAAI;aAId;SACF;KACF;IAED,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU,EAAE;QACtC,OAAOL,4DAAG,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAI,CAAC;KAC1C;IAED,OAAO,YAAY,GAAGA,4DAAG,KAAK,CAAC,QAAQ,CAAI,GAAG,IAAI,CAAC;AACrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/FronteggProvider.tsx","../src/AuthorizedContent.tsx"],"sourcesContent":["import React, { FC, useCallback, useEffect, 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\ntype ConnectorProps = FronteggAppOptions & {\n router: NextRouter;\n appName?: string;\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 useEffect(\n () => () => {\n try {\n (app.store as any)?.destroy?.();\n } catch (e) {}\n },\n []\n );\n return <FronteggStoreProvider {...({ ...props, app } as any)}>{props.children}</FronteggStoreProvider>;\n};\n\nexport const FronteggProvider: FC<FronteggAppOptions> = (props) => {\n const router = useRouter();\n\n return (\n <Connector {...props} router={router}>\n {props.children}\n </Connector>\n );\n};\n","import React, { FC } from 'react';\nimport { useAuthUserOrNull } from '@frontegg/react-hooks';\nimport { User } from '@frontegg/redux-store';\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 (!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","useEffect","React","FronteggStoreProvider","__assign","router","useRouter","useAuthUserOrNull"],"mappings":";;;;;;;;;;;;;;;;;IAYa,SAAS,GAAuB,UAAC,EAA6B;;IAA3B,IAAA,MAAM,YAAA,EAAE,OAAO,aAAA,EAAK,KAAK,oBAA3B,qBAA6B,CAAF;IACvE,IAAM,KAAK,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;;IAG5C,IAAM,QAAQ,SAAG,KAAK,CAAC,QAAQ,mCAAI,MAAM,CAAC,QAAQ,CAAC;IAEnD,IAAM,YAAY,GAAGA,iBAAW,CAAC,UAAC,KAAa,EAAE,IAAsB;QACrE,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;YAC7B,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACxC;QACD,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,mBAAmB,EAAE;YAC7B,IAAI,GAAG,KAAG,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAQ,CAAC;SAC3C;QACD,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,O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,SAAA;oBAAO,OAAA,GAAG,KAAK,IAAI;iBAAA,EAAC,EAAE;oBACjD,YAAY,GAAG,KAAK,CAAC;iBACtB;;YAHH,KAAmB,UAAmB,EAAnB,KAAA,KAAK,CAAC,aAAa,EAAnB,cAAmB,EAAnB,IAAmB;gBAAjC,IAAM,IAAI,SAAA;wBAAJ,IAAI;aAId;SACF;KACF;IAED,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU,EAAE;QACtC,OAAOL,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,12 +1,12 @@
1
1
  {
2
2
  "name": "@frontegg/nextjs",
3
3
  "libName": "FronteggNextJs",
4
- "version": "4.0.9",
4
+ "version": "4.0.10-alpha.2025557145",
5
5
  "author": "Frontegg LTD",
6
6
  "types": "index.d.ts",
7
7
  "dependencies": {
8
- "@frontegg/admin-portal": "5.30.0",
9
- "@frontegg/react-hooks": "5.30.0"
8
+ "@frontegg/admin-portal": "5.31.0",
9
+ "@frontegg/react-hooks": "5.31.0"
10
10
  },
11
11
  "peerDependencies": {
12
12
  "next": ">10.0.0",