feat(codex): include plan type in auth filename

This commit is contained in:
zhiqing0205
2026-01-06 02:25:56 +08:00
parent 9f1b445c7c
commit ac3ca0ad8e
3 changed files with 67 additions and 3 deletions

View File

@@ -186,7 +186,13 @@ waitForCallback:
return nil, fmt.Errorf("codex token storage missing account information")
}
fileName := fmt.Sprintf("codex-%s.json", tokenStorage.Email)
planType := ""
if tokenStorage.IDToken != "" {
if claims, errParse := codex.ParseJWTToken(tokenStorage.IDToken); errParse == nil && claims != nil {
planType = strings.TrimSpace(claims.CodexAuthInfo.ChatgptPlanType)
}
}
fileName := codex.CredentialFileName(tokenStorage.Email, planType, true)
metadata := map[string]any{
"email": tokenStorage.Email,
}