@frontegg/nextjs 6.7.15-alpha.4096079815 → 6.7.15-alpha.4096825791

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 CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
 
6
6
  ### NextJS Wrapper 6.7.15:
7
+ - FR-10557 - Fix url for hosted login refresh token
7
8
  - FR-10557 - Fix jose import JWK key
8
9
  - FR-10557 - Fix social login embedded mode
9
10
  - FR-10557 - Add playwright tests for FornteggMiddleware
package/client/index.js CHANGED
@@ -4,9 +4,9 @@ import { F as FronteggConfig } from '../CookieManager-e50dc144.js';
4
4
  import 'iron-session';
5
5
  import 'jose';
6
6
  import '../api-25516652.js';
7
- import { useContext, useEffect } from 'react';
8
7
  import { useLoginWithRedirect, useLoginActions } from '@frontegg/react-hooks';
9
8
  import '@frontegg/rest-api';
9
+ import { useContext, useEffect } from 'react';
10
10
  import { A as AppContext } from '../FronteggClientProviderNext13-6f27dcd0.js';
11
11
  export { F as FronteggClientProviderNext13 } from '../FronteggClientProviderNext13-6f27dcd0.js';
12
12
  import '@frontegg/js';
package/common/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { a as COOKIE_MAX_LENGTH, C as CookieManager, F as FronteggConfig, f as fronteggErrors } from '../CookieManager-e50dc144.js';
2
- export { c as createSessionFromAccessToken, a as getAllUserData, g as getTokensFromCookie } from '../helpers-26190cc3.js';
2
+ export { c as createSessionFromAccessToken, a as getAllUserData, g as getTokensFromCookie } from '../helpers-dac37998.js';
3
3
  export { c as createGetSession } from '../createGetSession-2e1e4506.js';
4
4
  import 'tslib';
5
5
  import 'cookie';
@@ -7,6 +7,4 @@ import 'jose';
7
7
  import 'iron-session';
8
8
  import '../api-25516652.js';
9
9
  import '@frontegg/rest-api';
10
- import 'react';
11
- import '@frontegg/react-hooks';
12
10
  //# sourceMappingURL=index.js.map
@@ -2,12 +2,9 @@ import { __awaiter, __generator, __assign } from 'tslib';
2
2
  import { sealData, unsealData } from 'iron-session';
3
3
  import { jwtVerify } from 'jose';
4
4
  import { g as getUsers, a as getTenants } from './api-25516652.js';
5
- import 'react';
6
- import '@frontegg/react-hooks';
7
5
  import { F as FronteggConfig } from './CookieManager-e50dc144.js';
8
6
 
9
- var calculateExpiresInFromExp = function (exp) { return Math.floor((exp * 1000 - Date.now()) / 1000); };
10
-
7
+ var calculateExpiresInFromExp = function (exp) { return Math.floor((exp * 1000 - Date.now()) / 1000); };
11
8
  function createSessionFromAccessToken(data) {
12
9
  var _a, _b;
13
10
  return __awaiter(this, void 0, void 0, function () {
@@ -88,4 +85,4 @@ var getAllUserData = function (_a) {
88
85
  };
89
86
 
90
87
  export { getAllUserData as a, createSessionFromAccessToken as c, getTokensFromCookie as g };
91
- //# sourceMappingURL=helpers-26190cc3.js.map
88
+ //# sourceMappingURL=helpers-dac37998.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers-dac37998.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/index.js CHANGED
@@ -170,13 +170,13 @@ var FronteggBaseProvider = function (props) {
170
170
  return (React__default["default"].createElement(Connector$1, tslib.__assign({}, props, { framework: 'nextjs' }), props.children));
171
171
  };
172
172
 
173
- var calculateExpiresInFromExp = function (exp) { return Math.floor((exp * 1000 - Date.now()) / 1000); };
173
+ var calculateExpiresInFromExp$1 = function (exp) { return Math.floor((exp * 1000 - Date.now()) / 1000); };
174
174
  var ExpireInListener = function () {
175
175
  var user = reactHooks.useAuthUserOrNull();
176
176
  var actions = reactHooks.useAuthActions();
177
177
  React.useEffect(function () {
178
178
  if (user && (user === null || user === void 0 ? void 0 : user.expiresIn) == null) {
179
- actions.setUser(tslib.__assign(tslib.__assign({}, user), { expiresIn: calculateExpiresInFromExp(user['exp']) }));
179
+ actions.setUser(tslib.__assign(tslib.__assign({}, user), { expiresIn: calculateExpiresInFromExp$1(user['exp']) }));
180
180
  }
181
181
  }, [actions, user]);
182
182
  // eslint-disable-next-line react/jsx-no-useless-fragment
@@ -456,6 +456,7 @@ var getTenants = function (headers) { return tslib.__awaiter(void 0, void 0, voi
456
456
  });
457
457
  }); };
458
458
 
459
+ var calculateExpiresInFromExp = function (exp) { return Math.floor((exp * 1000 - Date.now()) / 1000); };
459
460
  function createSessionFromAccessToken(data) {
460
461
  var _a, _b;
461
462
  return tslib.__awaiter(this, void 0, void 0, function () {
@@ -831,7 +832,7 @@ function FronteggRouterProps(context) {
831
832
 
832
833
  function refreshTokenHostedLogin(ctx, headers) {
833
834
  return tslib.__awaiter(this, void 0, void 0, function () {
834
- var sealFromCookies, tokens;
835
+ var sealFromCookies, tokens, e_1;
835
836
  return tslib.__generator(this, function (_a) {
836
837
  switch (_a.label) {
837
838
  case 0:
@@ -843,7 +844,7 @@ function refreshTokenHostedLogin(ctx, headers) {
843
844
  if (!(tokens === null || tokens === void 0 ? void 0 : tokens.refreshToken)) {
844
845
  return [2 /*return*/, null];
845
846
  }
846
- return [4 /*yield*/, fetch("".concat(process.env['FRONTEGG_BASE_URL'], "/frontegg").concat(restApi.fronteggSilentRefreshTokenUrl), {
847
+ return [4 /*yield*/, fetch("".concat(process.env['FRONTEGG_BASE_URL'], "/frontegg/oauth/token"), {
847
848
  method: 'POST',
848
849
  credentials: 'include',
849
850
  body: JSON.stringify({
@@ -853,8 +854,9 @@ function refreshTokenHostedLogin(ctx, headers) {
853
854
  headers: {
854
855
  'accept-encoding': headers['accept-encoding'],
855
856
  'accept-language': headers['accept-language'],
856
- cookie: headers['cookie'],
857
857
  accept: headers['accept'],
858
+ 'content-type': 'application/json',
859
+ origin: headers['origin'],
858
860
  'user-agent': headers['user-agent'],
859
861
  connection: headers['connection'],
860
862
  'cache-control': headers['cache-control'],
@@ -864,7 +866,8 @@ function refreshTokenHostedLogin(ctx, headers) {
864
866
  })];
865
867
  case 2: return [2 /*return*/, _a.sent()];
866
868
  case 3:
867
- _a.sent();
869
+ e_1 = _a.sent();
870
+ console.error('refreshTokenHostedLogin', e_1);
868
871
  return [2 /*return*/, null];
869
872
  case 4: return [2 /*return*/];
870
873
  }
@@ -906,10 +909,9 @@ function refreshTokenEmbedded(ctx, headers, cookies) {
906
909
  });
907
910
  }
908
911
  function refreshToken(ctx) {
909
- var _a, _b;
912
+ var _a, _b, _c;
910
913
  return tslib.__awaiter(this, void 0, void 0, function () {
911
- var request, isSecured, headers, cookies, response, data, cookieHeader, newSetCookie, _c, session, decodedJwt, refreshToken_1, cookieValue, e_2;
912
- var _d;
914
+ var request, isSecured, headers, cookies, response, data, cookieHeader, newSetCookie, _d, session, decodedJwt, refreshToken_1, cookieValue, e_2;
913
915
  return tslib.__generator(this, function (_e) {
914
916
  switch (_e.label) {
915
917
  case 0:
@@ -947,14 +949,11 @@ function refreshToken(ctx) {
947
949
  return [4 /*yield*/, response.json()];
948
950
  case 5:
949
951
  data = _e.sent();
950
- (_d = {},
951
- _d[fronteggConfig.baseUrlHost] = fronteggConfig.cookieDomain,
952
- _d);
953
952
  cookieHeader = response.headers.raw()['set-cookie'];
954
953
  newSetCookie = (_a = CookieManager$1.modifySetCookie(cookieHeader, isSecured)) !== null && _a !== void 0 ? _a : [];
955
954
  return [4 /*yield*/, createSessionFromAccessToken(data)];
956
955
  case 6:
957
- _c = _e.sent(), session = _c[0], decodedJwt = _c[1], refreshToken_1 = _c[2];
956
+ _d = _e.sent(), session = _d[0], decodedJwt = _d[1], refreshToken_1 = _d[2];
958
957
  if (!session) {
959
958
  return [2 /*return*/, null];
960
959
  }
@@ -963,13 +962,10 @@ function refreshToken(ctx) {
963
962
  expires: new Date(decodedJwt.exp * 1000),
964
963
  isSecured: isSecured,
965
964
  });
966
- // if (typeof newSetCookie === 'string') {
967
- // newSetCookie = [ newSetCookie ];
968
- // }
969
965
  newSetCookie.push.apply(newSetCookie, cookieValue);
970
966
  (_b = ctx.res) === null || _b === void 0 ? void 0 : _b.setHeader('set-cookie', newSetCookie);
971
967
  return [2 /*return*/, {
972
- accessToken: data.accessToken,
968
+ accessToken: (_c = data.accessToken) !== null && _c !== void 0 ? _c : data.access_token,
973
969
  user: decodedJwt,
974
970
  refreshToken: refreshToken_1,
975
971
  }];
@@ -1162,7 +1158,7 @@ var proxyResCallback = function (proxyRes, req, res) {
1162
1158
  buffer = Buffer.concat([buffer, chunk], totalLength);
1163
1159
  });
1164
1160
  proxyRes.on('end', function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
1165
- var url, statusCode, isSuccess, bodyStr, isLogout, cookies, body, _a, session, decodedJwt, sessionCookie, e_2;
1161
+ var url, statusCode, isSuccess, bodyStr, isLogout, cookies, body, _a, session, decodedJwt, sessionCookie, e_1, e_2;
1166
1162
  var _b, _c;
1167
1163
  return tslib.__generator(this, function (_d) {
1168
1164
  switch (_d.label) {
@@ -1189,7 +1185,7 @@ var proxyResCallback = function (proxyRes, req, res) {
1189
1185
  case 1:
1190
1186
  _d.trys.push([1, 4, , 5]);
1191
1187
  body = JSON.parse(bodyStr);
1192
- if (!(body.accessToken && body.access_token)) return [3 /*break*/, 3];
1188
+ if (!(body.accessToken || body.access_token)) return [3 /*break*/, 3];
1193
1189
  return [4 /*yield*/, createSessionFromAccessToken(body)];
1194
1190
  case 2:
1195
1191
  _a = _d.sent(), session = _a[0], decodedJwt = _a[1];
@@ -1204,7 +1200,12 @@ var proxyResCallback = function (proxyRes, req, res) {
1204
1200
  _d.label = 3;
1205
1201
  case 3: return [3 /*break*/, 5];
1206
1202
  case 4:
1207
- _d.sent();
1203
+ e_1 = _d.sent();
1204
+ /** ignore api call if:
1205
+ * - Does not have accessToken / access_token
1206
+ * - Not json response
1207
+ */
1208
+ console.log('failed to create session', e_1);
1208
1209
  return [3 /*break*/, 5];
1209
1210
  case 5:
1210
1211
  Object.keys(proxyRes.headers)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frontegg/nextjs",
3
3
  "libName": "FronteggNextJs",
4
- "version": "6.7.15-alpha.4096079815",
4
+ "version": "6.7.15-alpha.4096825791",
5
5
  "author": "Frontegg LTD",
6
6
  "license": "MIT",
7
7
  "types": "dist/index.d.ts",
package/refreshToken.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { NextPageContext } from 'next/dist/shared/lib/utils';
2
- import { FronteggNextJSSession } from './common/types';
2
+ import { FronteggNextJSSession } from './common';
3
3
  export declare function refreshToken(ctx: NextPageContext): Promise<FronteggNextJSSession | null>;
package/server/index.js CHANGED
@@ -2,7 +2,7 @@ import { __awaiter, __generator, __rest, __assign } from 'tslib';
2
2
  import React from 'react';
3
3
  import { cookies, headers } from 'next/headers';
4
4
  import { C as CookieManager } from '../CookieManager-e50dc144.js';
5
- import { g as getTokensFromCookie, a as getAllUserData } from '../helpers-26190cc3.js';
5
+ import { g as getTokensFromCookie, a as getAllUserData } from '../helpers-dac37998.js';
6
6
  import { c as createGetSession } from '../createGetSession-2e1e4506.js';
7
7
  import 'jose';
8
8
  import '@frontegg/react-hooks';
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers-26190cc3.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}