@thinkingcat/auth-utils 1.0.41 → 1.0.42

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 +19 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -461,11 +461,11 @@ async function createAuthResponse(accessToken, secret, options) {
461
461
  ? NextResponseClass.redirect(new URL(redirectPath, req.url), { status: 302 })
462
462
  : NextResponseClass.json({ success: true, message: text || 'Authentication successful' }, { status: 200 });
463
463
  // 4. NextAuth 세션 쿠키 생성 (Edge Runtime에서도 작동하도록 encodeNextAuthToken 사용)
464
+ const nextAuthCookieName = isProduction
465
+ ? '__Secure-next-auth.session-token'
466
+ : 'next-auth.session-token';
464
467
  try {
465
468
  const nextAuthToken = await encodeNextAuthToken(jwt, secret);
466
- const nextAuthCookieName = isProduction
467
- ? '__Secure-next-auth.session-token'
468
- : 'next-auth.session-token';
469
469
  const cookieOptions = {
470
470
  httpOnly: true,
471
471
  secure: isProduction,
@@ -503,6 +503,11 @@ async function createAuthResponse(accessToken, secret, options) {
503
503
  });
504
504
  }
505
505
  debugLog('createAuthResponse', 'Custom tokens set successfully');
506
+ console.log('[createAuthResponse] All cookies set:', {
507
+ nextAuthCookie: nextAuthCookieName,
508
+ accessTokenCookie: `${cookiePrefix}_access_token`,
509
+ refreshTokenCookie: refreshToken ? `${cookiePrefix}_refresh_token` : 'none',
510
+ });
506
511
  return response;
507
512
  }
508
513
  // ============================================================================
@@ -1590,6 +1595,13 @@ async function handleMiddleware(req, config, options) {
1590
1595
  // 4. 자체 토큰 생성 및 쿠키 설정
1591
1596
  const redirectPath = config.rolePaths[tokenRole] || config.rolePaths[defaultRole] || '/admin';
1592
1597
  debugLog('handleMiddleware', `Creating auth response, redirect to: ${redirectPath}`);
1598
+ console.log('[handleMiddleware] Creating auth response:', {
1599
+ redirectPath,
1600
+ hasRefreshToken: !!refreshToken,
1601
+ cookiePrefix,
1602
+ isProduction,
1603
+ cookieDomain,
1604
+ });
1593
1605
  const response = await createAuthResponse(tokenParam, secret, {
1594
1606
  req,
1595
1607
  refreshToken: refreshToken || undefined,
@@ -1601,6 +1613,10 @@ async function handleMiddleware(req, config, options) {
1601
1613
  serviceId,
1602
1614
  licenseKey: options.licenseKey,
1603
1615
  });
1616
+ console.log('[handleMiddleware] Auth response created, cookies set:', {
1617
+ hasResponse: !!response,
1618
+ cookieNames: ['renton_access_token', 'renton_refresh_token', isProduction ? '__Secure-next-auth.session-token' : 'next-auth.session-token'],
1619
+ });
1604
1620
  return response;
1605
1621
  }
1606
1622
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkingcat/auth-utils",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
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",