diff --git a/backend/mpc-system/services/service-party-app/electron/main.ts b/backend/mpc-system/services/service-party-app/electron/main.ts index 3d484edd..8a0efac2 100644 --- a/backend/mpc-system/services/service-party-app/electron/main.ts +++ b/backend/mpc-system/services/service-party-app/electron/main.ts @@ -549,6 +549,8 @@ function setupIpcHandlers() { // 加入会话 ipcMain.handle('grpc:joinSession', async (_event, { sessionId, partyId, joinToken, walletName }) => { try { + debugLog.info('grpc', `Joining session: sessionId=${sessionId}, partyId=${partyId}, has_token=${!!joinToken}, token_length=${joinToken?.length || 0}`); + const result = await grpcClient?.joinSession(sessionId, partyId, joinToken); if (result?.success) { // 设置活跃的 keygen 会话信息 @@ -686,7 +688,11 @@ function setupIpcHandlers() { // gRPC - 验证邀请码 (通过 Account 服务 HTTP API) ipcMain.handle('grpc:validateInviteCode', async (_event, { code }) => { try { + debugLog.info('account', `Validating invite code: ${code}`); const result = await accountClient?.getSessionByInviteCode(code); + + debugLog.info('account', `Got session for invite code: session_id=${result?.session_id}, has_join_token=${!!result?.join_token}, token_length=${result?.join_token?.length || 0}`); + return { success: true, sessionInfo: { @@ -703,6 +709,7 @@ function setupIpcHandlers() { joinToken: result?.join_token, }; } catch (error) { + debugLog.error('account', `Failed to validate invite code: ${(error as Error).message}`); return { success: false, error: (error as Error).message }; } }); diff --git a/backend/mpc-system/services/service-party-app/src/types/electron.d.ts b/backend/mpc-system/services/service-party-app/src/types/electron.d.ts index ba8bf52e..76ee1496 100644 --- a/backend/mpc-system/services/service-party-app/src/types/electron.d.ts +++ b/backend/mpc-system/services/service-party-app/src/types/electron.d.ts @@ -132,6 +132,7 @@ interface JoinSessionResult { interface ValidateInviteCodeResult { success: boolean; sessionInfo?: SessionInfo; + joinToken?: string; error?: string; } diff --git a/backend/mpc-system/services/session-coordinator/application/use_cases/join_session.go b/backend/mpc-system/services/session-coordinator/application/use_cases/join_session.go index f0a3706e..808a520d 100644 --- a/backend/mpc-system/services/session-coordinator/application/use_cases/join_session.go +++ b/backend/mpc-system/services/session-coordinator/application/use_cases/join_session.go @@ -59,9 +59,27 @@ func (uc *JoinSessionUseCase) Execute( ctx context.Context, inputData input.JoinSessionInput, ) (*input.JoinSessionOutput, error) { + // Debug: log token info + tokenLen := len(inputData.JoinToken) + tokenPreview := "" + if tokenLen > 20 { + tokenPreview = inputData.JoinToken[:20] + "..." + } else if tokenLen > 0 { + tokenPreview = inputData.JoinToken + } + logger.Debug("JoinSession: parsing token", + zap.String("session_id", inputData.SessionID.String()), + zap.String("party_id", inputData.PartyID), + zap.Int("token_length", tokenLen), + zap.String("token_preview", tokenPreview)) + // 1. Parse join token to extract session ID (in case not provided) claims, err := uc.tokenValidator.ParseJoinTokenClaims(inputData.JoinToken) if err != nil { + logger.Error("JoinSession: failed to parse token", + zap.String("session_id", inputData.SessionID.String()), + zap.String("party_id", inputData.PartyID), + zap.Error(err)) return nil, err }