Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions types/nodemailer/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
!**/*.d.mts
!**/*.d.*.ts
/v6/
/v7/
2 changes: 1 addition & 1 deletion types/nodemailer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/nodemailer",
"version": "7.0.9999",
"version": "8.0.9999",
"projects": [
"https://github.com/nodemailer/nodemailer",
"https://nodemailer.com"
Expand Down
5 changes: 5 additions & 0 deletions types/nodemailer/v7/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
82 changes: 82 additions & 0 deletions types/nodemailer/v7/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/// <reference types="node" />

import JSONTransport = require("./lib/json-transport");
import Mail = require("./lib/mailer");
import MailMessage = require("./lib/mailer/mail-message");
import SendmailTransport = require("./lib/sendmail-transport");
import SESTransport = require("./lib/ses-transport");
import SMTPPool = require("./lib/smtp-pool");
import SMTPTransport = require("./lib/smtp-transport");
import StreamTransport = require("./lib/stream-transport");

export type SendMailOptions = Mail.Options;

export type Transporter<T = any, D extends TransportOptions = TransportOptions> = Mail<T, D>;

export type SentMessageInfo = any;

export interface Transport<T = any, D extends TransportOptions = TransportOptions> {
mailer?: Transporter<T, D> | undefined;

name: string;
version: string;

send(mail: MailMessage<T>, callback: (err: Error | null, info: T) => void): void;

verify?(callback: (err: Error | null, success: true) => void): void;
verify?(): Promise<true>;

close?(): void;
}

export interface TransportOptions {
component?: string | undefined;
}

export interface TestAccount {
user: string;
pass: string;
smtp: { host: string; port: number; secure: boolean };
imap: { host: string; port: number; secure: boolean };
pop3: { host: string; port: number; secure: boolean };
web: string;
}

export function createTransport(
transport: SMTPPool | SMTPPool.Options,
defaults?: SMTPPool.Options,
): Transporter<SMTPPool.SentMessageInfo, SMTPPool.Options>;
export function createTransport(
transport: SendmailTransport | SendmailTransport.Options,
defaults?: SendmailTransport.Options,
): Transporter<SendmailTransport.SentMessageInfo, SendmailTransport.Options>;
export function createTransport(
transport: StreamTransport | StreamTransport.Options,
defaults?: StreamTransport.Options,
): Transporter<StreamTransport.SentMessageInfo, StreamTransport.Options>;
export function createTransport(
transport: JSONTransport | JSONTransport.Options,
defaults?: JSONTransport.Options,
): Transporter<JSONTransport.SentMessageInfo, JSONTransport.Options>;
export function createTransport(
transport: SESTransport | SESTransport.Options,
defaults?: SESTransport.Options,
): Transporter<SESTransport.SentMessageInfo, SESTransport.Options>;
export function createTransport(
transport?: SMTPTransport | SMTPTransport.Options | string,
defaults?: SMTPTransport.Options,
): Transporter<SMTPTransport.SentMessageInfo, SMTPTransport.Options>;
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
export function createTransport<T>(
transport: Transport<T> | TransportOptions,
defaults?: TransportOptions,
): Transporter<SMTPTransport.SentMessageInfo, SMTPTransport.Options>;

export function createTestAccount(
apiUrl: string,
callback: (err: Error | null, testAccount: TestAccount) => void,
): void;
export function createTestAccount(callback: (err: Error | null, testAccount: TestAccount) => void): void;
export function createTestAccount(apiUrl?: string): Promise<TestAccount>;

export function getTestMessageUrl(info: SESTransport.SentMessageInfo | SMTPTransport.SentMessageInfo): string | false;
31 changes: 31 additions & 0 deletions types/nodemailer/v7/lib/addressparser/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
declare namespace addressparser {
interface Address {
name: string;
address: string;
}

interface Group {
name: string;
group: Address[];
}

type AddressOrGroup = Address | Group;
}

/**
* Parses structured e-mail addresses from an address field
*
* Example:
*
* 'Name <address@domain>'
*
* will be converted to
*
* [{name: 'Name', address: 'address@domain'}]
*
* @return An array of address objects
*/
declare function addressparser(address: string, options: { flatten: true }): addressparser.Address[];
declare function addressparser(address: string, options?: { flatten: false }): addressparser.AddressOrGroup[];

export = addressparser;
22 changes: 22 additions & 0 deletions types/nodemailer/v7/lib/base64/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference types="node" />

import { Transform, TransformOptions } from "stream";

/** Encodes a Buffer into a base64 encoded string */
export function encode(buffer: Buffer | string): string;

/** Adds soft line breaks to a base64 string */
export function wrap(str: string, lineLength?: number): string;

export interface EncoderOptions extends TransformOptions {
lineLength?: number | false | undefined;
}

export class Encoder extends Transform {
options: EncoderOptions;

inputBytes: number;
outputBytes: number;

constructor(options?: EncoderOptions);
}
45 changes: 45 additions & 0 deletions types/nodemailer/v7/lib/dkim/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/// <reference types="node" />

import { PassThrough, Readable } from "stream";

declare namespace DKIM {
interface OptionalOptions {
/** optional location for cached messages. If not set then caching is not used. */
cacheDir?: string | false | undefined;
/** optional size in bytes, if message is larger than this treshold it gets cached to disk (assuming cacheDir is set and writable). Defaults to 131072 (128 kB). */
cacheTreshold?: number | undefined;
/** optional algorithm for the body hash, defaults to ‘sha256’ */
hashAlgo?: string | undefined;
/** an optional colon separated list of header keys to sign (eg. message-id:date:from:to...') */
headerFieldNames?: string | undefined;
/** optional colon separated list of header keys not to sign. This is useful if you want to sign all the relevant keys but your provider changes some values, ie Message-ID and Date. In this case you should use 'message-id:date' to prevent signing these values. */
skipFields?: string | undefined;
}

interface SingleKeyOptions extends OptionalOptions {
/** is the domain name to use in the signature */
domainName: string;
/** is the DKIM key selector */
keySelector: string;
/** is the private key for the selector in PEM format */
privateKey: string | { key: string; passphrase: string };
}

interface MultipleKeysOptions extends OptionalOptions {
/** is an optional array of key objects (domainName, keySelector, privateKey) if you want to add more than one signature to the message. If this value is set then the default key values are ignored */
keys: SingleKeyOptions[];
}

type Options = SingleKeyOptions | MultipleKeysOptions;
}

declare class DKIM {
options: DKIM.Options;
keys: DKIM.SingleKeyOptions[];

constructor(options?: DKIM.Options);

sign(input: string | Buffer | Readable, extraOptions?: DKIM.Options): PassThrough;
}

export = DKIM;
75 changes: 75 additions & 0 deletions types/nodemailer/v7/lib/dkim/message-parser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/// <reference types="node" />

import { Transform } from "stream";

declare namespace MessageParser {
interface Header {
key: string;
line: string;
}
}

/**
* MessageParser instance is a transform stream that separates message headers
* from the rest of the body. Headers are emitted with the 'headers' event. Message
* body is passed on as the resulting stream.
*/
declare class MessageParser extends Transform {
addListener(event: "headers", listener: (headers: MessageParser.Header[]) => void): this;
addListener(event: "close", listener: () => void): this;
addListener(event: "data", listener: (chunk: any) => void): this;
addListener(event: "end", listener: () => void): this;
addListener(event: "readable", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;

emit(event: "headers", headers: MessageParser.Header[]): boolean;
emit(event: "close"): boolean;
emit(event: "data", chunk: any): boolean;
emit(event: "end"): boolean;
emit(event: "readable"): boolean;
emit(event: "error", err: Error): boolean;
emit(event: string | symbol, ...args: any[]): boolean;

on(event: "headers", listener: (headers: MessageParser.Header[]) => void): this;
on(event: "close", listener: () => void): this;
on(event: "data", listener: (chunk: any) => void): this;
on(event: "end", listener: () => void): this;
on(event: "readable", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;

once(event: "headers", listener: (headers: MessageParser.Header[]) => void): this;
once(event: "close", listener: () => void): this;
once(event: "data", listener: (chunk: any) => void): this;
once(event: "end", listener: () => void): this;
once(event: "readable", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;

prependListener(event: "headers", listener: (headers: MessageParser.Header[]) => void): this;
prependListener(event: "close", listener: () => void): this;
prependListener(event: "data", listener: (chunk: any) => void): this;
prependListener(event: "end", listener: () => void): this;
prependListener(event: "readable", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;

prependOnceListener(event: "headers", listener: (headers: MessageParser.Header[]) => void): this;
prependOnceListener(event: "close", listener: () => void): this;
prependOnceListener(event: "data", listener: (chunk: any) => void): this;
prependOnceListener(event: "end", listener: () => void): this;
prependOnceListener(event: "readable", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;

removeListener(event: "headers", listener: (headers: MessageParser.Header[]) => void): this;
removeListener(event: "close", listener: () => void): this;
removeListener(event: "data", listener: (chunk: any) => void): this;
removeListener(event: "end", listener: () => void): this;
removeListener(event: "readable", listener: () => void): this;
removeListener(event: "error", listener: (err: Error) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
}

export = MessageParser;
75 changes: 75 additions & 0 deletions types/nodemailer/v7/lib/dkim/relaxed-body.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/// <reference types="node" />

import { Transform, TransformOptions } from "stream";

declare namespace RelaxedBody {
interface Options extends TransformOptions {
hashAlgo?: string;
debug?: boolean;
}
}

/**
* Streams through a message body and calculates relaxed body hash
*/
declare class RelaxedBody extends Transform {
constructor(options?: RelaxedBody.Options);

addListener(event: "hash", listener: (digest: Buffer, debugBody: Buffer | false) => void): this;
addListener(event: "close", listener: () => void): this;
addListener(event: "data", listener: (chunk: any) => void): this;
addListener(event: "end", listener: () => void): this;
addListener(event: "readable", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: string | symbol, listener: (...args: any[]) => void): this;

emit(event: "hash", digest: Buffer, debugBody: Buffer | false): boolean;
emit(event: "close"): boolean;
emit(event: "data", chunk: any): boolean;
emit(event: "end"): boolean;
emit(event: "readable"): boolean;
emit(event: "error", err: Error): boolean;
emit(event: string | symbol, ...args: any[]): boolean;

on(event: "hash", listener: (digest: Buffer, debugBody: Buffer | false) => void): this;
on(event: "close", listener: () => void): this;
on(event: "data", listener: (chunk: any) => void): this;
on(event: "end", listener: () => void): this;
on(event: "readable", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;

once(event: "hash", listener: (digest: Buffer, debugBody: Buffer | false) => void): this;
once(event: "close", listener: () => void): this;
once(event: "data", listener: (chunk: any) => void): this;
once(event: "end", listener: () => void): this;
once(event: "readable", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;

prependListener(event: "hash", listener: (digest: Buffer, debugBody: Buffer | false) => void): this;
prependListener(event: "close", listener: () => void): this;
prependListener(event: "data", listener: (chunk: any) => void): this;
prependListener(event: "end", listener: () => void): this;
prependListener(event: "readable", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;

prependOnceListener(event: "hash", listener: (digest: Buffer, debugBody: Buffer | false) => void): this;
prependOnceListener(event: "close", listener: () => void): this;
prependOnceListener(event: "data", listener: (chunk: any) => void): this;
prependOnceListener(event: "end", listener: () => void): this;
prependOnceListener(event: "readable", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;

removeListener(event: "hash", listener: (digest: Buffer, debugBody: Buffer | false) => void): this;
removeListener(event: "close", listener: () => void): this;
removeListener(event: "data", listener: (chunk: any) => void): this;
removeListener(event: "end", listener: () => void): this;
removeListener(event: "readable", listener: () => void): this;
removeListener(event: "error", listener: (err: Error) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
}

export = RelaxedBody;
21 changes: 21 additions & 0 deletions types/nodemailer/v7/lib/dkim/sign.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import DKIM = require(".");
import MessageParser = require("./message-parser");

/** Returns DKIM signature header line */
declare function relaxedHeaders(
headers: MessageParser.Header[],
hashAlgo: string,
bodyHash: string,
options?: DKIM.SingleKeyOptions,
): string;

declare namespace relaxedHeaders {
function relaxedHeaders(
headers: MessageParser.Header[],
hashAlgo: string,
bodyHash: string,
options?: DKIM.SingleKeyOptions,
): string;
}

export = relaxedHeaders;
Loading