@frontegg/nextjs 6.7.21-alpha.4455122973 → 6.7.21-alpha.4478596126
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 +3 -1
- package/api/urls.js.map +1 -1
- package/api/utils.d.ts +3 -9
- package/api/utils.js +26 -14
- package/api/utils.js.map +1 -1
- package/index.js +1 -1
- package/middleware/helpers.js +4 -2
- package/middleware/helpers.js.map +1 -1
- package/package.json +3 -3
- package/sdkVersion.js +1 -1
- package/sdkVersion.js.map +1 -1
- package/utils/initializeFronteggApp/index.js +3 -3
- package/utils/initializeFronteggApp/index.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## [6.7.21](https://github.com/frontegg/frontegg-nextjs/compare/v6.7.20...v6.7.21) (2023-3-
|
|
3
|
+
## [6.7.21](https://github.com/frontegg/frontegg-nextjs/compare/v6.7.20...v6.7.21) (2023-3-21)
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
### NextJS Wrapper 6.7.21:
|
|
7
|
+
- FR-10654 - Adjust middleware forward regex paths
|
|
8
|
+
- FR-10654 - Update @frontegg/js to 6.81.0 and add appName to createFro…
|
|
7
9
|
- FR-10654 - Add missing requestAuthorize for appDir architecture
|
|
8
10
|
- FR-10654 - Use CJS build instead of ESM
|
|
9
11
|
- FR-10654 - Prevent overriding default package.json file in dist folder
|
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","asPath","config","appUrl","encodeURIComponent","asUrl","URL","buildLogoutRoute","baseUrl"],"sources":["../../../../packages/nextjs/src/api/urls.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"urls.js","names":["_restApi","require","_config","_interopRequireDefault","ApiUrls","WellKnown","jwks","refreshToken","embedded","fronteggRefreshTokenUrl","hosted","exports","buildLoginRoute","redirectUrl","asPath","config","appUrl","encodeURIComponent","asUrl","URL","buildLogoutRoute","baseUrl"],"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\ninterface 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 * @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(redirectUrl: string): BuildRouteResult {\n const asPath = `${config.appUrl}/account/login?redirectUrl=${encodeURIComponent(redirectUrl)}`;\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;AACO,SAASQ,eAAeA,CAACC,WAAmB,EAAoB;EACrE,MAAMC,MAAM,GAAI,GAAEC,eAAM,CAACC,MAAO,8BAA6BC,kBAAkB,CAACJ,WAAW,CAAE,EAAC;EAC9F,MAAMK,KAAK,GAAG,IAAIC,GAAG,CAACL,MAAM,CAAC;EAC7B,OAAO;IACLA,MAAM;IACNI;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAACP,WAAmB,EAAEQ,OAAe,EAAoB;EACvF,MAAMP,MAAM,GAAI,GAAEO,OAAQ,0CAAyCJ,kBAAkB,CAACJ,WAAW,CAAE,EAAC;EACpG,MAAMK,KAAK,GAAG,IAAIC,GAAG,CAACL,MAAM,EAAEO,OAAO,CAAC;EACtC,OAAO;IACLP,MAAM;IACNI;EACF,CAAC;AACH"}
|
package/api/utils.d.ts
CHANGED
|
@@ -30,17 +30,11 @@ export declare function buildRequestHeaders(headers: Record<string, any>, additi
|
|
|
30
30
|
*/
|
|
31
31
|
export declare const parseHttpResponse: <T>(res: Response) => Promise<T | undefined>;
|
|
32
32
|
/**
|
|
33
|
-
* Checks if the given path
|
|
33
|
+
* Checks if the given path should be forwarded to the Next.js server middleware.
|
|
34
|
+
*
|
|
34
35
|
*
|
|
35
36
|
* @param {string} path - The path to check for authentication API routes.
|
|
36
37
|
* @returns {boolean} Returns true if the path is a frontegg authentication API route or ends with '/postlogin' or '/prelogin'; otherwise, returns false.
|
|
37
38
|
*/
|
|
38
|
-
export declare function
|
|
39
|
-
/**
|
|
40
|
-
* Checks if the given path matches the pattern for a social login prelogin route.
|
|
41
|
-
*
|
|
42
|
-
* @param {string} path - The path to check for a social login prelogin route pattern.
|
|
43
|
-
* @returns {boolean} Returns true if the path matches the social login prelogin route pattern; otherwise, returns false.
|
|
44
|
-
*/
|
|
45
|
-
export declare function isSocialLoginPath(path: string): boolean;
|
|
39
|
+
export declare function isMiddlewarePath(path: string): boolean;
|
|
46
40
|
export {};
|
package/api/utils.js
CHANGED
|
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.Post = exports.Get = void 0;
|
|
8
8
|
exports.buildRequestHeaders = buildRequestHeaders;
|
|
9
|
-
exports.
|
|
10
|
-
exports.isSocialLoginPath = isSocialLoginPath;
|
|
9
|
+
exports.isMiddlewarePath = isMiddlewarePath;
|
|
11
10
|
exports.parseHttpResponse = void 0;
|
|
12
11
|
exports.removeInvalidHeaders = removeInvalidHeaders;
|
|
13
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
@@ -101,23 +100,36 @@ const parseHttpResponse = async res => {
|
|
|
101
100
|
};
|
|
102
101
|
|
|
103
102
|
/**
|
|
104
|
-
* Checks if the given path
|
|
103
|
+
* Checks if the given path should be forwarded to the Next.js server middleware.
|
|
104
|
+
*
|
|
105
105
|
*
|
|
106
106
|
* @param {string} path - The path to check for authentication API routes.
|
|
107
107
|
* @returns {boolean} Returns true if the path is a frontegg authentication API route or ends with '/postlogin' or '/prelogin'; otherwise, returns false.
|
|
108
108
|
*/
|
|
109
109
|
exports.parseHttpResponse = parseHttpResponse;
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
function isMiddlewarePath(path) {
|
|
111
|
+
let isAuthPath = _restApi.fronteggAuthApiRoutesRegex.find(pathRegex => {
|
|
112
|
+
if (typeof pathRegex === 'string') {
|
|
113
|
+
return pathRegex === path;
|
|
114
|
+
} else {
|
|
115
|
+
return pathRegex.test(path);
|
|
116
|
+
}
|
|
117
|
+
}) != null;
|
|
113
118
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
// if(!isAuthPath){
|
|
120
|
+
// isAuthPath = /^\/identity\/resources\/auth\/v[0-9]*\/user\/sso\/[^\/]*\/postlogin$/g.test(path)
|
|
121
|
+
// }
|
|
122
|
+
// if(!isAuthPath){
|
|
123
|
+
// isAuthPath = /^\/identity\/resources\/auth\/v[0-9]*\/passwordless\/[^\/]*\/prelogin$/g.test(path)
|
|
124
|
+
// }
|
|
125
|
+
// if(!isAuthPath){
|
|
126
|
+
// isAuthPath = /^\/identity\/resources\/auth\/v[0-9]*\/[^\/]*\/prelogin$/g.test(path)
|
|
127
|
+
// }
|
|
128
|
+
|
|
129
|
+
if (!isAuthPath) {
|
|
130
|
+
const isSocialLoginPath = /^\/identity\/resources\/auth\/v[0-9]*\/user\/sso\/default\/[^\/]*\/prelogin$/.test(path);
|
|
131
|
+
isAuthPath = (path.endsWith('/postlogin') || path.endsWith('/prelogin')) && !isSocialLoginPath;
|
|
132
|
+
}
|
|
133
|
+
return isAuthPath;
|
|
122
134
|
}
|
|
123
135
|
//# sourceMappingURL=utils.js.map
|
package/api/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_config","_interopRequireDefault","require","_sdkVersion","_package","_restApi","_constants","Get","url","credentials","headers","fetch","method","exports","Post","body","removeInvalidHeaders","newHeaders","_extends2","default","Object","keys","forEach","key","val","Array","isArray","headerCharRegex","exec","undefined","length","buildRequestHeaders","additionalHeaders","cookie","replace","preparedHeaders","authorization","accept","origin","config","baseUrl","nextjsPkg","version","sdkVersion","parseHttpResponse","res","ok","json","
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_config","_interopRequireDefault","require","_sdkVersion","_package","_restApi","_constants","Get","url","credentials","headers","fetch","method","exports","Post","body","removeInvalidHeaders","newHeaders","_extends2","default","Object","keys","forEach","key","val","Array","isArray","headerCharRegex","exec","undefined","length","buildRequestHeaders","additionalHeaders","cookie","replace","preparedHeaders","authorization","accept","origin","config","baseUrl","nextjsPkg","version","sdkVersion","parseHttpResponse","res","ok","json","isMiddlewarePath","path","isAuthPath","fronteggAuthApiRoutesRegex","find","pathRegex","test","isSocialLoginPath","endsWith"],"sources":["../../../../packages/nextjs/src/api/utils.ts"],"sourcesContent":["import config from '../config';\nimport sdkVersion from '../sdkVersion';\nimport nextjsPkg from 'next/package.json';\nimport { fronteggAuthApiRoutesRegex } from '@frontegg/rest-api';\nimport { headerCharRegex } from '../utils/common/constants';\n\ninterface GetRequestOptions {\n url: string;\n credentials?: RequestCredentials;\n headers?: HeadersInit;\n}\n\nexport const Get = ({ url, credentials = 'include', headers }: GetRequestOptions) =>\n fetch(url, { method: 'GET', credentials, headers });\n\ninterface PostRequestOptions extends GetRequestOptions {\n body: string;\n}\n\nexport const Post = ({ url, credentials = 'include', headers, body }: PostRequestOptions) =>\n fetch(url, { method: 'POST', credentials, headers, body });\n\n/**\n * NodeJS 18 start using undici as http request handler,\n * undici http request does not accept invalid headers\n * for more details see:\n * https://github.com/nodejs/undici/blob/2b260c997ad4efe4ed2064b264b4b546a59e7a67/lib/core/request.js#L282\n * @param headers\n */\nexport function removeInvalidHeaders(headers: Record<string, string>) {\n const newHeaders = { ...headers };\n Object.keys(newHeaders).forEach((key: string) => {\n const val: any = headers[key];\n if (val && typeof val === 'object' && !Array.isArray(val)) {\n delete newHeaders[key];\n } else if (headerCharRegex.exec(val) !== null) {\n delete newHeaders[key];\n } else if (val === undefined || val === null) {\n delete newHeaders[key];\n } else if (key.length === 10 && key === 'connection') {\n delete newHeaders[key];\n }\n });\n return newHeaders;\n}\n\n/**\n * Build fetch request headers, remove invalid http headers\n * @param headers - Incoming request headers\n * @param additionalHeaders - Specify additional headers\n */\nexport function buildRequestHeaders(\n headers: Record<string, any>,\n additionalHeaders: Record<string, string> = {}\n): Record<string, string> {\n let cookie = headers['cookie'];\n if (cookie != null && typeof cookie === 'string') {\n cookie = cookie.replace(/fe_session-[^=]*=[^;]*$/, '').replace(/fe_session-[^=]*=[^;]*;/, '');\n }\n const preparedHeaders: Record<string, string> = {\n authorization: headers['authorization'],\n 'accept-encoding': headers['accept-encoding'],\n 'accept-language': headers['accept-language'],\n accept: headers['accept'],\n 'content-type': 'application/json',\n origin: config.baseUrl,\n cookie,\n 'user-agent': headers['user-agent'],\n 'cache-control': headers['cache-control'],\n 'x-frontegg-framework': `next@${nextjsPkg.version}`,\n 'x-frontegg-sdk': `@frontegg/nextjs@${sdkVersion.version}`,\n };\n\n return removeInvalidHeaders({\n ...preparedHeaders,\n ...additionalHeaders,\n });\n}\n\n/**\n * Return parsed json response if http status code = 200\n * @param res\n */\nexport const parseHttpResponse = async <T>(res: Response): Promise<T | undefined> => {\n if (!res.ok) {\n return undefined;\n }\n return await res.json();\n};\n\n/**\n * Checks if the given path should be forwarded to the Next.js server middleware.\n *\n *\n * @param {string} path - The path to check for authentication API routes.\n * @returns {boolean} Returns true if the path is a frontegg authentication API route or ends with '/postlogin' or '/prelogin'; otherwise, returns false.\n */\nexport function isMiddlewarePath(path: string): boolean {\n let isAuthPath =\n fronteggAuthApiRoutesRegex.find((pathRegex) => {\n if (typeof pathRegex === 'string') {\n return pathRegex === path;\n } else {\n return pathRegex.test(path);\n }\n }) != null;\n\n // if(!isAuthPath){\n // isAuthPath = /^\\/identity\\/resources\\/auth\\/v[0-9]*\\/user\\/sso\\/[^\\/]*\\/postlogin$/g.test(path)\n // }\n // if(!isAuthPath){\n // isAuthPath = /^\\/identity\\/resources\\/auth\\/v[0-9]*\\/passwordless\\/[^\\/]*\\/prelogin$/g.test(path)\n // }\n // if(!isAuthPath){\n // isAuthPath = /^\\/identity\\/resources\\/auth\\/v[0-9]*\\/[^\\/]*\\/prelogin$/g.test(path)\n // }\n\n if (!isAuthPath) {\n const isSocialLoginPath = /^\\/identity\\/resources\\/auth\\/v[0-9]*\\/user\\/sso\\/default\\/[^\\/]*\\/prelog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C3D,CAAC;EAED,OAAO1B,oBAAoB,KAAAE,SAAA,CAAAC,OAAA,MACtBgB,eAAe,EACfH,iBAAiB,EACpB;AACJ;;AAEA;AACA;AACA;AACA;AACO,MAAMY,iBAAiB,GAAG,MAAUC,GAAa,IAA6B;EACnF,IAAI,CAACA,GAAG,CAACC,EAAE,EAAE;IACX,OAAOjB,SAAS;EAClB;EACA,OAAO,MAAMgB,GAAG,CAACE,IAAI,EAAE;AACzB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AANAlC,OAAA,CAAA+B,iBAAA,GAAAA,iBAAA;AAOO,SAASI,gBAAgBA,CAACC,IAAY,EAAW;EACtD,IAAIC,UAAU,GACZC,mCAA0B,CAACC,IAAI,CAAEC,SAAS,IAAK;IAC7C,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;MACjC,OAAOA,SAAS,KAAKJ,IAAI;IAC3B,CAAC,MAAM;MACL,OAAOI,SAAS,CAACC,IAAI,CAACL,IAAI,CAAC;IAC7B;EACF,CAAC,CAAC,IAAI,IAAI;;EAEZ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,IAAI,CAACC,UAAU,EAAE;IACf,MAAMK,iBAAiB,GAAG,8EAA8E,CAACD,IAAI,CAACL,IAAI,CAAC;IACnHC,UAAU,GAAG,CAACD,IAAI,CAACO,QAAQ,CAAC,YAAY,CAAC,IAAIP,IAAI,CAACO,QAAQ,CAAC,WAAW,CAAC,KAAK,CAACD,iBAAiB;EAChG;EAEA,OAAOL,UAAU;AACnB"}
|
package/index.js
CHANGED
package/middleware/helpers.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.rewritePath = exports.isFronteggLogoutUrl = void 0;
|
|
7
|
-
var _restApi = require("@frontegg/rest-api");
|
|
8
7
|
/**
|
|
9
8
|
* If pattern information matching the input url information is found in the `pathRewrite` array,
|
|
10
9
|
* the url value is partially replaced with the `pathRewrite.replaceStr` value.
|
|
@@ -36,7 +35,10 @@ const rewritePath = (url, pathRewrite) => {
|
|
|
36
35
|
};
|
|
37
36
|
exports.rewritePath = rewritePath;
|
|
38
37
|
const isFronteggLogoutUrl = url => {
|
|
39
|
-
return
|
|
38
|
+
return url.endsWith('/logout');
|
|
39
|
+
// return (
|
|
40
|
+
// fronteggAuthApiRoutesRegex.filter((path) => path.endsWith('/logout')).findIndex((route) => url.endsWith(route)) >= 0
|
|
41
|
+
// );
|
|
40
42
|
};
|
|
41
43
|
exports.isFronteggLogoutUrl = isFronteggLogoutUrl;
|
|
42
44
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["
|
|
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) => {\n return url.endsWith('/logout');\n // return (\n // fronteggAuthApiRoutesRegex.filter((path) => path.endsWith('/logout')).findIndex((route) => url.endsWith(route)) >= 0\n // );\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAGA,CACzBC,GAAW,EACXC,WAAqF,KAClF;EACH,IAAIC,KAAK,CAACC,OAAO,CAACF,WAAW,CAAC,EAAE;IAC9B,KAAK,MAAMG,IAAI,IAAIH,WAAW,EAAE;MAC9B,MAAM;QAAEI,UAAU;QAAEC;MAAW,CAAC,GAAGF,IAAI;MACvC,MAAMG,OAAO,GAAGC,MAAM,CAACH,UAAU,CAAC;MAClC,IAAIE,OAAO,CAACE,IAAI,CAACT,GAAG,CAAW,EAAE;QAC/B,OAAOA,GAAG,CAACU,OAAO,CAACH,OAAO,EAAED,UAAU,CAAC;MACzC;IACF;EACF,CAAC,MAAM;IACL,KAAK,MAAMD,UAAU,IAAIJ,WAAW,EAAE;MACpC,MAAMM,OAAO,GAAGC,MAAM,CAACH,UAAU,CAAC;MAClC,MAAMM,IAAI,GAAGV,WAAW,CAACI,UAAU,CAAC;MACpC,IAAIE,OAAO,CAACE,IAAI,CAACT,GAAG,CAAW,EAAE;QAC/B,OAAOA,GAAG,CAACU,OAAO,CAACH,OAAO,EAAEI,IAAI,CAAC;MACnC;IACF;EACF;EACA,OAAOX,GAAG;AACZ,CAAC;AAACY,OAAA,CAAAb,WAAA,GAAAA,WAAA;AAEK,MAAMc,mBAAmB,GAAIb,GAAW,IAAK;EAClD,OAAOA,GAAG,CAACc,QAAQ,CAAC,SAAS,CAAC;EAC9B;EACA;EACA;AACF,CAAC;AAACF,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/nextjs",
|
|
3
3
|
"libName": "FronteggNextJs",
|
|
4
|
-
"version": "6.7.21-alpha.
|
|
4
|
+
"version": "6.7.21-alpha.4478596126",
|
|
5
5
|
"author": "Frontegg LTD",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"lint-json": "eslint -c .eslintrc.json -o ./lint-report.json --format json --no-color ./src/**/*.{ts,tsx}"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@frontegg/js": "6.
|
|
31
|
-
"@frontegg/react-hooks": "6.
|
|
30
|
+
"@frontegg/js": "6.81.0",
|
|
31
|
+
"@frontegg/react-hooks": "6.81.0",
|
|
32
32
|
"http-proxy": "^1.18.1",
|
|
33
33
|
"iron-session": "^6.3.1",
|
|
34
34
|
"jose": "^4.12.2"
|
package/sdkVersion.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: '6.7.21-alpha.
|
|
1
|
+
{"version":3,"file":"sdkVersion.js","names":["version","exports","default","_default"],"sources":["../../../packages/nextjs/src/sdkVersion.ts"],"sourcesContent":["export default { version: '6.7.21-alpha.4478596126' };\n"],"mappings":";;;;;;eAAe;EAAEA,OAAO,EAAE;AAA0B,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAC,QAAA"}
|
|
@@ -54,8 +54,7 @@ const initializeFronteggApp = ({
|
|
|
54
54
|
return additionalHeaders;
|
|
55
55
|
},
|
|
56
56
|
baseUrl: path => {
|
|
57
|
-
|
|
58
|
-
if (shouldGoThroughFronteggMiddleWare) {
|
|
57
|
+
if ((0, _utils.isMiddlewarePath)(path)) {
|
|
59
58
|
return `${options.envAppUrl}/api`;
|
|
60
59
|
} else {
|
|
61
60
|
return options.envBaseUrl;
|
|
@@ -80,7 +79,8 @@ const initializeFronteggApp = ({
|
|
|
80
79
|
tenantsState
|
|
81
80
|
});
|
|
82
81
|
const sharedStore = (0, _reduxStore.createFronteggStore)({
|
|
83
|
-
context: contextOptions
|
|
82
|
+
context: contextOptions,
|
|
83
|
+
appName: appName != null ? appName : 'default'
|
|
84
84
|
}, storeHolder, options.previewMode, authOptions, {
|
|
85
85
|
auth: authOptions != null ? authOptions : {},
|
|
86
86
|
audits: (_options$auditsOption = options.auditsOptions) != null ? _options$auditsOption : {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_js","require","_reduxStore","_sdkVersion","_interopRequireDefault","_package","_utils","initializeFronteggApp","options","onRedirectTo","appName","storeHolder","_options$authOptions","_options$authOptions2","_options$hostedLoginB","_options$authOptions$","_options$authOptions3","_options$auditsOption","session","user","tenants","accessToken","refreshToken","contextOptions","_extends2","default","requestCredentials","additionalHeadersResolver","_options$contextOptio","additionalHeaders","originalAdditionalHeadersResolver","push","e","Array","isArray","key","value","nextjsPkg","version","sdkVersion","baseUrl","path","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_js","require","_reduxStore","_sdkVersion","_interopRequireDefault","_package","_utils","initializeFronteggApp","options","onRedirectTo","appName","storeHolder","_options$authOptions","_options$authOptions2","_options$hostedLoginB","_options$authOptions$","_options$authOptions3","_options$auditsOption","session","user","tenants","accessToken","refreshToken","contextOptions","_extends2","default","requestCredentials","additionalHeadersResolver","_options$contextOptio","additionalHeaders","originalAdditionalHeadersResolver","push","e","Array","isArray","key","value","nextjsPkg","version","sdkVersion","baseUrl","path","isMiddlewarePath","envAppUrl","envBaseUrl","clientId","envClientId","tenantsState","defaultTenantsState","authOptions","userData","undefined","isLoading","isAuthenticated","hostedLoginBox","disableSilentRefresh","sharedStore","createFronteggStore","context","previewMode","auth","audits","auditsOptions","urlStrategy","createdApp","AppHolder","getInstance","store","_options$hostedLoginB2","_options$customLoginB","initialize","customLoginBox","basename","_default","exports"],"sources":["../../../../../packages/nextjs/src/utils/initializeFronteggApp/index.ts"],"sourcesContent":["import { AppHolder, FronteggApp, initialize } from '@frontegg/js';\nimport { createFronteggStore, AuthState, tenantsState as defaultTenantsState } from '@frontegg/redux-store';\nimport { KeyValuePair } from '@frontegg/rest-api';\nimport { FronteggAppOptions } from '@frontegg/types';\nimport sdkVersion from '../../sdkVersion';\nimport type { FronteggProviderOptions } from '../../types';\nimport nextjsPkg from 'next/package.json';\nimport { isMiddlewarePath } from '../../api/utils';\n\ntype CreateOrGetFronteggAppParams = {\n options: FronteggProviderOptions;\n onRedirectTo: AuthState['onRedirectTo'];\n appName?: string;\n storeHolder: any;\n};\n\nconst initializeFronteggApp = ({\n options,\n onRedirectTo,\n appName,\n storeHolder,\n}: CreateOrGetFronteggAppParams): FronteggApp => {\n const { session, user, tenants } = options;\n const { accessToken, refreshToken } = session ?? {};\n\n const contextOptions: FronteggAppOptions['contextOptions'] = {\n requestCredentials: 'include' as RequestCredentials,\n ...options.contextOptions,\n additionalHeadersResolver: async () => {\n const additionalHeaders: KeyValuePair[] = [];\n const originalAdditionalHeadersResolver = options.contextOptions?.additionalHeadersResolver;\n if (typeof originalAdditionalHeadersResolver === 'function') {\n try {\n additionalHeaders.push(...(await originalAdditionalHeadersResolver()));\n } catch (e) {\n /** ignore failed additionalHeadersResolver */\n }\n } else if (Array.isArray(originalAdditionalHeadersResolver)) {\n additionalHeaders.push(...(originalAdditionalHeadersResolver as KeyValuePair[]));\n }\n additionalHeaders.push({\n key: 'x-frontegg-framework',\n value: `next@${nextjsPkg.version}`,\n });\n additionalHeaders.push({\n key: 'x-frontegg-sdk',\n value: `@frontegg/nextjs@${sdkVersion.version}`,\n });\n return additionalHeaders;\n },\n baseUrl: (path: string) => {\n if (isMiddlewarePath(path)) {\n return `${options.envAppUrl}/api`;\n } else {\n return options.envBaseUrl;\n }\n },\n clientId: options.envClientId,\n };\n\n const tenantsState = {\n ...defaultTenantsState,\n tenants: tenants || [],\n ...options.authOptions?.tenantsState,\n };\n const userData = user\n ? {\n ...user,\n accessToken: accessToken ?? '',\n refreshToken: refreshToken ?? undefined,\n ...options.authOptions?.user,\n }\n : null;\n\n const authOptions: FronteggAppOptions['authOptions'] = {\n ...options.authOptions,\n onRedirectTo,\n isLoading: false,\n isAuthenticated: !!options.session,\n hostedLoginBox: options.hostedLoginBox ?? false,\n disableSilentRefresh: options.authOptions?.disableSilentRefresh ?? true,\n user: userData,\n tenantsState,\n };\n\n const sharedStore = createFronteggStore(\n { context: contextOptions, appName: appName ?? 'default' },\n storeHolder,\n options.previewMode,\n authOptions,\n {\n auth: authOptions ?? {},\n audits: options.auditsOptions ?? {},\n },\n false,\n options.urlStrategy\n );\n\n let createdApp;\n try {\n createdApp = AppHolder.getInstance(appName ?? 'default');\n createdApp.store = sharedStore;\n } catch (e) {\n createdApp = initialize(\n {\n ...options,\n store: sharedStore,\n hostedLoginBox: options.hostedLoginBox ?? false,\n customLoginBox: options.customLoginBox ?? false,\n basename: options.basename,\n authOptions,\n contextOptions,\n onRedirectTo,\n },\n appName ?? 'default'\n );\n }\n return createdApp;\n};\n\nexport default initializeFronteggApp;\n"],"mappings":";;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AASA,MAAMM,qBAAqB,GAAGA,CAAC;EAC7BC,OAAO;EACPC,YAAY;EACZC,OAAO;EACPC;AAC4B,CAAC,KAAkB;EAAA,IAAAC,oBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;EAC/C,MAAM;IAAEC,OAAO;IAAEC,IAAI;IAAEC;EAAQ,CAAC,GAAGZ,OAAO;EAC1C,MAAM;IAAEa,WAAW;IAAEC;EAAa,CAAC,GAAGJ,OAAO,WAAPA,OAAO,GAAI,CAAC,CAAC;EAEnD,MAAMK,cAAoD,OAAAC,SAAA,CAAAC,OAAA;IACxDC,kBAAkB,EAAE;EAA+B,GAChDlB,OAAO,CAACe,cAAc;IACzBI,yBAAyB,EAAE,MAAAA,CAAA,KAAY;MAAA,IAAAC,qBAAA;MACr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