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

Function formatApiKeyForDisplay

apps/sim/lib/api-key/auth.ts:123–137  ·  view source on GitHub ↗
(apiKey: string)

Source from the content-addressed store, hash-verified

121 * @returns string - The display format like "sk-sim-...r6AA" or "sim_...r6AA"
122 */
123export 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

Callers 2

auth.test.tsFile · 0.90
getApiKeyDisplayFormatFunction · 0.85

Calls 3

isEncryptedApiKeyFormatFunction · 0.90
isLegacyApiKeyFormatFunction · 0.90
getApiKeyLast4Function · 0.85

Tested by

no test coverage detected