mailauth 4.9.1 → 4.9.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.9.3](https://github.com/postalsys/mailauth/compare/v4.9.2...v4.9.3) (2025-09-02)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * bumped deps ([006475e](https://github.com/postalsys/mailauth/commit/006475ee7bbf61a8c7c00de793f4007f66dba61a))
9
+
10
+ ## [4.9.2](https://github.com/postalsys/mailauth/compare/v4.9.1...v4.9.2) (2025-08-28)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * ZMS-262 remove control chars from record add support for mappers in validateTagValueRecord ([#95](https://github.com/postalsys/mailauth/issues/95)) ([42828a6](https://github.com/postalsys/mailauth/commit/42828a6cb38add3aed35881f102488f8143407cb))
16
+
3
17
  ## [4.9.1](https://github.com/postalsys/mailauth/compare/v4.9.0...v4.9.1) (2025-08-27)
4
18
 
5
19
 
package/lib/bimi/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const { Buffer } = require('node:buffer');
4
4
  const crypto = require('node:crypto');
5
5
  const dns = require('node:dns');
6
- const { formatAuthHeaderRow, parseDkimHeaders, formatDomain, getAlignment, validateTagValueRecord } = require('../tools');
6
+ const { formatAuthHeaderRow, parseDkimHeaders, formatDomain, getAlignment } = require('../tools');
7
7
  const Joi = require('joi');
8
8
  //const packageData = require('../../package.json');
9
9
  const httpsSchema = Joi.string().uri({
@@ -184,8 +184,7 @@ const lookup = async data => {
184
184
  response.authority = recordData.parsed.a.value;
185
185
 
186
186
  // Apple Mail requires additional policy header values in Authentication-Results header
187
- const authorityUriValidationObj = validateTagValueRecord(recordData.parsed.a.value, 'bimi');
188
- response.status.policy = { authority: 'none', 'authority-uri': authorityUriValidationObj.sanitizedRecord }; // VMC has not been actually checked here yet, so authority is none
187
+ response.status.policy = { authority: 'none', 'authority-uri': recordData.parsed.a.value }; // VMC has not been actually checked here yet, so authority is none
189
188
  }
190
189
 
191
190
  response.info = formatAuthHeaderRow('bimi', response.status);
package/lib/tools.js CHANGED
@@ -580,9 +580,11 @@ function parseTagValueRecord(record, options = {}) {
580
580
  } = options;
581
581
 
582
582
  let sanitized = (record || '')
583
- .replace(/\\r\\n/g, '') // Remove literal \r\n
584
- .replace(/\\n/g, '') // Remove literal \n
585
- .replace(/\r?\n/g, '') // Remove actual newlines
583
+ .replace(/[\x00-\x1F]+/g, ' ') // control chars
584
+ .replace(/\\r\\n/g, '')
585
+ .replace(/\\n/g, '')
586
+ .replace(/\r?\n/g, '')
587
+ .replace(/\s+/g, ' ')
586
588
  .trim();
587
589
 
588
590
  // Split on semicolons
@@ -663,6 +665,10 @@ function parseTagValueRecord(record, options = {}) {
663
665
  };
664
666
  }
665
667
 
668
+ function convertToASCII(value) {
669
+ return (value || '').replace(/[^\x20-\x7E]/g, '');
670
+ }
671
+
666
672
  function validateTagValueRecord(record, recordType) {
667
673
  const configs = {
668
674
  BIMI: {
@@ -691,6 +697,9 @@ function validateTagValueRecord(record, recordType) {
691
697
  return `Invalid authority URL: ${value}`;
692
698
  }
693
699
  }
700
+ },
701
+ mappers: {
702
+ v: value => convertToASCII(value)
694
703
  }
695
704
  }
696
705
  };
@@ -702,6 +711,15 @@ function validateTagValueRecord(record, recordType) {
702
711
 
703
712
  const parsed = parseTagValueRecord(record, config);
704
713
 
714
+ // Mappers run regardless whether the resulting parsed object is valid
715
+ if (config.mappers) {
716
+ for (const [tag, mapper] of Object.entries(config.mappers)) {
717
+ if (parsed.tags && tag in parsed.tags) {
718
+ parsed.tags[tag] = mapper(parsed.tags[tag]);
719
+ }
720
+ }
721
+ }
722
+
705
723
  if (config.validators && parsed.isValid) {
706
724
  for (const [tag, validator] of Object.entries(config.validators)) {
707
725
  if (parsed.tags && tag in parsed.tags) {
@@ -748,5 +766,6 @@ module.exports = {
748
766
  TLDTS_OPTS,
749
767
 
750
768
  validateTagValueRecord,
751
- parseTagValueRecord
769
+ parseTagValueRecord,
770
+ convertToASCII
752
771
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailauth",
3
- "version": "4.9.1",
3
+ "version": "4.9.3",
4
4
  "description": "Email authentication library for Node.js",
5
5
  "main": "lib/mailauth.js",
6
6
  "scripts": {
@@ -37,22 +37,22 @@
37
37
  "eslint-config-nodemailer": "1.2.0",
38
38
  "eslint-config-prettier": "9.1.0",
39
39
  "js-yaml": "4.1.0",
40
- "license-report": "6.7.2",
40
+ "license-report": "6.8.0",
41
41
  "mbox-reader": "1.2.0",
42
- "mocha": "11.5.0",
42
+ "mocha": "11.7.2",
43
43
  "resedit": "^2.0.3"
44
44
  },
45
45
  "dependencies": {
46
46
  "@postalsys/vmc": "1.1.2",
47
47
  "fast-xml-parser": "4.5.2",
48
48
  "ipaddr.js": "2.2.0",
49
- "joi": "17.13.3",
50
- "libmime": "5.3.6",
51
- "nodemailer": "7.0.3",
49
+ "joi": "18.0.1",
50
+ "libmime": "5.3.7",
51
+ "nodemailer": "7.0.6",
52
52
  "punycode.js": "2.3.1",
53
- "tldts": "7.0.7",
54
- "undici": "7.10.0",
55
- "yargs": "17.7.2"
53
+ "tldts": "7.0.12",
54
+ "undici": "7.15.0",
55
+ "yargs": "18.0.0"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=18.0.0"