♻ Rewrite decrypt transform
This commit is contained in:
parent
8755fda1e3
commit
7cb458dfc5
1 changed files with 6 additions and 19 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue