()
| 576 | * @returns {Promise<string>} |
| 577 | */ |
| 578 | const getEncryptionKey = async (): Promise<string> => { |
| 579 | if (process.env.FLOWISE_SECRETKEY_OVERWRITE !== undefined && process.env.FLOWISE_SECRETKEY_OVERWRITE !== '') { |
| 580 | return process.env.FLOWISE_SECRETKEY_OVERWRITE |
| 581 | } |
| 582 | try { |
| 583 | if (USE_AWS_SECRETS_MANAGER && secretsManagerClient) { |
| 584 | const secretId = process.env.SECRETKEY_AWS_NAME || 'FlowiseEncryptionKey' |
| 585 | const command = new GetSecretValueCommand({ SecretId: secretId }) |
| 586 | const response = await secretsManagerClient.send(command) |
| 587 | |
| 588 | if (response.SecretString) { |
| 589 | return response.SecretString |
| 590 | } |
| 591 | } |
| 592 | return await fs.promises.readFile(getEncryptionKeyPath(), 'utf8') |
| 593 | } catch (error) { |
| 594 | throw new Error(error) |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * Decrypt credential data |
no test coverage detected