Skip to content

Commit

Permalink
fix(dkim): Store byteLength in BodyHashStream
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Oct 2, 2024
1 parent a322180 commit 081f823
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/dkim/body/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class BodyHashStream extends Transform {
this.finished = false;
this.finishCb = null;

this.byteLength = 0;

this.messageHasher = new MessageHasher(canonicalization, ...options);
this.bodyHash = null;
this.messageHasher.once('finish', () => this.finishHashing());
Expand Down Expand Up @@ -73,12 +75,15 @@ class BodyHashStream extends Transform {
chunk = Buffer.from(chunk, encoding);
}

this.byteLength += chunk.length;

this.push(chunk);

if (this.messageHasher.write(chunk) === false) {
// wait for drain
return this.messageHasher.once('drain', done);
}

this.push(chunk);
done();
}

Expand Down

0 comments on commit 081f823

Please sign in to comment.