@push.rocks/smartmta 13.1.0 → 14.0.1

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 (26) hide show
  1. package/changelog.md +33 -0
  2. package/dist_rust/mailer-bin_linux_amd64_musl +0 -0
  3. package/dist_rust/mailer-bin_linux_amd64_musl.third-party-notices.json +0 -51
  4. package/dist_rust/mailer-bin_linux_amd64_musl.third-party-notices.txt +1 -291
  5. package/dist_rust/mailer-bin_linux_amd64_musl.tsrust-build.json +5 -5
  6. package/dist_rust/mailer-bin_linux_arm64_musl +0 -0
  7. package/dist_rust/mailer-bin_linux_arm64_musl.third-party-notices.json +0 -51
  8. package/dist_rust/mailer-bin_linux_arm64_musl.third-party-notices.txt +1 -291
  9. package/dist_rust/mailer-bin_linux_arm64_musl.tsrust-build.json +5 -5
  10. package/dist_ts/00_commitinfo_data.js +1 -1
  11. package/dist_ts/mail/routing/classes.unified.email.server.d.ts +17 -14
  12. package/dist_ts/mail/routing/classes.unified.email.server.js +80 -71
  13. package/dist_ts/security/classes.rustsecuritybridge.d.ts +108 -1
  14. package/dist_ts/security/classes.rustsecuritybridge.js +187 -50
  15. package/native-notices/manifest.json +1 -64
  16. package/native-notices/readme.md +3 -3
  17. package/package.json +9 -10
  18. package/readme.md +20 -12
  19. package/ts/00_commitinfo_data.ts +1 -1
  20. package/ts/mail/routing/classes.unified.email.server.ts +82 -75
  21. package/ts/security/classes.rustsecuritybridge.ts +264 -49
  22. package/native-notices/crates/charset-0.1.5/copyright +0 -12
  23. package/native-notices/crates/charset-0.1.5/license-apache +0 -202
  24. package/native-notices/crates/charset-0.1.5/license-mit +0 -25
  25. package/native-notices/crates/mailparse-0.16.1/license +0 -13
  26. package/native-notices/crates/quoted_printable-0.5.2/license +0 -13
@@ -331,6 +331,68 @@ interface IEmailData {
331
331
  type: 'inline';
332
332
  base64: string;
333
333
  }
334
+ /** A mailbox of the parsed-message bridge JSON. */
335
+ export interface IBridgeMailAddress {
336
+ email: string;
337
+ name?: string;
338
+ }
339
+ /** The header fields of an inline nested message (never produced with smartmta's setting). */
340
+ export interface IBridgeMessageHeader {
341
+ from: IBridgeMailAddress[];
342
+ to: IBridgeMailAddress[];
343
+ cc: IBridgeMailAddress[];
344
+ bcc: IBridgeMailAddress[];
345
+ subject?: string;
346
+ date?: string;
347
+ }
348
+ /** One body group: the text and HTML sections of one multipart/alternative or one body part. */
349
+ export interface IBridgeMailBodyGroup {
350
+ text?: string;
351
+ html?: string;
352
+ messageHeader?: IBridgeMessageHeader;
353
+ }
354
+ export interface IBridgeParsedAttachment {
355
+ filename?: string;
356
+ contentType: string;
357
+ disposition?: 'attachment' | 'inline';
358
+ contentId?: string;
359
+ /** Standard base64 of the transfer-decoded bytes. */
360
+ content: string;
361
+ size: number;
362
+ }
363
+ /**
364
+ * A message as the Rust mailer-mime crate parsed it (docs/cleanroom/mailer-mime.md section 2.3).
365
+ * Each body travels once, in `bodyGroups`; the flattened From list is the concatenation of
366
+ * `fromFields`.
367
+ */
368
+ export interface IBridgeParsedMessage {
369
+ headers: Array<{
370
+ key: string;
371
+ name: string;
372
+ value: string;
373
+ }>;
374
+ headerLines: Array<{
375
+ key: string;
376
+ line: string;
377
+ }>;
378
+ messageId?: string;
379
+ inReplyTo?: string;
380
+ references: string[];
381
+ /** ISO 8601 UTC with milliseconds. */
382
+ date?: string;
383
+ subject?: string;
384
+ sender?: IBridgeMailAddress;
385
+ replyTo: IBridgeMailAddress[];
386
+ to: IBridgeMailAddress[];
387
+ cc: IBridgeMailAddress[];
388
+ bcc: IBridgeMailAddress[];
389
+ bodyGroups: IBridgeMailBodyGroup[];
390
+ attachments: IBridgeParsedAttachment[];
391
+ /** One flattened mailbox list per From field, in field order. */
392
+ fromFields: IBridgeMailAddress[][];
393
+ partFilenames: string[];
394
+ abruptHeaderEnd: boolean;
395
+ }
334
396
  interface IEmailReceivedEvent {
335
397
  correlationId: string;
336
398
  sessionId: string;
@@ -342,6 +404,8 @@ interface IEmailReceivedEvent {
342
404
  secure: boolean;
343
405
  authenticatedUser: string | null;
344
406
  securityResults: IInboundEmailSecurityResult | null;
407
+ /** The one parse Rust made at DATA. */
408
+ parsed: IBridgeParsedMessage;
345
409
  }
346
410
  interface IRcptToRequestEvent {
347
411
  correlationId: string;
@@ -395,7 +459,17 @@ export interface IBridgeResilienceConfig {
395
459
  export declare class RustSecurityBridge extends EventEmitter {
396
460
  private static instance;
397
461
  private static _resilienceConfig;
462
+ /** The server default maximum message size, used until `setMaxMessageSize` is called. */
463
+ private static readonly defaultMaxMessageSize;
464
+ /** The smartrust bridge of the running process; a new one is created at every spawn. */
398
465
  private bridge;
466
+ private readonly localPaths;
467
+ /** The IPC line cap the next spawn uses: 4 × the maximum message size. */
468
+ private _lineCap;
469
+ /** The line cap of the running process, which both transport ends were created with. */
470
+ private _runningLineCap;
471
+ /** Management event handlers, attached to every bridge this singleton creates. */
472
+ private readonly managementHandlers;
399
473
  private _running;
400
474
  private _state;
401
475
  private _restartAttempts;
@@ -406,12 +480,23 @@ export declare class RustSecurityBridge extends EventEmitter {
406
480
  private _deliberateStop;
407
481
  private _smtpServerConfig;
408
482
  /**
409
- * Map Node.js process.platform / process.arch to the tsrust target suffix
483
+ * Map Node.js process.platform / process.arch to the rsrepo target suffix
410
484
  * of the shipped binaries. Linux binaries are static musl builds, e.g.
411
485
  * mailer-bin_linux_amd64_musl.
412
486
  */
413
487
  private static getPlatformSuffix;
414
488
  private constructor();
489
+ /**
490
+ * Creates the smartrust bridge for one spawn. The line cap is fixed per process at both ends
491
+ * of the transport: smartrust's `maxPayloadSize` and `mailer-bin --max-line-bytes` get the
492
+ * one computed value. Lifecycle listeners and every registered management handler are
493
+ * attached, so a handler registered before a spawn or restart keeps receiving events.
494
+ */
495
+ private createBridge;
496
+ /** Replaces the bridge with a new one for the current cap and spawns it. */
497
+ private spawnBridge;
498
+ /** The bridge of the running process; commands are guarded by ensureRunning() first. */
499
+ private get activeBridge();
415
500
  /** Get or create the singleton instance. */
416
501
  static getInstance(): RustSecurityBridge;
417
502
  /** Reset the singleton instance (for testing). */
@@ -435,6 +520,20 @@ export declare class RustSecurityBridge extends EventEmitter {
435
520
  start(): Promise<boolean>;
436
521
  /** Kill the Rust process deliberately. */
437
522
  stop(): Promise<void>;
523
+ /** The IPC line cap the next spawn uses (4 × the maximum message size). */
524
+ get lineCap(): number;
525
+ /**
526
+ * Sets the SMTP maximum message size the IPC line cap derives from: `cap = 4 × n`, the one
527
+ * value used as smartrust's `maxPayloadSize` and as `mailer-bin --max-line-bytes`. Outbound
528
+ * requests (`sendEmail`, `sendRawEmail`, `signDkim`, `verifyDkim`) are limited by the same
529
+ * cap. When the process runs with a different cap it is restarted deliberately (no crash
530
+ * count, no backoff) and a stored listener configuration is restored; otherwise the value is
531
+ * recorded for the next spawn. Throws, changing nothing, for an `n` that is not a positive
532
+ * safe integer or whose cap is not a safe integer.
533
+ */
534
+ setMaxMessageSize(maxMessageSize: number): Promise<void>;
535
+ /** A deliberate restart for a changed line cap; it is not a crash. */
536
+ private restartForLineCap;
438
537
  private attemptRestart;
439
538
  private executeRestartAttempt;
440
539
  /**
@@ -500,6 +599,12 @@ export declare class RustSecurityBridge extends EventEmitter {
500
599
  hostname?: string;
501
600
  mailFrom: string;
502
601
  }): Promise<IEmailSecurityResult>;
602
+ /**
603
+ * Parses stored message bytes with the parser and setting of the DATA path (`parseMessage`,
604
+ * ruling Q1), so a replay builds the same Email the live path built. Rejects with the
605
+ * parser's error text when a parser limit is exceeded or the answer would exceed the line cap.
606
+ */
607
+ parseMessage(rawMessage: Buffer): Promise<IBridgeParsedMessage>;
503
608
  /** Send a structured email via the Rust SMTP client. */
504
609
  sendOutboundEmail(opts: ISmtpSendOptions): Promise<ISmtpSendResult>;
505
610
  /**
@@ -571,6 +676,8 @@ export declare class RustSecurityBridge extends EventEmitter {
571
676
  }): Promise<void>;
572
677
  /** Update rate limit configuration at runtime. */
573
678
  configureRateLimits(config: IRateLimitConfig): Promise<void>;
679
+ private addManagementHandler;
680
+ private removeManagementHandler;
574
681
  /**
575
682
  * Register a handler for emailReceived events from the Rust SMTP server.
576
683
  * These events fire when a complete email has been received and needs processing.