@geekmidas/emailkit 10.0.0-alpha.12 → 10.0.0-alpha.14
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/dist/client.cjs +81 -3
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +17 -3
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.mts +17 -3
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +56 -2
- package/dist/client.mjs.map +1 -0
- package/dist/errors.cjs +52 -4
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +39 -2
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +39 -2
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +49 -2
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +4 -5
- package/dist/types.d.cts +88 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +88 -2
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/url.cjs +60 -3
- package/dist/url.cjs.map +1 -0
- package/dist/url.d.cts +16 -3
- package/dist/url.d.cts.map +1 -0
- package/dist/url.d.mts +16 -3
- package/dist/url.d.mts.map +1 -0
- package/dist/url.mjs +59 -3
- package/dist/url.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/client-BkN5BGeJ.mjs +0 -58
- package/dist/client-BkN5BGeJ.mjs.map +0 -1
- package/dist/client-Dcgdc6HG.d.mts +0 -21
- package/dist/client-Dcgdc6HG.d.mts.map +0 -1
- package/dist/client-DyfZrCpo.d.cts +0 -21
- package/dist/client-DyfZrCpo.d.cts.map +0 -1
- package/dist/client-sZNHPYYg.cjs +0 -92
- package/dist/client-sZNHPYYg.cjs.map +0 -1
- package/dist/errors-6difZDw0.cjs +0 -68
- package/dist/errors-6difZDw0.cjs.map +0 -1
- package/dist/errors-Ba3cEHPO.mjs +0 -50
- package/dist/errors-Ba3cEHPO.mjs.map +0 -1
- package/dist/errors-ZllQgZ9Y.d.mts +0 -41
- package/dist/errors-ZllQgZ9Y.d.mts.map +0 -1
- package/dist/errors-xJ88z_5r.d.cts +0 -41
- package/dist/errors-xJ88z_5r.d.cts.map +0 -1
- package/dist/types-CoPG5az4.d.mts +0 -90
- package/dist/types-CoPG5az4.d.mts.map +0 -1
- package/dist/types-D5yAoaGX.d.cts +0 -90
- package/dist/types-D5yAoaGX.d.cts.map +0 -1
- package/dist/url-B2hKcFA3.d.mts +0 -20
- package/dist/url-B2hKcFA3.d.mts.map +0 -1
- package/dist/url-B8QqBrMt.mjs +0 -49
- package/dist/url-B8QqBrMt.mjs.map +0 -1
- package/dist/url-CVk3Cs_8.d.cts +0 -20
- package/dist/url-CVk3Cs_8.d.cts.map +0 -1
- package/dist/url-GT3jLGq-.cjs +0 -54
- package/dist/url-GT3jLGq-.cjs.map +0 -1
package/dist/errors-Ba3cEHPO.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
//#region src/errors.ts
|
|
2
|
-
/**
|
|
3
|
-
* Email URL errors.
|
|
4
|
-
*
|
|
5
|
-
* Every provider is reached over SMTP, so there are only two problems a URL can
|
|
6
|
-
* have: it is not a URL, or it names a scheme this transport cannot speak. Both
|
|
7
|
-
* carry the offending value as a field.
|
|
8
|
-
*
|
|
9
|
-
* Messages state the rule, which is constant, and never interpolate the value.
|
|
10
|
-
* An interpolated message cannot be matched on, reads differently every time it
|
|
11
|
-
* is thrown, and carries user input into every log line that touches it — and a
|
|
12
|
-
* mail URL's userinfo is a credential, which makes that leak a real one here.
|
|
13
|
-
*/
|
|
14
|
-
/** Base for anything wrong with an email URL, so callers may catch broadly. */
|
|
15
|
-
var EmailUrlError = class extends Error {
|
|
16
|
-
/** The URL that could not be used. Carries credentials — do not log it. */
|
|
17
|
-
url;
|
|
18
|
-
constructor(url, message) {
|
|
19
|
-
super(message);
|
|
20
|
-
this.url = url;
|
|
21
|
-
this.name = new.target.name;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
/** The string is not a URL at all. */
|
|
25
|
-
var MalformedEmailUrl = class extends EmailUrlError {
|
|
26
|
-
constructor(url) {
|
|
27
|
-
super(url, "Not a valid URL");
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* A URL, but naming a scheme that is not SMTP.
|
|
32
|
-
*
|
|
33
|
-
* Almost always `ses://` or `resend://` — a provider written where a protocol
|
|
34
|
-
* belongs. Mail is delivered over SMTP whoever is delivering it, so the provider
|
|
35
|
-
* shows up as the URL's host and credentials, never as its scheme.
|
|
36
|
-
*/
|
|
37
|
-
var UnsupportedEmailScheme = class extends EmailUrlError {
|
|
38
|
-
/** The scheme the URL carried, e.g. `'ses:'`. */
|
|
39
|
-
actual;
|
|
40
|
-
/** The schemes this transport speaks. */
|
|
41
|
-
expected = ["smtp:", "smtps:"];
|
|
42
|
-
constructor(url, actual) {
|
|
43
|
-
super(url, "Email URL scheme must be smtp: or smtps:");
|
|
44
|
-
this.actual = actual;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
export { EmailUrlError, MalformedEmailUrl, UnsupportedEmailScheme };
|
|
50
|
-
//# sourceMappingURL=errors-Ba3cEHPO.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-Ba3cEHPO.mjs","names":["url: string","message: string","actual: string"],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Email URL errors.\n *\n * Every provider is reached over SMTP, so there are only two problems a URL can\n * have: it is not a URL, or it names a scheme this transport cannot speak. Both\n * carry the offending value as a field.\n *\n * Messages state the rule, which is constant, and never interpolate the value.\n * An interpolated message cannot be matched on, reads differently every time it\n * is thrown, and carries user input into every log line that touches it — and a\n * mail URL's userinfo is a credential, which makes that leak a real one here.\n */\n\n/** Base for anything wrong with an email URL, so callers may catch broadly. */\nexport abstract class EmailUrlError extends Error {\n\t/** The URL that could not be used. Carries credentials — do not log it. */\n\treadonly url: string;\n\n\tconstructor(url: string, message: string) {\n\t\tsuper(message);\n\t\tthis.url = url;\n\t\tthis.name = new.target.name;\n\t}\n}\n\n/** The string is not a URL at all. */\nexport class MalformedEmailUrl extends EmailUrlError {\n\tconstructor(url: string) {\n\t\tsuper(url, 'Not a valid URL');\n\t}\n}\n\n/**\n * A URL, but naming a scheme that is not SMTP.\n *\n * Almost always `ses://` or `resend://` — a provider written where a protocol\n * belongs. Mail is delivered over SMTP whoever is delivering it, so the provider\n * shows up as the URL's host and credentials, never as its scheme.\n */\nexport class UnsupportedEmailScheme extends EmailUrlError {\n\t/** The scheme the URL carried, e.g. `'ses:'`. */\n\treadonly actual: string;\n\t/** The schemes this transport speaks. */\n\treadonly expected: readonly string[] = ['smtp:', 'smtps:'];\n\n\tconstructor(url: string, actual: string) {\n\t\tsuper(url, 'Email URL scheme must be smtp: or smtps:');\n\t\tthis.actual = actual;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,IAAsB,gBAAtB,cAA4C,MAAM;;CAEjD,AAAS;CAET,YAAYA,KAAaC,SAAiB;AACzC,QAAM,QAAQ;AACd,OAAK,MAAM;AACX,OAAK,OAAO,IAAI,OAAO;CACvB;AACD;;AAGD,IAAa,oBAAb,cAAuC,cAAc;CACpD,YAAYD,KAAa;AACxB,QAAM,KAAK,kBAAkB;CAC7B;AACD;;;;;;;;AASD,IAAa,yBAAb,cAA4C,cAAc;;CAEzD,AAAS;;CAET,AAAS,WAA8B,CAAC,SAAS,QAAS;CAE1D,YAAYA,KAAaE,QAAgB;AACxC,QAAM,KAAK,2CAA2C;AACtD,OAAK,SAAS;CACd;AACD"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/errors.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Email URL errors.
|
|
4
|
-
*
|
|
5
|
-
* Every provider is reached over SMTP, so there are only two problems a URL can
|
|
6
|
-
* have: it is not a URL, or it names a scheme this transport cannot speak. Both
|
|
7
|
-
* carry the offending value as a field.
|
|
8
|
-
*
|
|
9
|
-
* Messages state the rule, which is constant, and never interpolate the value.
|
|
10
|
-
* An interpolated message cannot be matched on, reads differently every time it
|
|
11
|
-
* is thrown, and carries user input into every log line that touches it — and a
|
|
12
|
-
* mail URL's userinfo is a credential, which makes that leak a real one here.
|
|
13
|
-
*/
|
|
14
|
-
/** Base for anything wrong with an email URL, so callers may catch broadly. */
|
|
15
|
-
declare abstract class EmailUrlError extends Error {
|
|
16
|
-
/** The URL that could not be used. Carries credentials — do not log it. */
|
|
17
|
-
readonly url: string;
|
|
18
|
-
constructor(url: string, message: string);
|
|
19
|
-
}
|
|
20
|
-
/** The string is not a URL at all. */
|
|
21
|
-
declare class MalformedEmailUrl extends EmailUrlError {
|
|
22
|
-
constructor(url: string);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* A URL, but naming a scheme that is not SMTP.
|
|
26
|
-
*
|
|
27
|
-
* Almost always `ses://` or `resend://` — a provider written where a protocol
|
|
28
|
-
* belongs. Mail is delivered over SMTP whoever is delivering it, so the provider
|
|
29
|
-
* shows up as the URL's host and credentials, never as its scheme.
|
|
30
|
-
*/
|
|
31
|
-
declare class UnsupportedEmailScheme extends EmailUrlError {
|
|
32
|
-
/** The scheme the URL carried, e.g. `'ses:'`. */
|
|
33
|
-
readonly actual: string;
|
|
34
|
-
/** The schemes this transport speaks. */
|
|
35
|
-
readonly expected: readonly string[];
|
|
36
|
-
constructor(url: string, actual: string);
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
39
|
-
//#endregion
|
|
40
|
-
export { EmailUrlError, MalformedEmailUrl, UnsupportedEmailScheme };
|
|
41
|
-
//# sourceMappingURL=errors-ZllQgZ9Y.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-ZllQgZ9Y.d.mts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;AAcA;AAYA;AAaA;;;;;;;;;;uBAzBsB,aAAA,SAAsB,KAAK;;;;;;cAYpC,iBAAA,SAA0B,aAAa;;;;;;;;;;cAavC,sBAAA,SAA+B,aAAa"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/errors.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Email URL errors.
|
|
4
|
-
*
|
|
5
|
-
* Every provider is reached over SMTP, so there are only two problems a URL can
|
|
6
|
-
* have: it is not a URL, or it names a scheme this transport cannot speak. Both
|
|
7
|
-
* carry the offending value as a field.
|
|
8
|
-
*
|
|
9
|
-
* Messages state the rule, which is constant, and never interpolate the value.
|
|
10
|
-
* An interpolated message cannot be matched on, reads differently every time it
|
|
11
|
-
* is thrown, and carries user input into every log line that touches it — and a
|
|
12
|
-
* mail URL's userinfo is a credential, which makes that leak a real one here.
|
|
13
|
-
*/
|
|
14
|
-
/** Base for anything wrong with an email URL, so callers may catch broadly. */
|
|
15
|
-
declare abstract class EmailUrlError extends Error {
|
|
16
|
-
/** The URL that could not be used. Carries credentials — do not log it. */
|
|
17
|
-
readonly url: string;
|
|
18
|
-
constructor(url: string, message: string);
|
|
19
|
-
}
|
|
20
|
-
/** The string is not a URL at all. */
|
|
21
|
-
declare class MalformedEmailUrl extends EmailUrlError {
|
|
22
|
-
constructor(url: string);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* A URL, but naming a scheme that is not SMTP.
|
|
26
|
-
*
|
|
27
|
-
* Almost always `ses://` or `resend://` — a provider written where a protocol
|
|
28
|
-
* belongs. Mail is delivered over SMTP whoever is delivering it, so the provider
|
|
29
|
-
* shows up as the URL's host and credentials, never as its scheme.
|
|
30
|
-
*/
|
|
31
|
-
declare class UnsupportedEmailScheme extends EmailUrlError {
|
|
32
|
-
/** The scheme the URL carried, e.g. `'ses:'`. */
|
|
33
|
-
readonly actual: string;
|
|
34
|
-
/** The schemes this transport speaks. */
|
|
35
|
-
readonly expected: readonly string[];
|
|
36
|
-
constructor(url: string, actual: string);
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
39
|
-
//#endregion
|
|
40
|
-
export { EmailUrlError, MalformedEmailUrl, UnsupportedEmailScheme };
|
|
41
|
-
//# sourceMappingURL=errors-xJ88z_5r.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-xJ88z_5r.d.cts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";;AAcA;AAYA;AAaA;;;;;;;;;;uBAzBsB,aAAA,SAAsB,KAAK;;;;;;cAYpC,iBAAA,SAA0B,aAAa;;;;;;;;;;cAavC,sBAAA,SAA+B,aAAa"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import Mail from "nodemailer/lib/mailer";
|
|
2
|
-
import { ReactElement } from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
type Address = Mail.Address;
|
|
6
|
-
interface EmailOptions {
|
|
7
|
-
from: string | Address;
|
|
8
|
-
to: string | string[] | Address[];
|
|
9
|
-
cc?: string | string[] | Address[];
|
|
10
|
-
bcc?: string | string[] | Address[];
|
|
11
|
-
subject: string;
|
|
12
|
-
replyTo?: string | Address;
|
|
13
|
-
attachments?: Attachment[];
|
|
14
|
-
}
|
|
15
|
-
interface Attachment {
|
|
16
|
-
filename: string;
|
|
17
|
-
content?: string | Buffer;
|
|
18
|
-
path?: string;
|
|
19
|
-
contentType?: string;
|
|
20
|
-
cid?: string;
|
|
21
|
-
}
|
|
22
|
-
interface PlainEmailOptions extends EmailOptions {
|
|
23
|
-
text?: string;
|
|
24
|
-
html?: string;
|
|
25
|
-
}
|
|
26
|
-
type SendOptions = Omit<PlainEmailOptions, 'from'> & {
|
|
27
|
-
from?: string | Address;
|
|
28
|
-
};
|
|
29
|
-
interface SMTPConfig {
|
|
30
|
-
host: string;
|
|
31
|
-
port: number;
|
|
32
|
-
secure?: boolean;
|
|
33
|
-
auth?: {
|
|
34
|
-
user: string;
|
|
35
|
-
pass: string;
|
|
36
|
-
};
|
|
37
|
-
tls?: {
|
|
38
|
-
rejectUnauthorized?: boolean;
|
|
39
|
-
servername?: string;
|
|
40
|
-
};
|
|
41
|
-
pool?: boolean;
|
|
42
|
-
maxConnections?: number;
|
|
43
|
-
maxMessages?: number;
|
|
44
|
-
rateLimit?: number;
|
|
45
|
-
logger?: boolean;
|
|
46
|
-
debug?: boolean;
|
|
47
|
-
}
|
|
48
|
-
interface SendResult {
|
|
49
|
-
messageId: string;
|
|
50
|
-
accepted: string[];
|
|
51
|
-
rejected: string[];
|
|
52
|
-
/**
|
|
53
|
-
* The transport's reply, where it made one.
|
|
54
|
-
*
|
|
55
|
-
* Optional because nodemailer types it that way: not every transport answers
|
|
56
|
-
* with a response line, and the previous `string` was a promise this could
|
|
57
|
-
* not keep. Defaulting it to `''` would have kept the shape by inventing a
|
|
58
|
-
* reply that never arrived.
|
|
59
|
-
*/
|
|
60
|
-
response?: string;
|
|
61
|
-
}
|
|
62
|
-
type EmailTemplate<T = any> = (props: T) => ReactElement;
|
|
63
|
-
type TemplateProps<T> = T extends EmailTemplate<infer P> ? P : never;
|
|
64
|
-
type TemplateRecord = Record<string, EmailTemplate<any>>;
|
|
65
|
-
type TemplateNames<T extends TemplateRecord> = keyof T;
|
|
66
|
-
type TemplatePropsFor<T extends TemplateRecord, K extends TemplateNames<T>> = TemplateProps<T[K]>;
|
|
67
|
-
interface EmailClientConfig<T extends TemplateRecord = TemplateRecord> {
|
|
68
|
-
smtp: SMTPConfig;
|
|
69
|
-
templates: T;
|
|
70
|
-
dkim?: {
|
|
71
|
-
domainName: string;
|
|
72
|
-
keySelector: string;
|
|
73
|
-
privateKey: string;
|
|
74
|
-
};
|
|
75
|
-
defaults: {
|
|
76
|
-
from?: string | Address;
|
|
77
|
-
replyTo?: string | Address;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
interface EmailClient<T extends TemplateRecord = TemplateRecord> {
|
|
81
|
-
send(options: SendOptions): Promise<SendResult>;
|
|
82
|
-
sendTemplate<K extends TemplateNames<T>>(template: K, options: SendOptions & {
|
|
83
|
-
props: TemplatePropsFor<T, K>;
|
|
84
|
-
}): Promise<SendResult>;
|
|
85
|
-
verify(): Promise<boolean>;
|
|
86
|
-
close(): Promise<void>;
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
export { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendOptions, SendResult, TemplateNames, TemplateProps, TemplatePropsFor, TemplateRecord };
|
|
90
|
-
//# sourceMappingURL=types-CoPG5az4.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-CoPG5az4.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;KAMK,OAAA,GAAU,IAAA,CAAK;UAEH,YAAA;EAFZ,IAAA,EAAA,MAAO,GAGI,OAHD;EAEE,EAAA,EAAA,MAAA,GAAA,MAAY,EAAA,GAEJ,OAFI,EAAA;EAAA,EAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAGH,OAHG,EAAA;EAAA,GACb,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAGW,OAHX,EAAA;EAAO,OACE,EAAA,MAAA;EAAO,OACN,CAAA,EAAA,MAAA,GAGN,OAHM;EAAO,WACN,CAAA,EAGZ,UAHY,EAAA;;AAGZ,UAGE,UAAA,CAHF;EAAU,QAAA,EAAA,MAAA;EAGR,OAAA,CAAA,EAAA,MAAU,GAEP,MAAA;EAMH,IAAA,CAAA,EAAA,MAAA;EAKL,WAAA,CAAA,EAAW,MAAA;EAAA,GAAA,CAAA,EAAA,MAAA;;AAAG,UALT,iBAAA,SAA0B,YAKjB,CAAA;EAAI,IACb,CAAA,EAAA,MAAA;EAAO,IAAA,CAAA,EAAA,MAAA;AAGxB;AAoBiB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,CAAA,CAAA,GAhBxB,aAgBwB,CAhBV,CAgBU,CAhBR,CAgBQ,CAAA,CAAA;AAAA,UAdX,iBAcW,CAAA,UAdiB,cAcjB,GAdkC,cAclC,CAAA,CAAA;EAAA,IAAW,EAbhC,UAagC;EAAc,SAAG,EAZ5C,CAY4C;EAAc,IACvD,CAAA,EAAA;IAAsB,UAAA,EAAA,MAAA;IAAR,WAAA,EAAA,MAAA;IACS,UAAA,EAAA,MAAA;EAAC,CAAA;EAAF,QACzB,EAAA;IACD,IAAA,CAAA,EAAA,MAAA,GATO,OASP;IACgB,OAAA,CAAA,EAAA,MAAA,GATN,OASM;EAAC,CAAA;;AAEhB,UAPK,WAOL,CAAA,UAP2B,cAO3B,GAP4C,cAO5C,CAAA,CAAA;EAAU,IAAlB,CAAA,OAAA,EANW,WAMX,CAAA,EANyB,OAMzB,CANiC,UAMjC,CAAA;EAAO,YACA,CAAA,UANa,aAMb,CAN2B,CAM3B,CAAA,CAAA,CAAA,QAAA,EALC,CAKD,EAAA,OAAA,EAJA,WAIA,GAAA;IACD,KAAA,EAJA,gBAIA,CAJiB,CAIjB,EAJoB,CAIpB,CAAA;EAAO,CAAA,CAAA,EAFb,OAEa,CAFL,UAEK,CAAA;YADN;WACD"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import Mail from "nodemailer/lib/mailer";
|
|
2
|
-
import { ReactElement } from "react";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
type Address = Mail.Address;
|
|
6
|
-
interface EmailOptions {
|
|
7
|
-
from: string | Address;
|
|
8
|
-
to: string | string[] | Address[];
|
|
9
|
-
cc?: string | string[] | Address[];
|
|
10
|
-
bcc?: string | string[] | Address[];
|
|
11
|
-
subject: string;
|
|
12
|
-
replyTo?: string | Address;
|
|
13
|
-
attachments?: Attachment[];
|
|
14
|
-
}
|
|
15
|
-
interface Attachment {
|
|
16
|
-
filename: string;
|
|
17
|
-
content?: string | Buffer;
|
|
18
|
-
path?: string;
|
|
19
|
-
contentType?: string;
|
|
20
|
-
cid?: string;
|
|
21
|
-
}
|
|
22
|
-
interface PlainEmailOptions extends EmailOptions {
|
|
23
|
-
text?: string;
|
|
24
|
-
html?: string;
|
|
25
|
-
}
|
|
26
|
-
type SendOptions = Omit<PlainEmailOptions, 'from'> & {
|
|
27
|
-
from?: string | Address;
|
|
28
|
-
};
|
|
29
|
-
interface SMTPConfig {
|
|
30
|
-
host: string;
|
|
31
|
-
port: number;
|
|
32
|
-
secure?: boolean;
|
|
33
|
-
auth?: {
|
|
34
|
-
user: string;
|
|
35
|
-
pass: string;
|
|
36
|
-
};
|
|
37
|
-
tls?: {
|
|
38
|
-
rejectUnauthorized?: boolean;
|
|
39
|
-
servername?: string;
|
|
40
|
-
};
|
|
41
|
-
pool?: boolean;
|
|
42
|
-
maxConnections?: number;
|
|
43
|
-
maxMessages?: number;
|
|
44
|
-
rateLimit?: number;
|
|
45
|
-
logger?: boolean;
|
|
46
|
-
debug?: boolean;
|
|
47
|
-
}
|
|
48
|
-
interface SendResult {
|
|
49
|
-
messageId: string;
|
|
50
|
-
accepted: string[];
|
|
51
|
-
rejected: string[];
|
|
52
|
-
/**
|
|
53
|
-
* The transport's reply, where it made one.
|
|
54
|
-
*
|
|
55
|
-
* Optional because nodemailer types it that way: not every transport answers
|
|
56
|
-
* with a response line, and the previous `string` was a promise this could
|
|
57
|
-
* not keep. Defaulting it to `''` would have kept the shape by inventing a
|
|
58
|
-
* reply that never arrived.
|
|
59
|
-
*/
|
|
60
|
-
response?: string;
|
|
61
|
-
}
|
|
62
|
-
type EmailTemplate<T = any> = (props: T) => ReactElement;
|
|
63
|
-
type TemplateProps<T> = T extends EmailTemplate<infer P> ? P : never;
|
|
64
|
-
type TemplateRecord = Record<string, EmailTemplate<any>>;
|
|
65
|
-
type TemplateNames<T extends TemplateRecord> = keyof T;
|
|
66
|
-
type TemplatePropsFor<T extends TemplateRecord, K extends TemplateNames<T>> = TemplateProps<T[K]>;
|
|
67
|
-
interface EmailClientConfig<T extends TemplateRecord = TemplateRecord> {
|
|
68
|
-
smtp: SMTPConfig;
|
|
69
|
-
templates: T;
|
|
70
|
-
dkim?: {
|
|
71
|
-
domainName: string;
|
|
72
|
-
keySelector: string;
|
|
73
|
-
privateKey: string;
|
|
74
|
-
};
|
|
75
|
-
defaults: {
|
|
76
|
-
from?: string | Address;
|
|
77
|
-
replyTo?: string | Address;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
interface EmailClient<T extends TemplateRecord = TemplateRecord> {
|
|
81
|
-
send(options: SendOptions): Promise<SendResult>;
|
|
82
|
-
sendTemplate<K extends TemplateNames<T>>(template: K, options: SendOptions & {
|
|
83
|
-
props: TemplatePropsFor<T, K>;
|
|
84
|
-
}): Promise<SendResult>;
|
|
85
|
-
verify(): Promise<boolean>;
|
|
86
|
-
close(): Promise<void>;
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
export { Attachment, EmailClient, EmailClientConfig, EmailOptions, EmailTemplate, PlainEmailOptions, SMTPConfig, SendOptions, SendResult, TemplateNames, TemplateProps, TemplatePropsFor, TemplateRecord };
|
|
90
|
-
//# sourceMappingURL=types-D5yAoaGX.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-D5yAoaGX.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;KAMK,OAAA,GAAU,IAAA,CAAK;UAEH,YAAA;EAFZ,IAAA,EAAA,MAAO,GAGI,OAHD;EAEE,EAAA,EAAA,MAAA,GAAA,MAAY,EAAA,GAEJ,OAFI,EAAA;EAAA,EAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAGH,OAHG,EAAA;EAAA,GACb,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAGW,OAHX,EAAA;EAAO,OACE,EAAA,MAAA;EAAO,OACN,CAAA,EAAA,MAAA,GAGN,OAHM;EAAO,WACN,CAAA,EAGZ,UAHY,E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|
5
|
-
/**
|
|
6
|
-
* Build an SMTP transport config from a `<NAME>_URL`.
|
|
7
|
-
*
|
|
8
|
-
* `smtps://` sets `secure`, which is nodemailer's flag for implicit TLS on
|
|
9
|
-
* connect rather than STARTTLS after `EHLO` — the distinction 465 and 587 carry,
|
|
10
|
-
* and the reason the scheme is worth having rather than inferring from the port.
|
|
11
|
-
*
|
|
12
|
-
* @example parseEmailUrl('smtp://mailpit:1025')
|
|
13
|
-
* @example parseEmailUrl('smtps://AKIA…:…@email-smtp.eu-west-1.amazonaws.com:465')
|
|
14
|
-
* @example parseEmailUrl('smtp://resend:re_123@smtp.resend.com:587')
|
|
15
|
-
*/
|
|
16
|
-
declare function parseEmailUrl(url: string): SMTPConfig;
|
|
17
|
-
//# sourceMappingURL=url.d.ts.map
|
|
18
|
-
//#endregion
|
|
19
|
-
export { parseEmailUrl };
|
|
20
|
-
//# sourceMappingURL=url-B2hKcFA3.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"url-B2hKcFA3.d.mts","names":[],"sources":["../src/url.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;iBAmCgB,aAAA,eAA4B"}
|
package/dist/url-B8QqBrMt.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { MalformedEmailUrl, UnsupportedEmailScheme } from "./errors-Ba3cEHPO.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/url.ts
|
|
4
|
-
/**
|
|
5
|
-
* The port to use when the URL names none.
|
|
6
|
-
*
|
|
7
|
-
* 587 is submission-with-STARTTLS, which is what SES, Resend, and Postmark all
|
|
8
|
-
* document; 465 is implicit TLS, which is what `smtps://` means.
|
|
9
|
-
*/
|
|
10
|
-
const DEFAULT_PORT = {
|
|
11
|
-
"smtp:": 587,
|
|
12
|
-
"smtps:": 465
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Build an SMTP transport config from a `<NAME>_URL`.
|
|
16
|
-
*
|
|
17
|
-
* `smtps://` sets `secure`, which is nodemailer's flag for implicit TLS on
|
|
18
|
-
* connect rather than STARTTLS after `EHLO` — the distinction 465 and 587 carry,
|
|
19
|
-
* and the reason the scheme is worth having rather than inferring from the port.
|
|
20
|
-
*
|
|
21
|
-
* @example parseEmailUrl('smtp://mailpit:1025')
|
|
22
|
-
* @example parseEmailUrl('smtps://AKIA…:…@email-smtp.eu-west-1.amazonaws.com:465')
|
|
23
|
-
* @example parseEmailUrl('smtp://resend:re_123@smtp.resend.com:587')
|
|
24
|
-
*/
|
|
25
|
-
function parseEmailUrl(url) {
|
|
26
|
-
let parsed;
|
|
27
|
-
try {
|
|
28
|
-
parsed = new URL(url);
|
|
29
|
-
} catch {
|
|
30
|
-
throw new MalformedEmailUrl(url);
|
|
31
|
-
}
|
|
32
|
-
if (parsed.protocol !== "smtp:" && parsed.protocol !== "smtps:") throw new UnsupportedEmailScheme(url, parsed.protocol);
|
|
33
|
-
const secure = parsed.protocol === "smtps:";
|
|
34
|
-
const config = {
|
|
35
|
-
host: parsed.hostname,
|
|
36
|
-
port: parsed.port ? Number(parsed.port) : DEFAULT_PORT[parsed.protocol],
|
|
37
|
-
secure
|
|
38
|
-
};
|
|
39
|
-
if (parsed.username) config.auth = {
|
|
40
|
-
user: decodeURIComponent(parsed.username),
|
|
41
|
-
pass: decodeURIComponent(parsed.password)
|
|
42
|
-
};
|
|
43
|
-
if (parsed.searchParams.get("insecure") === "true") config.tls = { rejectUnauthorized: false };
|
|
44
|
-
return config;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { parseEmailUrl };
|
|
49
|
-
//# sourceMappingURL=url-B8QqBrMt.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"url-B8QqBrMt.mjs","names":["url: string","parsed: URL","config: SMTPConfig"],"sources":["../src/url.ts"],"sourcesContent":["/**\n * `smtp://` — the one URL shape an email construct ever provides.\n *\n * Every provider is reached the same way: Mailpit locally, SES through its SMTP\n * interface, Resend and Postmark through theirs. So there is no scheme-keyed\n * driver registry here as there is in `@geekmidas/storage` — one transport, one\n * parser, and the client never branches on who is delivering the mail.\n *\n * What varies between providers is confined to the URL: host, port, and\n * credentials. That is what lets the same handler source run against Mailpit and\n * against SES without a conditional.\n */\n\nimport { MalformedEmailUrl, UnsupportedEmailScheme } from './errors';\nimport type { SMTPConfig } from './types';\n\n/**\n * The port to use when the URL names none.\n *\n * 587 is submission-with-STARTTLS, which is what SES, Resend, and Postmark all\n * document; 465 is implicit TLS, which is what `smtps://` means.\n */\nconst DEFAULT_PORT = { 'smtp:': 587, 'smtps:': 465 } as const;\n\n/**\n * Build an SMTP transport config from a `<NAME>_URL`.\n *\n * `smtps://` sets `secure`, which is nodemailer's flag for implicit TLS on\n * connect rather than STARTTLS after `EHLO` — the distinction 465 and 587 carry,\n * and the reason the scheme is worth having rather than inferring from the port.\n *\n * @example parseEmailUrl('smtp://mailpit:1025')\n * @example parseEmailUrl('smtps://AKIA…:…@email-smtp.eu-west-1.amazonaws.com:465')\n * @example parseEmailUrl('smtp://resend:re_123@smtp.resend.com:587')\n */\nexport function parseEmailUrl(url: string): SMTPConfig {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(url);\n\t} catch {\n\t\tthrow new MalformedEmailUrl(url);\n\t}\n\n\tif (parsed.protocol !== 'smtp:' && parsed.protocol !== 'smtps:') {\n\t\tthrow new UnsupportedEmailScheme(url, parsed.protocol);\n\t}\n\n\tconst secure = parsed.protocol === 'smtps:';\n\tconst config: SMTPConfig = {\n\t\thost: parsed.hostname,\n\t\tport: parsed.port ? Number(parsed.port) : DEFAULT_PORT[parsed.protocol],\n\t\tsecure,\n\t};\n\n\t// Mailpit accepts mail unauthenticated, so credentials are optional rather\n\t// than required — omitting `auth` entirely is what nodemailer expects, where\n\t// empty strings would be sent as a real (failing) AUTH exchange.\n\tif (parsed.username) {\n\t\tconfig.auth = {\n\t\t\tuser: decodeURIComponent(parsed.username),\n\t\t\tpass: decodeURIComponent(parsed.password),\n\t\t};\n\t}\n\n\t// Local containers present a self-signed certificate. Rather than have every\n\t// project set this, read it off the URL — the adapter that knows it is\n\t// pointing at a container is the one that can say so.\n\tif (parsed.searchParams.get('insecure') === 'true') {\n\t\tconfig.tls = { rejectUnauthorized: false };\n\t}\n\n\treturn config;\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,eAAe;CAAE,SAAS;CAAK,UAAU;AAAK;;;;;;;;;;;;AAapD,SAAgB,cAAcA,KAAyB;CACtD,IAAIC;AACJ,KAAI;AACH,WAAS,IAAI,IAAI;CACjB,QAAO;AACP,QAAM,IAAI,kBAAkB;CAC5B;AAED,KAAI,OAAO,aAAa,WAAW,OAAO,aAAa,SACtD,OAAM,IAAI,uBAAuB,KAAK,OAAO;CAG9C,MAAM,SAAS,OAAO,aAAa;CACnC,MAAMC,SAAqB;EAC1B,MAAM,OAAO;EACb,MAAM,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG,aAAa,OAAO;EAC9D;CACA;AAKD,KAAI,OAAO,SACV,QAAO,OAAO;EACb,MAAM,mBAAmB,OAAO,SAAS;EACzC,MAAM,mBAAmB,OAAO,SAAS;CACzC;AAMF,KAAI,OAAO,aAAa,IAAI,WAAW,KAAK,OAC3C,QAAO,MAAM,EAAE,oBAAoB,MAAO;AAG3C,QAAO;AACP"}
|
package/dist/url-CVk3Cs_8.d.cts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SMTPConfig } from "./types-D5yAoaGX.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/url.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Build an SMTP transport config from a `<NAME>_URL`.
|
|
7
|
-
*
|
|
8
|
-
* `smtps://` sets `secure`, which is nodemailer's flag for implicit TLS on
|
|
9
|
-
* connect rather than STARTTLS after `EHLO` — the distinction 465 and 587 carry,
|
|
10
|
-
* and the reason the scheme is worth having rather than inferring from the port.
|
|
11
|
-
*
|
|
12
|
-
* @example parseEmailUrl('smtp://mailpit:1025')
|
|
13
|
-
* @example parseEmailUrl('smtps://AKIA…:…@email-smtp.eu-west-1.amazonaws.com:465')
|
|
14
|
-
* @example parseEmailUrl('smtp://resend:re_123@smtp.resend.com:587')
|
|
15
|
-
*/
|
|
16
|
-
declare function parseEmailUrl(url: string): SMTPConfig;
|
|
17
|
-
//# sourceMappingURL=url.d.ts.map
|
|
18
|
-
//#endregion
|
|
19
|
-
export { parseEmailUrl };
|
|
20
|
-
//# sourceMappingURL=url-CVk3Cs_8.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"url-CVk3Cs_8.d.cts","names":[],"sources":["../src/url.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;iBAmCgB,aAAA,eAA4B"}
|
package/dist/url-GT3jLGq-.cjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const require_errors = require('./errors-6difZDw0.cjs');
|
|
2
|
-
|
|
3
|
-
//#region src/url.ts
|
|
4
|
-
/**
|
|
5
|
-
* The port to use when the URL names none.
|
|
6
|
-
*
|
|
7
|
-
* 587 is submission-with-STARTTLS, which is what SES, Resend, and Postmark all
|
|
8
|
-
* document; 465 is implicit TLS, which is what `smtps://` means.
|
|
9
|
-
*/
|
|
10
|
-
const DEFAULT_PORT = {
|
|
11
|
-
"smtp:": 587,
|
|
12
|
-
"smtps:": 465
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Build an SMTP transport config from a `<NAME>_URL`.
|
|
16
|
-
*
|
|
17
|
-
* `smtps://` sets `secure`, which is nodemailer's flag for implicit TLS on
|
|
18
|
-
* connect rather than STARTTLS after `EHLO` — the distinction 465 and 587 carry,
|
|
19
|
-
* and the reason the scheme is worth having rather than inferring from the port.
|
|
20
|
-
*
|
|
21
|
-
* @example parseEmailUrl('smtp://mailpit:1025')
|
|
22
|
-
* @example parseEmailUrl('smtps://AKIA…:…@email-smtp.eu-west-1.amazonaws.com:465')
|
|
23
|
-
* @example parseEmailUrl('smtp://resend:re_123@smtp.resend.com:587')
|
|
24
|
-
*/
|
|
25
|
-
function parseEmailUrl(url) {
|
|
26
|
-
let parsed;
|
|
27
|
-
try {
|
|
28
|
-
parsed = new URL(url);
|
|
29
|
-
} catch {
|
|
30
|
-
throw new require_errors.MalformedEmailUrl(url);
|
|
31
|
-
}
|
|
32
|
-
if (parsed.protocol !== "smtp:" && parsed.protocol !== "smtps:") throw new require_errors.UnsupportedEmailScheme(url, parsed.protocol);
|
|
33
|
-
const secure = parsed.protocol === "smtps:";
|
|
34
|
-
const config = {
|
|
35
|
-
host: parsed.hostname,
|
|
36
|
-
port: parsed.port ? Number(parsed.port) : DEFAULT_PORT[parsed.protocol],
|
|
37
|
-
secure
|
|
38
|
-
};
|
|
39
|
-
if (parsed.username) config.auth = {
|
|
40
|
-
user: decodeURIComponent(parsed.username),
|
|
41
|
-
pass: decodeURIComponent(parsed.password)
|
|
42
|
-
};
|
|
43
|
-
if (parsed.searchParams.get("insecure") === "true") config.tls = { rejectUnauthorized: false };
|
|
44
|
-
return config;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
Object.defineProperty(exports, 'parseEmailUrl', {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return parseEmailUrl;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
//# sourceMappingURL=url-GT3jLGq-.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"url-GT3jLGq-.cjs","names":["url: string","parsed: URL","MalformedEmailUrl","UnsupportedEmailScheme","config: SMTPConfig"],"sources":["../src/url.ts"],"sourcesContent":["/**\n * `smtp://` — the one URL shape an email construct ever provides.\n *\n * Every provider is reached the same way: Mailpit locally, SES through its SMTP\n * interface, Resend and Postmark through theirs. So there is no scheme-keyed\n * driver registry here as there is in `@geekmidas/storage` — one transport, one\n * parser, and the client never branches on who is delivering the mail.\n *\n * What varies between providers is confined to the URL: host, port, and\n * credentials. That is what lets the same handler source run against Mailpit and\n * against SES without a conditional.\n */\n\nimport { MalformedEmailUrl, UnsupportedEmailScheme } from './errors';\nimport type { SMTPConfig } from './types';\n\n/**\n * The port to use when the URL names none.\n *\n * 587 is submission-with-STARTTLS, which is what SES, Resend, and Postmark all\n * document; 465 is implicit TLS, which is what `smtps://` means.\n */\nconst DEFAULT_PORT = { 'smtp:': 587, 'smtps:': 465 } as const;\n\n/**\n * Build an SMTP transport config from a `<NAME>_URL`.\n *\n * `smtps://` sets `secure`, which is nodemailer's flag for implicit TLS on\n * connect rather than STARTTLS after `EHLO` — the distinction 465 and 587 carry,\n * and the reason the scheme is worth having rather than inferring from the port.\n *\n * @example parseEmailUrl('smtp://mailpit:1025')\n * @example parseEmailUrl('smtps://AKIA…:…@email-smtp.eu-west-1.amazonaws.com:465')\n * @example parseEmailUrl('smtp://resend:re_123@smtp.resend.com:587')\n */\nexport function parseEmailUrl(url: string): SMTPConfig {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(url);\n\t} catch {\n\t\tthrow new MalformedEmailUrl(url);\n\t}\n\n\tif (parsed.protocol !== 'smtp:' && parsed.protocol !== 'smtps:') {\n\t\tthrow new UnsupportedEmailScheme(url, parsed.protocol);\n\t}\n\n\tconst secure = parsed.protocol === 'smtps:';\n\tconst config: SMTPConfig = {\n\t\thost: parsed.hostname,\n\t\tport: parsed.port ? Number(parsed.port) : DEFAULT_PORT[parsed.protocol],\n\t\tsecure,\n\t};\n\n\t// Mailpit accepts mail unauthenticated, so credentials are optional rather\n\t// than required — omitting `auth` entirely is what nodemailer expects, where\n\t// empty strings would be sent as a real (failing) AUTH exchange.\n\tif (parsed.username) {\n\t\tconfig.auth = {\n\t\t\tuser: decodeURIComponent(parsed.username),\n\t\t\tpass: decodeURIComponent(parsed.password),\n\t\t};\n\t}\n\n\t// Local containers present a self-signed certificate. Rather than have every\n\t// project set this, read it off the URL — the adapter that knows it is\n\t// pointing at a container is the one that can say so.\n\tif (parsed.searchParams.get('insecure') === 'true') {\n\t\tconfig.tls = { rejectUnauthorized: false };\n\t}\n\n\treturn config;\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,eAAe;CAAE,SAAS;CAAK,UAAU;AAAK;;;;;;;;;;;;AAapD,SAAgB,cAAcA,KAAyB;CACtD,IAAIC;AACJ,KAAI;AACH,WAAS,IAAI,IAAI;CACjB,QAAO;AACP,QAAM,IAAIC,iCAAkB;CAC5B;AAED,KAAI,OAAO,aAAa,WAAW,OAAO,aAAa,SACtD,OAAM,IAAIC,sCAAuB,KAAK,OAAO;CAG9C,MAAM,SAAS,OAAO,aAAa;CACnC,MAAMC,SAAqB;EAC1B,MAAM,OAAO;EACb,MAAM,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG,aAAa,OAAO;EAC9D;CACA;AAKD,KAAI,OAAO,SACV,QAAO,OAAO;EACb,MAAM,mBAAmB,OAAO,SAAS;EACzC,MAAM,mBAAmB,OAAO,SAAS;CACzC;AAMF,KAAI,OAAO,aAAa,IAAI,WAAW,KAAK,OAC3C,QAAO,MAAM,EAAE,oBAAoB,MAAO;AAG3C,QAAO;AACP"}
|