From 7cb458dfc5d8156ef999181e78b6aac68d4a1ed1 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Thu, 5 Jul 2018 11:39:39 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20Rewrite=20decrypt=20transform?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssn/streams/decryptStream.ts | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/ssn/streams/decryptStream.ts b/src/ssn/streams/decryptStream.ts index 3e9169d..4da83e6 100644 --- a/src/ssn/streams/decryptStream.ts +++ b/src/ssn/streams/decryptStream.ts @@ -3,25 +3,12 @@ import getDecryptor from '../decryption/decryptChunk'; export default function decryptTransform(decryptionKeys: [number, number, number]): stream.Transform { const decryptor = getDecryptor(decryptionKeys); - const transform = new stream.Transform(); - //TODO: we need to set transform._transform = (chunk) => { return chunk; } - transform._transform = (chunk, encoding, callback) => { - const decryptedChunk = decryptor(chunk); - callback(undefined, decryptedChunk); - }; - - /*transform.on('readable', () => { - const encryptedChunk = transform.read(); - - if (encryptedChunk === null) { - transform.end(); - return; - } - - const decryptedChunk = decryptor(encryptedChunk); - - transform.write(decryptedChunk); - });*/ + const transform = new stream.Transform({ + transform(chunk, encoding, callback) { + const decryptedChunk = decryptor(chunk); + callback(undefined, decryptedChunk); + }, + }); return transform; }