(encryptedKey: string)
| 102 | * @returns Promise<string> - The display format like "sk-sim-...r6AA" |
| 103 | */ |
| 104 | export async function getApiKeyDisplayFormat(encryptedKey: string): Promise<string> { |
| 105 | try { |
| 106 | if (isEncryptedKey(encryptedKey)) { |
| 107 | const decryptedKey = await decryptApiKeyFromStorage(encryptedKey) |
| 108 | return formatApiKeyForDisplay(decryptedKey) |
| 109 | } |
| 110 | // For plain text keys (legacy), format directly |
| 111 | return formatApiKeyForDisplay(encryptedKey) |
| 112 | } catch (error) { |
| 113 | logger.error('Failed to format API key for display:', { error }) |
| 114 | return '****' |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Formats an API key for display showing prefix and last 4 characters |
no test coverage detected