@sharadox/email-web-library 0.6.1 → 0.7.0-amazon-ses.42

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  What changed in each version of `@sharadox/email-web-library`, newest first.
4
4
 
5
+ ## 0.7.0
6
+
7
+ Amazon SES without a password: `EMAIL_SERVER_AMAZON_SES_ROLE` and `EMAIL_SERVER_AMAZON_SES_REGION` send through the Amazon SES API as an AWS role the Vercel deployment takes with its own identity (OIDC), so no SMTP password is stored. New `createAmazonSesSender` (any AWS credential provider) and types `AmazonSesConfiguration`, `AmazonCredentials`, `SmtpServerConfiguration`; `EmailServerConfiguration` is now either kind. SMTP works as before.
8
+
5
9
  ## 0.6.1
6
10
 
7
11
  The lines between details are #E5E5E5, and #1A1A1A in dark themes.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @sharadox/email-web-library
2
2
 
3
- Send email from web applications — contact forms, notifications, receipts — through **any SMTP server**: your existing mailbox provider (Proton, Google Workspace, Microsoft 365, Fastmail…) or a sending service (Amazon SES, Postmark, Resend…). No provider SDK, no cloud account; switching provider is a change of four environment variables.
3
+ Send email from web applications — contact forms, notifications, receipts — through **any SMTP server**: your existing mailbox provider (Proton, Google Workspace, Microsoft 365, Fastmail…) or a sending service (Amazon SES, Postmark, Resend…). Switching provider is a change of four environment variables. On Vercel it can also send through **Amazon SES without any stored password**: the deployment takes an AWS role with its own identity (Vercel OIDC).
4
4
 
5
5
  - Checks every message before it leaves: valid addresses, a one-line subject, a body — so form input can't inject extra headers or recipients.
6
6
  - One error type, `EmailError`, whose `code` says whose problem it is: `configuration`, `invalid-message` or `delivery`.
@@ -16,7 +16,7 @@ pnpm add @sharadox/email-web-library
16
16
  ## Use
17
17
 
18
18
  Import each part from its own path, like every Sharadox library (`@sharadox/email-web-library/email-sender`,
19
- `…/email-layout`, `…/email-server-configuration`, `…/email-message`, `…/email-address`, `…/email-error`, `…/inline-image`, which turns a base64 image such as a logo into one to send). The root
19
+ `…/amazon-ses-sender`, `…/email-layout`, `…/email-server-configuration`, `…/email-message`, `…/email-address`, `…/email-error`, `…/inline-image`, which turns a base64 image such as a logo into one to send). The root
20
20
  import (`@sharadox/email-web-library`) still works in 0.5 and goes away in 0.6.
21
21
 
22
22
  Set the server in the environment:
@@ -29,6 +29,26 @@ Set the server in the environment:
29
29
  | `EMAIL_SERVER_PASSWORD` | an SMTP token or password | Keep it in your host's secret store, never in the repository |
30
30
  | `EMAIL_SERVER_SECURITY` | `starttls` | Optional: `starttls` (default), `tls` (default on port 465) or `none` (local test servers only) |
31
31
 
32
+ ### Amazon SES without a password (Vercel OIDC)
33
+
34
+ Set these two instead, and the SMTP variables are ignored:
35
+
36
+ | Variable | Example | Notes |
37
+ | -------------------------------- | ---------------------------------------------- | ------------------------------------------------------- |
38
+ | `EMAIL_SERVER_AMAZON_SES_ROLE` | `arn:aws:iam::123456789012:role/email-sending` | The role the deployment takes; not a secret |
39
+ | `EMAIL_SERVER_AMAZON_SES_REGION` | `eu-west-1` | The region the sending address or domain is verified in |
40
+
41
+ The Vercel project needs OIDC on (Settings → Security), and AWS an identity provider for `oidc.vercel.com/<team>` (audience `https://vercel.com/<team>`) that the role trusts, with a trust condition on the project's `sub` (`owner:<team>:project:<project>:environment:production`) and a policy allowing only `ses:SendRawEmail` and `ses:SendEmail` from the sending address. Credentials last an hour and are renewed by themselves; there is nothing to rotate. Elsewhere, pass any AWS credential provider yourself:
42
+
43
+ ```ts
44
+ import { createAmazonSesSender } from "@sharadox/email-web-library/amazon-ses-sender";
45
+ import { fromEnv } from "@aws-sdk/credential-providers";
46
+
47
+ const sender = createAmazonSesSender({ kind: "amazon-ses", region: "eu-west-1", credentials: fromEnv() });
48
+ ```
49
+
50
+ Amazon SES takes every recipient or refuses the message, so `rejected` is always empty. `verify()` gets the credentials (proving the role) without sending anything.
51
+
32
52
  ```ts
33
53
  "use server";
34
54
  import { createEmailSender, EmailError, readEmailServerConfiguration } from "@sharadox/email-web-library";
@@ -0,0 +1,17 @@
1
+ import type { AmazonSesConfiguration } from "@sharadox/email-web-library/amazon-ses-sender/type";
2
+ import type { EmailSender } from "@sharadox/email-web-library/email-sender/type";
3
+ /**
4
+ * Creates a sender that sends through the Amazon SES API (version 2) with short-lived credentials, so no SMTP
5
+ * password is kept. Nodemailer builds the message (MIME, inline images, non-English text), sent as one raw email.
6
+ *
7
+ * @example
8
+ * import { awsCredentialsProvider } from "@vercel/oidc-aws-credentials-provider";
9
+ * const sender = createAmazonSesSender({
10
+ * kind: "amazon-ses",
11
+ * region: "eu-west-1",
12
+ * credentials: awsCredentialsProvider({ roleArn: "arn:aws:iam::123456789012:role/email-sending" }),
13
+ * });
14
+ * await sender.send({ from: { name: "Example", address: "contact@web.example.com" }, to: "contact@example.com", subject: "Hi", text: "Hello" });
15
+ */
16
+ export declare function createAmazonSesSender(configuration: AmazonSesConfiguration): EmailSender;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/amazon-ses-sender/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oDAAoD,CAAC;AACjG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAKjF;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,sBAAsB,GAAG,WAAW,CA8CxF"}
@@ -0,0 +1,68 @@
1
+ import { SendEmailCommand, SESv2Client } from "@aws-sdk/client-sesv2";
2
+ import { createTransport } from "nodemailer";
3
+ import { EmailError } from "@sharadox/email-web-library/email-error";
4
+ import { checkEmailMessage } from "@sharadox/email-web-library/email-message";
5
+ /** The first line of an error's message, without the message content. */
6
+ const reason = (error) => error?.message?.split("\n")[0] || "unknown error";
7
+ /**
8
+ * Creates a sender that sends through the Amazon SES API (version 2) with short-lived credentials, so no SMTP
9
+ * password is kept. Nodemailer builds the message (MIME, inline images, non-English text), sent as one raw email.
10
+ *
11
+ * @example
12
+ * import { awsCredentialsProvider } from "@vercel/oidc-aws-credentials-provider";
13
+ * const sender = createAmazonSesSender({
14
+ * kind: "amazon-ses",
15
+ * region: "eu-west-1",
16
+ * credentials: awsCredentialsProvider({ roleArn: "arn:aws:iam::123456789012:role/email-sending" }),
17
+ * });
18
+ * await sender.send({ from: { name: "Example", address: "contact@web.example.com" }, to: "contact@example.com", subject: "Hi", text: "Hello" });
19
+ */
20
+ export function createAmazonSesSender(configuration) {
21
+ const timeout = configuration.timeout ?? 10_000;
22
+ const where = `Amazon SES (${configuration.region})`;
23
+ const sesClient = new SESv2Client({
24
+ region: configuration.region,
25
+ credentials: configuration.credentials,
26
+ requestHandler: { connectionTimeout: timeout, requestTimeout: timeout * 2 },
27
+ });
28
+ const transport = createTransport({ SES: { sesClient, SendEmailCommand } });
29
+ return {
30
+ async send(message) {
31
+ checkEmailMessage(message);
32
+ try {
33
+ const info = await transport.sendMail({
34
+ from: message.from,
35
+ to: message.to,
36
+ replyTo: message.replyTo,
37
+ subject: message.subject,
38
+ text: message.text,
39
+ html: message.html,
40
+ attachments: message.inlineImages?.map((image) => ({
41
+ cid: image.id,
42
+ filename: image.filename,
43
+ contentType: image.contentType,
44
+ content: Buffer.from(image.content),
45
+ contentDisposition: "inline",
46
+ })),
47
+ disableFileAccess: true,
48
+ disableUrlAccess: true,
49
+ });
50
+ // Amazon SES takes every recipient or refuses the whole message.
51
+ return { messageId: info.messageId, accepted: info.envelope.to, rejected: [] };
52
+ }
53
+ catch (error) {
54
+ throw new EmailError("delivery", `sending through ${where} failed: ${reason(error)}`, { cause: error });
55
+ }
56
+ },
57
+ async verify() {
58
+ // Getting the credentials proves the identity and role; a test message would need a real sender address.
59
+ try {
60
+ await configuration.credentials();
61
+ }
62
+ catch (error) {
63
+ throw new EmailError("delivery", `getting ${where} credentials failed: ${reason(error)}`, { cause: error });
64
+ }
65
+ },
66
+ };
67
+ }
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/amazon-ses-sender/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAI9E,yEAAyE;AACzE,MAAM,MAAM,GAAG,CAAC,KAAc,EAAE,EAAE,CAAE,KAA2B,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC;AAE5G;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB,CAAC,aAAqC;IACzE,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,MAAM,CAAC;IAChD,MAAM,KAAK,GAAG,eAAe,aAAa,CAAC,MAAM,GAAG,CAAC;IACrD,MAAM,SAAS,GAAG,IAAI,WAAW,CAAC;QAChC,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,WAAW,EAAE,aAAa,CAAC,WAAW;QACtC,cAAc,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,GAAG,CAAC,EAAE;KAC5E,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,eAAe,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAE5E,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,OAAO;YAChB,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC3B,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC;oBACpC,IAAI,EAAE,OAAO,CAAC,IAAI;oBACl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AAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ /** Short-lived AWS credentials, as an AWS credential provider gives them. */
2
+ export interface AmazonCredentials {
3
+ accessKeyId: string;
4
+ secretAccessKey: string;
5
+ sessionToken?: string;
6
+ expiration?: Date;
7
+ }
8
+ /**
9
+ * Sending through the Amazon SES API instead of SMTP, with short-lived credentials (for example a role the
10
+ * deployment takes with its own identity, through Vercel OIDC): no password is stored anywhere.
11
+ */
12
+ export interface AmazonSesConfiguration {
13
+ kind: "amazon-ses";
14
+ /** The region the sending identity is verified in, for example "eu-west-1". */
15
+ region: string;
16
+ /** Gives the credentials; asked again whenever they expire (any AWS credential provider fits). */
17
+ credentials: () => Promise<AmazonCredentials>;
18
+ /** Milliseconds to wait for Amazon SES before failing with `delivery`. Defaults to 10 000. */
19
+ timeout?: number;
20
+ }
21
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/amazon-ses-sender/type.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,YAAY,CAAC;IACnB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,kGAAkG;IAClG,WAAW,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9C,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/amazon-ses-sender/type.ts"],"names":[],"mappings":""}
@@ -1,11 +1,12 @@
1
1
  import type { EmailServerConfiguration } from "@sharadox/email-web-library/email-server-configuration/type";
2
2
  import type { EmailSender } from "@sharadox/email-web-library/email-sender/type";
3
3
  /**
4
- * Creates a sender for one SMTP server. Each `send` opens its own short connection, which suits serverless
5
- * functions (nothing to close, nothing kept between invocations).
4
+ * Creates a sender for one email server: an SMTP server, or Amazon SES with short-lived credentials (an
5
+ * `amazon-ses` configuration, sent by `createAmazonSesSender`).
6
6
  *
7
- * The SMTP protocol work (STARTTLS, login, MIME, encoding of non-English text) is done by Nodemailer; this library
8
- * adds the configuration, the message checks and one error type.
7
+ * @example
8
+ * const sender = createEmailSender(readEmailServerConfiguration());
9
+ * await sender.send({ from: { name: "Example", address: "contact@web.example.com" }, to: "contact@example.com", subject: "Hi", text: "Hello" });
9
10
  */
10
11
  export declare function createEmailSender(configuration: EmailServerConfiguration): EmailSender;
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/email-sender/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6DAA6D,CAAC;AAC5G,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAI/F;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,wBAAwB,GAAG,WAAW,CA8DtF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/email-sender/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,wBAAwB,EAEzB,MAAM,6DAA6D,CAAC;AACrE,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAI/F;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,wBAAwB,GAAG,WAAW,CAEtF"}
@@ -1,7 +1,19 @@
1
1
  import { createTransport } from "nodemailer";
2
+ import { createAmazonSesSender } from "@sharadox/email-web-library/amazon-ses-sender";
2
3
  import { EmailError } from "@sharadox/email-web-library/email-error";
3
4
  import { checkEmailMessage } from "@sharadox/email-web-library/email-message";
4
5
  const addressText = (entry) => (typeof entry === "string" ? entry : entry.address);
6
+ /**
7
+ * Creates a sender for one email server: an SMTP server, or Amazon SES with short-lived credentials (an
8
+ * `amazon-ses` configuration, sent by `createAmazonSesSender`).
9
+ *
10
+ * @example
11
+ * const sender = createEmailSender(readEmailServerConfiguration());
12
+ * await sender.send({ from: { name: "Example", address: "contact@web.example.com" }, to: "contact@example.com", subject: "Hi", text: "Hello" });
13
+ */
14
+ export function createEmailSender(configuration) {
15
+ return "kind" in configuration ? createAmazonSesSender(configuration) : createSmtpSender(configuration);
16
+ }
5
17
  /**
6
18
  * Creates a sender for one SMTP server. Each `send` opens its own short connection, which suits serverless
7
19
  * functions (nothing to close, nothing kept between invocations).
@@ -9,7 +21,7 @@ const addressText = (entry) => (typeof entry === "string" ? entry : entry.addres
9
21
  * The SMTP protocol work (STARTTLS, login, MIME, encoding of non-English text) is done by Nodemailer; this library
10
22
  * adds the configuration, the message checks and one error type.
11
23
  */
12
- export function createEmailSender(configuration) {
24
+ function createSmtpSender(configuration) {
13
25
  const security = configuration.security ?? (configuration.port === 465 ? "tls" : "starttls");
14
26
  const timeout = configuration.timeout ?? 10_000;
15
27
  const transport = createTransport({
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/email-sender/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAI9E,MAAM,WAAW,GAAG,CAAC,KAAmC,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;A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EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,eAAe,CAAC;AACpG,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import type { EmailServerConfiguration } from "@sharadox/email-web-library/email-server-configuration/type";
2
2
  /**
3
- * Reads the email server settings from environment variables:
3
+ * Reads the email server settings from environment variables. With `EMAIL_SERVER_AMAZON_SES_ROLE` (a role's ARN)
4
+ * and `EMAIL_SERVER_AMAZON_SES_REGION`, it sends through Amazon SES as that role, taken with the deployment's own
5
+ * Vercel OIDC identity: nothing secret is stored. Otherwise it reads an SMTP server:
4
6
  * `EMAIL_SERVER_HOST`, `EMAIL_SERVER_PORT` (default 587), `EMAIL_SERVER_USERNAME`, `EMAIL_SERVER_PASSWORD` and the
5
7
  * optional `EMAIL_SERVER_SECURITY` (`starttls`, `tls` or `none`). Pass another `prefix` to keep several servers.
6
8
  * Throws `configuration` naming every missing or invalid variable.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/email-server-configuration/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EAEzB,MAAM,6DAA6D,CAAC;AAIrE;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EAC7D,MAAM,SAAkB,GACvB,wBAAwB,CAwB1B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/email-server-configuration/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,wBAAwB,EAEzB,MAAM,6DAA6D,CAAC;AAIrE;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EAC7D,MAAM,SAAkB,GACvB,wBAAwB,CA8B1B"}
@@ -1,13 +1,23 @@
1
+ import { awsCredentialsProvider } from "@vercel/oidc-aws-credentials-provider";
1
2
  import { EmailError } from "@sharadox/email-web-library/email-error";
2
3
  const SECURITIES = ["starttls", "tls", "none"];
3
4
  /**
4
- * Reads the email server settings from environment variables:
5
+ * Reads the email server settings from environment variables. With `EMAIL_SERVER_AMAZON_SES_ROLE` (a role's ARN)
6
+ * and `EMAIL_SERVER_AMAZON_SES_REGION`, it sends through Amazon SES as that role, taken with the deployment's own
7
+ * Vercel OIDC identity: nothing secret is stored. Otherwise it reads an SMTP server:
5
8
  * `EMAIL_SERVER_HOST`, `EMAIL_SERVER_PORT` (default 587), `EMAIL_SERVER_USERNAME`, `EMAIL_SERVER_PASSWORD` and the
6
9
  * optional `EMAIL_SERVER_SECURITY` (`starttls`, `tls` or `none`). Pass another `prefix` to keep several servers.
7
10
  * Throws `configuration` naming every missing or invalid variable.
8
11
  */
9
12
  export function readEmailServerConfiguration(environment = process.env, prefix = "EMAIL_SERVER_") {
10
13
  const read = (name) => environment[`${prefix}${name}`]?.trim() || undefined;
14
+ const role = read("AMAZON_SES_ROLE");
15
+ if (role) {
16
+ const region = read("AMAZON_SES_REGION");
17
+ if (!region)
18
+ throw new EmailError("configuration", `${prefix}AMAZON_SES_REGION is missing`);
19
+ return { kind: "amazon-ses", region, credentials: awsCredentialsProvider({ roleArn: role }) };
20
+ }
11
21
  const host = read("HOST");
12
22
  const username = read("USERNAME");
13
23
  const password = read("PASSWORD");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/email-server-configuration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAMrE,MAAM,UAAU,GAAmC,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC1C,cAAkD,OAAO,CAAC,GAAG,EAC7D,M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-library/amazon-ses-sender/type";
1
2
  /**
2
3
  * How the connection is protected:
3
4
  * - `starttls`: connect in plain text, then upgrade with STARTTLS, which is required (port 587, the default).
@@ -6,7 +7,7 @@
6
7
  */
7
8
  export type EmailServerSecurity = "starttls" | "tls" | "none";
8
9
  /** Where and how to log in to the SMTP server that sends the email. */
9
- export interface EmailServerConfiguration {
10
+ export interface SmtpServerConfiguration {
10
11
  host: string;
11
12
  port: number;
12
13
  username: string;
@@ -16,4 +17,6 @@ export interface EmailServerConfiguration {
16
17
  /** Milliseconds to wait for the server before failing with `delivery`. Defaults to 10 000. */
17
18
  timeout?: number;
18
19
  }
20
+ /** The server that sends the email: an SMTP server, or Amazon SES with short-lived credentials. */
21
+ export type EmailServerConfiguration = SmtpServerConfiguration | AmazonSesConfiguration;
19
22
  //# sourceMappingURL=type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/email-server-configuration/type.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;AAE9D,uEAAuE;AACvE,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/email-server-configuration/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oDAAoD,CAAC;AAEjG;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;AAE9D,uEAAuE;AACvE,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,mGAAmG;AACnG,MAAM,MAAM,wBAAwB,GAAG,uBAAuB,GAAG,sBAAsB,CAAC"}
@@ -16,10 +16,12 @@ export { EmailError } from "@sharadox/email-web-library/email-error";
16
16
  export type { EmailErrorCode } from "@sharadox/email-web-library/email-error/type";
17
17
  export { checkEmailMessage, RECIPIENT_LIMIT, SUBJECT_LIMIT } from "@sharadox/email-web-library/email-message";
18
18
  export type { EmailMessage, InlineImage } from "@sharadox/email-web-library/email-message/type";
19
+ export { createAmazonSesSender } from "@sharadox/email-web-library/amazon-ses-sender";
20
+ export type { AmazonCredentials, AmazonSesConfiguration } from "@sharadox/email-web-library/amazon-ses-sender/type";
19
21
  export { createEmailSender } from "@sharadox/email-web-library/email-sender";
20
22
  export type { EmailReceipt, EmailSender } from "@sharadox/email-web-library/email-sender/type";
21
23
  export { readEmailServerConfiguration } from "@sharadox/email-web-library/email-server-configuration";
22
- export type { EmailServerConfiguration, EmailServerSecurity, } from "@sharadox/email-web-library/email-server-configuration/type";
24
+ export type { EmailServerConfiguration, EmailServerSecurity, SmtpServerConfiguration, } from "@sharadox/email-web-library/email-server-configuration/type";
23
25
  export { EMAIL_COLORS, EMAIL_FONT, EMAIL_SPACES, emailLayout } from "@sharadox/email-web-library/email-layout";
24
26
  export type { EmailContent, EmailDesign, EmailLogos, EmailRow } from "@sharadox/email-web-library/email-layout/type";
25
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE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AACtF,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oDAAoD,CAAC;AACpH,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAC/F,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AACtG,YAAY,EACV,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC/G,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC"}
@@ -13,6 +13,7 @@
13
13
  export { checkEmailAddress } from "@sharadox/email-web-library/email-address";
14
14
  export { EmailError } from "@sharadox/email-web-library/email-error";
15
15
  export { checkEmailMessage, RECIPIENT_LIMIT, SUBJECT_LIMIT } from "@sharadox/email-web-library/email-message";
16
+ export { createAmazonSesSender } from "@sharadox/email-web-library/amazon-ses-sender";
16
17
  export { createEmailSender } from "@sharadox/email-web-library/email-sender";
17
18
  export { readEmailServerConfiguration } from "@sharadox/email-web-library/email-server-configuration";
18
19
  export { EMAIL_COLORS, EMAIL_FONT, EMAIL_SPACES, emailLayout } from "@sharadox/email-web-library/email-layout";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AAKtG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAE9G,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AAEtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,wDAAwD,CAAC;AAMtG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC"}
package/llms.txt CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  > Send email from web applications through any SMTP server (Nodemailer underneath): configuration from the environment, checked messages, one error type, and an email layout in a brand's design.
4
4
 
5
- - /email-server-configuration: readEmailServerConfiguration(environment = process.env) → { host, port (587), username, password, security ("starttls" | "tls" on 465 | "none"), timeout? } from EMAIL_SERVER_HOST, _PORT, _USERNAME, _PASSWORD, _SECURITY; throws EmailError("configuration") naming what's missing
6
- - /email-sender: createEmailSender(configuration) → { send(message) → { messageId, accepted, rejected }, verify() }; one short connection per send (serverless); refused recipients reported, all refused or any server failure → EmailError("delivery") without the password or message content
5
+ - /email-server-configuration: readEmailServerConfiguration(environment = process.env) → { host, port (587), username, password, security ("starttls" | "tls" on 465 | "none"), timeout? } from EMAIL_SERVER_HOST, _PORT, _USERNAME, _PASSWORD, _SECURITY; throws EmailError("configuration") naming what's missing; with EMAIL_SERVER_AMAZON_SES_ROLE (role ARN) + EMAIL_SERVER_AMAZON_SES_REGION it returns { kind: "amazon-ses", region, credentials } instead, credentials from Vercel OIDC (awsCredentialsProvider), SMTP variables ignored
6
+ - /email-sender: createEmailSender(configuration) → { send(message) → { messageId, accepted, rejected }, verify() }; one short connection per send (serverless); refused recipients reported, all refused or any server failure → EmailError("delivery") without the password or message content; an { kind: "amazon-ses" } configuration goes to createAmazonSesSender
7
+ - /amazon-ses-sender: createAmazonSesSender({ kind: "amazon-ses", region, credentials: () => Promise<{ accessKeyId, secretAccessKey, sessionToken? }>, timeout? = 10000 }) → EmailSender through the Amazon SES API v2 (one raw MIME email built by Nodemailer); accepted = every recipient, rejected = []; verify() only resolves the credentials; failures → EmailError("delivery") with "Amazon SES (<region>)"
7
8
  - /email-message: checkEmailMessage(message) (valid addresses, one-line subject, at most RECIPIENT_LIMIT recipients, SUBJECT_LIMIT characters); EmailMessage { from, to, cc?, bcc?, replyTo?, subject, text, html?, inlineImages? [{ id, filename, contentType, content }] }
8
9
  - /inline-image: inlineImage(id, { filename, contentType, content (base64) }) → InlineImage with the bytes decoded (a library's logo kept as base64 text)
9
10
  - /email-address: checkEmailAddress(value, field) → the address, or EmailError("invalid-message"); EmailAddress = string | { name, address }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/email-web-library",
3
- "version": "0.6.1",
3
+ "version": "0.7.0-amazon-ses.42",
4
4
  "description": "Send email from web applications through any SMTP server, with message checks and clear errors.",
5
5
  "license": "SEE LICENSE IN LICENCA.md",
6
6
  "author": "Sharadox <contact@sharadox.com>",
@@ -60,7 +60,9 @@
60
60
  "*.{json,md,yml,yaml}": "prettier --write"
61
61
  },
62
62
  "dependencies": {
63
+ "@aws-sdk/client-sesv2": "^3.1175.0",
63
64
  "@sharadox/web-library": "^0.10.0",
65
+ "@vercel/oidc-aws-credentials-provider": "^3.3.21",
64
66
  "nodemailer": "^10.1.4"
65
67
  },
66
68
  "devDependencies": {
@@ -75,6 +77,7 @@
75
77
  "@types/smtp-server": "^3.5.13",
76
78
  "@vitest/coverage-v8": "^5.1.1",
77
79
  "eslint": "9.39.5",
80
+ "happy-dom": "^21.0.4",
78
81
  "husky": "^9.1.7",
79
82
  "lint-staged": "^17.6.0",
80
83
  "prettier": "^3.10.1",