From 3d75fb2be758772ab9d538ef40243e8317878e84 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Fri, 24 Mar 2023 22:29:14 +0900 Subject: fix(ext/node): make cipher/decipher transform stream (#18408) --- ext/node/polyfills/internal/crypto/cipher.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'ext/node/polyfills/internal/crypto') diff --git a/ext/node/polyfills/internal/crypto/cipher.ts b/ext/node/polyfills/internal/crypto/cipher.ts index d40978cf6..670c1bcce 100644 --- a/ext/node/polyfills/internal/crypto/cipher.ts +++ b/ext/node/polyfills/internal/crypto/cipher.ts @@ -129,7 +129,17 @@ export class Cipheriv extends Transform implements Cipher { iv: BinaryLike | null, options?: TransformOptions, ) { - super(options); + super({ + transform(chunk, encoding, cb) { + this.push(this.update(chunk, encoding)); + cb(); + }, + final(cb) { + this.push(this.final()); + cb(); + }, + ...options, + }); this.#cache = new BlockModeCache(false); this.#context = ops.op_node_create_cipheriv(cipher, key, iv); } @@ -235,7 +245,17 @@ export class Decipheriv extends Transform implements Cipher { iv: BinaryLike | null, options?: TransformOptions, ) { - super(options); + super({ + transform(chunk, encoding, cb) { + this.push(this.update(chunk, encoding)); + cb(); + }, + final(cb) { + this.push(this.final()); + cb(); + }, + ...options, + }); this.#cache = new BlockModeCache(true); this.#context = ops.op_node_create_decipheriv(cipher, key, iv); } -- cgit v1.2.3