/** * CLI: re-encrypt database secrets with the current ENCRYPTION_KEY. * Usage: * 1. Set ENCRYPTION_KEY_PREVIOUS to the old key * 2. Set ENCRYPTION_KEY to the new key * 3. npm run rotate-encryption-key */ import { rotateAllEncryptedData } from '../services/encryptionRotationService'; import { recordEncryptionKeyRotatedAt } from '../services/encryptionRotationReminderService'; async function main(): Promise { const stats = await rotateAllEncryptedData(); await recordEncryptionKeyRotatedAt(); console.log('[rotate-encryption-key] Completed:', stats); console.log( 'Remove ENCRYPTION_KEY_PREVIOUS from the environment after verifying the application.' ); } main().catch((e) => { console.error('[rotate-encryption-key] Failed:', e instanceof Error ? e.message : e); process.exit(1); });