Comparing version 4.0.1 to 4.0.2
@@ -34,3 +34,3 @@ /* eslint no-control-regex: 0 */ | ||
this.maxSizeReached = false; | ||
this.maxSizeReached = maxBodyLength === 0; | ||
@@ -37,0 +37,0 @@ this.emptyLinesQueue = []; |
@@ -24,3 +24,5 @@ 'use strict'; | ||
this.bodyHashedBytes = 0; | ||
this.maxBodyLength = maxBodyLength; | ||
this.maxSizeReached = maxBodyLength === 0; | ||
@@ -31,2 +33,6 @@ this.lastNewline = false; | ||
_updateBodyHash(chunk) { | ||
if (this.maxSizeReached) { | ||
return; | ||
} | ||
// the following is needed for l= option | ||
@@ -39,2 +45,3 @@ if ( | ||
) { | ||
this.maxSizeReached = true; | ||
if (this.bodyHashedBytes >= this.maxBodyLength) { | ||
@@ -44,2 +51,3 @@ // nothing to do here, skip entire chunk | ||
} | ||
// only use allowed size of bytes | ||
@@ -56,2 +64,7 @@ chunk = chunk.slice(0, this.maxBodyLength - this.bodyHashedBytes); | ||
update(chunk) { | ||
this.byteLength += (chunk && chunk.length) || 0; | ||
if (this.maxSizeReached) { | ||
return; | ||
} | ||
if (this.remainder.length) { | ||
@@ -58,0 +71,0 @@ // see if we can release the last remainder |
@@ -13,3 +13,3 @@ 'use strict'; | ||
let { canonicalization, algorithm, signTime, headerList, signatureData, arc, bodyHash, headers, getARChain } = options || {}; | ||
let { canonicalization, algorithm, signTime, headerList, signatureData, arc, bodyHash, headers, getARChain, expires } = options || {}; | ||
@@ -21,3 +21,5 @@ this.algorithm = algorithm || false; | ||
this.expires = expires; | ||
this.signTime = signTime; | ||
this.headerList = headerList; | ||
@@ -248,3 +250,6 @@ | ||
canonicalization: this.getCanonicalization(signatureData).canonicalization, | ||
signTime: this.signTime, | ||
expires: this.expires, | ||
bodyHash: this.bodyHashes.has(hashKey) ? this.bodyHashes.get(hashKey).hash : null | ||
@@ -251,0 +256,0 @@ }, |
'use strict'; | ||
const { getSigningHeaderLines, getPublicKey, parseDkimHeaders, formatAuthHeaderRow, getAlignment } = require('../../lib/tools'); | ||
const { getSigningHeaderLines, getPublicKey, parseDkimHeaders, formatAuthHeaderRow, getAlignment, getCurTime } = require('../../lib/tools'); | ||
const { MessageParser } = require('./message-parser'); | ||
@@ -19,2 +19,4 @@ const { dkimBody } = require('./body'); | ||
this.curTime = getCurTime(this.options.curTime); | ||
this.results = []; | ||
@@ -118,2 +120,8 @@ | ||
signatureHeader.timestamp = | ||
signatureHeader.parsed?.t && !isNaN(signatureHeader.parsed?.t?.value) ? new Date(signatureHeader.parsed?.t?.value * 1000) : null; | ||
signatureHeader.expiration = | ||
signatureHeader.parsed?.x && !isNaN(signatureHeader.parsed?.x?.value) ? new Date(signatureHeader.parsed?.x?.value * 1000) : null; | ||
signatureHeader.maxBodyLength = | ||
@@ -233,2 +241,14 @@ signatureHeader.parsed?.l?.value && !isNaN(signatureHeader.parsed?.l?.value) ? signatureHeader.parsed?.l?.value : ''; | ||
} | ||
if (status.result === 'pass') { | ||
if (signatureHeader.expiration && signatureHeader.timestamp && signatureHeader.expiration < signatureHeader.timestamp) { | ||
status.result = 'neutral'; | ||
status.comment = 'invalid expiration'; | ||
} | ||
if (signatureHeader.expiration && signatureHeader.expiration < this.curTime) { | ||
status.result = 'neutral'; | ||
status.comment = 'expired'; | ||
} | ||
} | ||
} catch (err) { | ||
@@ -235,0 +255,0 @@ status.result = 'neutral'; |
'use strict'; | ||
const { formatSignatureHeaderLine, formatRelaxedLine } = require('../../../lib/tools'); | ||
const { formatSignatureHeaderLine, formatRelaxedLine, getCurTime } = require('../../../lib/tools'); | ||
// generate headers for signing | ||
const relaxedHeaders = (type, signingHeaderLines, options) => { | ||
let { signatureHeaderLine, signingDomain, selector, algorithm, canonicalization, bodyHash, signTime, signature, instance, bodyHashedBytes } = options || {}; | ||
let { signatureHeaderLine, signingDomain, selector, algorithm, canonicalization, bodyHash, signTime, signature, instance, bodyHashedBytes, expires } = | ||
options || {}; | ||
let chunks = []; | ||
@@ -36,11 +37,7 @@ | ||
if (signTime) { | ||
if (typeof signTime === 'string' || typeof signTime === 'number') { | ||
signTime = new Date(signTime); | ||
} | ||
opts.t = Math.floor(getCurTime(signTime).getTime() / 1000); | ||
} | ||
if (Object.prototype.toString.call(signTime) === '[object Date]' && signTime.toString() !== 'Invalid Date') { | ||
// we need a unix timestamp value | ||
signTime = Math.round(signTime.getTime() / 1000); | ||
opts.t = signTime; | ||
} | ||
if (expires) { | ||
opts.x = Math.floor(getCurTime(expires).getTime() / 1000); | ||
} | ||
@@ -47,0 +44,0 @@ |
'use strict'; | ||
const { formatSignatureHeaderLine } = require('../../../lib/tools'); | ||
const { formatSignatureHeaderLine, getCurTime } = require('../../../lib/tools'); | ||
@@ -9,3 +9,4 @@ const formatSimpleLine = (line, suffix) => Buffer.from(line.toString('binary') + (suffix ? suffix : ''), 'binary'); | ||
const simpleHeaders = (type, signingHeaderLines, options) => { | ||
let { signatureHeaderLine, signingDomain, selector, algorithm, canonicalization, bodyHash, signTime, signature, instance, bodyHashedBytes } = options || {}; | ||
let { signatureHeaderLine, signingDomain, selector, algorithm, canonicalization, bodyHash, signTime, signature, instance, bodyHashedBytes, expires } = | ||
options || {}; | ||
let chunks = []; | ||
@@ -39,11 +40,7 @@ | ||
if (signTime) { | ||
if (typeof signTime === 'string' || typeof signTime === 'number') { | ||
signTime = new Date(signTime); | ||
} | ||
opts.t = Math.floor(getCurTime(signTime).getTime() / 1000); | ||
} | ||
if (Object.prototype.toString.call(signTime) === '[object Date]' && signTime.toString() !== 'Invalid Date') { | ||
// we need a unix timestamp value | ||
signTime = Math.round(signTime.getTime() / 1000); | ||
opts.t = signTime; | ||
} | ||
if (expires) { | ||
opts.x = Math.floor(getCurTime(expires).getTime() / 1000); | ||
} | ||
@@ -50,0 +47,0 @@ |
@@ -248,3 +248,3 @@ 'use strict'; | ||
parts[i].value = parts[i].value.replace(/\s+/g, ''); | ||
} else if (['l', 'v', 't'].includes(parts[i].key) && !isNaN(parts[i].value)) { | ||
} else if (['l', 'v', 't', 'x'].includes(parts[i].key) && !isNaN(parts[i].value)) { | ||
parts[i].value = Number(parts[i].value); | ||
@@ -251,0 +251,0 @@ } else if (parts[i].key === 'i' && /^arc-/i.test(headerKey)) { |
@@ -488,2 +488,25 @@ /* eslint no-control-regex: 0 */ | ||
function getCurTime(timeValue) { | ||
if (timeValue) { | ||
if (typeof timeValue === 'object' && typeof timeValue.toISOString === 'function') { | ||
return timeValue; | ||
} | ||
if (typeof timeValue === 'number' || !isNaN(timeValue)) { | ||
let timestamp = Number(timeValue); | ||
let curTime = new Date(timestamp); | ||
if (curTime.toString !== 'Invalid Date') { | ||
return curTime; | ||
} | ||
} else if (typeof timeValue === 'string') { | ||
let curTime = new Date(timeValue); | ||
if (curTime.toString !== 'Invalid Date') { | ||
return curTime; | ||
} | ||
} | ||
} | ||
return new Date(); | ||
} | ||
module.exports = { | ||
@@ -512,3 +535,5 @@ writeToStream, | ||
getPtrHostname | ||
getPtrHostname, | ||
getCurTime | ||
}; |
name license type link installed version author | ||
---- ------------ ---- ----------------- ------ | ||
@postalsys/vmc MIT https://registry.npmjs.org/@postalsys/vmc/-/vmc-1.0.5.tgz 1.0.5 Postal Systems OÜ | ||
@postalsys/vmc MIT https://registry.npmjs.org/@postalsys/vmc/-/vmc-1.0.6.tgz 1.0.6 Postal Systems OÜ | ||
fast-xml-parser MIT git+https://github.com/NaturalIntelligence/fast-xml-parser.git 4.0.9 Amit Gupta (https://amitkumargupta.work/) | ||
@@ -9,5 +9,5 @@ ipaddr.js MIT git://github.com/whitequark/ipaddr.js.git 2.0.1 whitequark <whitequark@whitequark.org> | ||
node-forge (BSD-3-Clause OR GPL-2.0) git+https://github.com/digitalbazaar/forge.git 1.3.1 Digital Bazaar, Inc. support@digitalbazaar.com http://digitalbazaar.com/ | ||
nodemailer MIT git+https://github.com/nodemailer/nodemailer.git 6.7.7 Andris Reinman | ||
nodemailer MIT git+https://github.com/nodemailer/nodemailer.git 6.7.8 Andris Reinman | ||
psl MIT git+ssh://git@github.com/lupomontero/psl.git 1.9.0 Lupo Montero <lupomontero@gmail.com> (https://lupomontero.com/) | ||
punycode MIT git+https://github.com/bestiejs/punycode.js.git 2.1.1 Mathias Bynens https://mathiasbynens.be/ | ||
yargs MIT git+https://github.com/yargs/yargs.git 17.5.1 n/a |
{ | ||
"name": "mailauth", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "Email authentication library for Node.js", | ||
@@ -36,7 +36,7 @@ "main": "lib/mailauth.js", | ||
"chai": "4.3.6", | ||
"eslint": "8.22.0", | ||
"eslint": "8.24.0", | ||
"eslint-config-nodemailer": "1.2.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"js-yaml": "4.1.0", | ||
"license-report": "6.0.0", | ||
"license-report": "6.1.0", | ||
"marked": "0.7.0", | ||
@@ -50,5 +50,5 @@ "marked-man": "0.7.0", | ||
"@postalsys/vmc": "1.0.6", | ||
"fast-xml-parser": "4.0.9", | ||
"fast-xml-parser": "4.0.10", | ||
"ipaddr.js": "2.0.1", | ||
"joi": "17.6.0", | ||
"joi": "17.6.1", | ||
"libmime": "5.1.0", | ||
@@ -55,0 +55,0 @@ "node-forge": "1.3.1", |
Sorry, the diff of this file is not supported yet
265283
5140
+ Addedfast-xml-parser@4.0.10(transitive)
+ Addedjoi@17.6.1(transitive)
- Removedfast-xml-parser@4.0.9(transitive)
- Removedjoi@17.6.0(transitive)
Updatedfast-xml-parser@4.0.10
Updatedjoi@17.6.1