MCPcopy Index your code
hub / github.com/simstudioai/sim / getEncryptedApiKeyLast4

Function getEncryptedApiKeyLast4

apps/sim/lib/api-key/auth.ts:144–156  ·  view source on GitHub ↗

* Gets the last 4 characters of an encrypted API key by decrypting it first * @param encryptedKey - The encrypted API key from the database * @returns Promise - The last 4 characters

(encryptedKey: string)

Source from the content-addressed store, hash-verified

142 * @returns Promise<string> - The last 4 characters
143 */
144async function getEncryptedApiKeyLast4(encryptedKey: string): Promise<string> {
145 try {
146 if (isEncryptedKey(encryptedKey)) {
147 const decryptedKey = await decryptApiKeyFromStorage(encryptedKey)
148 return getApiKeyLast4(decryptedKey)
149 }
150 // For plain text keys (legacy), return last 4 directly
151 return getApiKeyLast4(encryptedKey)
152 } catch (error) {
153 logger.error('Failed to get last 4 characters of API key:', { error })
154 return '****'
155 }
156}
157
158/**
159 * Validates API key format (basic validation)

Callers

nothing calls this directly

Calls 4

decryptApiKeyFromStorageFunction · 0.85
getApiKeyLast4Function · 0.85
errorMethod · 0.80
isEncryptedKeyFunction · 0.70

Tested by

no test coverage detected