@postalsys/email-ai-tools 2.3.1 → 2.4.0

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
+ ## [2.4.0](https://github.com/postalsys/email-ai-tools/compare/v2.3.2...v2.4.0) (2026-10-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * list the signing domains of passing DKIM signatures in parseAuthenticationResults ([e6d468e](https://github.com/postalsys/email-ai-tools/commit/e6d468e7ed4ce71d27da756d540a89cbdd7259b4))
9
+
10
+ ## [2.3.2](https://github.com/postalsys/email-ai-tools/compare/v2.3.1...v2.3.2) (2026-10-22)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * update dependencies ([2e71292](https://github.com/postalsys/email-ai-tools/commit/2e7129248ccd98a0c73989a100f1ef4b1f81836f))
16
+
3
17
  ## [2.3.1](https://github.com/postalsys/email-ai-tools/compare/v2.3.0...v2.3.1) (2026-10-20)
4
18
 
5
19
 
@@ -15,11 +15,13 @@ export interface AuthenticationTrust {
15
15
  * Parses one Authentication-Results header value
16
16
  *
17
17
  * @param value - Header value, unfolded
18
- * @returns The authserv-id (null when the header carries none, as Microsoft's do) and the first result per method
18
+ * @returns The authserv-id (null when the header carries none, as Microsoft's do), the first result per method,
19
+ * and the signing domains of every passing DKIM signature (header.d, or the domain of header.i)
19
20
  */
20
21
  declare function parseAuthenticationResults(value: unknown): {
21
22
  authservId: string | null;
22
23
  results: AuthenticationResults;
24
+ dkimDomains: string[];
23
25
  } | null;
24
26
  /**
25
27
  * Tells whether an authserv-id names a server the caller trusts: the name itself or a host
@@ -67,7 +67,8 @@ function splitResinfo(value) {
67
67
  * Parses one Authentication-Results header value
68
68
  *
69
69
  * @param value - Header value, unfolded
70
- * @returns The authserv-id (null when the header carries none, as Microsoft's do) and the first result per method
70
+ * @returns The authserv-id (null when the header carries none, as Microsoft's do), the first result per method,
71
+ * and the signing domains of every passing DKIM signature (header.d, or the domain of header.i)
71
72
  */
72
73
  function parseAuthenticationResults(value) {
73
74
  const segments = splitResinfo(String(value ?? ''));
@@ -88,6 +89,7 @@ function parseAuthenticationResults(value) {
88
89
  segments[0] = first.substring(firstToken.length).trim();
89
90
  }
90
91
  const results = {};
92
+ const dkimDomains = [];
91
93
  for (const segment of segments) {
92
94
  const match = /^([a-z0-9-]+)\s*=\s*([a-z0-9-]+)/i.exec(segment);
93
95
  if (!match) {
@@ -98,13 +100,19 @@ function parseAuthenticationResults(value) {
98
100
  if (!METHODS.includes(method)) {
99
101
  continue;
100
102
  }
103
+ if (method === 'dkim' && result === 'pass') {
104
+ const domain = /\bheader\.d\s*=\s*([a-z0-9.-]+)/i.exec(segment) || /\bheader\.i\s*=\s*[^\s@]*@([a-z0-9.-]+)/i.exec(segment);
105
+ if (domain) {
106
+ dkimDomains.push(domain[1].toLowerCase().replace(/\.$/, ''));
107
+ }
108
+ }
101
109
  // the first result per method: a second DKIM entry is another signature on the message,
102
110
  // a mailing list's broken one as often as not, and not a verdict on the first
103
111
  if (!(method in results)) {
104
112
  results[method] = result;
105
113
  }
106
114
  }
107
- return { authservId, results };
115
+ return { authservId, results, dkimDomains };
108
116
  }
109
117
  /**
110
118
  * Tells whether an authserv-id names a server the caller trusts: the name itself or a host
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@postalsys/email-ai-tools";
2
- export declare const version = "2.3.1";
2
+ export declare const version = "2.4.0";
@@ -3,4 +3,4 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.version = exports.name = void 0;
5
5
  exports.name = "@postalsys/email-ai-tools";
6
- exports.version = "2.3.1";
6
+ exports.version = "2.4.0";
@@ -15,11 +15,13 @@ export interface AuthenticationTrust {
15
15
  * Parses one Authentication-Results header value
16
16
  *
17
17
  * @param value - Header value, unfolded
18
- * @returns The authserv-id (null when the header carries none, as Microsoft's do) and the first result per method
18
+ * @returns The authserv-id (null when the header carries none, as Microsoft's do), the first result per method,
19
+ * and the signing domains of every passing DKIM signature (header.d, or the domain of header.i)
19
20
  */
20
21
  declare function parseAuthenticationResults(value: unknown): {
21
22
  authservId: string | null;
22
23
  results: AuthenticationResults;
24
+ dkimDomains: string[];
23
25
  } | null;
24
26
  /**
25
27
  * Tells whether an authserv-id names a server the caller trusts: the name itself or a host
@@ -61,7 +61,8 @@ function splitResinfo(value) {
61
61
  * Parses one Authentication-Results header value
62
62
  *
63
63
  * @param value - Header value, unfolded
64
- * @returns The authserv-id (null when the header carries none, as Microsoft's do) and the first result per method
64
+ * @returns The authserv-id (null when the header carries none, as Microsoft's do), the first result per method,
65
+ * and the signing domains of every passing DKIM signature (header.d, or the domain of header.i)
65
66
  */
66
67
  function parseAuthenticationResults(value) {
67
68
  const segments = splitResinfo(String(value ?? ''));
@@ -82,6 +83,7 @@ function parseAuthenticationResults(value) {
82
83
  segments[0] = first.substring(firstToken.length).trim();
83
84
  }
84
85
  const results = {};
86
+ const dkimDomains = [];
85
87
  for (const segment of segments) {
86
88
  const match = /^([a-z0-9-]+)\s*=\s*([a-z0-9-]+)/i.exec(segment);
87
89
  if (!match) {
@@ -92,13 +94,19 @@ function parseAuthenticationResults(value) {
92
94
  if (!METHODS.includes(method)) {
93
95
  continue;
94
96
  }
97
+ if (method === 'dkim' && result === 'pass') {
98
+ const domain = /\bheader\.d\s*=\s*([a-z0-9.-]+)/i.exec(segment) || /\bheader\.i\s*=\s*[^\s@]*@([a-z0-9.-]+)/i.exec(segment);
99
+ if (domain) {
100
+ dkimDomains.push(domain[1].toLowerCase().replace(/\.$/, ''));
101
+ }
102
+ }
95
103
  // the first result per method: a second DKIM entry is another signature on the message,
96
104
  // a mailing list's broken one as often as not, and not a verdict on the first
97
105
  if (!(method in results)) {
98
106
  results[method] = result;
99
107
  }
100
108
  }
101
- return { authservId, results };
109
+ return { authservId, results, dkimDomains };
102
110
  }
103
111
  /**
104
112
  * Tells whether an authserv-id names a server the caller trusts: the name itself or a host
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@postalsys/email-ai-tools";
2
- export declare const version = "2.3.1";
2
+ export declare const version = "2.4.0";
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/build.js from package.json. Do not edit by hand.
2
2
  export const name = "@postalsys/email-ai-tools";
3
- export const version = "2.3.1";
3
+ export const version = "2.4.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postalsys/email-ai-tools",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "Summarize and risk-score email messages with an OpenAI-compatible chat model",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -81,17 +81,17 @@
81
81
  "eslint": "10.13.0",
82
82
  "eslint-config-prettier": "10.1.8",
83
83
  "globals": "17.13.0",
84
- "mailparser": "3.10.0",
84
+ "mailparser": "3.14.0",
85
85
  "prettier": "3.9.10",
86
86
  "typescript": "6.0.3",
87
- "typescript-eslint": "8.72.0"
87
+ "typescript-eslint": "8.72.1"
88
88
  },
89
89
  "dependencies": {
90
- "@postalsys/email-text-tools": "2.5.0",
90
+ "@postalsys/email-text-tools": "2.6.1",
91
91
  "dom-serializer": "2.0.0",
92
92
  "domutils": "3.2.2",
93
93
  "htmlparser2": "10.1.0",
94
- "libmime": "5.5.2",
94
+ "libmime": "5.6.3",
95
95
  "tldts": "7.4.19",
96
96
  "undici": "7.30.1"
97
97
  },