mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2026-10-12 02:42:27 +07:00
node_modules: update (#344)
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
This commit is contained in:
1 parent
b099186883
commit
6e88c72525
63 files changed
+2863
-1227
No files matched your search
+45
-31
@@ -37,51 +37,67 @@ class DKIMSigner {
|
||||
this.output = output;
|
||||
this.output.usingCache = false;
|
||||
this.hasErrored = false;
|
||||
this.input.on('error', err => {
|
||||
this.input.on('error', err => this.fail(err));
|
||||
// A consumer that goes away before the signed message was read in full destroys the
|
||||
// output. Stop reading the input and drop the cache file instead of leaving them open
|
||||
this.output.once('close', () => {
|
||||
if (this.output.writableFinished) {
|
||||
return;
|
||||
}
|
||||
this.hasErrored = true;
|
||||
this.input.unpipe();
|
||||
this.input.destroy();
|
||||
this.cleanup();
|
||||
output.emit('error', err);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Ends the output with an error and releases the cache file
|
||||
*/
|
||||
fail(err) {
|
||||
this.hasErrored = true;
|
||||
this.cleanup();
|
||||
this.output.destroy(err);
|
||||
}
|
||||
cleanup() {
|
||||
if (!this.cache || !this.cachePath) {
|
||||
return;
|
||||
}
|
||||
const cache = this.cache;
|
||||
this.cache = false;
|
||||
cache.destroy();
|
||||
node_fs_1.default.unlink(this.cachePath, () => false);
|
||||
}
|
||||
createReadCache() {
|
||||
// pipe remainings to cache file
|
||||
this.cache = node_fs_1.default.createReadStream(this.cachePath);
|
||||
this.cache.once('error', err => {
|
||||
this.cleanup();
|
||||
this.output.emit('error', err);
|
||||
});
|
||||
this.cache.once('error', err => this.fail(err));
|
||||
this.cache.once('close', () => {
|
||||
this.cleanup();
|
||||
});
|
||||
this.cache.pipe(this.output);
|
||||
}
|
||||
sendNextChunk() {
|
||||
while (!this.hasErrored) {
|
||||
if (this.readPos >= this.chunks.length) {
|
||||
if (!this.cache) {
|
||||
this.output.end();
|
||||
return;
|
||||
}
|
||||
return this.createReadCache();
|
||||
}
|
||||
const chunk = this.chunks[this.readPos++];
|
||||
if (this.output.write(chunk) === false) {
|
||||
this.output.once('drain', () => {
|
||||
this.sendNextChunk();
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
sendSignedOutput() {
|
||||
if (this.hasErrored) {
|
||||
return;
|
||||
}
|
||||
if (this.readPos >= this.chunks.length) {
|
||||
if (!this.cache) {
|
||||
this.output.end();
|
||||
return;
|
||||
}
|
||||
return this.createReadCache();
|
||||
}
|
||||
const chunk = this.chunks[this.readPos++];
|
||||
if (this.output.write(chunk) === false) {
|
||||
this.output.once('drain', () => {
|
||||
this.sendNextChunk();
|
||||
});
|
||||
return;
|
||||
}
|
||||
setImmediate(() => this.sendNextChunk());
|
||||
}
|
||||
sendSignedOutput() {
|
||||
let keyPos = 0;
|
||||
const signNextKey = () => {
|
||||
if (keyPos >= this.keys.length) {
|
||||
@@ -101,9 +117,7 @@ class DKIMSigner {
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
this.hasErrored = true;
|
||||
this.cleanup();
|
||||
this.output.emit('error', err);
|
||||
this.fail(err);
|
||||
return;
|
||||
}
|
||||
if (dkimField) {
|
||||
@@ -122,7 +136,6 @@ class DKIMSigner {
|
||||
// pipe remainings to cache file
|
||||
this.cache = node_fs_1.default.createWriteStream(this.cachePath);
|
||||
this.cache.once('error', err => {
|
||||
this.cleanup();
|
||||
// drain input
|
||||
this.relaxedBody.unpipe(this.cache);
|
||||
this.relaxedBody.on('readable', () => {
|
||||
@@ -130,11 +143,12 @@ class DKIMSigner {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
this.hasErrored = true;
|
||||
// emit error
|
||||
this.output.emit('error', err);
|
||||
this.fail(err);
|
||||
});
|
||||
this.cache.once('close', () => {
|
||||
if (this.hasErrored) {
|
||||
return;
|
||||
}
|
||||
this.sendSignedOutput();
|
||||
});
|
||||
this.relaxedBody.removeAllListeners('readable');
|
||||
@@ -211,7 +225,7 @@ class DKIM {
|
||||
catch (_E) {
|
||||
// the body hash is created here, an unknown hashAlgo throws inside this timer
|
||||
// where nothing else could catch it
|
||||
output.emit('error', sign_js_1.default.unsupportedHashAlgoError(signer.hashAlgo));
|
||||
signer.fail(sign_js_1.default.unsupportedHashAlgoError(signer.hashAlgo));
|
||||
return;
|
||||
}
|
||||
if (writeValue) {
|
||||
|
||||
Reference in new issue
Block a user