2026-02-10 16:38:31 +00:00
|
|
|
interface IDkimVerificationResult {
|
|
|
|
|
is_valid: boolean;
|
|
|
|
|
domain: string | null;
|
|
|
|
|
selector: string | null;
|
|
|
|
|
status: string;
|
|
|
|
|
details: string | null;
|
|
|
|
|
}
|
|
|
|
|
interface ISpfResult {
|
|
|
|
|
result: string;
|
|
|
|
|
domain: string;
|
|
|
|
|
ip: string;
|
|
|
|
|
explanation: string | null;
|
|
|
|
|
}
|
|
|
|
|
interface IDmarcResult {
|
|
|
|
|
passed: boolean;
|
|
|
|
|
policy: string;
|
|
|
|
|
domain: string;
|
|
|
|
|
dkim_result: string;
|
|
|
|
|
spf_result: string;
|
|
|
|
|
action: string;
|
|
|
|
|
details: string | null;
|
|
|
|
|
}
|
|
|
|
|
interface IEmailSecurityResult {
|
|
|
|
|
dkim: IDkimVerificationResult[];
|
|
|
|
|
spf: ISpfResult | null;
|
|
|
|
|
dmarc: IDmarcResult | null;
|
|
|
|
|
}
|
|
|
|
|
interface IValidationResult {
|
|
|
|
|
valid: boolean;
|
|
|
|
|
formatValid: boolean;
|
|
|
|
|
score: number;
|
|
|
|
|
error: string | null;
|
|
|
|
|
}
|
|
|
|
|
interface IBounceDetection {
|
|
|
|
|
bounce_type: string;
|
|
|
|
|
category: string;
|
|
|
|
|
}
|
|
|
|
|
interface IReputationResult {
|
|
|
|
|
ip: string;
|
|
|
|
|
score: number;
|
|
|
|
|
risk_level: string;
|
|
|
|
|
ip_type: string;
|
|
|
|
|
dnsbl_results: Array<{
|
|
|
|
|
server: string;
|
|
|
|
|
listed: boolean;
|
|
|
|
|
response: string | null;
|
|
|
|
|
}>;
|
|
|
|
|
listed_count: number;
|
|
|
|
|
total_checked: number;
|
|
|
|
|
}
|
2026-02-10 21:19:13 +00:00
|
|
|
interface IContentScanResult {
|
|
|
|
|
threatScore: number;
|
|
|
|
|
threatType: string | null;
|
|
|
|
|
threatDetails: string | null;
|
|
|
|
|
scannedElements: string[];
|
|
|
|
|
}
|
2026-02-10 16:38:31 +00:00
|
|
|
interface IVersionInfo {
|
|
|
|
|
bin: string;
|
|
|
|
|
core: string;
|
|
|
|
|
security: string;
|
|
|
|
|
smtp: string;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Bridge between TypeScript and the Rust `mailer-bin` binary.
|
|
|
|
|
*
|
|
|
|
|
* Uses `@push.rocks/smartrust` for JSON-over-stdin/stdout IPC.
|
|
|
|
|
* Singleton — access via `RustSecurityBridge.getInstance()`.
|
|
|
|
|
*/
|
|
|
|
|
export declare class RustSecurityBridge {
|
|
|
|
|
private static instance;
|
|
|
|
|
private bridge;
|
|
|
|
|
private _running;
|
|
|
|
|
private constructor();
|
|
|
|
|
/** Get or create the singleton instance. */
|
|
|
|
|
static getInstance(): RustSecurityBridge;
|
|
|
|
|
/** Whether the Rust process is currently running and accepting commands. */
|
|
|
|
|
get running(): boolean;
|
|
|
|
|
/**
|
|
|
|
|
* Spawn the Rust binary and wait for the ready signal.
|
|
|
|
|
* @returns `true` if the binary started successfully, `false` otherwise.
|
|
|
|
|
*/
|
|
|
|
|
start(): Promise<boolean>;
|
|
|
|
|
/** Kill the Rust process. */
|
|
|
|
|
stop(): Promise<void>;
|
|
|
|
|
/** Ping the Rust process. */
|
|
|
|
|
ping(): Promise<boolean>;
|
|
|
|
|
/** Get version information for all Rust crates. */
|
|
|
|
|
getVersion(): Promise<IVersionInfo>;
|
|
|
|
|
/** Validate an email address. */
|
|
|
|
|
validateEmail(email: string): Promise<IValidationResult>;
|
|
|
|
|
/** Detect bounce type from SMTP response / diagnostic code. */
|
|
|
|
|
detectBounce(opts: {
|
|
|
|
|
smtpResponse?: string;
|
|
|
|
|
diagnosticCode?: string;
|
|
|
|
|
statusCode?: string;
|
|
|
|
|
}): Promise<IBounceDetection>;
|
2026-02-10 21:19:13 +00:00
|
|
|
/** Scan email content for threats (phishing, spam, malware, etc.). */
|
|
|
|
|
scanContent(opts: {
|
|
|
|
|
subject?: string;
|
|
|
|
|
textBody?: string;
|
|
|
|
|
htmlBody?: string;
|
|
|
|
|
attachmentNames?: string[];
|
|
|
|
|
}): Promise<IContentScanResult>;
|
2026-02-10 16:38:31 +00:00
|
|
|
/** Check IP reputation via DNSBL. */
|
|
|
|
|
checkIpReputation(ip: string): Promise<IReputationResult>;
|
|
|
|
|
/** Verify DKIM signatures on a raw email message. */
|
|
|
|
|
verifyDkim(rawMessage: string): Promise<IDkimVerificationResult[]>;
|
|
|
|
|
/** Sign an email with DKIM. */
|
|
|
|
|
signDkim(opts: {
|
|
|
|
|
rawMessage: string;
|
|
|
|
|
domain: string;
|
|
|
|
|
selector?: string;
|
|
|
|
|
privateKey: string;
|
|
|
|
|
}): Promise<{
|
|
|
|
|
header: string;
|
|
|
|
|
signedMessage: string;
|
|
|
|
|
}>;
|
|
|
|
|
/** Check SPF for a sender. */
|
|
|
|
|
checkSpf(opts: {
|
|
|
|
|
ip: string;
|
|
|
|
|
heloDomain: string;
|
|
|
|
|
hostname?: string;
|
|
|
|
|
mailFrom: string;
|
|
|
|
|
}): Promise<ISpfResult>;
|
|
|
|
|
/**
|
|
|
|
|
* Compound email security verification: DKIM + SPF + DMARC in one IPC call.
|
|
|
|
|
*
|
|
|
|
|
* This is the preferred method for inbound email verification — it avoids
|
|
|
|
|
* 3 sequential round-trips and correctly passes raw mail-auth types internally.
|
|
|
|
|
*/
|
|
|
|
|
verifyEmail(opts: {
|
|
|
|
|
rawMessage: string;
|
|
|
|
|
ip: string;
|
|
|
|
|
heloDomain: string;
|
|
|
|
|
hostname?: string;
|
|
|
|
|
mailFrom: string;
|
|
|
|
|
}): Promise<IEmailSecurityResult>;
|
|
|
|
|
}
|
2026-02-10 21:19:13 +00:00
|
|
|
export type { IDkimVerificationResult, ISpfResult, IDmarcResult, IEmailSecurityResult, IValidationResult, IBounceDetection, IContentScanResult, IReputationResult as IRustReputationResult, IVersionInfo, };
|