2026-09-15 13:00:32 +02:00
|
|
|
import { Transform } from 'node:stream';
|
|
|
|
|
import crypto from 'node:crypto';
|
|
|
|
|
/**
|
|
|
|
|
* Options for the relaxed body hash stream
|
|
|
|
|
*/
|
|
|
|
|
export interface RelaxedBodyOptions {
|
|
|
|
|
/** Hash algorithm for the body hash, defaults to sha256 */
|
|
|
|
|
hashAlgo?: string | undefined;
|
|
|
|
|
/** Collect the canonicalized body and emit it with the 'hash' event */
|
|
|
|
|
debug?: boolean | undefined;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Passes the message body through unchanged and hashes its relaxed
|
|
|
|
|
* canonicalization (RFC 6376 section 3.4.4) on the side: whitespace at the end
|
|
|
|
|
* of a line is dropped, runs of whitespace within a line become a single space,
|
|
|
|
|
* every line ends with CRLF, empty lines at the end of the body are ignored and
|
|
|
|
|
* a non-empty body always ends with CRLF. Bytes are canonicalized as they arrive,
|
|
|
|
|
* so a line of any length costs constant memory.
|
|
|
|
|
*/
|
2026-10-01 09:48:38 +02:00
|
|
|
declare class RelaxedBody extends Transform {
|
2026-09-15 13:00:32 +02:00
|
|
|
bodyHash: crypto.Hash;
|
|
|
|
|
/** Bytes of the original body seen so far */
|
|
|
|
|
byteLength: number;
|
|
|
|
|
debug: boolean | undefined;
|
|
|
|
|
constructor(options?: RelaxedBodyOptions);
|
|
|
|
|
updateHash(chunk: Buffer, final?: boolean): void;
|
|
|
|
|
}
|
2026-10-01 09:48:38 +02:00
|
|
|
/**
|
|
|
|
|
* Type aliases in the layout of @types/nodemailer, so `RelaxedBody.Options` style references keep working
|
|
|
|
|
*/
|
|
|
|
|
declare namespace RelaxedBody {
|
|
|
|
|
type Options = RelaxedBodyOptions;
|
|
|
|
|
}
|
|
|
|
|
/** The same alias as a module level export, for `import * as RelaxedBody` and `import RelaxedBody = require()` */
|
|
|
|
|
export type { RelaxedBodyOptions as Options };
|
|
|
|
|
export default RelaxedBody;
|