(apiKey: string)
| 121 | * @returns string - The display format like "sk-sim-...r6AA" or "sim_...r6AA" |
| 122 | */ |
| 123 | export function formatApiKeyForDisplay(apiKey: string): string { |
| 124 | if (isEncryptedApiKeyFormat(apiKey)) { |
| 125 | // For sk-sim- format: "sk-sim-...r6AA" |
| 126 | const last4 = getApiKeyLast4(apiKey) |
| 127 | return `sk-sim-...${last4}` |
| 128 | } |
| 129 | if (isLegacyApiKeyFormat(apiKey)) { |
| 130 | // For sim_ format: "sim_...r6AA" |
| 131 | const last4 = getApiKeyLast4(apiKey) |
| 132 | return `sim_...${last4}` |
| 133 | } |
| 134 | // Unknown format, just show last 4 |
| 135 | const last4 = getApiKeyLast4(apiKey) |
| 136 | return `...${last4}` |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Gets the last 4 characters of an encrypted API key by decrypting it first |
no test coverage detected