( userId: string, workspaceId?: string )
| 361 | * Returns a merged decrypted env map for webhook/copilot/MCP config resolution. |
| 362 | */ |
| 363 | export async function getEffectiveDecryptedEnv( |
| 364 | userId: string, |
| 365 | workspaceId?: string |
| 366 | ): Promise<Record<string, string>> { |
| 367 | const cacheKey = getEffectiveDecryptedEnvCacheKey(userId, workspaceId) |
| 368 | const cached = effectiveDecryptedEnvCache.get(cacheKey) |
| 369 | if (cached) { |
| 370 | return cloneEnvVars(await cached.promise) |
| 371 | } |
| 372 | |
| 373 | const promise = getPersonalAndWorkspaceEnv(userId, workspaceId) |
| 374 | .then(({ personalDecrypted, workspaceDecrypted }) => ({ |
| 375 | ...personalDecrypted, |
| 376 | ...workspaceDecrypted, |
| 377 | })) |
| 378 | .catch((error) => { |
| 379 | effectiveDecryptedEnvCache.delete(cacheKey) |
| 380 | throw error |
| 381 | }) |
| 382 | |
| 383 | effectiveDecryptedEnvCache.set(cacheKey, { |
| 384 | userId, |
| 385 | workspaceId, |
| 386 | promise, |
| 387 | }) |
| 388 | |
| 389 | return cloneEnvVars(await promise) |
| 390 | } |
no test coverage detected