debug(mpc-system): 添加 joinToken 调试日志

- service-party-app: validateInviteCode 记录 token 长度
- service-party-app: joinSession 记录 token 信息
- service-party-app: 修复 ValidateInviteCodeResult 类型缺少 joinToken 字段
- session-coordinator: JoinSession 记录 token 解析详情

用于调试 "invalid token" 错误

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-29 05:55:46 -08:00
parent 5f4c7c135f
commit df8a14211e
3 changed files with 26 additions and 0 deletions

View File

@ -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 };
}
});

View File

@ -132,6 +132,7 @@ interface JoinSessionResult {
interface ValidateInviteCodeResult {
success: boolean;
sessionInfo?: SessionInfo;
joinToken?: string;
error?: string;
}

View File

@ -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
}