feat(rust): scaffold Rust workspace and fix TypeScript build errors
- Add @git.zone/tsrust with linux_amd64/linux_arm64 cross-compilation - Scaffold Rust workspace with 5 crates: mailer-core, mailer-smtp, mailer-security, mailer-napi, mailer-bin - Fix all TypeScript compilation errors for upgraded dependencies (smartfile v13, mailauth v4.13, smartproxy v23) - Replace smartfile.fs/memory with @push.rocks/smartfs throughout codebase - Fix .ts import extensions to .js for NodeNext module resolution - Update DKIMSignOptions usage to match mailauth v4.13 API - Add MTA error classes with permissive signatures for legacy SMTP client - Replace removed DcRouter/StorageManager/deliverability imports with local interfaces
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import * as plugins from '../../plugins.ts';
|
||||
import { logger } from '../../logger.ts';
|
||||
import * as plugins from '../../plugins.js';
|
||||
import { logger } from '../../logger.js';
|
||||
import {
|
||||
SecurityLogger,
|
||||
SecurityLogLevel,
|
||||
SecurityEventType
|
||||
} from '../../security/index.ts';
|
||||
} from '../../security/index.js';
|
||||
|
||||
import {
|
||||
MtaConnectionError,
|
||||
@@ -13,10 +13,10 @@ import {
|
||||
MtaConfigurationError,
|
||||
MtaTimeoutError,
|
||||
MtaProtocolError
|
||||
} from '../../errors/index.ts';
|
||||
} from '../../errors/index.js';
|
||||
|
||||
import { Email } from '../core/classes.email.ts';
|
||||
import type { EmailProcessingMode } from './interfaces.ts';
|
||||
import { Email } from '../core/classes.email.js';
|
||||
import type { EmailProcessingMode } from './interfaces.js';
|
||||
|
||||
// Custom error type extension
|
||||
interface NodeNetworkError extends Error {
|
||||
@@ -851,22 +851,33 @@ export class SmtpClient {
|
||||
|
||||
// Sign email
|
||||
const signOptions = {
|
||||
domainName: this.options.dkim.domain,
|
||||
keySelector: this.options.dkim.selector,
|
||||
signingDomain: this.options.dkim.domain,
|
||||
selector: this.options.dkim.selector,
|
||||
privateKey: this.options.dkim.privateKey,
|
||||
headerFieldNames: this.options.dkim.headers || [
|
||||
'from', 'to', 'subject', 'date', 'message-id'
|
||||
canonicalization: 'relaxed/relaxed' as const,
|
||||
algorithm: 'rsa-sha256' as const,
|
||||
signTime: new Date(),
|
||||
signatureData: [
|
||||
{
|
||||
signingDomain: this.options.dkim.domain,
|
||||
selector: this.options.dkim.selector,
|
||||
privateKey: this.options.dkim.privateKey,
|
||||
algorithm: 'rsa-sha256',
|
||||
canonicalization: 'relaxed/relaxed',
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const signedEmail = await dkimSign(emailContent, signOptions);
|
||||
|
||||
// Replace headers in original email
|
||||
const dkimHeader = signedEmail.substring(0, signedEmail.indexOf('\r\n\r\n')).split('\r\n')
|
||||
.find(line => line.startsWith('DKIM-Signature: '));
|
||||
|
||||
if (dkimHeader) {
|
||||
email.addHeader('DKIM-Signature', dkimHeader.substring('DKIM-Signature: '.length));
|
||||
|
||||
const signResult = await dkimSign(emailContent, signOptions);
|
||||
|
||||
// Add DKIM-Signature header from the signing result
|
||||
if (signResult.signatures) {
|
||||
const dkimHeader = signResult.signatures.split('\r\n')
|
||||
.find(line => line.startsWith('DKIM-Signature: '));
|
||||
|
||||
if (dkimHeader) {
|
||||
email.addHeader('DKIM-Signature', dkimHeader.substring('DKIM-Signature: '.length));
|
||||
}
|
||||
}
|
||||
|
||||
logger.log('debug', 'DKIM signature applied successfully');
|
||||
|
||||
Reference in New Issue
Block a user