fix(co-sign): fix threshold_n display and add missing fields in GetSignSessionByInviteCode
- Add threshold_n to GetSignSessionByInviteCodeResponse interface - Fix main.ts to use result.threshold_n instead of result.parties?.length - Add message_hash, joined_count, join_token to GetSignSessionByInviteCode response - Generate join token for sign session lookup 🤖 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
4d65b8dd83
commit
c1e32a8c04
|
|
@ -685,13 +685,14 @@ func (h *CoManagedHTTPHandler) GetSignSessionByInviteCode(c *gin.Context) {
|
|||
var thresholdN, thresholdT int
|
||||
var status string
|
||||
var expiresAt time.Time
|
||||
var messageHash []byte
|
||||
|
||||
err := h.db.QueryRowContext(ctx, `
|
||||
SELECT id, COALESCE(wallet_name, ''), COALESCE(keygen_session_id::text, ''),
|
||||
threshold_n, threshold_t, status, expires_at
|
||||
threshold_n, threshold_t, status, expires_at, COALESCE(message_hash, '')
|
||||
FROM mpc_sessions
|
||||
WHERE invite_code = $1 AND session_type = 'sign'
|
||||
`, inviteCode).Scan(&sessionID, &walletName, &keygenSessionID, &thresholdN, &thresholdT, &status, &expiresAt)
|
||||
`, inviteCode).Scan(&sessionID, &walletName, &keygenSessionID, &thresholdN, &thresholdT, &status, &expiresAt, &messageHash)
|
||||
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
|
|
@ -727,28 +728,48 @@ func (h *CoManagedHTTPHandler) GetSignSessionByInviteCode(c *gin.Context) {
|
|||
"session_id": sessionID,
|
||||
"keygen_session_id": keygenSessionID,
|
||||
"wallet_name": walletName,
|
||||
"message_hash": hex.EncodeToString(messageHash),
|
||||
"threshold_n": thresholdN,
|
||||
"threshold_t": thresholdT,
|
||||
"status": status,
|
||||
"joined_count": 0,
|
||||
"expires_at": expiresAt.UnixMilli(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Generate join token for this session (wildcard token that allows any party to join)
|
||||
var joinToken string
|
||||
if h.jwtService != nil {
|
||||
sessionUUID, parseErr := uuid.Parse(sessionID)
|
||||
if parseErr == nil {
|
||||
token, err := h.jwtService.GenerateJoinToken(sessionUUID, "*", time.Hour) // Wildcard party ID, 1 hour expiry
|
||||
if err != nil {
|
||||
logger.Warn("Failed to generate join token for sign session",
|
||||
zap.String("session_id", sessionID),
|
||||
zap.Error(err))
|
||||
} else {
|
||||
joinToken = token
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info("Found sign session for invite_code",
|
||||
zap.String("invite_code", inviteCode),
|
||||
zap.String("session_id", sessionID),
|
||||
zap.String("wallet_name", walletName))
|
||||
zap.String("wallet_name", walletName),
|
||||
zap.Bool("has_join_token", joinToken != ""))
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"session_id": sessionID,
|
||||
"keygen_session_id": keygenSessionID,
|
||||
"wallet_name": walletName,
|
||||
"message_hash": hex.EncodeToString(messageHash),
|
||||
"threshold_n": thresholdN,
|
||||
"threshold_t": thresholdT,
|
||||
"status": statusResp.Status,
|
||||
"completed_parties": statusResp.CompletedParties,
|
||||
"total_parties": statusResp.TotalParties,
|
||||
"joined_count": statusResp.CompletedParties,
|
||||
"expires_at": expiresAt.UnixMilli(),
|
||||
"join_token": joinToken,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1712,7 +1712,7 @@ function setupIpcHandlers() {
|
|||
messageHash: result.message_hash,
|
||||
threshold: {
|
||||
t: result.threshold_t,
|
||||
n: result.parties?.length || 0,
|
||||
n: result.threshold_n,
|
||||
},
|
||||
status: result.status,
|
||||
currentParticipants: result.joined_count || 0,
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ export interface GetSignSessionByInviteCodeResponse {
|
|||
wallet_name: string;
|
||||
message_hash: string;
|
||||
threshold_t: number;
|
||||
threshold_n: number;
|
||||
status: string;
|
||||
invite_code: string;
|
||||
expires_at: number;
|
||||
|
|
|
|||
Loading…
Reference in New Issue