fix(co-sign): return join_tokens map for initiator auto-join

- Add join_tokens (map[partyID]token) to CreateSignSession response
- Keep join_token for backward compatibility
- Update frontend to use join_tokens[partyId] for initiator auto-join

🤖 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-30 19:54:20 -08:00
parent cd1d2cf8d2
commit c1e749e532
3 changed files with 20 additions and 16 deletions

View File

@ -563,7 +563,7 @@ func (h *CoManagedHTTPHandler) CreateSignSession(c *gin.Context) {
}
}
// Get wildcard join token for participants
// Get wildcard token for backward compatibility (join_token field)
wildcardToken := ""
if token, ok := resp.JoinTokens["*"]; ok {
wildcardToken = token
@ -572,20 +572,22 @@ func (h *CoManagedHTTPHandler) CreateSignSession(c *gin.Context) {
logger.Info("Co-managed sign session created successfully",
zap.String("session_id", resp.SessionID),
zap.String("invite_code", inviteCode),
zap.Int("num_parties", len(resp.SelectedParties)))
zap.Int("num_parties", len(resp.SelectedParties)),
zap.Int("num_join_tokens", len(resp.JoinTokens)))
c.JSON(http.StatusCreated, gin.H{
"session_id": resp.SessionID,
"keygen_session_id": req.KeygenSessionID,
"wallet_name": req.WalletName,
"invite_code": inviteCode,
"join_token": wildcardToken,
"threshold_t": req.ThresholdT,
"selected_parties": resp.SelectedParties,
"status": "waiting_for_participants",
"current_participants": 0,
"session_id": resp.SessionID,
"keygen_session_id": req.KeygenSessionID,
"wallet_name": req.WalletName,
"invite_code": inviteCode,
"join_token": wildcardToken, // Backward compatible: wildcard token (may be empty)
"join_tokens": resp.JoinTokens, // New: all join tokens (map[partyID]token)
"threshold_t": req.ThresholdT,
"selected_parties": resp.SelectedParties,
"status": "waiting_for_participants",
"current_participants": 0,
"required_participants": len(req.Parties),
"expires_at": resp.ExpiresAt,
"expires_at": resp.ExpiresAt,
})
}

View File

@ -1595,7 +1595,8 @@ function setupIpcHandlers() {
});
// 发起方自动加入会话
const joinToken = result.join_token;
// 支持新格式 join_tokens (map[partyID]token) 和旧格式 join_token (单一通配符 token)
const joinToken = result.join_tokens?.[partyId] || (result as { join_token?: string }).join_token;
if (joinToken) {
console.log('[CO-SIGN] Initiator auto-joining session...');
const joinResult = await grpcClient?.joinSession(result.session_id, partyId, joinToken);

View File

@ -119,11 +119,12 @@ export interface CreateSignSessionResponse {
session_id: string;
invite_code: string;
keygen_session_id: string;
message_hash: string;
wallet_name: string;
threshold_t: number;
parties: SignPartyInfo[];
selected_parties: string[];
expires_at: number;
join_token: string;
join_token?: string; // Backward compatible: wildcard token (may be empty)
join_tokens: Record<string, string>; // New: all join tokens (map[partyID]token)
}
export interface GetSignSessionByInviteCodeResponse {