enable encryption from cli

This commit is contained in:
Ben Irvin 2022-10-31 10:13:32 +01:00
parent c38d159565
commit ed3e460e7a

View File

@ -4,9 +4,10 @@ import zip from 'zlib';
import { Duplex } from 'stream';
import { chain, Writable } from 'stream-chain';
import { stringer } from 'stream-json/jsonl/Stringer';
import type { Cipher } from 'crypto';
import type { IDestinationProvider, ProviderType, Stream } from '../../types';
// import { encrypt } from '../encryption';
import { createCipher } from '../encryption/encrypt';
export interface ILocalFileDestinationProviderOptions {
// Encryption
@ -37,6 +38,7 @@ class LocalFileDestinationProvider implements IDestinationProvider {
name: string = 'destination::local-file';
type: ProviderType = 'destination';
options: ILocalFileDestinationProviderOptions;
cipher?: Cipher;
constructor(options: ILocalFileDestinationProviderOptions) {
this.options = options;
@ -88,9 +90,10 @@ class LocalFileDestinationProvider implements IDestinationProvider {
}
// Encryption
// if (options.encryption?.enabled) {
// streams.push(encrypt(options.encryption.key).cipher());
// }
if (this.options.encryption?.enabled) {
this.cipher = createCipher(this.options.encryption.key);
streams.push(this.cipher);
}
// FS write stream
streams.push(createMultiFilesWriteStream(filePathFactory, this.options.file.maxSize));