(secret: string)
| 124 | } |
| 125 | |
| 126 | async function encryptSecret(secret: string): Promise<string> { |
| 127 | const iv = randomBytes(16) |
| 128 | const key = getEncryptionKeyBuffer() |
| 129 | const cipher = createCipheriv('aes-256-gcm', key, iv, { authTagLength: 16 }) |
| 130 | let encrypted = cipher.update(secret, 'utf8', 'hex') |
| 131 | encrypted += cipher.final('hex') |
| 132 | const authTag = cipher.getAuthTag() |
| 133 | return `${iv.toString('hex')}:${encrypted}:${authTag.toString('hex')}` |
| 134 | } |
| 135 | |
| 136 | async function decryptSecret(encryptedValue: string): Promise<string> { |
| 137 | const parts = encryptedValue.split(':') |
no test coverage detected