@crewhaus/tool-notify 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +2167 -0
- package/dist/lib/blocks.d.ts +113 -0
- package/dist/lib/blocks.js +217 -0
- package/dist/lib/digest.d.ts +56 -0
- package/dist/lib/digest.js +140 -0
- package/dist/lib/dns-records.d.ts +179 -0
- package/dist/lib/dns-records.js +431 -0
- package/dist/lib/mime.d.ts +125 -0
- package/dist/lib/mime.js +618 -0
- package/dist/lib/preflight.d.ts +71 -0
- package/dist/lib/preflight.js +291 -0
- package/dist/lib/quiet.d.ts +59 -0
- package/dist/lib/quiet.js +217 -0
- package/dist/lib/ratelimit.d.ts +57 -0
- package/dist/lib/ratelimit.js +87 -0
- package/dist/lib/sign.d.ts +8 -0
- package/dist/lib/sign.js +39 -0
- package/dist/lib/template.d.ts +41 -0
- package/dist/lib/template.js +85 -0
- package/dist/net.d.ts +391 -0
- package/dist/net.js +1131 -0
- package/dist/paths.d.ts +42 -0
- package/dist/paths.js +158 -0
- package/dist/smtp.d.ts +56 -0
- package/dist/smtp.js +479 -0
- package/package.json +45 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export declare const CRLF = "\r\n";
|
|
2
|
+
/**
|
|
3
|
+
* An address the message may carry. `name` is optional; when present it is
|
|
4
|
+
* encoded or quoted as the address form requires.
|
|
5
|
+
*/
|
|
6
|
+
export type Mailbox = {
|
|
7
|
+
readonly address: string;
|
|
8
|
+
readonly name?: string;
|
|
9
|
+
};
|
|
10
|
+
export type Attachment = {
|
|
11
|
+
readonly filename: string;
|
|
12
|
+
readonly contentType: string;
|
|
13
|
+
readonly content: Uint8Array;
|
|
14
|
+
/** `inline` for something referenced by the HTML part; `attachment` else. */
|
|
15
|
+
readonly disposition?: "attachment" | "inline";
|
|
16
|
+
/** `cid:` reference for an inline part. */
|
|
17
|
+
readonly contentId?: string;
|
|
18
|
+
};
|
|
19
|
+
export type ComposeInput = {
|
|
20
|
+
readonly from: Mailbox;
|
|
21
|
+
readonly to: readonly Mailbox[];
|
|
22
|
+
readonly cc?: readonly Mailbox[];
|
|
23
|
+
/**
|
|
24
|
+
* Blind recipients. They are envelope-only: an address here reaches the
|
|
25
|
+
* RCPT TO list and NEVER a header, because a `Bcc:` header in a delivered
|
|
26
|
+
* message is how blind copies stop being blind.
|
|
27
|
+
*/
|
|
28
|
+
readonly bcc?: readonly Mailbox[];
|
|
29
|
+
readonly replyTo?: readonly Mailbox[];
|
|
30
|
+
readonly subject: string;
|
|
31
|
+
readonly text: string;
|
|
32
|
+
readonly html?: string;
|
|
33
|
+
readonly attachments?: readonly Attachment[];
|
|
34
|
+
/** The instant the message claims to have been written. Never the clock. */
|
|
35
|
+
readonly date: Date;
|
|
36
|
+
/**
|
|
37
|
+
* The left-hand side of `Message-ID`. Omitted ⇒ derived from a hash of the
|
|
38
|
+
* message, so the same message always carries the same id and a duplicate
|
|
39
|
+
* is recognisable as one.
|
|
40
|
+
*/
|
|
41
|
+
readonly messageIdLocal?: string;
|
|
42
|
+
/** Domain for `Message-ID`. Omitted ⇒ the sender address's domain. */
|
|
43
|
+
readonly messageIdDomain?: string;
|
|
44
|
+
readonly inReplyTo?: string;
|
|
45
|
+
readonly references?: readonly string[];
|
|
46
|
+
/** Extra headers. Names are validated; values are encoded like any other. */
|
|
47
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
48
|
+
};
|
|
49
|
+
export type ComposeResult = {
|
|
50
|
+
readonly ok: true;
|
|
51
|
+
/** The full message: headers, blank line, body. CRLF line endings. */
|
|
52
|
+
readonly message: string;
|
|
53
|
+
readonly messageId: string;
|
|
54
|
+
readonly bytes: number;
|
|
55
|
+
/** Envelope recipients, deduplicated and in a stable order. */
|
|
56
|
+
readonly envelopeTo: readonly string[];
|
|
57
|
+
} | {
|
|
58
|
+
readonly ok: false;
|
|
59
|
+
readonly error: string;
|
|
60
|
+
};
|
|
61
|
+
export declare function isValidAddress(address: string): boolean;
|
|
62
|
+
/** The domain half of an address, lowercased. `null` when there is none. */
|
|
63
|
+
export declare function addressDomain(address: string): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* RFC 2047 encoded words, base64, UTF-8.
|
|
66
|
+
*
|
|
67
|
+
* An encoded word may be at most 75 characters. `=?UTF-8?B?` + `?=` costs
|
|
68
|
+
* 12, so the base64 payload is capped at 60 characters — 45 source bytes —
|
|
69
|
+
* and the split is made on whole code points, because half of a UTF-8
|
|
70
|
+
* sequence in one word and half in the next decodes to a replacement
|
|
71
|
+
* character on every client.
|
|
72
|
+
*/
|
|
73
|
+
export declare function encodeWords(text: string): string;
|
|
74
|
+
/** A header value safe to emit: encoded when it has to be, raw when it can be. */
|
|
75
|
+
export declare function encodeHeaderValue(text: string): string;
|
|
76
|
+
/** `Name <addr>`, with the display name quoted or encoded as needed. */
|
|
77
|
+
export declare function formatMailbox(mailbox: Mailbox): string;
|
|
78
|
+
/** RFC 5322 date in UTC. Locale-free by construction — no `toLocaleString`. */
|
|
79
|
+
export declare function formatDate(date: Date): string;
|
|
80
|
+
/**
|
|
81
|
+
* The two header questions asked in more than one place.
|
|
82
|
+
*
|
|
83
|
+
* `EmailSendPreflight` reports every bad header name at once, while
|
|
84
|
+
* `composeMessage` refuses at the first. Both have to be asking the SAME
|
|
85
|
+
* question: a preflight that says "ready" against its own copy of the rule,
|
|
86
|
+
* and a compose that then refuses, is a preflight nobody can act on. So the
|
|
87
|
+
* predicate is exported and the composer below is one of its callers rather
|
|
88
|
+
* than a second implementation.
|
|
89
|
+
*/
|
|
90
|
+
export declare function isValidHeaderName(name: string): boolean;
|
|
91
|
+
export declare function isReservedHeaderName(name: string): boolean;
|
|
92
|
+
/** True for exactly one bracketed message id, per the grammar above. */
|
|
93
|
+
export declare function isMessageId(value: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Quoted-printable, per RFC 2045 §6.7.
|
|
96
|
+
*
|
|
97
|
+
* The parts people get wrong, handled explicitly: trailing whitespace before
|
|
98
|
+
* a hard break is encoded (a relay that strips it would otherwise change the
|
|
99
|
+
* message), a soft break is never inserted inside an `=XX` triplet, hard
|
|
100
|
+
* breaks stay CRLF rather than being encoded, and a line-leading `.` is
|
|
101
|
+
* encoded so no amount of SMTP dot handling can eat it.
|
|
102
|
+
*/
|
|
103
|
+
export declare function encodeQuotedPrintable(text: string): string;
|
|
104
|
+
/** Base64, wrapped at 76 columns. */
|
|
105
|
+
export declare function encodeBase64Lines(bytes: Uint8Array): string;
|
|
106
|
+
/**
|
|
107
|
+
* A MIME boundary derived from the content it separates.
|
|
108
|
+
*
|
|
109
|
+
* Random boundaries make the same message compose to different bytes every
|
|
110
|
+
* time, which costs the caller the ability to compare two composes or to use
|
|
111
|
+
* the message as its own idempotency key. Hashing the parts keeps the
|
|
112
|
+
* boundary unique-in-practice while staying reproducible; the `=_` prefix
|
|
113
|
+
* uses characters that cannot appear in base64 or quoted-printable output,
|
|
114
|
+
* so a boundary can never collide with the content it delimits.
|
|
115
|
+
*/
|
|
116
|
+
export declare function boundaryFor(kind: string, material: string): string;
|
|
117
|
+
/** Build the complete message. Pure: same input, same bytes, every time. */
|
|
118
|
+
export declare function composeMessage(input: ComposeInput): ComposeResult;
|
|
119
|
+
/**
|
|
120
|
+
* Dot-stuff a message for SMTP DATA, per RFC 5321 §4.5.2, and terminate it.
|
|
121
|
+
*
|
|
122
|
+
* A line that begins with `.` would otherwise end the DATA phase early and
|
|
123
|
+
* leave the remainder of the message being parsed as commands.
|
|
124
|
+
*/
|
|
125
|
+
export declare function dotStuff(message: string): string;
|