@frontegg/nextjs 6.7.12 → 6.7.13

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/index.js +26 -15
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## [6.7.13](https://github.com/frontegg/frontegg-nextjs/compare/v6.7.12...v6.7.13) (2023-1-31)
4
+
5
+
6
+ ### NextJS Wrapper 6.7.13:
7
+ - FR-10557 - Bypass session creation if bodyStr is empty
8
+
3
9
  ## [6.7.12](https://github.com/frontegg/frontegg-nextjs/compare/v6.7.11...v6.7.12) (2023-1-31)
4
10
 
5
11
  - FR-10549 - fix error login with sms
package/index.js CHANGED
@@ -1154,12 +1154,12 @@ var middlewarePromise = function (req, res) {
1154
1154
  buffer = Buffer.concat([buffer, chunk], totalLength);
1155
1155
  });
1156
1156
  proxyRes.on('end', function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
1157
- var url, statusCode, isSuccess, bodyStr, isLogout, body, _a, session, decodedJwt, cookies, sessionCookie, e_1;
1157
+ var url, statusCode, isSuccess, bodyStr, isLogout, cookies, body, _a, session, decodedJwt, sessionCookie, e_1, e_2;
1158
1158
  var _b, _c;
1159
1159
  return tslib.__generator(this, function (_d) {
1160
1160
  switch (_d.label) {
1161
1161
  case 0:
1162
- _d.trys.push([0, 4, , 5]);
1162
+ _d.trys.push([0, 7, , 8]);
1163
1163
  url = req.url;
1164
1164
  statusCode = (_b = proxyRes.statusCode) !== null && _b !== void 0 ? _b : 500;
1165
1165
  isSuccess = statusCode >= 200 && statusCode < 300;
@@ -1176,12 +1176,15 @@ var middlewarePromise = function (req, res) {
1176
1176
  resolve();
1177
1177
  return [2 /*return*/];
1178
1178
  }
1179
- if (!isSuccess) return [3 /*break*/, 2];
1179
+ if (!isSuccess) return [3 /*break*/, 5];
1180
+ cookies = (_c = CookieManager$1.modifySetCookie(proxyRes.headers['set-cookie'], isSecured)) !== null && _c !== void 0 ? _c : [];
1181
+ _d.label = 1;
1182
+ case 1:
1183
+ _d.trys.push([1, 3, , 4]);
1180
1184
  body = JSON.parse(bodyStr);
1181
1185
  return [4 /*yield*/, createSessionFromAccessToken(body)];
1182
- case 1:
1186
+ case 2:
1183
1187
  _a = _d.sent(), session = _a[0], decodedJwt = _a[1];
1184
- cookies = (_c = CookieManager$1.modifySetCookie(proxyRes.headers['set-cookie'], isSecured)) !== null && _c !== void 0 ? _c : [];
1185
1188
  if (session) {
1186
1189
  sessionCookie = CookieManager$1.createCookie({
1187
1190
  value: session,
@@ -1190,23 +1193,31 @@ var middlewarePromise = function (req, res) {
1190
1193
  });
1191
1194
  cookies.push.apply(cookies, sessionCookie);
1192
1195
  }
1196
+ return [3 /*break*/, 4];
1197
+ case 3:
1198
+ e_1 = _d.sent();
1199
+ if (bodyStr !== '') {
1200
+ console.error('[ERROR] FronteggMiddleware', 'proxy failed to parse response body', bodyStr, e_1);
1201
+ }
1202
+ return [3 /*break*/, 4];
1203
+ case 4:
1193
1204
  res.setHeader('set-cookie', cookies);
1194
1205
  res.status(statusCode).end(bodyStr);
1195
- return [3 /*break*/, 3];
1196
- case 2:
1206
+ return [3 /*break*/, 6];
1207
+ case 5:
1197
1208
  console.error('[ERROR] FronteggMiddleware', { url: url, statusCode: statusCode, bodyStr: bodyStr });
1198
1209
  res.status(statusCode).send(bodyStr);
1199
- _d.label = 3;
1200
- case 3:
1210
+ _d.label = 6;
1211
+ case 6:
1201
1212
  resolve();
1202
- return [3 /*break*/, 5];
1203
- case 4:
1204
- e_1 = _d.sent();
1205
- console.error('[ERROR] FronteggMiddleware', 'proxy failed to send request', e_1);
1213
+ return [3 /*break*/, 8];
1214
+ case 7:
1215
+ e_2 = _d.sent();
1216
+ console.error('[ERROR] FronteggMiddleware', 'proxy failed to send request', e_2);
1206
1217
  res.status(500).end('Internal Server Error');
1207
1218
  resolve();
1208
- return [3 /*break*/, 5];
1209
- case 5: return [2 /*return*/];
1219
+ return [3 /*break*/, 8];
1220
+ case 8: return [2 /*return*/];
1210
1221
  }
1211
1222
  });
1212
1223
  }); });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frontegg/nextjs",
3
3
  "libName": "FronteggNextJs",
4
- "version": "6.7.12",
4
+ "version": "6.7.13",
5
5
  "author": "Frontegg LTD",
6
6
  "license": "MIT",
7
7
  "types": "dist/index.d.ts",