@frontegg/nextjs 8.0.11-alpha.7600753901 → 8.0.11-alpha.7627624188
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/CHANGELOG.md +0 -9
- package/api/urls.d.ts +1 -2
- package/api/urls.js.map +1 -1
- package/common/FronteggBaseProvider.js +2 -6
- package/common/FronteggBaseProvider.js.map +1 -1
- package/common/FronteggRouterBase.js +4 -5
- package/common/FronteggRouterBase.js.map +1 -1
- package/common/hooks.d.ts +1 -0
- package/common/hooks.js +1 -0
- package/common/hooks.js.map +1 -1
- package/common/useRequestAuthorizeSSR.js +6 -3
- package/common/useRequestAuthorizeSSR.js.map +1 -1
- package/config/index.d.ts +1 -1
- package/config/index.js +6 -3
- package/config/index.js.map +1 -1
- package/index.js +1 -1
- package/middleware/ProxyResponseCallback.js +7 -0
- package/middleware/ProxyResponseCallback.js.map +1 -1
- package/middleware/helpers.d.ts +15 -0
- package/middleware/helpers.js +32 -7
- package/middleware/helpers.js.map +1 -1
- package/package.json +1 -1
- package/pages/withFronteggApp/withFronteggApp.js +0 -3
- package/pages/withFronteggApp/withFronteggApp.js.map +1 -1
- package/sdkVersion.js +1 -1
- package/sdkVersion.js.map +1 -1
- package/utils/routing/index.js +1 -1
- package/utils/routing/index.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## [8.0.11](https://github.com/frontegg/frontegg-nextjs/compare/v8.0.10...v8.0.11) (2024-1-21)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### NextJS Wrapper 8.0.11:
|
|
7
|
-
- FR-14458 - fix build
|
|
8
|
-
- FR-14827 - allow alpha creation manually
|
|
9
|
-
- FR-14458 - Fixed error on middleware request since NextJs V14.0.2
|
|
10
|
-
- FR-14800 - remove app url end char if is /
|
|
11
|
-
|
|
12
3
|
## [8.0.10](https://github.com/frontegg/frontegg-nextjs/compare/v8.0.9...v8.0.10) (2023-12-31)
|
|
13
4
|
|
|
14
5
|
- FR-14578 - Fixed custom login without tenant alias
|
package/api/urls.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const ApiUrls: {
|
|
|
7
7
|
hosted: string;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
interface BuildRouteResult {
|
|
10
|
+
export interface BuildRouteResult {
|
|
11
11
|
asPath: string;
|
|
12
12
|
asUrl: URL;
|
|
13
13
|
}
|
|
@@ -32,4 +32,3 @@ export declare function buildLoginRoute(redirectUrl: string, searchParams?: URLS
|
|
|
32
32
|
* @throws {TypeError} If redirectUrl is not a string.
|
|
33
33
|
*/
|
|
34
34
|
export declare function buildLogoutRoute(redirectUrl: string, baseUrl: string): BuildRouteResult;
|
|
35
|
-
export {};
|
package/api/urls.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urls.js","names":["_restApi","require","_config","_interopRequireDefault","ApiUrls","WellKnown","jwks","refreshToken","embedded","fronteggRefreshTokenUrl","hosted","exports","buildLoginRoute","redirectUrl","searchParams","baseUrl","config","appUrl","asPath","encodeURIComponent","toString","asUrl","URL","buildLogoutRoute"],"sources":["../../../../packages/nextjs/src/api/urls.ts"],"sourcesContent":["import { fronteggRefreshTokenUrl } from '@frontegg/rest-api';\nimport config from '../config';\n\nexport const ApiUrls = {\n WellKnown: {\n jwks: `/.well-known/jwks.json`,\n },\n refreshToken: {\n embedded: `/frontegg${fronteggRefreshTokenUrl}`,\n hosted: `/frontegg/oauth/token`,\n },\n};\n\
|
|
1
|
+
{"version":3,"file":"urls.js","names":["_restApi","require","_config","_interopRequireDefault","ApiUrls","WellKnown","jwks","refreshToken","embedded","fronteggRefreshTokenUrl","hosted","exports","buildLoginRoute","redirectUrl","searchParams","baseUrl","config","appUrl","asPath","encodeURIComponent","toString","asUrl","URL","buildLogoutRoute"],"sources":["../../../../packages/nextjs/src/api/urls.ts"],"sourcesContent":["import { fronteggRefreshTokenUrl } from '@frontegg/rest-api';\nimport config from '../config';\n\nexport const ApiUrls = {\n WellKnown: {\n jwks: `/.well-known/jwks.json`,\n },\n refreshToken: {\n embedded: `/frontegg${fronteggRefreshTokenUrl}`,\n hosted: `/frontegg/oauth/token`,\n },\n};\n\nexport interface BuildRouteResult {\n asPath: string;\n asUrl: URL;\n}\n\n/**\n * Builds a login route with a redirect URL encoded as a query parameter.\n *\n * @param {string} redirectUrl - The URL to redirect to after successful login.\n * @param {URLSearchParams} searchParams - optional The URL search Params to preserve to login\n * @param {string} baseUrl - optional The login base URL the user will be redirected to (default .env.local FRONTEGG_APP_URL)\n * @returns {BuildRouteResult} An object containing the generated login route and URL.\n *\n * @throws {TypeError} If redirectUrl is not a string.\n */\nexport function buildLoginRoute(\n redirectUrl: string,\n searchParams?: URLSearchParams,\n baseUrl: string = config.appUrl\n): BuildRouteResult {\n const asPath = `${baseUrl}/account/login?redirectUrl=${encodeURIComponent(redirectUrl)}${\n searchParams ? `&${searchParams.toString()}` : ''\n }`;\n const asUrl = new URL(asPath);\n return {\n asPath,\n asUrl,\n };\n}\n\n/**\n * Builds a HostedLogin's logout route with a redirect URL encoded as a query parameter.\n *\n * @param {string} redirectUrl - The URL to redirect to after successful login.\n * @param {string} baseUrl - The frontegg domain url\n * @returns {BuildRouteResult} An object containing the generated login route and URL.\n *\n * @throws {TypeError} If redirectUrl is not a string.\n */\nexport function buildLogoutRoute(redirectUrl: string, baseUrl: string): BuildRouteResult {\n const asPath = `${baseUrl}/oauth/logout?post_logout_redirect_uri=${encodeURIComponent(redirectUrl)}`;\n const asUrl = new URL(asPath, baseUrl);\n return {\n asPath,\n asUrl,\n };\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEO,MAAMG,OAAO,GAAG;EACrBC,SAAS,EAAE;IACTC,IAAI,EAAG;EACT,CAAC;EACDC,YAAY,EAAE;IACZC,QAAQ,EAAG,YAAWC,gCAAwB,EAAC;IAC/CC,MAAM,EAAG;EACX;AACF,CAAC;AAACC,OAAA,CAAAP,OAAA,GAAAA,OAAA;AAOF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,eAAeA,CAC7BC,WAAmB,EACnBC,YAA8B,EAC9BC,OAAe,GAAGC,eAAM,CAACC,MAAM,EACb;EAClB,MAAMC,MAAM,GAAI,GAAEH,OAAQ,8BAA6BI,kBAAkB,CAACN,WAAW,CAAE,GACrFC,YAAY,GAAI,IAAGA,YAAY,CAACM,QAAQ,EAAG,EAAC,GAAG,EAChD,EAAC;EACF,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAACJ,MAAM,CAAC;EAC7B,OAAO;IACLA,MAAM;IACNG;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAACV,WAAmB,EAAEE,OAAe,EAAoB;EACvF,MAAMG,MAAM,GAAI,GAAEH,OAAQ,0CAAyCI,kBAAkB,CAACN,WAAW,CAAE,EAAC;EACpG,MAAMQ,KAAK,GAAG,IAAIC,GAAG,CAACJ,MAAM,EAAEH,OAAO,CAAC;EACtC,OAAO;IACLG,MAAM;IACNG;EACF,CAAC;AACH"}
|
|
@@ -15,6 +15,7 @@ var _AppContext = _interopRequireDefault(require("./AppContext"));
|
|
|
15
15
|
var _initializeFronteggApp = _interopRequireDefault(require("../utils/initializeFronteggApp"));
|
|
16
16
|
var _useRequestAuthorizeSSR = _interopRequireDefault(require("./useRequestAuthorizeSSR"));
|
|
17
17
|
var _useOnRedirectTo = _interopRequireDefault(require("../utils/useOnRedirectTo"));
|
|
18
|
+
var _config = _interopRequireDefault(require("../config"));
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
const _excluded = ["router", "appName"];
|
|
20
21
|
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); }
|
|
@@ -46,12 +47,6 @@ const Connector = _ref => {
|
|
|
46
47
|
storeHolder
|
|
47
48
|
}), [props]);
|
|
48
49
|
_restApi.ContextHolder.setOnRedirectTo(onRedirectTo);
|
|
49
|
-
|
|
50
|
-
// useEffect(() => {
|
|
51
|
-
// if(window.location.pathname == '/account/login') {
|
|
52
|
-
// app.store.dispatch({ type: 'auth/requestAuthorize', payload: true });
|
|
53
|
-
// }
|
|
54
|
-
// }, [app]);
|
|
55
50
|
(0, _useRequestAuthorizeSSR.default)({
|
|
56
51
|
app,
|
|
57
52
|
user,
|
|
@@ -73,6 +68,7 @@ const Connector = _ref => {
|
|
|
73
68
|
});
|
|
74
69
|
};
|
|
75
70
|
const FronteggBaseProvider = props => {
|
|
71
|
+
_config.default.fronteggAppOptions = props != null ? props : {};
|
|
76
72
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Connector, (0, _extends2.default)({}, props, {
|
|
77
73
|
framework: 'nextjs',
|
|
78
74
|
children: props.children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FronteggBaseProvider.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","FronteggBaseProvider","_extends2","_objectWithoutPropertiesLoose2","_react","_interopRequireWildcard","_reactHooks","_restApi","_AppContext","_initializeFronteggApp","_useRequestAuthorizeSSR","_useOnRedirectTo","_jsxRuntime","_excluded","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Connector","_ref","_props$basename","_props$authOptions","router","appName","props","isSSR","window","user","session","tenants","activeTenant","baseName","basename","ssrStoreHolder","useRef","storeHolder","current","undefined","onRedirectTo","useOnRedirectTo","authOptions","routes","app","useMemo","initializeFronteggApp","options","ContextHolder","setOnRedirectTo","useRequestAuthorizeSSR","jsx","Provider","children","FronteggStoreProvider","alwaysVisibleChildren","CustomComponentRegister","themeOptions","framework"],"sources":["../../../../packages/nextjs/src/common/FronteggBaseProvider.tsx"],"sourcesContent":["'use client';\n\nimport React, { FC, useMemo, useRef } from 'react';\nimport { FronteggStoreProvider, CustomComponentRegister } from '@frontegg/react-hooks';\nimport { ContextHolder } from '@frontegg/rest-api';\nimport type { FronteggProviderProps } from '../types';\nimport AppContext from './AppContext';\nimport initializeFronteggApp from '../utils/initializeFronteggApp';\nimport useRequestAuthorizeSSR from './useRequestAuthorizeSSR';\nimport useOnRedirectTo from '../utils/useOnRedirectTo';\n\nconst Connector: FC<FronteggProviderProps> = ({ router, appName = 'default', ...props }) => {\n const isSSR = typeof window === 'undefined';\n const { user, session, tenants, activeTenant } = props;\n const baseName = props.basename ?? '';\n const ssrStoreHolder = useRef({});\n const storeHolder = isSSR ? ssrStoreHolder.current : undefined;\n\n const onRedirectTo = useOnRedirectTo(baseName, router, props.authOptions?.routes);\n\n const app = useMemo(\n () =>\n initializeFronteggApp({\n options: { ...props, basename: baseName },\n onRedirectTo,\n appName,\n storeHolder,\n }),\n [props]\n );\n ContextHolder.setOnRedirectTo(onRedirectTo);\n\n
|
|
1
|
+
{"version":3,"file":"FronteggBaseProvider.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","FronteggBaseProvider","_extends2","_objectWithoutPropertiesLoose2","_react","_interopRequireWildcard","_reactHooks","_restApi","_AppContext","_initializeFronteggApp","_useRequestAuthorizeSSR","_useOnRedirectTo","_config","_jsxRuntime","_excluded","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Connector","_ref","_props$basename","_props$authOptions","router","appName","props","isSSR","window","user","session","tenants","activeTenant","baseName","basename","ssrStoreHolder","useRef","storeHolder","current","undefined","onRedirectTo","useOnRedirectTo","authOptions","routes","app","useMemo","initializeFronteggApp","options","ContextHolder","setOnRedirectTo","useRequestAuthorizeSSR","jsx","Provider","children","FronteggStoreProvider","alwaysVisibleChildren","CustomComponentRegister","themeOptions","config","fronteggAppOptions","framework"],"sources":["../../../../packages/nextjs/src/common/FronteggBaseProvider.tsx"],"sourcesContent":["'use client';\n\nimport React, { FC, useMemo, useRef } from 'react';\nimport { FronteggStoreProvider, CustomComponentRegister } from '@frontegg/react-hooks';\nimport { ContextHolder } from '@frontegg/rest-api';\nimport type { FronteggProviderProps } from '../types';\nimport AppContext from './AppContext';\nimport initializeFronteggApp from '../utils/initializeFronteggApp';\nimport useRequestAuthorizeSSR from './useRequestAuthorizeSSR';\nimport useOnRedirectTo from '../utils/useOnRedirectTo';\nimport config from '../config';\n\nconst Connector: FC<FronteggProviderProps> = ({ router, appName = 'default', ...props }) => {\n const isSSR = typeof window === 'undefined';\n const { user, session, tenants, activeTenant } = props;\n const baseName = props.basename ?? '';\n const ssrStoreHolder = useRef({});\n const storeHolder = isSSR ? ssrStoreHolder.current : undefined;\n\n const onRedirectTo = useOnRedirectTo(baseName, router, props.authOptions?.routes);\n\n const app = useMemo(\n () =>\n initializeFronteggApp({\n options: { ...props, basename: baseName },\n onRedirectTo,\n appName,\n storeHolder,\n }),\n [props]\n );\n ContextHolder.setOnRedirectTo(onRedirectTo);\n\n useRequestAuthorizeSSR({ app, user, tenants, activeTenant, session });\n return (\n <AppContext.Provider value={app}>\n <FronteggStoreProvider\n {...({ ...props, app } as any)}\n alwaysVisibleChildren={!isSSR && <CustomComponentRegister app={app} themeOptions={props.themeOptions} />}\n >\n {props.children}\n </FronteggStoreProvider>\n </AppContext.Provider>\n );\n};\n\nexport const FronteggBaseProvider: FC<FronteggProviderProps> = (props) => {\n config.fronteggAppOptions = props ?? {};\n\n return (\n <Connector {...props} framework={'nextjs'}>\n {props.children}\n </Connector>\n );\n};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rE,OAAA,CAAAE,oBAAA,GAAAA,oBAAA"}
|
|
@@ -13,7 +13,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
13
13
|
var _reactHooks = require("@frontegg/react-hooks");
|
|
14
14
|
var _constants = require("../utils/common/constants");
|
|
15
15
|
var _AppContext = _interopRequireDefault(require("./AppContext"));
|
|
16
|
-
var _hooks = require("./hooks");
|
|
17
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
17
|
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); }
|
|
19
18
|
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; }
|
|
@@ -26,9 +25,9 @@ function FronteggRouterBase(props) {
|
|
|
26
25
|
const app = (0, _react.useContext)(_AppContext.default);
|
|
27
26
|
const loginWithRedirect = (0, _reactHooks.useLoginWithRedirect)();
|
|
28
27
|
const {
|
|
29
|
-
requestAuthorize
|
|
28
|
+
requestAuthorize,
|
|
29
|
+
logout
|
|
30
30
|
} = (0, _reactHooks.useLoginActions)();
|
|
31
|
-
const logoutHosted = (0, _hooks.useLogoutHostedLogin)();
|
|
32
31
|
(0, _react.useEffect)(() => {
|
|
33
32
|
if (!app) {
|
|
34
33
|
return;
|
|
@@ -42,7 +41,7 @@ function FronteggRouterBase(props) {
|
|
|
42
41
|
}
|
|
43
42
|
loginWithRedirect();
|
|
44
43
|
} else if (pathname === routesObj.logoutUrl) {
|
|
45
|
-
|
|
44
|
+
logout();
|
|
46
45
|
}
|
|
47
46
|
} else {
|
|
48
47
|
var _routesObj$hostedLogi;
|
|
@@ -57,7 +56,7 @@ function FronteggRouterBase(props) {
|
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
}, [app, queryParams, pathArr, loginWithRedirect,
|
|
59
|
+
}, [app, queryParams, pathArr, loginWithRedirect, logout]);
|
|
61
60
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
|
|
62
61
|
}
|
|
63
62
|
//# sourceMappingURL=FronteggRouterBase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FronteggRouterBase.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","FronteggRouterBase","_extends2","_config","_reduxStore","_react","_interopRequireWildcard","_reactHooks","_constants","_AppContext","
|
|
1
|
+
{"version":3,"file":"FronteggRouterBase.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","FronteggRouterBase","_extends2","_config","_reduxStore","_react","_interopRequireWildcard","_reactHooks","_constants","_AppContext","_jsxRuntime","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","props","queryParams","pathArr","isAppDirEnabled","app","useContext","AppContext","loginWithRedirect","useLoginWithRedirect","requestAuthorize","logout","useLoginActions","useEffect","pathname","join","routesObj","authInitialState","routes","config","authRoutes","options","hostedLoginBox","loginUrl","redirectUrl","localStorage","setItem","FRONTEGG_AFTER_AUTH_REDIRECT_URL","window","location","origin","logoutUrl","_routesObj$hostedLogi","startsWith","hostedLoginRedirectUrl","href","authenticatedUrl","isSamlCallback","samlCallbackUrl","isLoginPage","jsx","Fragment"],"sources":["../../../../packages/nextjs/src/common/FronteggRouterBase.tsx"],"sourcesContent":["'use client';\n\nimport config from '../config';\nimport { authInitialState } from '@frontegg/redux-store';\nimport { useContext, useEffect } from 'react';\nimport { useLoginActions, useLoginWithRedirect } from '@frontegg/react-hooks';\nimport { FRONTEGG_AFTER_AUTH_REDIRECT_URL } from '../utils/common/constants';\nimport AppContext from './AppContext';\nimport React from 'react';\nimport { ParsedUrlQuery } from 'querystring';\n\ninterface FronteggRouterBaseProps {\n queryParams?: ParsedUrlQuery;\n pathArr: string[];\n isAppDirEnabled?: boolean;\n}\n\nexport function FronteggRouterBase(props: FronteggRouterBaseProps) {\n const { queryParams = {}, pathArr, isAppDirEnabled } = props;\n const app = useContext(AppContext);\n const loginWithRedirect = useLoginWithRedirect();\n const { requestAuthorize, logout } = useLoginActions();\n\n useEffect(() => {\n if (!app) {\n return;\n }\n const pathname = `/${pathArr.join('/')}`;\n const routesObj = {\n ...authInitialState.routes,\n ...config.authRoutes,\n };\n\n if (app.options.hostedLoginBox) {\n if (pathname === routesObj.loginUrl) {\n if (queryParams.redirectUrl) {\n localStorage.setItem(FRONTEGG_AFTER_AUTH_REDIRECT_URL, `${window.location.origin}${queryParams.redirectUrl}`);\n }\n loginWithRedirect();\n } else if (pathname === routesObj.logoutUrl) {\n logout();\n }\n } else {\n if (pathname.startsWith(routesObj.hostedLoginRedirectUrl ?? '/oauth/callback')) {\n // if not hosted login, redirect the user to the authenticated url\n window.location.href = routesObj.authenticatedUrl;\n } else {\n const isSamlCallback = pathname === routesObj.samlCallbackUrl;\n const isLoginPage = pathname.startsWith(routesObj.loginUrl);\n if ((isAppDirEnabled && isLoginPage) || isSamlCallback) {\n requestAuthorize(true);\n }\n }\n }\n }, [app, queryParams, pathArr, loginWithRedirect, logout]);\n return <></>;\n}\n"],"mappings":";AAAA,YAAY;;AAAC,IAAAA,s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,EAAE;QAC3CpB,MAAM,EAAE;MACV;IACF,CAAC,MAAM;MAAA,IAAAqB,qBAAA;MACL,IAAIlB,QAAQ,CAACmB,UAAU,EAAAD,qBAAA,GAAChB,SAAS,CAACkB,sBAAsB,YAAAF,qBAAA,GAAI,iBAAiB,CAAC,EAAE;QAC9E;QACAJ,MAAM,CAACC,QAAQ,CAACM,IAAI,GAAGnB,SAAS,CAACoB,gBAAgB;MACnD,CAAC,MAAM;QACL,MAAMC,cAAc,GAAGvB,QAAQ,KAAKE,SAAS,CAACsB,eAAe;QAC7D,MAAMC,WAAW,GAAGzB,QAAQ,CAACmB,UAAU,CAACjB,SAAS,CAACO,QAAQ,CAAC;QAC3D,IAAKnB,eAAe,IAAImC,WAAW,IAAKF,cAAc,EAAE;UACtD3B,gBAAgB,CAAC,IAAI,CAAC;QACxB;MACF;IACF;EACF,CAAC,EAAE,CAACL,GAAG,EAAEH,WAAW,EAAEC,OAAO,EAAEK,iBAAiB,EAAEG,MAAM,CAAC,CAAC;EAC1D,oBAAO,IAAA/B,WAAA,CAAA4D,GAAA,EAAA5D,WAAA,CAAA6D,QAAA,KAAK;AACd"}
|
package/common/hooks.d.ts
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* Hook to logout client side for hosted login
|
|
3
3
|
* @returns {Function} logout function to be used in the client side for hosted login
|
|
4
4
|
* @param redirectUrl - The URL to redirect to after successful logout will be window.location.href by default.
|
|
5
|
+
* @deprecated use `const { logout } = useLoginActions();`
|
|
5
6
|
*/
|
|
6
7
|
export declare const useLogoutHostedLogin: () => (redirectUrl?: string) => void;
|
package/common/hooks.js
CHANGED
|
@@ -11,6 +11,7 @@ var _urls = require("../api/urls");
|
|
|
11
11
|
* Hook to logout client side for hosted login
|
|
12
12
|
* @returns {Function} logout function to be used in the client side for hosted login
|
|
13
13
|
* @param redirectUrl - The URL to redirect to after successful logout will be window.location.href by default.
|
|
14
|
+
* @deprecated use `const { logout } = useLoginActions();`
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
const useLogoutHostedLogin = () => {
|
package/common/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":["_reactHooks","require","_restApi","_urls","useLogoutHostedLogin","logout","useLoginActions","redirectUrl","_ContextHolder$getCon","contextBaseUrl","ContextHolder","getContext","baseUrl","finalRedirectUrl","window","location","href","logoutRoute","buildLogoutRoute","asPath","exports"],"sources":["../../../../packages/nextjs/src/common/hooks.ts"],"sourcesContent":["import { useLoginActions } from '@frontegg/react-hooks';\nimport { ContextHolder } from '@frontegg/rest-api';\nimport { buildLogoutRoute } from '../api/urls';\n\n/**\n * Hook to logout client side for hosted login\n * @returns {Function} logout function to be used in the client side for hosted login\n * @param redirectUrl - The URL to redirect to after successful logout will be window.location.href by default.\n */\n\nexport const useLogoutHostedLogin = () => {\n const { logout } = useLoginActions();\n\n return (redirectUrl?: string) => {\n const contextBaseUrl = ContextHolder.getContext()?.baseUrl;\n const baseUrl = typeof contextBaseUrl === 'function' ? contextBaseUrl('') : contextBaseUrl;\n const finalRedirectUrl = redirectUrl ?? window.location.href;\n const logoutRoute = buildLogoutRoute(finalRedirectUrl, baseUrl).asPath;\n logout(() => {\n window.location.href = logoutRoute;\n });\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;;AAEO,MAAMG,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,2BAAe,GAAE;EAEpC,OAAQC,WAAoB,IAAK;IAAA,IAAAC,qBAAA;IAC/B,MAAMC,cAAc,IAAAD,qBAAA,GAAGE,sBAAa,CAACC,UAAU,EAAE,qBAA1BH,qBAAA,CAA4BI,OAAO;IAC1D,MAAMA,OAAO,GAAG,OAAOH,cAAc,KAAK,UAAU,GAAGA,cAAc,CAAC,EAAE,CAAC,GAAGA,cAAc;IAC1F,MAAMI,gBAAgB,GAAGN,WAAW,WAAXA,WAAW,GAAIO,MAAM,CAACC,QAAQ,CAACC,IAAI;IAC5D,MAAMC,WAAW,GAAG,IAAAC,sBAAgB,EAACL,gBAAgB,EAAED,OAAO,CAAC,CAACO,MAAM;IACtEd,MAAM,CAAC,MAAM;MACXS,MAAM,CAACC,QAAQ,CAACC,IAAI,GAAGC,WAAW;IACpC,CAAC,CAAC;EACJ,CAAC;AACH,CAAC;AAACG,OAAA,CAAAhB,oBAAA,GAAAA,oBAAA"}
|
|
1
|
+
{"version":3,"file":"hooks.js","names":["_reactHooks","require","_restApi","_urls","useLogoutHostedLogin","logout","useLoginActions","redirectUrl","_ContextHolder$getCon","contextBaseUrl","ContextHolder","getContext","baseUrl","finalRedirectUrl","window","location","href","logoutRoute","buildLogoutRoute","asPath","exports"],"sources":["../../../../packages/nextjs/src/common/hooks.ts"],"sourcesContent":["import { useLoginActions } from '@frontegg/react-hooks';\nimport { ContextHolder } from '@frontegg/rest-api';\nimport { buildLogoutRoute } from '../api/urls';\n\n/**\n * Hook to logout client side for hosted login\n * @returns {Function} logout function to be used in the client side for hosted login\n * @param redirectUrl - The URL to redirect to after successful logout will be window.location.href by default.\n * @deprecated use `const { logout } = useLoginActions();`\n */\n\nexport const useLogoutHostedLogin = () => {\n const { logout } = useLoginActions();\n\n return (redirectUrl?: string) => {\n const contextBaseUrl = ContextHolder.getContext()?.baseUrl;\n const baseUrl = typeof contextBaseUrl === 'function' ? contextBaseUrl('') : contextBaseUrl;\n const finalRedirectUrl = redirectUrl ?? window.location.href;\n const logoutRoute = buildLogoutRoute(finalRedirectUrl, baseUrl).asPath;\n logout(() => {\n window.location.href = logoutRoute;\n });\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEO,MAAMG,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAM;IAAEC;EAAO,CAAC,GAAG,IAAAC,2BAAe,GAAE;EAEpC,OAAQC,WAAoB,IAAK;IAAA,IAAAC,qBAAA;IAC/B,MAAMC,cAAc,IAAAD,qBAAA,GAAGE,sBAAa,CAACC,UAAU,EAAE,qBAA1BH,qBAAA,CAA4BI,OAAO;IAC1D,MAAMA,OAAO,GAAG,OAAOH,cAAc,KAAK,UAAU,GAAGA,cAAc,CAAC,EAAE,CAAC,GAAGA,cAAc;IAC1F,MAAMI,gBAAgB,GAAGN,WAAW,WAAXA,WAAW,GAAIO,MAAM,CAACC,QAAQ,CAACC,IAAI;IAC5D,MAAMC,WAAW,GAAG,IAAAC,sBAAgB,EAACL,gBAAgB,EAAED,OAAO,CAAC,CAACO,MAAM;IACtEd,MAAM,CAAC,MAAM;MACXS,MAAM,CAACC,QAAQ,CAACC,IAAI,GAAGC,WAAW;IACpC,CAAC,CAAC;EACJ,CAAC;AACH,CAAC;AAACG,OAAA,CAAAhB,oBAAA,GAAAA,oBAAA"}
|
|
@@ -14,14 +14,17 @@ function useRequestAuthorizeSSR({
|
|
|
14
14
|
tenants,
|
|
15
15
|
session
|
|
16
16
|
}) {
|
|
17
|
+
var _user$accessToken;
|
|
18
|
+
const userWithTokensOrNull = user ? (0, _extends2.default)({}, user, {
|
|
19
|
+
refreshToken: session == null ? void 0 : session.refreshToken,
|
|
20
|
+
accessToken: (_user$accessToken = user.accessToken) != null ? _user$accessToken : session == null ? void 0 : session.accessToken
|
|
21
|
+
}) : null;
|
|
17
22
|
(0, _react.useEffect)(() => {
|
|
18
23
|
app == null ? void 0 : app.store.dispatch({
|
|
19
24
|
type: 'auth/requestAuthorizeSSR',
|
|
20
25
|
payload: {
|
|
21
26
|
accessToken: session == null ? void 0 : session.accessToken,
|
|
22
|
-
user:
|
|
23
|
-
refreshToken: session == null ? void 0 : session.refreshToken
|
|
24
|
-
}) : null,
|
|
27
|
+
user: userWithTokensOrNull,
|
|
25
28
|
tenants
|
|
26
29
|
}
|
|
27
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRequestAuthorizeSSR.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","default","useRequestAuthorizeSSR","_extends2","_react","app","user","tenants","session","
|
|
1
|
+
{"version":3,"file":"useRequestAuthorizeSSR.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","default","useRequestAuthorizeSSR","_extends2","_react","app","user","tenants","session","_user$accessToken","userWithTokensOrNull","refreshToken","accessToken","useEffect","store","dispatch","type","payload"],"sources":["../../../../packages/nextjs/src/common/useRequestAuthorizeSSR.ts"],"sourcesContent":["'use client';\n\nimport { useEffect } from 'react';\nimport { FronteggApp } from '@frontegg/js';\nimport { AllUserData } from '../types';\n\nexport default function useRequestAuthorizeSSR({ app, user, tenants, session }: { app: FronteggApp } & AllUserData) {\n const userWithTokensOrNull = user\n ? {\n ...user,\n refreshToken: session?.refreshToken,\n accessToken: user.accessToken ?? session?.accessToken,\n }\n : null;\n useEffect(() => {\n app?.store.dispatch({\n type: 'auth/requestAuthorizeSSR',\n payload: {\n accessToken: session?.accessToken,\n user: userWithTokensOrNull,\n tenants,\n },\n });\n }, [app]);\n}\n"],"mappings":";AAAA,YAAY;;AAAC,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,OAAA,GAAAC,sBAAA;AAAA,IAAAC,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEb,IAAAQ,MAAA,GAAAR,OAAA;AAIe,SAASM,sBAAsBA,CAAC;EAAEG,GAAG;EAAEC,IAAI;EAAEC,OAAO;EAAEC;AAA4C,CAAC,EAAE;EAAA,IAAAC,iBAAA;EAClH,MAAMC,oBAAoB,GAAGJ,IAAI,OAAAH,SAAA,CAAAF,OAAA,MAExBK,IAAI;IACPK,YAAY,EAAEH,OAAO,oBAAPA,OAAO,CAAEG,YAAY;IACnCC,WAAW,GAAAH,iBAAA,GAAEH,IAAI,CAACM,WAAW,YAAAH,iBAAA,GAAID,OAAO,oBAAPA,OAAO,CAAEI;EAAW,KAEvD,IAAI;EACR,IAAAC,gBAAS,EAAC,MAAM;IACdR,GAAG,oBAAHA,GAAG,CAAES,KAAK,CAACC,QAAQ,CAAC;MAClBC,IAAI,EAAE,0BAA0B;MAChCC,OAAO,EAAE;QACPL,WAAW,EAAEJ,OAAO,oBAAPA,OAAO,CAAEI,WAAW;QACjCN,IAAI,EAAEI,oBAAoB;QAC1BH;MACF;IACF,CAAC,CAAC;EACJ,CAAC,EAAE,CAACF,GAAG,CAAC,CAAC;AACX"}
|
package/config/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { AuthPageRoutes } from '@frontegg/redux-store';
|
|
|
2
2
|
import { WithFronteggAppOptions } from '../pages';
|
|
3
3
|
import { AppEnvConfig, PasswordsMap } from './types';
|
|
4
4
|
declare class Config {
|
|
5
|
-
authRoutes: Partial<AuthPageRoutes>;
|
|
6
5
|
fronteggAppOptions: Partial<WithFronteggAppOptions>;
|
|
7
6
|
constructor();
|
|
8
7
|
get appUrl(): string;
|
|
@@ -13,6 +12,7 @@ declare class Config {
|
|
|
13
12
|
get jwtPublicKeyJson(): string | undefined;
|
|
14
13
|
get cookieName(): string;
|
|
15
14
|
get cookieDomain(): string;
|
|
15
|
+
get authRoutes(): Partial<AuthPageRoutes>;
|
|
16
16
|
private validatePassword;
|
|
17
17
|
get password(): PasswordsMap;
|
|
18
18
|
get isSSL(): boolean;
|
package/config/index.js
CHANGED
|
@@ -26,7 +26,6 @@ const setupEnvVariables = {
|
|
|
26
26
|
};
|
|
27
27
|
class Config {
|
|
28
28
|
constructor() {
|
|
29
|
-
this.authRoutes = {};
|
|
30
29
|
this.fronteggAppOptions = {};
|
|
31
30
|
if (typeof window === 'undefined') {
|
|
32
31
|
this.validatePassword();
|
|
@@ -64,6 +63,10 @@ class Config {
|
|
|
64
63
|
get cookieDomain() {
|
|
65
64
|
return (0, _helpers.generateCookieDomain)(this.appUrl);
|
|
66
65
|
}
|
|
66
|
+
get authRoutes() {
|
|
67
|
+
var _this$fronteggAppOpti, _this$fronteggAppOpti2, _this$fronteggAppOpti3;
|
|
68
|
+
return (_this$fronteggAppOpti = (_this$fronteggAppOpti2 = this.fronteggAppOptions) == null ? void 0 : (_this$fronteggAppOpti3 = _this$fronteggAppOpti2.authOptions) == null ? void 0 : _this$fronteggAppOpti3.routes) != null ? _this$fronteggAppOpti : {};
|
|
69
|
+
}
|
|
67
70
|
validatePassword() {
|
|
68
71
|
const passwordMaps = this.password;
|
|
69
72
|
for (let key of Object.keys(passwordMaps)) {
|
|
@@ -82,8 +85,8 @@ class Config {
|
|
|
82
85
|
return new URL(this.appUrl).protocol === 'https:';
|
|
83
86
|
}
|
|
84
87
|
get isHostedLogin() {
|
|
85
|
-
var _this$
|
|
86
|
-
return (_this$
|
|
88
|
+
var _this$fronteggAppOpti4;
|
|
89
|
+
return (_this$fronteggAppOpti4 = this.fronteggAppOptions.hostedLoginBox) != null ? _this$fronteggAppOpti4 : false;
|
|
87
90
|
}
|
|
88
91
|
get appEnvConfig() {
|
|
89
92
|
return {
|
package/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_helpers","require","_constants","_errors","setupEnvVariables","FRONTEGG_APP_URL","process","env","FRONTEGG_BASE_URL","FRONTEGG_TEST_URL","FRONTEGG_CLIENT_ID","FRONTEGG_ENCRYPTION_PASSWORD","FRONTEGG_COOKIE_NAME","FRONTEGG_JWT_PUBLIC_KEY","VERCEL","VERCEL_URL","Config","constructor","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_helpers","require","_constants","_errors","setupEnvVariables","FRONTEGG_APP_URL","process","env","FRONTEGG_BASE_URL","FRONTEGG_TEST_URL","FRONTEGG_CLIENT_ID","FRONTEGG_ENCRYPTION_PASSWORD","FRONTEGG_COOKIE_NAME","FRONTEGG_JWT_PUBLIC_KEY","VERCEL","VERCEL_URL","Config","constructor","fronteggAppOptions","window","validatePassword","appUrl","generateAppUrl","testUrl","getEnvOrDefault","EnvVariables","baseUrl","_getEnv","getEnv","endsWith","slice","baseUrlHost","URL","hostname","clientId","_getEnv2","jwtPublicKeyJson","cookieName","_setupEnvVariables$FR","cookieNameEnv","replace","cookieDomain","generateCookieDomain","authRoutes","_this$fronteggAppOpti","_this$fronteggAppOpti2","_this$fronteggAppOpti3","authOptions","routes","passwordMaps","password","key","Object","keys","match","length","InvalidFronteggEnv","_getEnv3","encryptionPasswordEnv","normalizeStringPasswordToMap","isSSL","protocol","isHostedLogin","_this$fronteggAppOpti4","hostedLoginBox","appEnvConfig","envAppUrl","envBaseUrl","envClientId","_default","exports","default"],"sources":["../../../../packages/nextjs/src/config/index.ts"],"sourcesContent":["import { AuthPageRoutes } from '@frontegg/redux-store';\nimport { WithFronteggAppOptions } from '../pages';\nimport { AppEnvConfig, PasswordsMap } from './types';\nimport { generateAppUrl, generateCookieDomain, getEnv, getEnvOrDefault, normalizeStringPasswordToMap } from './helpers';\nimport { EnvVariables } from './constants';\nimport { InvalidFronteggEnv } from '../utils/errors';\n\nconst setupEnvVariables = {\n FRONTEGG_APP_URL: process.env.FRONTEGG_APP_URL,\n FRONTEGG_BASE_URL: process.env.FRONTEGG_BASE_URL,\n FRONTEGG_TEST_URL: process.env.FRONTEGG_TEST_URL,\n FRONTEGG_CLIENT_ID: process.env.FRONTEGG_CLIENT_ID,\n FRONTEGG_ENCRYPTION_PASSWORD: process.env.FRONTEGG_ENCRYPTION_PASSWORD,\n FRONTEGG_COOKIE_NAME: process.env.FRONTEGG_COOKIE_NAME,\n FRONTEGG_JWT_PUBLIC_KEY: process.env.FRONTEGG_JWT_PUBLIC_KEY,\n VERCEL: process.env.VERCEL,\n VERCEL_URL: process.env.VERCEL_URL,\n};\n\nclass Config {\n public fronteggAppOptions: Partial<WithFronteggAppOptions> = {};\n constructor() {\n if (typeof window === 'undefined') {\n this.validatePassword();\n }\n }\n\n get appUrl(): string {\n return generateAppUrl();\n }\n\n get testUrl(): string | undefined {\n return getEnvOrDefault(EnvVariables.FRONTEGG_TEST_URL, setupEnvVariables.FRONTEGG_TEST_URL);\n }\n\n get baseUrl(): string {\n const baseUrl = getEnv(EnvVariables.FRONTEGG_BASE_URL) ?? setupEnvVariables.FRONTEGG_BASE_URL;\n if (baseUrl.endsWith('/')) {\n return baseUrl.slice(0, -1);\n }\n return baseUrl;\n }\n\n get baseUrlHost(): string {\n return new URL(this.baseUrl).hostname;\n }\n\n get clientId(): string {\n return getEnv(EnvVariables.FRONTEGG_CLIENT_ID) ?? setupEnvVariables.FRONTEGG_CLIENT_ID;\n }\n\n get jwtPublicKeyJson(): string | undefined {\n return getEnv(EnvVariables.FRONTEGG_JWT_PUBLIC_KEY);\n }\n\n get cookieName(): string {\n const cookieNameEnv = getEnvOrDefault(\n EnvVariables.FRONTEGG_COOKIE_NAME,\n setupEnvVariables.FRONTEGG_COOKIE_NAME ?? 'fe_session'\n );\n return `${cookieNameEnv}-${this.clientId.replace(/-/g, '')}`;\n }\n\n get cookieDomain(): string {\n return generateCookieDomain(this.appUrl);\n }\n\n get authRoutes(): Partial<AuthPageRoutes> {\n return this.fronteggAppOptions?.authOptions?.routes ?? {};\n }\n\n private validatePassword() {\n const passwordMaps = this.password;\n for (let key of Object.keys(passwordMaps)) {\n const password = passwordMaps[key];\n if (!password.match(/[0-9A-Fa-f]{6}/g) || password.length !== 64) {\n throw new InvalidFronteggEnv(\n EnvVariables.FRONTEGG_ENCRYPTION_PASSWORD,\n `Hex string.\\n\\nFor quick password generation use the following command:\\nnode -e \"console.log(crypto.randomBytes(32).toString('hex'))\"`\n );\n }\n }\n }\n get password(): PasswordsMap {\n const encryptionPasswordEnv =\n getEnv(EnvVariables.FRONTEGG_ENCRYPTION_PASSWORD) ?? setupEnvVariables.FRONTEGG_ENCRYPTION_PASSWORD;\n\n return normalizeStringPasswordToMap(encryptionPasswordEnv);\n }\n\n get isSSL(): boolean {\n return new URL(this.appUrl).protocol === 'https:';\n }\n\n get isHostedLogin(): boolean {\n return this.fronteggAppOptions.hostedLoginBox ?? false;\n }\n\n get appEnvConfig(): AppEnvConfig {\n return {\n envAppUrl: this.appUrl,\n envBaseUrl: this.baseUrl,\n envClientId: this.clientId,\n };\n }\n}\n\nexport { EnvVariables } from './constants';\nexport default new Config();\n"],"mappings":";;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA,MAAMG,iBAAiB,GAAG;EACxBC,gBAAgB,EAAEC,OAAO,CAACC,GAAG,CAACF,gBAAgB;EAC9CG,iBAAiB,EAAEF,OAAO,CAACC,GAAG,CAACC,iBAAiB;EAChDC,iBAAiB,EAAEH,OAAO,CAACC,GAAG,CAACE,iBAAiB;EAChDC,kBAAkB,EAAEJ,OAAO,CAACC,GAAG,CAACG,kBAAkB;EAClDC,4BAA4B,EAAEL,OAAO,CAACC,GAAG,CAACI,4BAA4B;EACtEC,oBAAoB,EAAEN,OAAO,CAACC,GAAG,CAACK,oBAAoB;EACtDC,uBAAuB,EAAEP,OAAO,CAACC,GAAG,CAACM,uBAAuB;EAC5DC,MAAM,EAAER,OAAO,CAACC,GAAG,CAACO,MAAM;EAC1BC,UAAU,EAAET,OAAO,CAACC,GAAG,CAACQ;AAC1B,CAAC;AAED,MAAMC,MAAM,CAAC;EAEXC,WAAWA,CAAA,EAAG;IAAA,KADPC,kBAAkB,GAAoC,CAAC,CAAC;IAE7D,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;MACjC,IAAI,CAACC,gBAAgB,EAAE;IACzB;EACF;EAEA,IAAIC,MAAMA,CAAA,EAAW;IACnB,OAAO,IAAAC,uBAAc,GAAE;EACzB;EAEA,IAAIC,OAAOA,CAAA,EAAuB;IAChC,OAA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,SAAS,EAAE,IAAI,CAAC7C,MAAM;MACtB8C,UAAU,EAAE,IAAI,CAACzC,OAAO;MACxB0C,WAAW,EAAE,IAAI,CAAClC;IACpB,CAAC;EACH;AACF;AAAC,IAAAmC,QAAA,GAGc,IAAIrD,MAAM,EAAE;AAAAsD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
package/index.js
CHANGED
|
@@ -45,6 +45,13 @@ const ProxyResponseCallback = (proxyRes, req, res) => {
|
|
|
45
45
|
res,
|
|
46
46
|
req
|
|
47
47
|
});
|
|
48
|
+
if ((0, _helpers.isFronteggOauthLogoutUrl)(url) || _config.default.isHostedLogin) {
|
|
49
|
+
const {
|
|
50
|
+
asPath: hostedLogoutUrl
|
|
51
|
+
} = (0, _helpers.getHostedLogoutUrl)(req.headers['referer']);
|
|
52
|
+
res.status(302).end(hostedLogoutUrl);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
48
55
|
res.status(statusCode).end(bodyStr);
|
|
49
56
|
return;
|
|
50
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyResponseCallback.js","names":["_config","_interopRequireDefault","require","_cookies","_common","_helpers","_fronteggLogger","_helpers2","logger","fronteggLogger","child","tag","ProxyResponseCallback","proxyRes","req","res","buffer","Buffer","totalLength","isSecured","URL","config","appUrl","protocol","on","chunk","length","concat","_proxyRes$statusCode","url","statusCode","isSuccess","bodyStr","toString","isLogout","isFronteggLogoutUrl","CookieManager","removeCookies","cookieDomain","status","end","_CookieManager$modify","cookies","modifySetCookie","
|
|
1
|
+
{"version":3,"file":"ProxyResponseCallback.js","names":["_config","_interopRequireDefault","require","_cookies","_common","_helpers","_fronteggLogger","_helpers2","logger","fronteggLogger","child","tag","ProxyResponseCallback","proxyRes","req","res","buffer","Buffer","totalLength","isSecured","URL","config","appUrl","protocol","on","chunk","length","concat","_proxyRes$statusCode","url","statusCode","isSuccess","bodyStr","toString","isLogout","isFronteggLogoutUrl","CookieManager","removeCookies","cookieDomain","isFronteggOauthLogoutUrl","isHostedLogin","asPath","hostedLogoutUrl","getHostedLogoutUrl","headers","status","end","_CookieManager$modify","cookies","modifySetCookie","body","JSON","parse","accessToken","access_token","session","decodedJwt","createSessionFromAccessToken","sessionCookie","create","value","expires","Date","exp","secure","push","e","isSSOPostRequest","error","Object","keys","filter","header","forEach","setHeader","_default","exports","default"],"sources":["../../../../packages/nextjs/src/middleware/ProxyResponseCallback.ts"],"sourcesContent":["import { ProxyResCallback } from 'http-proxy';\nimport { IncomingMessage } from 'http';\nimport { NextApiResponse } from 'next';\nimport config from '../config';\nimport CookieManager from '../utils/cookies';\nimport { createSessionFromAccessToken } from '../common';\nimport { getHostedLogoutUrl, isFronteggLogoutUrl, isFronteggOauthLogoutUrl } from './helpers';\nimport fronteggLogger from '../utils/fronteggLogger';\nimport { isSSOPostRequest } from '../utils/refreshAccessToken/helpers';\n\nconst logger = fronteggLogger.child({ tag: 'FronteggApiMiddleware.ProxyResponseCallback' });\n/**\n * Proxy response callback fired on after each response from Frontegg services,\n * to transport frontegg modify cookies and generating encrypted JWT session cookie.\n *\n * @param {IncomingMessage} proxyRes - Proxy response from Frontegg services\n * @param {NextApiRequest} req - Next.js request sent from client-side\n * @param {NextApiResponse} res - Next.js response to send to client-side\n */\nconst ProxyResponseCallback: ProxyResCallback<IncomingMessage, NextApiResponse> = (proxyRes, req, res) => {\n let buffer = new Buffer('');\n let totalLength: number = 0;\n const isSecured = new URL(config.appUrl).protocol === 'https:';\n\n proxyRes.on('data', (chunk: Buffer) => {\n totalLength += chunk.length;\n buffer = Buffer.concat([buffer, chunk], totalLength);\n });\n proxyRes.on('end', async () => {\n try {\n const url = req.url!;\n const statusCode = proxyRes.statusCode ?? 500;\n const isSuccess = statusCode >= 200 && statusCode < 400;\n const bodyStr = buffer.toString('utf-8');\n const isLogout = isFronteggLogoutUrl(url);\n\n if (isLogout) {\n CookieManager.removeCookies({\n isSecured,\n cookieDomain: config.cookieDomain,\n res,\n req,\n });\n if (isFronteggOauthLogoutUrl(url) || config.isHostedLogin) {\n const { asPath: hostedLogoutUrl } = getHostedLogoutUrl(req.headers['referer']);\n res.status(302).end(hostedLogoutUrl);\n return;\n }\n res.status(statusCode).end(bodyStr);\n return;\n }\n\n if (isSuccess) {\n const cookies = CookieManager.modifySetCookie(proxyRes.headers['set-cookie'], isSecured) ?? [];\n\n try {\n if (bodyStr && bodyStr.length > 0) {\n const body = JSON.parse(bodyStr);\n if (body.accessToken || body.access_token) {\n const [session, decodedJwt] = await createSessionFromAccessToken(body);\n if (session) {\n const sessionCookie = CookieManager.create({\n value: session,\n expires: new Date(decodedJwt.exp * 1000),\n secure: isSecured,\n req,\n });\n cookies.push(...sessionCookie);\n }\n }\n }\n } catch (e) {\n /** ignore api call if:\n * - Does not have accessToken / access_token\n * - Not json response\n */\n if (statusCode === 302 && isSSOPostRequest(url)) {\n /**\n * Ignore saml/oidc postLogin response with redirect\n */\n } else {\n logger.error('failed to create session', e, {\n url,\n statusCode,\n });\n }\n }\n Object.keys(proxyRes.headers)\n .filter((header) => header !== 'cookie')\n .forEach((header) => {\n res.setHeader(header, `${proxyRes.headers[header]}`);\n });\n res.setHeader('set-cookie', cookies);\n res.status(statusCode).end(bodyStr);\n } else {\n if (statusCode >= 400 && statusCode !== 404) {\n logger.error(`Middleware request failed statusCode: ${statusCode} for url: ${url}`);\n }\n Object.keys(proxyRes.headers)\n .filter((header) => header !== 'cookie')\n .forEach((header) => {\n res.setHeader(header, `${proxyRes.headers[header]}`);\n });\n res.status(statusCode).end(bodyStr);\n }\n } catch (e: any) {\n logger.error('proxy failed to send request', e);\n res.status(500).end('Internal Server Error');\n }\n });\n};\n\nexport default ProxyResponseCallback;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,I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,KAAK,CAAC,8BAA8B,EAAEF,CAAC,CAAC;MAC/CnD,GAAG,CAAC8B,MAAM,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,uBAAuB,CAAC;IAC9C;EACF,CAAC,CAAC;AACJ,CAAC;AAAC,IAAA6B,QAAA,GAEa/D,qBAAqB;AAAAgE,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
package/middleware/helpers.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BuildRouteResult } from '../api/urls';
|
|
1
2
|
/**
|
|
2
3
|
* If pattern information matching the input url information is found in the `pathRewrite` array,
|
|
3
4
|
* the url value is partially replaced with the `pathRewrite.replaceStr` value.
|
|
@@ -10,4 +11,18 @@ export declare const rewritePath: (url: string, pathRewrite: {
|
|
|
10
11
|
patternStr: string;
|
|
11
12
|
replaceStr: string;
|
|
12
13
|
}[]) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Checks If route is a logout route
|
|
16
|
+
* @param url
|
|
17
|
+
*/
|
|
13
18
|
export declare const isFronteggLogoutUrl: (url: string) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Checks If route is a hosted logout route
|
|
21
|
+
* @param url
|
|
22
|
+
*/
|
|
23
|
+
export declare const isFronteggOauthLogoutUrl: (url: string) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns url to be redirected for hosted logout
|
|
26
|
+
* @param referer the route to redirect to after logout
|
|
27
|
+
*/
|
|
28
|
+
export declare const getHostedLogoutUrl: (referer?: string) => BuildRouteResult;
|
package/middleware/helpers.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.rewritePath = exports.isFronteggLogoutUrl = void 0;
|
|
7
|
+
exports.rewritePath = exports.isFronteggOauthLogoutUrl = exports.isFronteggLogoutUrl = exports.getHostedLogoutUrl = void 0;
|
|
8
|
+
var _urls = require("../api/urls");
|
|
9
|
+
var _config = _interopRequireDefault(require("../config"));
|
|
10
|
+
var _reduxStore = require("@frontegg/redux-store");
|
|
7
11
|
/**
|
|
8
12
|
* If pattern information matching the input url information is found in the `pathRewrite` array,
|
|
9
13
|
* the url value is partially replaced with the `pathRewrite.replaceStr` value.
|
|
@@ -33,12 +37,33 @@ const rewritePath = (url, pathRewrite) => {
|
|
|
33
37
|
}
|
|
34
38
|
return url;
|
|
35
39
|
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Checks If route is a logout route
|
|
43
|
+
* @param url
|
|
44
|
+
*/
|
|
36
45
|
exports.rewritePath = rewritePath;
|
|
37
|
-
const isFronteggLogoutUrl = url =>
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
const isFronteggLogoutUrl = url => url.endsWith('/logout');
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Checks If route is a hosted logout route
|
|
50
|
+
* @param url
|
|
51
|
+
*/
|
|
43
52
|
exports.isFronteggLogoutUrl = isFronteggLogoutUrl;
|
|
53
|
+
const isFronteggOauthLogoutUrl = url => url.endsWith('/oauth/logout');
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Returns url to be redirected for hosted logout
|
|
57
|
+
* @param referer the route to redirect to after logout
|
|
58
|
+
*/
|
|
59
|
+
exports.isFronteggOauthLogoutUrl = isFronteggOauthLogoutUrl;
|
|
60
|
+
const getHostedLogoutUrl = (referer = _config.default.appUrl) => {
|
|
61
|
+
var _config$authRoutes$lo, _config$authRoutes;
|
|
62
|
+
const logoutPath = (_config$authRoutes$lo = (_config$authRoutes = _config.default.authRoutes) == null ? void 0 : _config$authRoutes.logoutUrl) != null ? _config$authRoutes$lo : _reduxStore.authInitialState.routes.logoutUrl;
|
|
63
|
+
const refererUrl = new URL(referer);
|
|
64
|
+
const isLogoutRoute = refererUrl.toString().includes(logoutPath);
|
|
65
|
+
const redirectUrl = isLogoutRoute ? refererUrl.origin + refererUrl.search : refererUrl.toString();
|
|
66
|
+
return (0, _urls.buildLogoutRoute)(redirectUrl, _config.default.baseUrl);
|
|
67
|
+
};
|
|
68
|
+
exports.getHostedLogoutUrl = getHostedLogoutUrl;
|
|
44
69
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["rewritePath","url","pathRewrite","Array","isArray","item","patternStr","replaceStr","pattern","RegExp","test","replace","path","exports","isFronteggLogoutUrl","endsWith"],"sources":["../../../../packages/nextjs/src/middleware/helpers.ts"],"sourcesContent":["/**\n * If pattern information matching the input url information is found in the `pathRewrite` array,\n * the url value is partially replaced with the `pathRewrite.replaceStr` value.\n * @param url\n * @param pathRewrite\n */\nexport const rewritePath = (\n url: string,\n pathRewrite: { [key: string]: string } | { patternStr: string; replaceStr: string }[]\n) => {\n if (Array.isArray(pathRewrite)) {\n for (const item of pathRewrite) {\n const { patternStr, replaceStr } = item;\n const pattern = RegExp(patternStr);\n if (pattern.test(url as string)) {\n return url.replace(pattern, replaceStr);\n }\n }\n } else {\n for (const patternStr in pathRewrite) {\n const pattern = RegExp(patternStr);\n const path = pathRewrite[patternStr];\n if (pattern.test(url as string)) {\n return url.replace(pattern, path);\n }\n }\n }\n return url;\n};\n\nexport const isFronteggLogoutUrl = (url: string) =>
|
|
1
|
+
{"version":3,"file":"helpers.js","names":["_urls","require","_config","_interopRequireDefault","_reduxStore","rewritePath","url","pathRewrite","Array","isArray","item","patternStr","replaceStr","pattern","RegExp","test","replace","path","exports","isFronteggLogoutUrl","endsWith","isFronteggOauthLogoutUrl","getHostedLogoutUrl","referer","config","appUrl","_config$authRoutes$lo","_config$authRoutes","logoutPath","authRoutes","logoutUrl","authInitialState","routes","refererUrl","URL","isLogoutRoute","toString","includes","redirectUrl","origin","search","buildLogoutRoute","baseUrl"],"sources":["../../../../packages/nextjs/src/middleware/helpers.ts"],"sourcesContent":["import { BuildRouteResult, buildLogoutRoute } from '../api/urls';\nimport config from '../config';\nimport { authInitialState } from '@frontegg/redux-store';\n\n/**\n * If pattern information matching the input url information is found in the `pathRewrite` array,\n * the url value is partially replaced with the `pathRewrite.replaceStr` value.\n * @param url\n * @param pathRewrite\n */\nexport const rewritePath = (\n url: string,\n pathRewrite: { [key: string]: string } | { patternStr: string; replaceStr: string }[]\n) => {\n if (Array.isArray(pathRewrite)) {\n for (const item of pathRewrite) {\n const { patternStr, replaceStr } = item;\n const pattern = RegExp(patternStr);\n if (pattern.test(url as string)) {\n return url.replace(pattern, replaceStr);\n }\n }\n } else {\n for (const patternStr in pathRewrite) {\n const pattern = RegExp(patternStr);\n const path = pathRewrite[patternStr];\n if (pattern.test(url as string)) {\n return url.replace(pattern, path);\n }\n }\n }\n return url;\n};\n\n/**\n * Checks If route is a logout route\n * @param url\n */\nexport const isFronteggLogoutUrl = (url: string) => url.endsWith('/logout');\n\n/**\n * Checks If route is a hosted logout route\n * @param url\n */\nexport const isFronteggOauthLogoutUrl = (url: string) => url.endsWith('/oauth/logout');\n\n/**\n * Returns url to be redirected for hosted logout\n * @param referer the route to redirect to after logout\n */\nexport const getHostedLogoutUrl = (referer = config.appUrl): BuildRouteResult => {\n const logoutPath = config.authRoutes?.logoutUrl ?? authInitialState.routes.logoutUrl;\n const refererUrl = new URL(referer);\n const isLogoutRoute = refererUrl.toString().includes(logoutPath);\n\n const redirectUrl = isLogoutRoute ? refererUrl.origin + refererUrl.search : refererUrl.toString();\n\n return buildLogoutRoute(redirectUrl, config.baseUrl);\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMI,WAAW,GAAGA,CACzBC,GAAW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,CAAmBG,SAAS,YAAAJ,qBAAA,GAAIK,4BAAgB,CAACC,MAAM,CAACF,SAAS;EACpF,MAAMG,UAAU,GAAG,IAAIC,GAAG,CAACX,OAAO,CAAC;EACnC,MAAMY,aAAa,GAAGF,UAAU,CAACG,QAAQ,EAAE,CAACC,QAAQ,CAACT,UAAU,CAAC;EAEhE,MAAMU,WAAW,GAAGH,aAAa,GAAGF,UAAU,CAACM,MAAM,GAAGN,UAAU,CAACO,MAAM,GAAGP,UAAU,CAACG,QAAQ,EAAE;EAEjG,OAAO,IAAAK,sBAAgB,EAACH,WAAW,EAAEd,eAAM,CAACkB,OAAO,CAAC;AACtD,CAAC;AAACxB,OAAA,CAAAI,kBAAA,GAAAA,kBAAA"}
|
package/package.json
CHANGED
|
@@ -13,7 +13,6 @@ var _fetchUserData = _interopRequireDefault(require("../../utils/fetchUserData")
|
|
|
13
13
|
var _config = _interopRequireDefault(require("../../config"));
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
15
|
const withFronteggApp = (app, options) => {
|
|
16
|
-
var _options$authOptions$, _options$authOptions;
|
|
17
16
|
const originalGetInitialProps = app.getInitialProps;
|
|
18
17
|
app.getInitialProps = async appContext => {
|
|
19
18
|
const {
|
|
@@ -42,8 +41,6 @@ const withFronteggApp = (app, options) => {
|
|
|
42
41
|
pageProps: (0, _extends2.default)({}, originalGetInitialProps ? await originalGetInitialProps(appContext) : {}, Component.getInitialProps ? await Component.getInitialProps(ctx) : {}, appContextSessionData.session == null ? {} : appContextSessionData, appEnvConfig)
|
|
43
42
|
};
|
|
44
43
|
};
|
|
45
|
-
_config.default.authRoutes = (_options$authOptions$ = options == null ? void 0 : (_options$authOptions = options.authOptions) == null ? void 0 : _options$authOptions.routes) != null ? _options$authOptions$ : {};
|
|
46
|
-
_config.default.fronteggAppOptions = options != null ? options : {};
|
|
47
44
|
function CustomFronteggApp(appProps) {
|
|
48
45
|
const {
|
|
49
46
|
user,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFronteggApp.js","names":["_react","_interopRequireDefault","require","_FronteggPagesProvider","_refreshAccessToken","_fetchUserData","_config","_jsxRuntime","withFronteggApp","app","options","
|
|
1
|
+
{"version":3,"file":"withFronteggApp.js","names":["_react","_interopRequireDefault","require","_FronteggPagesProvider","_refreshAccessToken","_fetchUserData","_config","_jsxRuntime","withFronteggApp","app","options","originalGetInitialProps","getInitialProps","appContext","ctx","Component","appEnvConfig","appContextSessionData","session","user","tenants","req","config","userData","fetchUserData","getSession","refreshAccessToken","getHeaders","_ctx$req$headers","_ctx$req","headers","Object","assign","pageProps","_extends2","default","CustomFronteggApp","appProps","activeTenant","envAppUrl","envBaseUrl","envClientId","jsx","children","exports"],"sources":["../../../../../packages/nextjs/src/pages/withFronteggApp/withFronteggApp.tsx"],"sourcesContent":["import React from 'react';\nimport type { AppContext, AppInitialProps, AppProps } from 'next/app';\nimport type { FronteggCustomAppClass, FronteggCustomApp, WithFronteggAppOptions } from './types';\nimport FronteggProvider from '../FronteggPagesProvider';\nimport refreshAccessToken from '../../utils/refreshAccessToken';\nimport fetchUserData from '../../utils/fetchUserData';\nimport config from '../../config';\nimport { AllUserData } from '../../types';\n\nexport const withFronteggApp = (app: FronteggCustomAppClass, options?: WithFronteggAppOptions): FronteggCustomApp => {\n const originalGetInitialProps = app.getInitialProps;\n\n app.getInitialProps = async (appContext: AppContext & AllUserData): Promise<AppInitialProps> => {\n const { ctx, Component } = appContext;\n\n let appEnvConfig = {};\n let appContextSessionData: AllUserData = {\n session: null,\n user: null,\n tenants: null,\n };\n\n if (ctx.req) {\n appEnvConfig = config.appEnvConfig;\n const userData = await fetchUserData({\n getSession: async () => await refreshAccessToken(ctx),\n getHeaders: async () => ctx.req?.headers ?? {},\n });\n Object.assign(appContextSessionData, userData);\n }\n\n Object.assign(appContext, appContextSessionData);\n\n return {\n pageProps: {\n ...(originalGetInitialProps ? await originalGetInitialProps(appContext) : {}),\n ...(Component.getInitialProps ? await Component.getInitialProps(ctx) : {}),\n ...(appContextSessionData.session == null ? {} : appContextSessionData),\n ...appEnvConfig,\n },\n };\n };\n\n function CustomFronteggApp(appProps: AppProps) {\n const { user, tenants, activeTenant, session, envAppUrl, envBaseUrl, envClientId } = appProps.pageProps;\n return (\n <FronteggProvider {...options} {...{ user, tenants, activeTenant, session, envAppUrl, envBaseUrl, envClientId }}>\n {app(appProps) as any}\n </FronteggProvider>\n );\n }\n\n CustomFronteggApp.getInitialProps = app.getInitialProps;\n\n return CustomFronteggApp as FronteggCustomApp;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,sBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,mBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAkC,IAAAK,WAAA,GAAAL,OAAA;AAG3B,MAAMM,eAAe,GAAGA,CAACC,GAA2B,EAAEC,OAAgC,KAAwB;EACnH,MAAMC,uBAAuB,GAAGF,GAAG,CAACG,eAAe;EAEnDH,GAAG,CAACG,eAAe,GAAG,MAAOC,UAAoC,IAA+B;IAC9F,MAAM;MAAEC,GAAG;MAAEC;IAAU,CAAC,GAAGF,UAAU;IAErC,IAAIG,YAAY,GAAG,CAAC,CAAC;IACrB,IAAIC,qBAAkC,GAAG;MACvCC,OAAO,EAAE,IAAI;MACbC,IAAI,EAAE,IAAI;MACVC,OAAO,EAAE;IACX,CAAC;IAED,IAAIN,GAAG,CAACO,GAAG,EAAE;MACXL,YAAY,GAAGM,eAAM,CAACN,YAAY;MAClC,MAAMO,QAAQ,GAAG,MAAM,IAAAC,sBAAa,EAAC;QACnCC,UAAU,EAAE,MAAAA,CAAA,KAAY,MAAM,IAAAC,2BAAkB,EAACZ,GAAG,CAAC;QACrDa,UAAU,EAAE,MAAAA,CAAA;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ion.js
CHANGED
package/sdkVersion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdkVersion.js","names":["version","exports","default","_default"],"sources":["../../../packages/nextjs/src/sdkVersion.ts"],"sourcesContent":["export default { version: '8.0.11-alpha.
|
|
1
|
+
{"version":3,"file":"sdkVersion.js","names":["version","exports","default","_default"],"sources":["../../../packages/nextjs/src/sdkVersion.ts"],"sourcesContent":["export default { version: '8.0.11-alpha.7627624188' };\n"],"mappings":";;;;;;eAAe;EAAEA,OAAO,EAAE;AAA0B,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAC,QAAA"}
|
package/utils/routing/index.js
CHANGED
|
@@ -22,7 +22,7 @@ function isAuthRoute(pathname) {
|
|
|
22
22
|
routesArr,
|
|
23
23
|
routesObj
|
|
24
24
|
} = getAuthRoutes();
|
|
25
|
-
if (_config.default.
|
|
25
|
+
if (_config.default.isHostedLogin) {
|
|
26
26
|
return routesObj.loginUrl === pathname || routesObj.logoutUrl === pathname || routesObj.hostedLoginRedirectUrl === pathname;
|
|
27
27
|
} else {
|
|
28
28
|
return routesArr.indexOf(pathname) !== -1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_reduxStore","require","_config","_interopRequireDefault","getAuthRoutes","routesObj","_extends2","default","authInitialState","routes","config","authRoutes","routesArr","Object","keys","reduce","p","key","isAuthRoute","pathname","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_reduxStore","require","_config","_interopRequireDefault","getAuthRoutes","routesObj","_extends2","default","authInitialState","routes","config","authRoutes","routesArr","Object","keys","reduce","p","key","isAuthRoute","pathname","isHostedLogin","loginUrl","logoutUrl","hostedLoginRedirectUrl","indexOf"],"sources":["../../../../../packages/nextjs/src/utils/routing/index.ts"],"sourcesContent":["import { authInitialState } from '@frontegg/redux-store';\nimport config from '../../config';\n\nexport function getAuthRoutes(): { routesArr: string[]; routesObj: Record<string, string> } {\n const routesObj = {\n ...authInitialState.routes,\n ...config.authRoutes,\n };\n const routesArr: string[] = Object.keys(routesObj).reduce(\n (p: string[], key: string) => [...p, (routesObj as any)[key]],\n []\n );\n return { routesArr, routesObj };\n}\n\nexport function isAuthRoute(pathname: string): boolean {\n const { routesArr, routesObj } = getAuthRoutes();\n\n if (config.isHostedLogin) {\n return (\n routesObj.loginUrl === pathname ||\n routesObj.logoutUrl === pathname ||\n routesObj.hostedLoginRedirectUrl === pathname\n );\n } else {\n return routesArr.indexOf(pathname) !== -1;\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEO,SAASG,aAAaA,CAAA,EAA+D;EAC1F,MAAMC,SAAS,OAAAC,SAAA,CAAAC,OAAA,MACVC,4BAAgB,CAACC,MAAM,EACvBC,eAAM,CAACC,UAAU,CACrB;EACD,MAAMC,SAAmB,GAAGC,MAAM,CAACC,IAAI,CAACT,SAAS,CAAC,CAACU,MAAM,CACvD,CAACC,CAAW,EAAEC,GAAW,KAAK,CAAC,GAAGD,CAAC,EAAGX,SAAS,CAASY,GAAG,CAAC,CAAC,EAC7D,EAAE,CACH;EACD,OAAO;IAAEL,SAAS;IAAEP;EAAU,CAAC;AACjC;AAEO,SAASa,WAAWA,CAACC,QAAgB,EAAW;EACrD,MAAM;IAAEP,SAAS;IAAEP;EAAU,CAAC,GAAGD,aAAa,EAAE;EAEhD,IAAIM,eAAM,CAACU,aAAa,EAAE;IACxB,OACEf,SAAS,CAACgB,QAAQ,KAAKF,QAAQ,IAC/Bd,SAAS,CAACiB,SAAS,KAAKH,QAAQ,IAChCd,SAAS,CAACkB,sBAAsB,KAAKJ,QAAQ;EAEjD,CAAC,MAAM;IACL,OAAOP,SAAS,CAACY,OAAO,CAACL,QAAQ,CAAC,KAAK,CAAC,CAAC;EAC3C;AACF"}
|