This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypto from 'node:crypto'; | |
import { CryptographyError } from './errors'; | |
const ALGORITHM = 'aes-256-gcm'; | |
const IV_LENGTH = 12; // GCM standard | |
const LATEST_KEY = 'v1'; // Current version of the encryption key | |
export namespace secrets { | |
const keys = { | |
v1: Buffer.from(process.env.ENCRYPTION_KEY_V1!, 'hex') // Must be 32 bytes |