(src: Record<string, string>, source: 'personal' | 'workspace')
| 189 | const decryptionFailures: string[] = [] |
| 190 | |
| 191 | const decryptAll = async (src: Record<string, string>, source: 'personal' | 'workspace') => { |
| 192 | const entries = Object.entries(src) |
| 193 | const results = await Promise.all( |
| 194 | entries.map(async ([k, v]) => { |
| 195 | try { |
| 196 | const { decrypted } = await decryptSecret(v) |
| 197 | return [k, decrypted] as const |
| 198 | } catch (error) { |
| 199 | logger.error(`Failed to decrypt ${source} environment variable "${k}"`, { |
| 200 | userId, |
| 201 | workspaceId, |
| 202 | source, |
| 203 | error: getErrorMessage(error, 'Unknown error'), |
| 204 | }) |
| 205 | decryptionFailures.push(k) |
| 206 | return [k, ''] as const |
| 207 | } |
| 208 | }) |
| 209 | ) |
| 210 | return Object.fromEntries(results) |
| 211 | } |
| 212 | |
| 213 | const [personalDecrypted, workspaceDecrypted] = await Promise.all([ |
| 214 | decryptAll(personalEncrypted, 'personal'), |
no test coverage detected