@thinkingcat/auth-utils 1.0.46 → 1.0.47

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 (2) hide show
  1. package/dist/index.js +17 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -663,12 +663,23 @@ async function verifyAndRefreshToken(req, secret, options) {
663
663
  }
664
664
  jwt.accessTokenExpires = Date.now() + (15 * 60 * 1000);
665
665
  // NextAuth 세션 쿠키 생성
666
- // 주의: NextAuth 세션 쿠키를 자동으로 관리하므로, 직접 설정하는 것이 문제를 일으킬 수 있습니다.
667
- // 따라서 커스텀 토큰만 설정하고, NextAuth 세션은 JWT 콜백에서 처리하도록 합니다.
668
- debugLog('verifyAndRefreshToken', 'Skipping NextAuth session cookie - will be handled by NextAuth JWT callback', {
669
- hasJWT: !!jwt,
670
- jwtId: jwt?.id,
671
- });
666
+ // 미들웨어에서는 NextAuth JWT callback이 실행되지 않으므로,
667
+ // refresh NextAuth 세션 쿠키를 직접 설정해야 합니다.
668
+ try {
669
+ const encodedSessionToken = await encodeNextAuthToken(jwt, secret, 30 * 24 * 60 * 60);
670
+ setNextAuthToken(response, encodedSessionToken, {
671
+ isProduction,
672
+ cookieDomain,
673
+ });
674
+ debugLog('verifyAndRefreshToken', 'NextAuth session cookie set successfully', {
675
+ hasJWT: !!jwt,
676
+ jwtId: jwt?.id,
677
+ });
678
+ }
679
+ catch (error) {
680
+ debugError('verifyAndRefreshToken', 'Failed to set NextAuth session cookie:', error);
681
+ // NextAuth 세션 쿠키 설정 실패해도 커스텀 토큰은 설정하므로 계속 진행
682
+ }
672
683
  // 커스텀 토큰 쿠키 설정
673
684
  if (newRefreshToken) {
674
685
  setCustomTokens(response, refreshResult.accessToken, newRefreshToken, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkingcat/auth-utils",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "Authentication utilities for ThinkingCat SSO services with conditional logging",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",