@molecule/api-emails-ses 1.0.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/LICENSE ADDED
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=browser-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-guard.d.ts","sourceRoot":"","sources":["../src/browser-guard.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Browser guard — `@molecule/api-emails-ses` is SERVER-ONLY.
3
+ *
4
+ * Generated by scripts/gen-browser-guards.mjs (workspace root) — edit THAT, not this.
5
+ * Evaluating a server package in a browser bundle is always an import-graph mistake
6
+ * (node APIs, secrets); without this guard it surfaces as a cryptic downstream crash
7
+ * ("Buffer is not defined") far from the culprit. Throwing here names the package and
8
+ * the fix at the exact moment the client bundle evaluates it. jsdom tests and SSR are
9
+ * unaffected: the throw requires browser globals AND the absence of a node runtime.
10
+ */
11
+ const g = globalThis;
12
+ if (g.window !== undefined && g.document !== undefined && !g.process?.versions?.node) {
13
+ throw new Error('@molecule/api-emails-ses is SERVER-ONLY: it was bundled into browser/client code. Import it only ' +
14
+ 'from server code (a server route/function or your API), or dynamic-import it inside ' +
15
+ 'the server handler — never from components or shared client modules, and never ' +
16
+ 'polyfill Buffer/process to silence this.');
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=browser-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-guard.js","sourceRoot":"","sources":["../src/browser-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,GAAG,UAIT,CAAA;AACD,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrF,MAAM,IAAI,KAAK,CACb,mGAAmG;QACjG,sFAAsF;QACtF,iFAAiF;QACjF,0CAA0C,CAC7C,CAAA;AACH,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * AWS SES email provider for molecule.dev.
3
+ *
4
+ * @see https://www.npmjs.com/package/nodemailer
5
+ * @see https://aws.amazon.com/ses/
6
+ *
7
+ * @remarks
8
+ * - **Configuration is lazy and env-driven**: the SES client is constructed on
9
+ * the FIRST send — NOT at import — so `AWS_SES_REGION` (default `us-east-1`)
10
+ * and the optional `AWS_SES_ENDPOINT` are read at send time. A region resolved
11
+ * into env AFTER this module is imported (late secrets resolution via a
12
+ * secrets bond) is honored; reading it at import instead froze the
13
+ * default/empty region and sends failed in the WRONG region ("Email address
14
+ * is not verified"). Credentials resolve lazily via the AWS default chain
15
+ * (`AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`, shared config, or an instance
16
+ * role), so they may arrive after import too.
17
+ * - **No fail-fast**: because credentials can legitimately come from an instance
18
+ * role or shared config (not env), missing credentials are not pre-checked —
19
+ * they surface at first send as a descriptive AWS SDK error ("Could not load
20
+ * credentials…"), not a tagged config error naming the env var.
21
+ * - New SES accounts are sandboxed: both the sender identity AND every
22
+ * recipient must be verified until production access is granted.
23
+ * - On success `accepted` is mapped from `envelope.to` — nodemailer's SES
24
+ * transport never sets `accepted`/`rejected` (the `@types/nodemailer` typings
25
+ * claiming otherwise are drift); a resolved send means SES accepted the
26
+ * message for every envelope recipient.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { setTransport } from '@molecule/api-emails'
31
+ * import { provider } from '@molecule/api-emails-ses'
32
+ *
33
+ * setTransport(provider)
34
+ * ```
35
+ *
36
+ * @module
37
+ */
38
+ export * from './browser-guard.js';
39
+ export * from './provider.js';
40
+ export * from './secrets.js';
41
+ export * from './types.js';
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * AWS SES email provider for molecule.dev.
3
+ *
4
+ * @see https://www.npmjs.com/package/nodemailer
5
+ * @see https://aws.amazon.com/ses/
6
+ *
7
+ * @remarks
8
+ * - **Configuration is lazy and env-driven**: the SES client is constructed on
9
+ * the FIRST send — NOT at import — so `AWS_SES_REGION` (default `us-east-1`)
10
+ * and the optional `AWS_SES_ENDPOINT` are read at send time. A region resolved
11
+ * into env AFTER this module is imported (late secrets resolution via a
12
+ * secrets bond) is honored; reading it at import instead froze the
13
+ * default/empty region and sends failed in the WRONG region ("Email address
14
+ * is not verified"). Credentials resolve lazily via the AWS default chain
15
+ * (`AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`, shared config, or an instance
16
+ * role), so they may arrive after import too.
17
+ * - **No fail-fast**: because credentials can legitimately come from an instance
18
+ * role or shared config (not env), missing credentials are not pre-checked —
19
+ * they surface at first send as a descriptive AWS SDK error ("Could not load
20
+ * credentials…"), not a tagged config error naming the env var.
21
+ * - New SES accounts are sandboxed: both the sender identity AND every
22
+ * recipient must be verified until production access is granted.
23
+ * - On success `accepted` is mapped from `envelope.to` — nodemailer's SES
24
+ * transport never sets `accepted`/`rejected` (the `@types/nodemailer` typings
25
+ * claiming otherwise are drift); a resolved send means SES accepted the
26
+ * message for every envelope recipient.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { setTransport } from '@molecule/api-emails'
31
+ * import { provider } from '@molecule/api-emails-ses'
32
+ *
33
+ * setTransport(provider)
34
+ * ```
35
+ *
36
+ * @module
37
+ */
38
+ export * from './browser-guard.js';
39
+ export * from './provider.js';
40
+ export * from './secrets.js';
41
+ export * from './types.js';
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * AWS SES email provider implementation.
3
+ *
4
+ * @see https://www.npmjs.com/package/nodemailer
5
+ * @see https://aws.amazon.com/ses/
6
+ *
7
+ * @module
8
+ */
9
+ import './secrets.js';
10
+ import { SESv2Client } from '@aws-sdk/client-sesv2';
11
+ import nodemailer from 'nodemailer';
12
+ import type { EmailMessage, EmailSendResult, EmailTransport } from '@molecule/api-emails';
13
+ /**
14
+ * Returns the AWS SESv2 client, constructing it from the environment on the
15
+ * FIRST call and memoizing thereafter.
16
+ *
17
+ * Construction is deferred to first use — NOT module load — so a region resolved
18
+ * into `process.env` AFTER this module is imported (late secrets resolution via
19
+ * a secrets bond) is honored: `AWS_SES_REGION` (default `us-east-1`) and the
20
+ * optional `AWS_SES_ENDPOINT` are read at send time, not frozen at import.
21
+ * Reading them at import instead pinned an empty/default region and every send
22
+ * failed in the WRONG region ("Email address is not verified"). Credentials
23
+ * still resolve lazily via the AWS default chain (`AWS_ACCESS_KEY_ID`/
24
+ * `AWS_SECRET_ACCESS_KEY`, shared config, or an instance role) at send time, so
25
+ * a missing credential surfaces then as a descriptive AWS SDK error.
26
+ *
27
+ * nodemailer 7 requires the SESv2 client + `SendEmailCommand` pair — the old
28
+ * `{ ses, aws }` (@aws-sdk/client-ses) shape made `createTransport` THROW
29
+ * ("legacy SES configuration"), breaking every real consumer of this bond.
30
+ *
31
+ * @returns The configured SESv2 client.
32
+ */
33
+ export declare const getSesClient: () => SESv2Client;
34
+ /**
35
+ * Sends an email through AWS SES via nodemailer. The SES client and transport
36
+ * are configured lazily from the environment on the first call, so late-resolved
37
+ * region/credentials are honored.
38
+ *
39
+ * @param message - The email message (to, from, subject, text/html, attachments).
40
+ * @returns Send result with accepted/rejected addresses and message ID.
41
+ */
42
+ export declare const sendMail: (message: EmailMessage) => Promise<EmailSendResult>;
43
+ /**
44
+ * The SES email provider implementing the `EmailTransport` interface.
45
+ */
46
+ export declare const provider: EmailTransport;
47
+ /**
48
+ * Raw nodemailer transport for direct access. Lazily configured on first send.
49
+ * @deprecated Use `sendMail()` or `provider` instead.
50
+ */
51
+ export declare const transport: {
52
+ sendMail: (msg: nodemailer.SendMailOptions) => Promise<any>;
53
+ };
54
+ /**
55
+ * Raw nodemailer transport alias.
56
+ * @deprecated Use `sendMail()` or `provider` instead.
57
+ */
58
+ export declare const email: {
59
+ sendMail: (msg: nodemailer.SendMailOptions) => Promise<any>;
60
+ };
61
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,cAAc,CAAA;AACrB,OAAO,EAAoB,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAErE,OAAO,UAAU,MAAM,YAAY,CAAA;AAGnC,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAWzF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,QAAO,WAS/B,CAAA;AAkBD;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAU,SAAS,YAAY,KAAG,OAAO,CAAC,eAAe,CAsB7E,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,cAEtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS;oBACJ,UAAU,CAAC,eAAe;CAC3C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK;oBAPA,UAAU,CAAC,eAAe;CAOd,CAAA"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * AWS SES email provider implementation.
3
+ *
4
+ * @see https://www.npmjs.com/package/nodemailer
5
+ * @see https://aws.amazon.com/ses/
6
+ *
7
+ * @module
8
+ */
9
+ // Side-effect import: registers this bond's secret definitions so the
10
+ // runtime registry is populated even when provider.js is imported directly
11
+ // (not through the package barrel).
12
+ import './secrets.js';
13
+ import { SendEmailCommand, SESv2Client } from '@aws-sdk/client-sesv2';
14
+ import { defaultProvider } from '@aws-sdk/credential-provider-node';
15
+ import nodemailer from 'nodemailer';
16
+ import { getLogger } from '@molecule/api-bond';
17
+ const logger = getLogger();
18
+ /**
19
+ * The lazily-constructed AWS SESv2 client and nodemailer transport. Both are
20
+ * built on first send — NOT at import — and memoized thereafter.
21
+ */
22
+ let _ses;
23
+ let _nodemailerTransport;
24
+ /**
25
+ * Returns the AWS SESv2 client, constructing it from the environment on the
26
+ * FIRST call and memoizing thereafter.
27
+ *
28
+ * Construction is deferred to first use — NOT module load — so a region resolved
29
+ * into `process.env` AFTER this module is imported (late secrets resolution via
30
+ * a secrets bond) is honored: `AWS_SES_REGION` (default `us-east-1`) and the
31
+ * optional `AWS_SES_ENDPOINT` are read at send time, not frozen at import.
32
+ * Reading them at import instead pinned an empty/default region and every send
33
+ * failed in the WRONG region ("Email address is not verified"). Credentials
34
+ * still resolve lazily via the AWS default chain (`AWS_ACCESS_KEY_ID`/
35
+ * `AWS_SECRET_ACCESS_KEY`, shared config, or an instance role) at send time, so
36
+ * a missing credential surfaces then as a descriptive AWS SDK error.
37
+ *
38
+ * nodemailer 7 requires the SESv2 client + `SendEmailCommand` pair — the old
39
+ * `{ ses, aws }` (@aws-sdk/client-ses) shape made `createTransport` THROW
40
+ * ("legacy SES configuration"), breaking every real consumer of this bond.
41
+ *
42
+ * @returns The configured SESv2 client.
43
+ */
44
+ export const getSesClient = () => {
45
+ if (!_ses) {
46
+ _ses = new SESv2Client({
47
+ region: process.env.AWS_SES_REGION || 'us-east-1',
48
+ credentialDefaultProvider: defaultProvider,
49
+ ...(process.env.AWS_SES_ENDPOINT ? { endpoint: process.env.AWS_SES_ENDPOINT } : {}),
50
+ });
51
+ }
52
+ return _ses;
53
+ };
54
+ /**
55
+ * Returns the lazily-initialized nodemailer transport (nodemailer 7 SESv2
56
+ * shape), constructing it — and the underlying SESv2 client — from the
57
+ * environment on the first send and memoizing thereafter.
58
+ *
59
+ * @returns The nodemailer `Transporter` backed by AWS SES.
60
+ */
61
+ const getTransport = () => {
62
+ if (!_nodemailerTransport) {
63
+ _nodemailerTransport = nodemailer.createTransport({
64
+ SES: { sesClient: getSesClient(), SendEmailCommand },
65
+ });
66
+ }
67
+ return _nodemailerTransport;
68
+ };
69
+ /**
70
+ * Sends an email through AWS SES via nodemailer. The SES client and transport
71
+ * are configured lazily from the environment on the first call, so late-resolved
72
+ * region/credentials are honored.
73
+ *
74
+ * @param message - The email message (to, from, subject, text/html, attachments).
75
+ * @returns Send result with accepted/rejected addresses and message ID.
76
+ */
77
+ export const sendMail = async (message) => {
78
+ try {
79
+ const result = await getTransport().sendMail(message);
80
+ return {
81
+ // nodemailer's SES transport resolves with `{ envelope, messageId,
82
+ // response, raw }` — it NEVER sets `accepted`/`rejected` (only the SMTP
83
+ // transports do; the @types/nodemailer SentMessageInfo claiming otherwise
84
+ // is type-level drift). A resolved SendEmail call means SES accepted the
85
+ // message for every envelope recipient, so map `envelope.to` to
86
+ // `accepted` — without this, every successful send reported
87
+ // `accepted: []` and callers gating on "was my recipient accepted?"
88
+ // concluded delivery failed.
89
+ accepted: (result.accepted ?? result.envelope?.to ?? []),
90
+ rejected: (result.rejected ?? []),
91
+ messageId: result.messageId,
92
+ response: result.response,
93
+ };
94
+ }
95
+ catch (error) {
96
+ logger.error('SES sendMail error:', error);
97
+ throw error;
98
+ }
99
+ };
100
+ /**
101
+ * The SES email provider implementing the `EmailTransport` interface.
102
+ */
103
+ export const provider = {
104
+ sendMail,
105
+ };
106
+ /**
107
+ * Raw nodemailer transport for direct access. Lazily configured on first send.
108
+ * @deprecated Use `sendMail()` or `provider` instead.
109
+ */
110
+ export const transport = {
111
+ sendMail: (msg) => getTransport().sendMail(msg),
112
+ };
113
+ /**
114
+ * Raw nodemailer transport alias.
115
+ * @deprecated Use `sendMail()` or `provider` instead.
116
+ */
117
+ export const email = transport;
118
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sEAAsE;AACtE,2EAA2E;AAC3E,oCAAoC;AACpC,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;AAE1B;;;GAGG;AACH,IAAI,IAA6B,CAAA;AACjC,IAAI,oBAAwD,CAAA;AAE5D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAgB,EAAE;IAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,GAAG,IAAI,WAAW,CAAC;YACrB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,WAAW;YACjD,yBAAyB,EAAE,eAAe;YAC1C,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpF,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,GAA2B,EAAE;IAChD,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,oBAAoB,GAAG,UAAU,CAAC,eAAe,CAAC;YAChD,GAAG,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,gBAAgB,EAAE;SACD,CAAC,CAAA;IACxD,CAAC;IACD,OAAO,oBAAoB,CAAA;AAC7B,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,OAAqB,EAA4B,EAAE;IAChF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC,QAAQ,CAAC,OAAqC,CAAC,CAAA;QAEnF,OAAO;YACL,mEAAmE;YACnE,wEAAwE;YACxE,0EAA0E;YAC1E,yEAAyE;YACzE,gEAAgE;YAChE,4DAA4D;YAC5D,oEAAoE;YACpE,6BAA6B;YAC7B,QAAQ,EAAE,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAa;YACpE,QAAQ,EAAE,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAa;YAC7C,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;QAC1C,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAmB;IACtC,QAAQ;CACT,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,QAAQ,EAAE,CAAC,GAA+B,EAAE,EAAE,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;CAC5E,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * AWS SES secret definitions — self-registered at import time so the
3
+ * runtime secrets registry (`@molecule/api-secrets`) can drive boot-time
4
+ * configuration reports and actionable "not configured" errors.
5
+ *
6
+ * Content is derived MECHANICALLY from this package's mlcl registry secrets
7
+ * entry (label/instructions/setupUrl/example) via the fleet formula, so
8
+ * packages sharing a key register byte-identical definitions and
9
+ * registration order never matters.
10
+ *
11
+ * @module
12
+ */
13
+ import type { SecretDefinition } from '@molecule/api-secrets';
14
+ /** Secret definitions required by the AWS SES email bond. */
15
+ export declare const emailsSesSecretDefinitions: SecretDefinition[];
16
+ //# sourceMappingURL=secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAG7D,6DAA6D;AAC7D,eAAO,MAAM,0BAA0B,EAAE,gBAAgB,EAuBxD,CAAA"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * AWS SES secret definitions — self-registered at import time so the
3
+ * runtime secrets registry (`@molecule/api-secrets`) can drive boot-time
4
+ * configuration reports and actionable "not configured" errors.
5
+ *
6
+ * Content is derived MECHANICALLY from this package's mlcl registry secrets
7
+ * entry (label/instructions/setupUrl/example) via the fleet formula, so
8
+ * packages sharing a key register byte-identical definitions and
9
+ * registration order never matters.
10
+ *
11
+ * @module
12
+ */
13
+ import { registerSecrets } from '@molecule/api-secrets';
14
+ /** Secret definitions required by the AWS SES email bond. */
15
+ export const emailsSesSecretDefinitions = [
16
+ {
17
+ key: 'AWS_ACCESS_KEY_ID',
18
+ description: 'AWS access key ID — Create an IAM user with the needed policy (SES/S3/SQS) and create an access key under Security credentials.',
19
+ helpUrl: 'https://console.aws.amazon.com/iam/',
20
+ required: true,
21
+ example: 'AKIA...',
22
+ },
23
+ {
24
+ key: 'AWS_SECRET_ACCESS_KEY',
25
+ description: 'AWS secret access key — Shown once when creating the IAM access key — store it immediately.',
26
+ helpUrl: 'https://console.aws.amazon.com/iam/',
27
+ required: true,
28
+ },
29
+ {
30
+ key: 'AWS_SES_REGION',
31
+ description: 'AWS SES region — The AWS region where SES is set up (and out of sandbox for production sending).',
32
+ required: true,
33
+ example: 'us-east-1',
34
+ },
35
+ ];
36
+ registerSecrets(emailsSesSecretDefinitions);
37
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../src/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,0BAA0B,GAAuB;IAC5D;QACE,GAAG,EAAE,mBAAmB;QACxB,WAAW,EACT,iIAAiI;QACnI,OAAO,EAAE,qCAAqC;QAC9C,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,SAAS;KACnB;IACD;QACE,GAAG,EAAE,uBAAuB;QAC5B,WAAW,EACT,6FAA6F;QAC/F,OAAO,EAAE,qCAAqC;QAC9C,QAAQ,EAAE,IAAI;KACf;IACD;QACE,GAAG,EAAE,gBAAgB;QACrB,WAAW,EACT,kGAAkG;QACpG,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,WAAW;KACrB;CACF,CAAA;AAED,eAAe,CAAC,0BAA0B,CAAC,CAAA"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Type definitions for the AWS SES email provider.
3
+ *
4
+ * @module
5
+ */
6
+ export type { EmailMessage, EmailSendResult, EmailTransport } from '@molecule/api-emails';
7
+ declare global {
8
+ namespace NodeJS {
9
+ /**
10
+ * Process Env interface.
11
+ */
12
+ interface ProcessEnv {
13
+ /**
14
+ * The AWS API access key ID.
15
+ */
16
+ AWS_ACCESS_KEY_ID?: string;
17
+ /**
18
+ * The AWS API secret access key.
19
+ */
20
+ AWS_SECRET_ACCESS_KEY?: string;
21
+ /**
22
+ * The AWS region for SES.
23
+ *
24
+ * @default us-east-1
25
+ */
26
+ AWS_SES_REGION?: string;
27
+ /**
28
+ * Optional SES service endpoint override (e.g. a credential broker or a
29
+ * self-hosted / SES-compatible service). When unset, the SDK resolves the
30
+ * default regional endpoint.
31
+ */
32
+ AWS_SES_ENDPOINT?: string;
33
+ }
34
+ }
35
+ }
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAEzF,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,MAAM,CAAC;QACf;;WAEG;QACH,UAAiB,UAAU;YACzB;;eAEG;YACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;YAE1B;;eAEG;YACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;YAE9B;;;;eAIG;YACH,cAAc,CAAC,EAAE,MAAM,CAAA;YAEvB;;;;eAIG;YACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;SAC1B;KACF;CACF"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Type definitions for the AWS SES email provider.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@molecule/api-emails-ses",
3
+ "version": "1.0.0",
4
+ "description": "AWS SES email provider for molecule.dev.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "molecule",
24
+ "email",
25
+ "ses",
26
+ "aws",
27
+ "nodemailer"
28
+ ],
29
+ "license": "Apache-2.0",
30
+ "dependencies": {
31
+ "@aws-sdk/client-sesv2": "3.1098.0",
32
+ "@aws-sdk/credential-provider-node": "3.972.75",
33
+ "nodemailer": "9.0.3"
34
+ },
35
+ "devDependencies": {
36
+ "@molecule/api-bond": "1.0.0",
37
+ "@types/node": "26.1.2",
38
+ "@types/nodemailer": "8.0.1",
39
+ "typescript": "6.0.3",
40
+ "vitest": "4.1.10"
41
+ },
42
+ "peerDependencies": {
43
+ "@molecule/api-bond": "^1.0.0",
44
+ "@molecule/api-emails": "^1.0.0",
45
+ "@molecule/api-secrets": "^1.0.0"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/molecule-dev/molecule.git",
50
+ "directory": "packages/api/bonds/emails/ses"
51
+ },
52
+ "homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/api/bonds/emails/ses",
53
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
54
+ "publishConfig": {
55
+ "access": "public"
56
+ }
57
+ }