CredentialFileName returns the filename used to persist Codex OAuth credentials. When planType is available (e.g. "plus", "team"), it is appended after the email as a suffix to disambiguate subscriptions.
(email, planType, hashAccountID string, includeProviderPrefix bool)
| 10 | // When planType is available (e.g. "plus", "team"), it is appended after the email |
| 11 | // as a suffix to disambiguate subscriptions. |
| 12 | func CredentialFileName(email, planType, hashAccountID string, includeProviderPrefix bool) string { |
| 13 | email = strings.TrimSpace(email) |
| 14 | plan := normalizePlanTypeForFilename(planType) |
| 15 | |
| 16 | prefix := "" |
| 17 | if includeProviderPrefix { |
| 18 | prefix = "codex" |
| 19 | } |
| 20 | |
| 21 | if plan == "" { |
| 22 | return fmt.Sprintf("%s-%s.json", prefix, email) |
| 23 | } else if plan == "team" { |
| 24 | return fmt.Sprintf("%s-%s-%s-%s.json", prefix, hashAccountID, email, plan) |
| 25 | } |
| 26 | return fmt.Sprintf("%s-%s-%s.json", prefix, email, plan) |
| 27 | } |
| 28 | |
| 29 | func normalizePlanTypeForFilename(planType string) string { |
| 30 | planType = strings.TrimSpace(planType) |
no test coverage detected