@thinkingcat/auth-utils 1.0.33 → 1.0.34

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 +3 -31
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -449,47 +449,19 @@ async function createAuthResponse(accessToken, secret, options) {
449
449
  }
450
450
  // accessTokenExpires 추가 (15분)
451
451
  jwt.accessTokenExpires = Date.now() + (15 * 60 * 1000);
452
- debugLog('createAuthResponse', 'JWT created:', {
452
+ debugLog('createAuthResponse', 'JWT created (for handleJWTCallback):', {
453
453
  hasId: !!jwt.id,
454
454
  hasEmail: !!jwt.email,
455
455
  hasRole: !!jwt.role,
456
456
  hasRefreshToken: !!jwt.refreshToken,
457
457
  });
458
- // 3. NextAuth session cookie 생성
459
- const nextAuthToken = await encodeNextAuthToken(jwt, secret);
460
- debugLog('createAuthResponse', 'NextAuth session token encoded:', {
461
- tokenLength: nextAuthToken.length,
462
- tokenPrefix: nextAuthToken.substring(0, 30) + '...',
463
- jwtId: jwt.id,
464
- jwtEmail: jwt.email?.substring(0, 20) + '...',
465
- });
466
- // 4. Response 생성 (HTTP 302 리다이렉트 사용)
458
+ // 3. Response 생성 (HTTP 302 리다이렉트 사용)
467
459
  const { NextResponse: NextResponseClass } = await getNextServer();
468
460
  // redirectPath가 있으면 302 리다이렉트, 없으면 200 OK
469
461
  const response = redirectPath
470
462
  ? NextResponseClass.redirect(new URL(redirectPath, req.url), { status: 302 })
471
463
  : NextResponseClass.json({ success: true, message: text || 'Authentication successful' }, { status: 200 });
472
- // 4. NextAuth session cookie 설정
473
- const nextAuthCookieName = isProduction
474
- ? '__Secure-next-auth.session-token'
475
- : 'next-auth.session-token';
476
- const cookieOptions = {
477
- httpOnly: true,
478
- secure: isProduction,
479
- sameSite: isProduction ? 'none' : 'lax',
480
- path: '/',
481
- maxAge: 30 * 24 * 60 * 60, // 30일
482
- };
483
- if (cookieDomain) {
484
- cookieOptions.domain = cookieDomain;
485
- }
486
- response.cookies.set(nextAuthCookieName, nextAuthToken, cookieOptions);
487
- debugLog('createAuthResponse', 'NextAuth session cookie set:', {
488
- name: nextAuthCookieName,
489
- valueLength: nextAuthToken.length,
490
- ...cookieOptions,
491
- });
492
- // 5. 커스텀 토큰 쿠키 설정
464
+ // 4. 커스텀 토큰 쿠키만 설정 (NextAuth 쿠키는 handleJWTCallback에서 생성됨)
493
465
  if (refreshToken) {
494
466
  setCustomTokens(response, accessToken, refreshToken, {
495
467
  cookiePrefix,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkingcat/auth-utils",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
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",