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:
parent
cd1d2cf8d2
commit
c1e749e532
|
|
@ -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 := ""
|
wildcardToken := ""
|
||||||
if token, ok := resp.JoinTokens["*"]; ok {
|
if token, ok := resp.JoinTokens["*"]; ok {
|
||||||
wildcardToken = token
|
wildcardToken = token
|
||||||
|
|
@ -572,20 +572,22 @@ func (h *CoManagedHTTPHandler) CreateSignSession(c *gin.Context) {
|
||||||
logger.Info("Co-managed sign session created successfully",
|
logger.Info("Co-managed sign session created successfully",
|
||||||
zap.String("session_id", resp.SessionID),
|
zap.String("session_id", resp.SessionID),
|
||||||
zap.String("invite_code", inviteCode),
|
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{
|
c.JSON(http.StatusCreated, gin.H{
|
||||||
"session_id": resp.SessionID,
|
"session_id": resp.SessionID,
|
||||||
"keygen_session_id": req.KeygenSessionID,
|
"keygen_session_id": req.KeygenSessionID,
|
||||||
"wallet_name": req.WalletName,
|
"wallet_name": req.WalletName,
|
||||||
"invite_code": inviteCode,
|
"invite_code": inviteCode,
|
||||||
"join_token": wildcardToken,
|
"join_token": wildcardToken, // Backward compatible: wildcard token (may be empty)
|
||||||
"threshold_t": req.ThresholdT,
|
"join_tokens": resp.JoinTokens, // New: all join tokens (map[partyID]token)
|
||||||
"selected_parties": resp.SelectedParties,
|
"threshold_t": req.ThresholdT,
|
||||||
"status": "waiting_for_participants",
|
"selected_parties": resp.SelectedParties,
|
||||||
"current_participants": 0,
|
"status": "waiting_for_participants",
|
||||||
|
"current_participants": 0,
|
||||||
"required_participants": len(req.Parties),
|
"required_participants": len(req.Parties),
|
||||||
"expires_at": resp.ExpiresAt,
|
"expires_at": resp.ExpiresAt,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
if (joinToken) {
|
||||||
console.log('[CO-SIGN] Initiator auto-joining session...');
|
console.log('[CO-SIGN] Initiator auto-joining session...');
|
||||||
const joinResult = await grpcClient?.joinSession(result.session_id, partyId, joinToken);
|
const joinResult = await grpcClient?.joinSession(result.session_id, partyId, joinToken);
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,12 @@ export interface CreateSignSessionResponse {
|
||||||
session_id: string;
|
session_id: string;
|
||||||
invite_code: string;
|
invite_code: string;
|
||||||
keygen_session_id: string;
|
keygen_session_id: string;
|
||||||
message_hash: string;
|
wallet_name: string;
|
||||||
threshold_t: number;
|
threshold_t: number;
|
||||||
parties: SignPartyInfo[];
|
selected_parties: string[];
|
||||||
expires_at: number;
|
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 {
|
export interface GetSignSessionByInviteCodeResponse {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue