@thinkingcat/auth-utils 1.0.27 → 1.0.28
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 +23 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -451,7 +451,12 @@ async function createAuthResponse(accessToken, secret, options) {
|
|
|
451
451
|
});
|
|
452
452
|
// 3. NextAuth session cookie 생성
|
|
453
453
|
const nextAuthToken = await encodeNextAuthToken(jwt, secret);
|
|
454
|
-
debugLog('createAuthResponse', 'NextAuth session token encoded'
|
|
454
|
+
debugLog('createAuthResponse', 'NextAuth session token encoded:', {
|
|
455
|
+
tokenLength: nextAuthToken.length,
|
|
456
|
+
tokenPrefix: nextAuthToken.substring(0, 30) + '...',
|
|
457
|
+
jwtId: jwt.id,
|
|
458
|
+
jwtEmail: jwt.email?.substring(0, 20) + '...',
|
|
459
|
+
});
|
|
455
460
|
// 5. HTML 생성
|
|
456
461
|
const displayText = text || serviceId;
|
|
457
462
|
const html = redirectPath
|
|
@@ -480,7 +485,11 @@ async function createAuthResponse(accessToken, secret, options) {
|
|
|
480
485
|
cookieOptions.domain = cookieDomain;
|
|
481
486
|
}
|
|
482
487
|
response.cookies.set(nextAuthCookieName, nextAuthToken, cookieOptions);
|
|
483
|
-
debugLog('createAuthResponse', 'NextAuth session cookie set:',
|
|
488
|
+
debugLog('createAuthResponse', 'NextAuth session cookie set:', {
|
|
489
|
+
name: nextAuthCookieName,
|
|
490
|
+
valueLength: nextAuthToken.length,
|
|
491
|
+
...cookieOptions,
|
|
492
|
+
});
|
|
484
493
|
// 5. 커스텀 토큰 쿠키 설정
|
|
485
494
|
if (refreshToken) {
|
|
486
495
|
setCustomTokens(response, accessToken, refreshToken, {
|
|
@@ -1248,7 +1257,14 @@ async function verifyAndRefreshTokenWithNextAuth(req, nextAuthToken, secret, opt
|
|
|
1248
1257
|
const nextAuthSessionTokenCookieName = isProduction
|
|
1249
1258
|
? '__Secure-next-auth.session-token'
|
|
1250
1259
|
: 'next-auth.session-token';
|
|
1251
|
-
const
|
|
1260
|
+
const nextAuthCookieValue = req.cookies.get(nextAuthSessionTokenCookieName)?.value;
|
|
1261
|
+
const hasNextAuthSessionTokenCookie = !!nextAuthCookieValue;
|
|
1262
|
+
debugLog('verifyAndRefreshTokenWithNextAuth', 'NextAuth cookie check:', {
|
|
1263
|
+
cookieName: nextAuthSessionTokenCookieName,
|
|
1264
|
+
hasCookie: hasNextAuthSessionTokenCookie,
|
|
1265
|
+
cookieLength: nextAuthCookieValue?.length || 0,
|
|
1266
|
+
cookiePrefix: nextAuthCookieValue?.substring(0, 30) + '...' || 'none',
|
|
1267
|
+
});
|
|
1252
1268
|
// NextAuth 토큰 확인
|
|
1253
1269
|
const hasValidNextAuthToken = nextAuthToken && isValidToken(nextAuthToken);
|
|
1254
1270
|
// Access token 확인
|
|
@@ -1430,13 +1446,16 @@ async function handleMiddleware(req, config, options) {
|
|
|
1430
1446
|
let token = null;
|
|
1431
1447
|
if (getNextAuthToken) {
|
|
1432
1448
|
token = await getNextAuthToken(req);
|
|
1449
|
+
debugLog('handleMiddleware', 'Custom getNextAuthToken result:', { hasToken: !!token });
|
|
1433
1450
|
}
|
|
1434
1451
|
else {
|
|
1435
1452
|
try {
|
|
1436
1453
|
const { getToken } = await Promise.resolve().then(() => __importStar(require('next-auth/jwt')));
|
|
1437
1454
|
token = await getToken({ req, secret });
|
|
1455
|
+
debugLog('handleMiddleware', 'getToken result:', { hasToken: !!token });
|
|
1438
1456
|
}
|
|
1439
|
-
catch {
|
|
1457
|
+
catch (error) {
|
|
1458
|
+
debugLog('handleMiddleware', 'getToken failed:', error);
|
|
1440
1459
|
// NextAuth가 없으면 null 유지
|
|
1441
1460
|
}
|
|
1442
1461
|
}
|
package/package.json
CHANGED