mailauth 4.5.0 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bimi/index.js +20 -73
- package/licenses.txt +2 -1
- package/man/mailauth.1 +1 -1
- package/package.json +3 -2
package/lib/bimi/index.js
CHANGED
|
@@ -4,18 +4,19 @@ const crypto = require('crypto');
|
|
|
4
4
|
const dns = require('dns');
|
|
5
5
|
const { formatAuthHeaderRow, parseDkimHeaders, formatDomain, getAlignment } = require('../tools');
|
|
6
6
|
const Joi = require('joi');
|
|
7
|
-
const packageData = require('../../package.json');
|
|
7
|
+
//const packageData = require('../../package.json');
|
|
8
8
|
const httpsSchema = Joi.string().uri({
|
|
9
9
|
scheme: ['https']
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const FETCH_TIMEOUT = 5 * 1000;
|
|
13
|
+
|
|
14
|
+
const { fetch: fetchCmd, Agent } = require('undici');
|
|
15
|
+
const fetchAgent = new Agent({ connect: { timeout: FETCH_TIMEOUT } });
|
|
16
|
+
|
|
14
17
|
const { vmc } = require('@postalsys/vmc');
|
|
15
18
|
const { validateSvg } = require('./validate-svg');
|
|
16
19
|
|
|
17
|
-
const HTTP_REQUEST_TIMEOUT = 15 * 1000;
|
|
18
|
-
|
|
19
20
|
const lookup = async data => {
|
|
20
21
|
let { dmarc, headers, resolver, bimiWithAlignedDkim } = data;
|
|
21
22
|
let headerRows = (headers && headers.parsed) || [];
|
|
@@ -177,7 +178,7 @@ const lookup = async data => {
|
|
|
177
178
|
return response;
|
|
178
179
|
};
|
|
179
180
|
|
|
180
|
-
const downloadPromise = (url, cachedFile) => {
|
|
181
|
+
const downloadPromise = async (url, cachedFile) => {
|
|
181
182
|
if (cachedFile) {
|
|
182
183
|
return cachedFile;
|
|
183
184
|
}
|
|
@@ -186,76 +187,22 @@ const downloadPromise = (url, cachedFile) => {
|
|
|
186
187
|
return false;
|
|
187
188
|
}
|
|
188
189
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const options = {
|
|
192
|
-
protocol: parsedUrl.protocol,
|
|
193
|
-
host: parsedUrl.host,
|
|
190
|
+
let res = await fetchCmd(url, {
|
|
194
191
|
headers: {
|
|
195
|
-
|
|
196
|
-
'User-Agent': `mailauth/${packageData.version} (+${packageData.homepage}`
|
|
192
|
+
// Comment: AKAMAI does some strange UA based filtering that messes up the request
|
|
193
|
+
// 'User-Agent': `mailauth/${packageData.version} (+${packageData.homepage}`
|
|
197
194
|
},
|
|
198
|
-
|
|
199
|
-
port: 443,
|
|
200
|
-
path: parsedUrl.pathname,
|
|
201
|
-
method: 'GET',
|
|
202
|
-
rejectUnauthorized: true,
|
|
203
|
-
|
|
204
|
-
timeout: HTTP_REQUEST_TIMEOUT
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
return new Promise((resolve, reject) => {
|
|
208
|
-
let protoHandler;
|
|
209
|
-
switch (parsedUrl.protocol) {
|
|
210
|
-
case 'https:':
|
|
211
|
-
protoHandler = https;
|
|
212
|
-
break;
|
|
213
|
-
case 'http:':
|
|
214
|
-
protoHandler = http;
|
|
215
|
-
break;
|
|
216
|
-
default:
|
|
217
|
-
reject(new Error(`Unknown protocol ${parsedUrl.protocol}`));
|
|
218
|
-
}
|
|
219
|
-
const req = protoHandler.request(options, res => {
|
|
220
|
-
let chunks = [],
|
|
221
|
-
chunklen = 0;
|
|
222
|
-
res.on('readable', () => {
|
|
223
|
-
let chunk;
|
|
224
|
-
while ((chunk = res.read()) !== null) {
|
|
225
|
-
chunks.push(chunk);
|
|
226
|
-
chunklen += chunk.length;
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
res.on('end', () => {
|
|
230
|
-
let data = Buffer.concat(chunks, chunklen);
|
|
231
|
-
if (!res.statusCode || res.statusCode < 200 || res.statusCode >= 300) {
|
|
232
|
-
let err = new Error(`Invalid response code ${res.statusCode || '-'}`);
|
|
233
|
-
err.code = 'http_status_' + (res.statusCode || 'na');
|
|
234
|
-
if (res.headers.location && res.statusCode >= 300 && res.statusCode < 400) {
|
|
235
|
-
err.redirect = {
|
|
236
|
-
code: res.statusCode,
|
|
237
|
-
location: res.headers.location
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
return reject(err);
|
|
241
|
-
}
|
|
242
|
-
resolve(data);
|
|
243
|
-
});
|
|
244
|
-
res.on('error', err => reject(err));
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
req.on('timeout', () => {
|
|
248
|
-
req.destroy(); // cancel request
|
|
249
|
-
let error = new Error(`Request timeout for ${parsedUrl.href}`);
|
|
250
|
-
error.code = 'HTTP_SOCKET_TIMEOUT';
|
|
251
|
-
reject(error);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
req.on('error', err => {
|
|
255
|
-
reject(err);
|
|
256
|
-
});
|
|
257
|
-
req.end();
|
|
195
|
+
dispatcher: fetchAgent
|
|
258
196
|
});
|
|
197
|
+
|
|
198
|
+
if (!res.ok) {
|
|
199
|
+
let error = new Error(`Request failed with status ${res.status}`);
|
|
200
|
+
error.code = 'HTTP_REQUEST_FAILED';
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const arrayBufferValue = await res.arrayBuffer();
|
|
205
|
+
return Buffer.from(arrayBufferValue);
|
|
259
206
|
};
|
|
260
207
|
|
|
261
208
|
const validateVMC = async (bimiData, opts) => {
|
package/licenses.txt
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
name license type link installed version author
|
|
2
2
|
---- ------------ ---- ----------------- ------
|
|
3
3
|
@postalsys/vmc MIT https://registry.npmjs.org/@postalsys/vmc/-/vmc-1.0.6.tgz 1.0.6 Postal Systems OÜ
|
|
4
|
-
fast-xml-parser MIT git+https://github.com/NaturalIntelligence/fast-xml-parser.git 4.2.
|
|
4
|
+
fast-xml-parser MIT git+https://github.com/NaturalIntelligence/fast-xml-parser.git 4.2.7 Amit Gupta (https://amitguptagwl.github.io)
|
|
5
5
|
ipaddr.js MIT git://github.com/whitequark/ipaddr.js.git 2.1.0 whitequark <whitequark@whitequark.org>
|
|
6
6
|
joi BSD-3-Clause git://github.com/hapijs/joi.git 17.9.2 n/a
|
|
7
7
|
libmime MIT git://github.com/andris9/libmime.git 5.2.1 Andris Reinman <andris@kreata.ee>
|
|
8
8
|
nodemailer MIT-0 git+https://github.com/nodemailer/nodemailer.git 6.9.4 Andris Reinman
|
|
9
9
|
psl MIT git+ssh://git@github.com/lupomontero/psl.git 1.9.0 Lupo Montero <lupomontero@gmail.com> (https://lupomontero.com/)
|
|
10
10
|
punycode MIT git+https://github.com/mathiasbynens/punycode.js.git 2.3.0 Mathias Bynens https://mathiasbynens.be/
|
|
11
|
+
undici MIT git+https://github.com/nodejs/undici.git 5.23.0 Matteo Collina <hello@matteocollina.com>
|
|
11
12
|
yargs MIT git+https://github.com/yargs/yargs.git 17.7.2 n/a
|
package/man/mailauth.1
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailauth",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.2",
|
|
4
4
|
"description": "Email authentication library for Node.js",
|
|
5
5
|
"main": "lib/mailauth.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"chai": "4.3.7",
|
|
36
36
|
"eslint": "8.46.0",
|
|
37
37
|
"eslint-config-nodemailer": "1.2.0",
|
|
38
|
-
"eslint-config-prettier": "8.
|
|
38
|
+
"eslint-config-prettier": "8.10.0",
|
|
39
39
|
"js-yaml": "4.1.0",
|
|
40
40
|
"license-report": "6.4.0",
|
|
41
41
|
"marked": "0.7.0",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"nodemailer": "6.9.4",
|
|
54
54
|
"psl": "1.9.0",
|
|
55
55
|
"punycode": "2.3.0",
|
|
56
|
+
"undici": "5.23.0",
|
|
56
57
|
"yargs": "17.7.2"
|
|
57
58
|
},
|
|
58
59
|
"engines": {
|