-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c973e20
commit aadcd28
Showing
9 changed files
with
194 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import type { Email, MailboxAddrObject, MailboxAddrText, MailboxConfig } from './Mailbox.js'; | ||
import { type HeadersObject, MIMEMessageHeader } from './MIMEMessageHeader.js'; | ||
import { Mailbox } from './Mailbox.js'; | ||
import { MIMEMessageContent } from './MIMEMessageContent.js'; | ||
export declare class MIMEMessage { | ||
envctx: EnvironmentContext; | ||
headers: MIMEMessageHeader; | ||
boundaries: Boundaries; | ||
validTypes: string[]; | ||
validContentTransferEncodings: string[]; | ||
messages: MIMEMessageContent[]; | ||
constructor(envctx: EnvironmentContext); | ||
asRaw(): string; | ||
asEncoded(): string; | ||
dumpTextContent(plaintext: MIMEMessageContent | undefined, html: MIMEMessageContent | undefined, boundary: string): string; | ||
hasInlineAttachments(): boolean; | ||
hasAttachments(): boolean; | ||
getAttachments(): MIMEMessageContent[] | []; | ||
getInlineAttachments(): MIMEMessageContent[] | []; | ||
getMessageByType(type: string): MIMEMessageContent | undefined; | ||
addAttachment(opts: AttachmentOptions): MIMEMessageContent; | ||
addMessage(opts: ContentOptions): MIMEMessageContent; | ||
private _addMessage; | ||
setSender(input: MailboxAddrObject | MailboxAddrText | Email, config?: MailboxConfig): Mailbox; | ||
getSender(): string | Mailbox | undefined; | ||
setRecipients(input: MailboxAddrObject | MailboxAddrText | Email | MailboxAddrObject[] | MailboxAddrText[] | Email[], config?: MailboxConfig): Mailbox[]; | ||
getRecipients(config?: MailboxConfig): string | Mailbox | undefined; | ||
setRecipient(input: MailboxAddrObject | MailboxAddrText | Email | MailboxAddrObject[] | MailboxAddrText[] | Email[], config?: MailboxConfig): Mailbox[]; | ||
setTo(input: MailboxAddrObject | MailboxAddrText | Email | MailboxAddrObject[] | MailboxAddrText[] | Email[], config?: MailboxConfig): Mailbox[]; | ||
setCc(input: MailboxAddrObject | MailboxAddrText | Email | MailboxAddrObject[] | MailboxAddrText[] | Email[], config?: MailboxConfig): Mailbox[]; | ||
setBcc(input: MailboxAddrObject | MailboxAddrText | Email | MailboxAddrObject[] | MailboxAddrText[] | Email[], config?: MailboxConfig): Mailbox[]; | ||
setSubject(value: string): string; | ||
getSubject(): string | Mailbox | undefined; | ||
setHeader(name: string, value: any): string; | ||
getHeader(name: string): string | Mailbox | undefined; | ||
setHeaders(obj: Record<string, any>): string[]; | ||
getHeaders(): HeadersObject; | ||
toBase64(v: string): string; | ||
toBase64WebSafe(v: string): string; | ||
generateBoundaries(): void; | ||
isArray(v: unknown): v is any[]; | ||
isObject(v: unknown): v is object; | ||
} | ||
export interface EnvironmentContext { | ||
toBase64: (v: string) => string; | ||
toBase64WebSafe: (v: string) => string; | ||
eol: string; | ||
validateContentType: (v: string) => string | false; | ||
} | ||
export interface Boundaries { | ||
mixed: string; | ||
alt: string; | ||
related: string; | ||
} | ||
export type ContentTransferEncoding = '7bit' | '8bit' | 'binary' | 'quoted-printable' | 'base64'; | ||
export interface ContentHeaders { | ||
'Content-Type'?: string; | ||
'Content-Transfer-Encoding'?: ContentTransferEncoding; | ||
'Content-Disposition'?: string; | ||
'Content-ID'?: string; | ||
[index: string]: string | undefined; | ||
} | ||
export interface ContentOptions { | ||
data: string; | ||
encoding?: ContentTransferEncoding; | ||
contentType: string; | ||
headers?: ContentHeaders; | ||
charset?: string; | ||
} | ||
export interface AttachmentOptions extends ContentOptions { | ||
inline?: boolean; | ||
filename: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { EnvironmentContext } from './MIMEMessage'; | ||
import type { Mailbox } from './Mailbox'; | ||
import { type HeadersObject, MIMEMessageContentHeader } from './MIMEMessageHeader.js'; | ||
export declare class MIMEMessageContent { | ||
envctx: EnvironmentContext; | ||
headers: MIMEMessageContentHeader; | ||
data: string; | ||
constructor(envctx: EnvironmentContext, data: string, headers?: {}); | ||
dump(): string; | ||
isAttachment(): boolean; | ||
isInlineAttachment(): boolean; | ||
setHeader(name: string, value: any): string; | ||
getHeader(name: string): string | Mailbox | undefined; | ||
setHeaders(obj: Record<string, any>): string[]; | ||
getHeaders(): HeadersObject; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { EnvironmentContext } from './MIMEMessage'; | ||
import { Mailbox } from './Mailbox.js'; | ||
export declare class MIMEMessageHeader { | ||
envctx: EnvironmentContext; | ||
fields: HeaderField[]; | ||
constructor(envctx: EnvironmentContext); | ||
dump(): string; | ||
toObject(): HeadersObject; | ||
get(name: string): string | Mailbox | undefined; | ||
set(name: string, value: any): HeaderField; | ||
setCustom(obj: HeaderField): HeaderField; | ||
validateMailboxSingle(v: unknown): v is Mailbox; | ||
validateMailboxMulti(v: unknown): boolean; | ||
dumpMailboxMulti(v: unknown): string; | ||
dumpMailboxSingle(v: unknown): string; | ||
isHeaderField(v: unknown): v is HeaderField; | ||
isObject(v: unknown): v is object; | ||
isArrayOfMailboxes(v: unknown): v is Mailbox[]; | ||
isArray(v: unknown): v is any[]; | ||
} | ||
export declare class MIMEMessageContentHeader extends MIMEMessageHeader { | ||
fields: { | ||
name: string; | ||
}[]; | ||
constructor(envctx: EnvironmentContext); | ||
} | ||
export type HeadersObject = Record<string, string | Mailbox | undefined>; | ||
export interface HeaderField { | ||
name: string; | ||
dump?: (v: string | Mailbox | Mailbox[] | undefined) => string; | ||
value?: string | Mailbox | undefined; | ||
validate?: (v: unknown) => boolean; | ||
required?: boolean; | ||
disabled?: boolean; | ||
generator?: () => string; | ||
custom?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export declare class MIMETextError extends Error { | ||
name: string; | ||
description: string; | ||
constructor(message: string, description?: string); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export declare class Mailbox { | ||
reSpecCompliantAddr: RegExp; | ||
name: string; | ||
addr: string; | ||
type: MailboxType; | ||
constructor(input: MailboxAddrObject | MailboxAddrText | Email, config?: MailboxConfig); | ||
getAddrDomain(): string; | ||
dump(): string; | ||
parse(input: MailboxAddrObject | MailboxAddrText | Email): this; | ||
isMailboxAddrText(v: unknown): v is MailboxAddrText; | ||
isMailboxAddrObject(v: unknown): v is MailboxAddrObject; | ||
isObject(v: unknown): v is object; | ||
} | ||
export interface MailboxConfig { | ||
type: MailboxType; | ||
} | ||
export interface MailboxAddrObject { | ||
addr: string; | ||
name?: string; | ||
type?: MailboxType; | ||
} | ||
export type MailboxType = 'To' | 'From' | 'Cc' | 'Bcc'; | ||
export type Email = string; | ||
export type MailboxAddrText = string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { MIMEMessage } from '../MIMEMessage.js'; | ||
export declare function createMimeMessage(): MIMEMessage; | ||
export { MIMEMessage } from '../MIMEMessage.js'; | ||
export { Mailbox } from '../Mailbox.js'; | ||
export { MIMETextError } from '../MIMETextError.js'; | ||
export { MIMEMessageHeader } from '../MIMEMessageHeader.js'; | ||
export { MIMEMessageContent } from '../MIMEMessageContent.js'; | ||
export type * from '../MIMEMessage.js'; | ||
export type * from '../Mailbox.js'; | ||
export type * from '../MIMETextError.js'; | ||
export type * from '../MIMEMessageHeader.js'; | ||
export type * from '../MIMEMessageContent.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { MIMEMessage } from '../MIMEMessage.js'; | ||
export declare function createMimeMessage(): MIMEMessage; | ||
export { MIMEMessage } from '../MIMEMessage.js'; | ||
export { Mailbox } from '../Mailbox.js'; | ||
export { MIMETextError } from '../MIMETextError.js'; | ||
export { MIMEMessageHeader } from '../MIMEMessageHeader.js'; | ||
export { MIMEMessageContent } from '../MIMEMessageContent.js'; | ||
export type * from '../MIMEMessage.js'; | ||
export type * from '../Mailbox.js'; | ||
export type * from '../MIMETextError.js'; | ||
export type * from '../MIMEMessageHeader.js'; | ||
export type * from '../MIMEMessageContent.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { MIMEMessage } from '../MIMEMessage.js'; | ||
export declare function createMimeMessage(): MIMEMessage; | ||
export { MIMEMessage } from '../MIMEMessage.js'; | ||
export { Mailbox } from '../Mailbox.js'; | ||
export { MIMETextError } from '../MIMETextError.js'; | ||
export { MIMEMessageHeader } from '../MIMEMessageHeader.js'; | ||
export { MIMEMessageContent } from '../MIMEMessageContent.js'; | ||
export type * from '../MIMEMessage.js'; | ||
export type * from '../Mailbox.js'; | ||
export type * from '../MIMETextError.js'; | ||
export type * from '../MIMEMessageHeader.js'; | ||
export type * from '../MIMEMessageContent.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters