()
| 38 | } |
| 39 | |
| 40 | function checkEncryptionKeys() { |
| 41 | const productionKey = process.env.CB_ENCRYPTION_KEY; |
| 42 | const developmentKey = process.env.CB_ENCRYPTION_KEY_DEV; |
| 43 | |
| 44 | // Validate production key |
| 45 | if (!isValidAES256Key(productionKey) && process.env.NODE_ENV === "production") { |
| 46 | console.error("Invalid AES-256 encryption key in CB_ENCRYPTION_KEY. It must be a 64-character hexadecimal string."); // eslint-disable-line |
| 47 | process.exit(1); // Exit with an error code |
| 48 | } |
| 49 | |
| 50 | // Validate development key |
| 51 | if (!isValidAES256Key(developmentKey) && process.env.NODE_ENV !== "production") { |
| 52 | console.error("Invalid AES-256 encryption key in CB_ENCRYPTION_KEY_DEV. It must be a 64-character hexadecimal string."); // eslint-disable-line |
| 53 | process.exit(1); // Exit with an error code |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | module.exports = { encrypt, decrypt, checkEncryptionKeys }; |
no test coverage detected