diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2023-03-24 22:29:14 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-24 22:29:14 +0900 |
commit | 3d75fb2be758772ab9d538ef40243e8317878e84 (patch) | |
tree | d38fca0225f80379b6792aaac73389e0466e7802 /ext/node/polyfills/internal/crypto/cipher.ts | |
parent | 94ef428b564f8ba60c2752fb7ca64f804f88baf2 (diff) |
fix(ext/node): make cipher/decipher transform stream (#18408)
Diffstat (limited to 'ext/node/polyfills/internal/crypto/cipher.ts')
-rw-r--r-- | ext/node/polyfills/internal/crypto/cipher.ts | 24 |
1 files changed, 22 insertions, 2 deletions
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); } |