@frontegg/nextjs 8.0.11 → 8.0.12-alpha.7739680683
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 +11 -0
- package/index.js +1 -1
- package/middleware/ProxyResponseCallback.js +3 -3
- package/middleware/ProxyResponseCallback.js.map +1 -1
- package/package.json +3 -3
- package/sdkVersion.js +1 -1
- package/sdkVersion.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
## [8.0.12](https://github.com/frontegg/frontegg-nextjs/compare/v8.0.11...v8.0.12) (2024-2-1)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### NextJS Wrapper 8.0.12:
|
|
7
|
+
- FR-15071 - Rewrite cookies on failure request to support Microsoft SSO activation process
|
|
8
|
+
- FR-13875 - support logout hosted login in middleware
|
|
9
|
+
- FR-14458 - fix build
|
|
10
|
+
- FR-14827 - allow alpha creation manually
|
|
11
|
+
- FR-14458 - Fixed error on middleware request since NextJs V14.0.2
|
|
1
12
|
# Change Log
|
|
2
13
|
|
|
3
14
|
## [8.0.11](https://github.com/frontegg/frontegg-nextjs/compare/v8.0.10...v8.0.11) (2024-1-24)
|
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ const ProxyResponseCallback = (proxyRes, req, res) => {
|
|
|
32
32
|
});
|
|
33
33
|
proxyRes.on('end', async () => {
|
|
34
34
|
try {
|
|
35
|
-
var _proxyRes$statusCode;
|
|
35
|
+
var _proxyRes$statusCode, _CookieManager$modify;
|
|
36
36
|
const url = req.url;
|
|
37
37
|
const statusCode = (_proxyRes$statusCode = proxyRes.statusCode) != null ? _proxyRes$statusCode : 500;
|
|
38
38
|
const isSuccess = statusCode >= 200 && statusCode < 400;
|
|
@@ -55,9 +55,8 @@ const ProxyResponseCallback = (proxyRes, req, res) => {
|
|
|
55
55
|
res.status(statusCode).end(bodyStr);
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
+
const cookies = (_CookieManager$modify = _cookies.default.modifySetCookie(proxyRes.headers['set-cookie'], isSecured)) != null ? _CookieManager$modify : [];
|
|
58
59
|
if (isSuccess) {
|
|
59
|
-
var _CookieManager$modify;
|
|
60
|
-
const cookies = (_CookieManager$modify = _cookies.default.modifySetCookie(proxyRes.headers['set-cookie'], isSecured)) != null ? _CookieManager$modify : [];
|
|
61
60
|
try {
|
|
62
61
|
if (bodyStr && bodyStr.length > 0) {
|
|
63
62
|
const body = JSON.parse(bodyStr);
|
|
@@ -102,6 +101,7 @@ const ProxyResponseCallback = (proxyRes, req, res) => {
|
|
|
102
101
|
Object.keys(proxyRes.headers).filter(header => header !== 'cookie').forEach(header => {
|
|
103
102
|
res.setHeader(header, `${proxyRes.headers[header]}`);
|
|
104
103
|
});
|
|
104
|
+
res.setHeader('set-cookie', cookies);
|
|
105
105
|
res.status(statusCode).end(bodyStr);
|
|
106
106
|
}
|
|
107
107
|
} catch (e) {
|
|
@@ -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","isFronteggOauthLogoutUrl","isHostedLogin","asPath","hostedLogoutUrl","getHostedLogoutUrl","headers","status","end","
|
|
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","_CookieManager$modify","url","statusCode","isSuccess","bodyStr","toString","isLogout","isFronteggLogoutUrl","CookieManager","removeCookies","cookieDomain","isFronteggOauthLogoutUrl","isHostedLogin","asPath","hostedLogoutUrl","getHostedLogoutUrl","headers","status","end","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 const cookies = CookieManager.modifySetCookie(proxyRes.headers['set-cookie'], isSecured) ?? [];\n if (isSuccess) {\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.setHeader('set-cookie', cookies);\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,I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AACf,UAAU,CAAC,CAACgB,GAAG,CAACd,OAAO,CAAC;MACrC;IACF,CAAC,CAAC,OAAOiC,CAAM,EAAE;MACf1D,MAAM,CAAC4D,KAAK,CAAC,8BAA8B,EAAEF,CAAC,CAAC;MAC/CnD,GAAG,CAAC+B,MAAM,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,uBAAuB,CAAC;IAC9C;EACF,CAAC,CAAC;AACJ,CAAC;AAAC,IAAA4B,QAAA,GAEa/D,qBAAqB;AAAAgE,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/nextjs",
|
|
3
3
|
"libName": "FronteggNextJs",
|
|
4
|
-
"version": "8.0.
|
|
4
|
+
"version": "8.0.12-alpha.7739680683",
|
|
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.176.0",
|
|
31
|
+
"@frontegg/react-hooks": "6.176.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: '8.0.
|
|
1
|
+
{"version":3,"file":"sdkVersion.js","names":["version","exports","default","_default"],"sources":["../../../packages/nextjs/src/sdkVersion.ts"],"sourcesContent":["export default { version: '8.0.12-alpha.7739680683' };\n"],"mappings":";;;;;;eAAe;EAAEA,OAAO,EAAE;AAA0B,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAC,QAAA"}
|