@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.
- package/dist/index.js +17 -6
- 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
|
-
//
|
|
667
|
-
//
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
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