@bobfrankston/mailx-store 0.1.91 → 0.1.95

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.
Files changed (3) hide show
  1. package/package.json +5 -5
  2. package/store.d.ts +7 -0
  3. package/store.js +26 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-store",
3
- "version": "0.1.91",
3
+ "version": "0.1.95",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@bobfrankston/mailx-types": "^0.1.59",
13
- "@bobfrankston/mailx-settings": "^0.1.59",
12
+ "@bobfrankston/mailx-types": "^0.1.63",
13
+ "@bobfrankston/mailx-settings": "^0.1.62",
14
14
  "@bobfrankston/mailx-bus": "^0.1.2",
15
15
  "mailparser": "^3.7.2"
16
16
  },
@@ -29,8 +29,8 @@
29
29
  },
30
30
  ".transformedSnapshot": {
31
31
  "dependencies": {
32
- "@bobfrankston/mailx-types": "^0.1.59",
33
- "@bobfrankston/mailx-settings": "^0.1.59",
32
+ "@bobfrankston/mailx-types": "^0.1.63",
33
+ "@bobfrankston/mailx-settings": "^0.1.62",
34
34
  "@bobfrankston/mailx-bus": "^0.1.2",
35
35
  "mailparser": "^3.7.2"
36
36
  }
package/store.d.ts CHANGED
@@ -19,6 +19,7 @@
19
19
  * be able to consume it without depending on mailx-service — that's the
20
20
  * "arrow points the right way" property of the architecture.
21
21
  */
22
+ import { type TrustFinding, type SpamScore } from "@bobfrankston/mailx-types";
22
23
  import type { ParsedInvite } from "@bobfrankston/mailx-types";
23
24
  import { MailxDB } from "./db.js";
24
25
  import { FileMessageStore } from "./file-store.js";
@@ -53,6 +54,12 @@ export interface StoreMessage extends MessageEnvelope {
53
54
  bodyOnDisk: boolean;
54
55
  deliveredTo: string;
55
56
  returnPath: string;
57
+ /** Evidence that this message is forged — empty for ordinary mail. See
58
+ * assessMessageTrust; the viewer renders these above the body. */
59
+ trust: TrustFinding[];
60
+ /** The receiving server SpamAssassin score, present or not, flagged or
61
+ * not. Shown as a badge so a below-threshold score is still visible. */
62
+ spamScore: SpamScore;
56
63
  listUnsubscribe: string;
57
64
  listUnsubscribeMail: string;
58
65
  listUnsubscribeHttp: string;
package/store.js CHANGED
@@ -21,6 +21,7 @@
21
21
  */
22
22
  import * as fs from "node:fs";
23
23
  import { parseSerial } from "./parse-serial.js";
24
+ import { assessMessageTrust, spamScoreOf } from "@bobfrankston/mailx-types";
24
25
  import { parseInvite } from "@bobfrankston/mailx-types";
25
26
  import { storeBus } from "./bus.js";
26
27
  import { sanitizeHtml, htmlToPlainText } from "@bobfrankston/mailx-types";
@@ -532,6 +533,30 @@ export class Store {
532
533
  if (dAddr && recipients.includes(dAddr))
533
534
  allowRemote = true;
534
535
  }
536
+ // Forgery evidence. Runs on the RAW html on purpose: sanitizeHtml
537
+ // disarms the image-map overlay, so by the time bodyHtml is safe the
538
+ // thing worth reporting is gone. Header-only checks would be immune,
539
+ // but the link checks would silently stop firing.
540
+ //
541
+ // "Own addresses" is the union of the recipient allowlist and the
542
+ // address this copy was delivered to. Delivered-To matters most: it
543
+ // needs no configuration and it is exactly the address a self-spoof
544
+ // forges, so an alias the user never got round to listing is still
545
+ // covered. (Claude Code 2026-08-25)
546
+ const trustHeaderLines = (parsed.headerLines || []).map(h => ({ key: h.key, line: h.line }));
547
+ const trust = assessMessageTrust({
548
+ headerLines: trustHeaderLines,
549
+ fromAddress: envelope.from?.address || "",
550
+ ownAddresses: [...recipients, (deliveredTo.match(/[^\s<>]+@[^\s<>]+/) || [""])[0]].filter(Boolean),
551
+ bodyHtml,
552
+ bodyText,
553
+ });
554
+ // The server's score travels separately from the findings: a finding is
555
+ // an accusation and fires only on evidence, this is a measurement the
556
+ // reader asked to see either way (Bob 2026-08-25). A 2.7 against a 4.5
557
+ // threshold is "did not quite trip the wire", which is not the same
558
+ // thing as clean — and that is exactly the message that got through.
559
+ const spamScore = spamScoreOf(trustHeaderLines);
535
560
  if (bodyHtml && !allowRemote) {
536
561
  const result = sanitizeHtml(bodyHtml);
537
562
  bodyHtml = result.html;
@@ -543,7 +568,7 @@ export class Store {
543
568
  hasRemoteContent, remoteAllowed: allowRemote,
544
569
  attachments,
545
570
  cached: true,
546
- deliveredTo, returnPath,
571
+ deliveredTo, returnPath, trust, spamScore,
547
572
  listUnsubscribe, listUnsubscribeMail, listUnsubscribeHttp, listUnsubscribeOneClick,
548
573
  // body_path in the DB is stored relative to the body-store
549
574
  // basePath; resolve to absolute so the UI's "Source" button