Minima.js API / @minimajs/disk / plugins / encryption
Function: encryption()
ts
function encryption(options): (disk) => void;Encryption plugin — transparently encrypts files on write and decrypts on read.
Uses AES-256-GCM by default. All crypto parameters (salt, IV, auth tag) are embedded in the stream itself — no external metadata or sidecar files needed.
Requires capabilities.metadata = true on the driver. The encryption flag (x-minimajs-encrypt) is stored in file metadata so the decryption hook knows which files to decrypt. Drivers that do not support metadata cannot use this plugin.
Parameters
options
Returns
ts
(disk): void;Parameters
disk
Returns
void
Example
ts
const disk = createDisk({ driver }, encrypt({ password: process.env.SECRET! }))
await disk.put('secret.txt', 'sensitive data') // stored encrypted
const file = await disk.get('secret.txt') // automatically decrypted