mymx 0.3.8 → 0.3.91

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.
@@ -1,4 +1,4 @@
1
- import { EmailAddress, EmailAuth, EmailReceivedEvent, ParsedDataComplete, ParsedDataFailed, ParsedError, RawContentDownloadOnly, RawContentInline, WEBHOOK_VERSION$1 as WEBHOOK_VERSION, WebhookAttachment } from "./types-B5aR2RnG.js";
1
+ import { EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, ParsedDataComplete, ParsedDataFailed, ParsedError, RawContentDownloadOnly, RawContentInline, WEBHOOK_VERSION$1 as WEBHOOK_VERSION, WebhookAttachment } from "./types-COLkx-eW.js";
2
2
  import { SignResult, signWebhookPayload$1 as signWebhookPayload } from "./signing-Ecohrukk.js";
3
3
 
4
4
  //#region src/contract.d.ts
@@ -86,6 +86,8 @@ interface EmailReceivedEventInput {
86
86
  parsed?: ParsedInput;
87
87
  /** Email authentication results (SPF, DKIM, DMARC) */
88
88
  auth: EmailAuth;
89
+ /** Email analysis results */
90
+ analysis: EmailAnalysis;
89
91
  }
90
92
  /**
91
93
  * Generate a stable event ID for webhook deduplication.
@@ -145,4 +147,4 @@ declare function buildEmailReceivedEvent(input: EmailReceivedEventInput, options
145
147
  /** Override attempted_at timestamp (for testing) */
146
148
  attempted_at?: string;
147
149
  }): EmailReceivedEvent; //#endregion
148
- export { EmailAddress, EmailAuth, EmailReceivedEvent, EmailReceivedEventInput, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedInput, ParsedInputComplete, ParsedInputFailed, RAW_EMAIL_INLINE_THRESHOLD, RawContentDownloadOnly, RawContentInline, SignResult, WEBHOOK_VERSION, WebhookAttachment, buildEmailReceivedEvent, generateEventId, signWebhookPayload };
150
+ export { EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EmailReceivedEventInput, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedInput, ParsedInputComplete, ParsedInputFailed, RAW_EMAIL_INLINE_THRESHOLD, RawContentDownloadOnly, RawContentInline, SignResult, WEBHOOK_VERSION, WebhookAttachment, buildEmailReceivedEvent, generateEventId, signWebhookPayload };
package/dist/contract.js CHANGED
@@ -175,6 +175,7 @@ function buildEmailReceivedEvent(input, options) {
175
175
  }
176
176
  },
177
177
  parsed: parsedData,
178
+ analysis: input.analysis,
178
179
  auth: input.auth
179
180
  }
180
181
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AuthConfidence, AuthVerdict, DkimSignature, DkimSignatureResult, DmarcPolicy, DmarcResult, EmailAddress, EmailAuth, EmailReceivedEvent, KnownWebhookEvent, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, RawContent, RawContentDownloadOnly, RawContentInline, SpfResult, UnknownEvent, ValidateEmailAuthResult, WEBHOOK_VERSION$1 as WEBHOOK_VERSION, WebhookAttachment, WebhookEvent } from "./types-B5aR2RnG.js";
1
+ import { AuthConfidence, AuthVerdict, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, KnownWebhookEvent, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, RawContent, RawContentDownloadOnly, RawContentInline, SpfResult, UnknownEvent, ValidateEmailAuthResult, WEBHOOK_VERSION$1 as WEBHOOK_VERSION, WebhookAttachment, WebhookEvent } from "./types-COLkx-eW.js";
2
2
  import { MYMX_CONFIRMED_HEADER$1 as MYMX_CONFIRMED_HEADER, MYMX_SIGNATURE_HEADER$1 as MYMX_SIGNATURE_HEADER, VerifyOptions, verifyWebhookSignature$1 as verifyWebhookSignature } from "./signing-Ecohrukk.js";
3
3
  import { MyMXWebhookError$1 as MyMXWebhookError, PAYLOAD_ERRORS$1 as PAYLOAD_ERRORS, RAW_EMAIL_ERRORS$1 as RAW_EMAIL_ERRORS, RawEmailDecodeError$1 as RawEmailDecodeError, RawEmailDecodeErrorCode, VERIFICATION_ERRORS$1 as VERIFICATION_ERRORS, WebhookErrorCode, WebhookPayloadError$1 as WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError$1 as WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError$1 as WebhookVerificationError, WebhookVerificationErrorCode } from "./errors-CSPHzZB_.js";
4
4
 
@@ -152,31 +152,15 @@ declare const emailReceivedEventJsonSchema: {
152
152
  readonly description: "Parsed email content (body text, HTML, attachments). Check `status` to determine if parsing succeeded.";
153
153
  };
154
154
  readonly analysis: {
155
- readonly type: "object";
156
- readonly properties: {
157
- readonly spamassassin: {
158
- readonly type: "object";
159
- readonly properties: {
160
- readonly score: {
161
- readonly type: "number";
162
- readonly description: "Overall spam score (sum of all rule scores). Higher scores indicate higher likelihood of spam. Unbounded - can be negative (ham) or very high (spam).";
163
- };
164
- };
165
- readonly required: ["score"];
166
- readonly additionalProperties: false;
167
- readonly description: "SpamAssassin analysis results.";
168
- };
169
- };
170
- readonly required: ["spamassassin"];
171
- readonly additionalProperties: false;
172
- readonly description: "Email analysis and classification results. May be absent if analysis was not performed.";
155
+ readonly $ref: "#/definitions/EmailAnalysis";
156
+ readonly description: "Email analysis and classification results.";
173
157
  };
174
158
  readonly auth: {
175
159
  readonly $ref: "#/definitions/EmailAuth";
176
160
  readonly description: "Email authentication results (SPF, DKIM, DMARC).";
177
161
  };
178
162
  };
179
- readonly required: ["id", "received_at", "smtp", "headers", "content", "parsed", "auth"];
163
+ readonly required: ["id", "received_at", "smtp", "headers", "content", "parsed", "analysis", "auth"];
180
164
  readonly additionalProperties: false;
181
165
  readonly description: "The email that triggered this event.";
182
166
  };
@@ -487,6 +471,235 @@ declare const emailReceivedEventJsonSchema: {
487
471
  readonly additionalProperties: false;
488
472
  readonly description: "Error details when email parsing fails.";
489
473
  };
474
+ readonly EmailAnalysis: {
475
+ readonly type: "object";
476
+ readonly properties: {
477
+ readonly spamassassin: {
478
+ readonly type: "object";
479
+ readonly properties: {
480
+ readonly score: {
481
+ readonly type: "number";
482
+ readonly description: "Overall spam score (sum of all rule scores). Higher scores indicate higher likelihood of spam. Unbounded - can be negative (ham) or very high (spam).";
483
+ };
484
+ };
485
+ readonly required: ["score"];
486
+ readonly additionalProperties: false;
487
+ readonly description: "SpamAssassin analysis results.";
488
+ };
489
+ readonly forward: {
490
+ readonly $ref: "#/definitions/ForwardAnalysis";
491
+ readonly description: "Forward detection and analysis results.";
492
+ };
493
+ };
494
+ readonly additionalProperties: false;
495
+ readonly description: "Email analysis and classification results.";
496
+ };
497
+ readonly ForwardAnalysis: {
498
+ readonly type: "object";
499
+ readonly properties: {
500
+ readonly detected: {
501
+ readonly type: "boolean";
502
+ readonly description: "Whether any forwards were detected in the email.";
503
+ };
504
+ readonly results: {
505
+ readonly type: "array";
506
+ readonly items: {
507
+ readonly $ref: "#/definitions/ForwardResult";
508
+ };
509
+ readonly description: "Analysis results for each detected forward.";
510
+ };
511
+ readonly attachments_found: {
512
+ readonly type: "number";
513
+ readonly description: "Total number of .eml attachments found.";
514
+ };
515
+ readonly attachments_analyzed: {
516
+ readonly type: "number";
517
+ readonly description: "Number of .eml attachments that were analyzed.";
518
+ };
519
+ readonly attachments_limit: {
520
+ readonly type: ["number", "null"];
521
+ readonly description: "Maximum number of attachments that will be analyzed, or null if unlimited.";
522
+ };
523
+ };
524
+ readonly required: ["detected", "results", "attachments_found", "attachments_analyzed", "attachments_limit"];
525
+ readonly additionalProperties: false;
526
+ readonly description: "Forward detection and analysis results.";
527
+ };
528
+ readonly ForwardResult: {
529
+ readonly anyOf: [{
530
+ readonly $ref: "#/definitions/ForwardResultInline";
531
+ }, {
532
+ readonly $ref: "#/definitions/ForwardResultAttachmentAnalyzed";
533
+ }, {
534
+ readonly $ref: "#/definitions/ForwardResultAttachmentSkipped";
535
+ }];
536
+ readonly description: "Result for a single forwarded email detected in the message.\n\nUse the `type` and `analyzed` fields to narrow the type:\n- `type: 'inline'` - Inline forward, always analyzed\n- `type: 'attachment'` + `analyzed: true` - Analyzed attachment\n- `type: 'attachment'` + `analyzed: false` - Skipped attachment";
537
+ };
538
+ readonly ForwardResultInline: {
539
+ readonly type: "object";
540
+ readonly properties: {
541
+ readonly type: {
542
+ readonly type: "string";
543
+ readonly const: "inline";
544
+ };
545
+ readonly original_sender: {
546
+ readonly anyOf: [{
547
+ readonly $ref: "#/definitions/ForwardOriginalSender";
548
+ }, {
549
+ readonly type: "null";
550
+ }];
551
+ readonly description: "Original sender of the forwarded email, if extractable.";
552
+ };
553
+ readonly verification: {
554
+ readonly $ref: "#/definitions/ForwardVerification";
555
+ readonly description: "Verification result for the forwarded email.";
556
+ };
557
+ readonly summary: {
558
+ readonly type: "string";
559
+ readonly description: "Human-readable summary of the forward analysis.";
560
+ };
561
+ };
562
+ readonly required: ["type", "original_sender", "verification", "summary"];
563
+ readonly additionalProperties: false;
564
+ readonly description: "Result for an inline forward that was detected and analyzed. Inline forwards are always analyzed when forward detection is enabled.";
565
+ };
566
+ readonly ForwardOriginalSender: {
567
+ readonly type: "object";
568
+ readonly properties: {
569
+ readonly email: {
570
+ readonly type: "string";
571
+ readonly description: "Email address of the original sender.";
572
+ };
573
+ readonly domain: {
574
+ readonly type: "string";
575
+ readonly description: "Domain of the original sender.";
576
+ };
577
+ };
578
+ readonly required: ["email", "domain"];
579
+ readonly additionalProperties: false;
580
+ readonly description: "Original sender information extracted from the forwarded email.";
581
+ };
582
+ readonly ForwardVerification: {
583
+ readonly type: "object";
584
+ readonly properties: {
585
+ readonly verdict: {
586
+ readonly $ref: "#/definitions/ForwardVerdict";
587
+ readonly description: "Overall verdict on whether the forward is authentic.";
588
+ };
589
+ readonly confidence: {
590
+ readonly $ref: "#/definitions/AuthConfidence";
591
+ readonly description: "Confidence level for this verdict.";
592
+ };
593
+ readonly dkim_verified: {
594
+ readonly type: "boolean";
595
+ readonly description: "Whether a valid DKIM signature was found that verifies the original sender.";
596
+ };
597
+ readonly dkim_domain: {
598
+ readonly type: ["string", "null"];
599
+ readonly description: "Domain of the DKIM signature that verified the forward, if any.";
600
+ };
601
+ readonly dmarc_policy: {
602
+ readonly $ref: "#/definitions/DmarcPolicy";
603
+ readonly description: "DMARC policy of the original sender's domain.";
604
+ };
605
+ };
606
+ readonly required: ["verdict", "confidence", "dkim_verified", "dkim_domain", "dmarc_policy"];
607
+ readonly additionalProperties: false;
608
+ readonly description: "Verification result for a forwarded email.";
609
+ };
610
+ readonly ForwardVerdict: {
611
+ readonly type: "string";
612
+ readonly enum: ["legit", "unknown"];
613
+ readonly description: "Verdict for forwarded email verification.\n\n- `legit`: DKIM signature verified the original sender\n- `unknown`: Could not verify the forwarded email's authenticity";
614
+ };
615
+ readonly AuthConfidence: {
616
+ readonly type: "string";
617
+ readonly enum: ["high", "medium", "low"];
618
+ readonly description: "Confidence level for the authentication verdict.\n\n- `high`: Strong cryptographic evidence (DKIM aligned + DMARC pass)\n- `medium`: Good evidence but with caveats (SPF-only alignment)\n- `low`: Weak evidence (missing authentication or unclear results)";
619
+ };
620
+ readonly DmarcPolicy: {
621
+ readonly type: ["string", "null"];
622
+ readonly enum: ["reject", "quarantine", "none", null];
623
+ readonly description: "DMARC policy action specified in the domain's DMARC record.\n\n- `reject`: The domain owner requests that receivers reject failing emails\n- `quarantine`: The domain owner requests that failing emails be treated as suspicious\n- `none`: The domain owner is only monitoring (no action requested)\n- `null`: No DMARC policy was found for the domain";
624
+ };
625
+ readonly ForwardResultAttachmentAnalyzed: {
626
+ readonly type: "object";
627
+ readonly properties: {
628
+ readonly type: {
629
+ readonly type: "string";
630
+ readonly const: "attachment";
631
+ };
632
+ readonly attachment_tar_path: {
633
+ readonly type: "string";
634
+ readonly description: "Path to the attachment in the attachments tar archive.";
635
+ };
636
+ readonly attachment_filename: {
637
+ readonly type: ["string", "null"];
638
+ readonly description: "Original filename of the attachment, if available.";
639
+ };
640
+ readonly analyzed: {
641
+ readonly type: "boolean";
642
+ readonly const: true;
643
+ readonly description: "Whether this attachment was analyzed.";
644
+ };
645
+ readonly original_sender: {
646
+ readonly anyOf: [{
647
+ readonly $ref: "#/definitions/ForwardOriginalSender";
648
+ }, {
649
+ readonly type: "null";
650
+ }];
651
+ readonly description: "Original sender of the forwarded email, if extractable.";
652
+ };
653
+ readonly verification: {
654
+ readonly $ref: "#/definitions/ForwardVerification";
655
+ readonly description: "Verification result for the forwarded email.";
656
+ };
657
+ readonly summary: {
658
+ readonly type: "string";
659
+ readonly description: "Human-readable summary of the forward analysis.";
660
+ };
661
+ };
662
+ readonly required: ["type", "attachment_tar_path", "attachment_filename", "analyzed", "original_sender", "verification", "summary"];
663
+ readonly additionalProperties: false;
664
+ readonly description: "Result for an attachment forward that was analyzed.";
665
+ };
666
+ readonly ForwardResultAttachmentSkipped: {
667
+ readonly type: "object";
668
+ readonly properties: {
669
+ readonly type: {
670
+ readonly type: "string";
671
+ readonly const: "attachment";
672
+ };
673
+ readonly attachment_tar_path: {
674
+ readonly type: "string";
675
+ readonly description: "Path to the attachment in the attachments tar archive.";
676
+ };
677
+ readonly attachment_filename: {
678
+ readonly type: ["string", "null"];
679
+ readonly description: "Original filename of the attachment, if available.";
680
+ };
681
+ readonly analyzed: {
682
+ readonly type: "boolean";
683
+ readonly const: false;
684
+ readonly description: "Whether this attachment was analyzed.";
685
+ };
686
+ readonly original_sender: {
687
+ readonly type: "null";
688
+ readonly description: "Always null when not analyzed.";
689
+ };
690
+ readonly verification: {
691
+ readonly type: "null";
692
+ readonly description: "Always null when not analyzed.";
693
+ };
694
+ readonly summary: {
695
+ readonly type: "string";
696
+ readonly description: "Human-readable summary explaining why analysis was skipped.";
697
+ };
698
+ };
699
+ readonly required: ["type", "attachment_tar_path", "attachment_filename", "analyzed", "original_sender", "verification", "summary"];
700
+ readonly additionalProperties: false;
701
+ readonly description: "Result for an attachment forward that was detected but not analyzed. This occurs when attachment analysis is disabled or the limit was reached.";
702
+ };
490
703
  readonly EmailAuth: {
491
704
  readonly type: "object";
492
705
  readonly properties: {
@@ -544,11 +757,6 @@ declare const emailReceivedEventJsonSchema: {
544
757
  readonly enum: ["pass", "fail", "none", "temperror", "permerror"];
545
758
  readonly description: "DMARC verification result.";
546
759
  };
547
- readonly DmarcPolicy: {
548
- readonly type: ["string", "null"];
549
- readonly enum: ["reject", "quarantine", "none", null];
550
- readonly description: "DMARC policy action specified in the domain's DMARC record.\n\n- `reject`: The domain owner requests that receivers reject failing emails\n- `quarantine`: The domain owner requests that failing emails be treated as suspicious\n- `none`: The domain owner is only monitoring (no action requested)\n- `null`: No DMARC policy was found for the domain";
551
- };
552
760
  readonly DkimSignature: {
553
761
  readonly type: "object";
554
762
  readonly properties: {
@@ -561,7 +769,7 @@ declare const emailReceivedEventJsonSchema: {
561
769
  readonly description: "The DKIM selector used to locate the public key (s= tag). Combined with the domain to form the DNS lookup: `selector._domainkey.domain`";
562
770
  };
563
771
  readonly result: {
564
- readonly $ref: "#/definitions/DkimSignatureResult";
772
+ readonly $ref: "#/definitions/DkimResult";
565
773
  readonly description: "Verification result for this specific signature.";
566
774
  };
567
775
  readonly aligned: {
@@ -581,7 +789,7 @@ declare const emailReceivedEventJsonSchema: {
581
789
  readonly additionalProperties: false;
582
790
  readonly description: "Details about a single DKIM signature found in the email.\n\nAn email may have multiple DKIM signatures (e.g., one from the sending domain and one from the ESP). Each signature is verified independently.";
583
791
  };
584
- readonly DkimSignatureResult: {
792
+ readonly DkimResult: {
585
793
  readonly type: "string";
586
794
  readonly enum: ["pass", "fail", "temperror", "permerror"];
587
795
  readonly description: "DKIM signature verification result for a single signature.";
@@ -927,4 +1135,4 @@ declare function decodeRawEmail(event: EmailReceivedEvent, options?: DecodeRawEm
927
1135
  declare function verifyRawEmailDownload(downloaded: Buffer | ArrayBuffer | Uint8Array, event: EmailReceivedEvent): Buffer;
928
1136
 
929
1137
  //#endregion
930
- export { AuthConfidence, AuthVerdict, DecodeRawEmailOptions, DkimSignature, DkimSignatureResult, DmarcPolicy, DmarcResult, EmailAddress, EmailAuth, EmailReceivedEvent, HandleWebhookOptions, KnownWebhookEvent, MYMX_CONFIRMED_HEADER, MYMX_SIGNATURE_HEADER, MyMXWebhookError, PAYLOAD_ERRORS, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, RAW_EMAIL_ERRORS, RawContent, RawContentDownloadOnly, RawContentInline, RawEmailDecodeError, RawEmailDecodeErrorCode, SpfResult, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, validateEmailAuth, verifyRawEmailDownload, verifyWebhookSignature };
1138
+ export { AuthConfidence, AuthVerdict, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, HandleWebhookOptions, KnownWebhookEvent, MYMX_CONFIRMED_HEADER, MYMX_SIGNATURE_HEADER, MyMXWebhookError, PAYLOAD_ERRORS, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, RAW_EMAIL_ERRORS, RawContent, RawContentDownloadOnly, RawContentInline, RawEmailDecodeError, RawEmailDecodeErrorCode, SpfResult, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, validateEmailAuth, verifyRawEmailDownload, verifyWebhookSignature };