@masonjames/emdash-smtp 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - Initial trusted EmDash SMTP release
6
+ - Full EmDash SMTP provider coverage, including generic SMTP and local sendmail
7
+ - Block Kit admin pages for provider configuration and delivery logs
8
+ - Shared provider catalog with fallback delivery support
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mason James
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # `@masonjames/emdash-smtp`
2
+
3
+ Trusted installation of the EmDash SMTP plugin family.
4
+
5
+ Use this package when you need the full EmDash SMTP feature set, including transports that cannot run in the EmDash marketplace sandbox.
6
+
7
+ ## Includes
8
+
9
+ - full shared provider catalog
10
+ - generic SMTP
11
+ - provider-specific SMTP-style setups where a raw transport is required
12
+ - local sendmail / PHP mail analogue
13
+ - Block Kit admin pages for providers and logs
14
+ - delivery fallback support
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pnpm add @masonjames/emdash-smtp
20
+ ```
21
+
22
+ ## Register in `astro.config.mjs`
23
+
24
+ ```ts
25
+ import { defineConfig } from "astro/config";
26
+ import emdash from "emdash/astro";
27
+ import { emdashSmtp } from "@masonjames/emdash-smtp";
28
+
29
+ export default defineConfig({
30
+ integrations: [
31
+ emdash({
32
+ plugins: [emdashSmtp()],
33
+ }),
34
+ ],
35
+ });
36
+ ```
37
+
38
+ ## When to use this package
39
+
40
+ Choose the trusted package if you need any of the following:
41
+
42
+ - Generic SMTP
43
+ - local sendmail delivery
44
+ - maximum provider compatibility on Node deployments
45
+ - first-party control via npm and source review
46
+
47
+ ## Do not install both variants together
48
+
49
+ Choose one runtime path per site:
50
+
51
+ - `@masonjames/emdash-smtp` for trusted/npm installs
52
+ - `@masonjames/emdash-smtp-marketplace` for marketplace or sandbox installs
53
+ - both distributions identify as `emdash-smtp` inside EmDash
54
+
55
+ If you need a user-installable marketplace listing and a first-party npm install path, publish both packages as a split pair.
@@ -0,0 +1,10 @@
1
+ import { PluginDescriptor } from "emdash";
2
+
3
+ //#region src/index.d.ts
4
+ interface EmdashSmtpOptions {
5
+ label?: string;
6
+ }
7
+ declare function emdashSmtp(options?: EmdashSmtpOptions): PluginDescriptor<EmdashSmtpOptions>;
8
+ //#endregion
9
+ export { EmdashSmtpOptions, emdashSmtp as default, emdashSmtp };
10
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;UAUiB,iBAAA;EAChB,KAAA;AAAA;AAAA,iBAGe,UAAA,CAAW,OAAA,GAAS,iBAAA,GAAyB,gBAAA,CAAiB,iBAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,25 @@
1
+ import { SMTP_ADMIN_PAGES, SMTP_ADMIN_WIDGETS, SMTP_PLUGIN_ID, SMTP_PLUGIN_VERSION, collectAllowedHosts } from "@masonjames/emdash-smtp-core";
2
+
3
+ //#region src/index.ts
4
+ function emdashSmtp(options = {}) {
5
+ return {
6
+ id: SMTP_PLUGIN_ID,
7
+ version: SMTP_PLUGIN_VERSION,
8
+ entrypoint: "@masonjames/emdash-smtp/plugin",
9
+ options,
10
+ capabilities: ["email:provide", "network:fetch"],
11
+ allowedHosts: collectAllowedHosts("trusted"),
12
+ storage: { deliveryLogs: { indexes: [
13
+ "providerId",
14
+ "status",
15
+ "createdAt",
16
+ "source"
17
+ ] } },
18
+ adminPages: [...SMTP_ADMIN_PAGES],
19
+ adminWidgets: [...SMTP_ADMIN_WIDGETS]
20
+ };
21
+ }
22
+
23
+ //#endregion
24
+ export { emdashSmtp as default, emdashSmtp };
25
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { PluginDescriptor } from \"emdash\";\n\nimport {\n\tcollectAllowedHosts,\n\tSMTP_ADMIN_PAGES,\n\tSMTP_ADMIN_WIDGETS,\n\tSMTP_PLUGIN_ID,\n\tSMTP_PLUGIN_VERSION,\n} from \"@masonjames/emdash-smtp-core\";\n\nexport interface EmdashSmtpOptions {\n\tlabel?: string;\n}\n\nexport function emdashSmtp(options: EmdashSmtpOptions = {}): PluginDescriptor<EmdashSmtpOptions> {\n\treturn {\n\t\tid: SMTP_PLUGIN_ID,\n\t\tversion: SMTP_PLUGIN_VERSION,\n\t\tentrypoint: \"@masonjames/emdash-smtp/plugin\",\n\t\toptions,\n\t\tcapabilities: [\"email:provide\", \"network:fetch\"],\n\t\tallowedHosts: collectAllowedHosts(\"trusted\"),\n\t\tstorage: {\n\t\t\tdeliveryLogs: {\n\t\t\t\tindexes: [\"providerId\", \"status\", \"createdAt\", \"source\"],\n\t\t\t},\n\t\t},\n\t\tadminPages: [...SMTP_ADMIN_PAGES],\n\t\tadminWidgets: [...SMTP_ADMIN_WIDGETS],\n\t};\n}\n\nexport default emdashSmtp;\n"],"mappings":";;;AAcA,SAAgB,WAAW,UAA6B,EAAE,EAAuC;AAChG,QAAO;EACN,IAAI;EACJ,SAAS;EACT,YAAY;EACZ;EACA,cAAc,CAAC,iBAAiB,gBAAgB;EAChD,cAAc,oBAAoB,UAAU;EAC5C,SAAS,EACR,cAAc,EACb,SAAS;GAAC;GAAc;GAAU;GAAa;GAAS,EACxD,EACD;EACD,YAAY,CAAC,GAAG,iBAAiB;EACjC,cAAc,CAAC,GAAG,mBAAmB;EACrC"}
@@ -0,0 +1,7 @@
1
+ import { ResolvedPlugin } from "emdash";
2
+
3
+ //#region src/plugin.d.ts
4
+ declare function createPlugin(): ResolvedPlugin;
5
+ //#endregion
6
+ export { createPlugin, createPlugin as default };
7
+ //# sourceMappingURL=plugin.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;iBAmFgB,YAAA,CAAA,GAAgB,cAAA"}
@@ -0,0 +1,96 @@
1
+ import { SMTP_ADMIN_PAGES, SMTP_ADMIN_WIDGETS, SMTP_PLUGIN_ID, SMTP_PLUGIN_VERSION, collectAllowedHosts, createDeliveryLogRecord, deliverWithConfiguredProvider, handleAdminInteraction, isDeliveryReady, writeDeliveryLog } from "@masonjames/emdash-smtp-core";
2
+ import { definePlugin } from "emdash";
3
+ import { sendmailSend, smtpSend } from "@masonjames/emdash-smtp-node-transports";
4
+
5
+ //#region src/plugin.ts
6
+ function createTrustedRuntime(ctx) {
7
+ return {
8
+ variant: "trusted",
9
+ fetch: ctx.http ? (url, init) => ctx.http.fetch(url, init) : void 0,
10
+ smtpSend,
11
+ sendmailSend
12
+ };
13
+ }
14
+ async function logSuccessfulDelivery(ctx, event, source, result) {
15
+ await writeDeliveryLog(ctx, createDeliveryLogRecord({
16
+ providerId: result.providerId,
17
+ status: "sent",
18
+ message: {
19
+ to: event.message.to,
20
+ subject: event.message.subject
21
+ },
22
+ source,
23
+ durationMs: result.durationMs,
24
+ remoteMessageId: result.remoteMessageId
25
+ }));
26
+ }
27
+ async function logFailedDelivery(ctx, event, source, error) {
28
+ await writeDeliveryLog(ctx, createDeliveryLogRecord({
29
+ providerId: "unknown",
30
+ status: "failed",
31
+ message: {
32
+ to: event.message.to,
33
+ subject: event.message.subject
34
+ },
35
+ source,
36
+ durationMs: 0,
37
+ errorMessage: error.message
38
+ }));
39
+ }
40
+ function createPlugin() {
41
+ return definePlugin({
42
+ id: SMTP_PLUGIN_ID,
43
+ version: SMTP_PLUGIN_VERSION,
44
+ capabilities: ["email:provide", "network:fetch"],
45
+ allowedHosts: collectAllowedHosts("trusted"),
46
+ storage: { deliveryLogs: { indexes: [
47
+ "providerId",
48
+ "status",
49
+ "createdAt",
50
+ "source"
51
+ ] } },
52
+ admin: {
53
+ pages: [...SMTP_ADMIN_PAGES],
54
+ widgets: [...SMTP_ADMIN_WIDGETS]
55
+ },
56
+ hooks: {
57
+ "email:deliver": {
58
+ exclusive: true,
59
+ handler: async (event, ctx) => {
60
+ const source = event.source || ctx.plugin.id;
61
+ try {
62
+ await logSuccessfulDelivery(ctx, event, source, await deliverWithConfiguredProvider({
63
+ ctx,
64
+ runtime: createTrustedRuntime(ctx),
65
+ message: event.message,
66
+ source
67
+ }));
68
+ } catch (error) {
69
+ const err = error instanceof Error ? error : new Error(String(error));
70
+ await logFailedDelivery(ctx, event, source, err);
71
+ throw err;
72
+ }
73
+ }
74
+ },
75
+ "email:status": { handler: async (_event, ctx) => isDeliveryReady({
76
+ ctx,
77
+ runtime: createTrustedRuntime(ctx)
78
+ }) }
79
+ },
80
+ routes: { admin: { handler: (async (routeCtx, ctx) => {
81
+ return handleAdminInteraction({
82
+ ctx,
83
+ variant: "trusted",
84
+ runtime: createTrustedRuntime(ctx),
85
+ interaction: routeCtx.input ?? {
86
+ type: "page_load",
87
+ page: "/providers"
88
+ }
89
+ });
90
+ }) } }
91
+ });
92
+ }
93
+
94
+ //#endregion
95
+ export { createPlugin, createPlugin as default };
96
+ //# sourceMappingURL=plugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { definePlugin } from \"emdash\";\nimport type { PluginContext, ResolvedPlugin } from \"emdash\";\n\nimport {\n\tcollectAllowedHosts,\n\tcreateDeliveryLogRecord,\n\tdeliverWithConfiguredProvider,\n\thandleAdminInteraction,\n\tisDeliveryReady,\n\tSMTP_ADMIN_PAGES,\n\tSMTP_ADMIN_WIDGETS,\n\tSMTP_PLUGIN_ID,\n\tSMTP_PLUGIN_VERSION,\n\ttype AdminInteraction,\n\ttype DeliveryRuntime,\n\ttype SmtpPluginContextLike,\n\twriteDeliveryLog,\n} from \"@masonjames/emdash-smtp-core\";\nimport { sendmailSend, smtpSend } from \"@masonjames/emdash-smtp-node-transports\";\n\nfunction createTrustedRuntime(ctx: PluginContext): DeliveryRuntime {\n\treturn {\n\t\tvariant: \"trusted\",\n\t\tfetch: ctx.http ? (url, init) => ctx.http!.fetch(url, init) : undefined,\n\t\tsmtpSend,\n\t\tsendmailSend,\n\t};\n}\n\ninterface TrustedEmailDeliverEvent {\n\tmessage: {\n\t\tto: string;\n\t\tsubject: string;\n\t\ttext: string;\n\t\thtml?: string;\n\t};\n\tsource: string;\n}\n\nasync function logSuccessfulDelivery(\n\tctx: SmtpPluginContextLike,\n\tevent: TrustedEmailDeliverEvent,\n\tsource: string,\n\tresult: Awaited<ReturnType<typeof deliverWithConfiguredProvider>>,\n): Promise<void> {\n\tawait writeDeliveryLog(\n\t\tctx,\n\t\tcreateDeliveryLogRecord({\n\t\t\tproviderId: result.providerId,\n\t\t\tstatus: \"sent\",\n\t\t\tmessage: {\n\t\t\t\tto: event.message.to,\n\t\t\t\tsubject: event.message.subject,\n\t\t\t},\n\t\t\tsource,\n\t\t\tdurationMs: result.durationMs,\n\t\t\tremoteMessageId: result.remoteMessageId,\n\t\t}),\n\t);\n}\n\nasync function logFailedDelivery(\n\tctx: SmtpPluginContextLike,\n\tevent: TrustedEmailDeliverEvent,\n\tsource: string,\n\terror: Error,\n): Promise<void> {\n\tawait writeDeliveryLog(\n\t\tctx,\n\t\tcreateDeliveryLogRecord({\n\t\t\tproviderId: \"unknown\",\n\t\t\tstatus: \"failed\",\n\t\t\tmessage: {\n\t\t\t\tto: event.message.to,\n\t\t\t\tsubject: event.message.subject,\n\t\t\t},\n\t\t\tsource,\n\t\t\tdurationMs: 0,\n\t\t\terrorMessage: error.message,\n\t\t}),\n\t);\n}\n\nexport function createPlugin(): ResolvedPlugin {\n\treturn definePlugin({\n\t\tid: SMTP_PLUGIN_ID,\n\t\tversion: SMTP_PLUGIN_VERSION,\n\t\tcapabilities: [\"email:provide\", \"network:fetch\"],\n\t\tallowedHosts: collectAllowedHosts(\"trusted\"),\n\t\tstorage: {\n\t\t\tdeliveryLogs: {\n\t\t\t\tindexes: [\"providerId\", \"status\", \"createdAt\", \"source\"],\n\t\t\t},\n\t\t},\n\t\tadmin: {\n\t\t\tpages: [...SMTP_ADMIN_PAGES],\n\t\t\twidgets: [...SMTP_ADMIN_WIDGETS],\n\t\t},\n\t\thooks: {\n\t\t\t\"email:deliver\": {\n\t\t\t\texclusive: true,\n\t\t\t\thandler: async (event: TrustedEmailDeliverEvent, ctx: PluginContext) => {\n\t\t\t\t\tconst source = event.source || ctx.plugin.id;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await deliverWithConfiguredProvider({\n\t\t\t\t\t\t\tctx: ctx as unknown as SmtpPluginContextLike,\n\t\t\t\t\t\t\truntime: createTrustedRuntime(ctx),\n\t\t\t\t\t\t\tmessage: event.message,\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait logSuccessfulDelivery(\n\t\t\t\t\t\t\tctx as unknown as SmtpPluginContextLike,\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\tresult,\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\tawait logFailedDelivery(ctx as unknown as SmtpPluginContextLike, event, source, err);\n\t\t\t\t\t\tthrow err;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"email:status\": {\n\t\t\t\thandler: async (_event: unknown, ctx: PluginContext) =>\n\t\t\t\t\tisDeliveryReady({\n\t\t\t\t\t\tctx: ctx as unknown as SmtpPluginContextLike,\n\t\t\t\t\t\truntime: createTrustedRuntime(ctx),\n\t\t\t\t\t}),\n\t\t\t},\n\t\t},\n\t\troutes: {\n\t\t\tadmin: {\n\t\t\t\thandler: (async (\n\t\t\t\t\trouteCtx: { input: unknown; request: unknown },\n\t\t\t\t\tctx: PluginContext,\n\t\t\t\t) => {\n\t\t\t\t\treturn handleAdminInteraction({\n\t\t\t\t\t\tctx: ctx as unknown as SmtpPluginContextLike,\n\t\t\t\t\t\tvariant: \"trusted\",\n\t\t\t\t\t\truntime: createTrustedRuntime(ctx),\n\t\t\t\t\t\tinteraction: (routeCtx.input ?? { type: \"page_load\", page: \"/providers\" }) as AdminInteraction,\n\t\t\t\t\t});\n\t\t\t\t}) as never,\n\t\t\t},\n\t\t},\n\t});\n}\n\nexport default createPlugin;\n"],"mappings":";;;;;AAoBA,SAAS,qBAAqB,KAAqC;AAClE,QAAO;EACN,SAAS;EACT,OAAO,IAAI,QAAQ,KAAK,SAAS,IAAI,KAAM,MAAM,KAAK,KAAK,GAAG;EAC9D;EACA;EACA;;AAaF,eAAe,sBACd,KACA,OACA,QACA,QACgB;AAChB,OAAM,iBACL,KACA,wBAAwB;EACvB,YAAY,OAAO;EACnB,QAAQ;EACR,SAAS;GACR,IAAI,MAAM,QAAQ;GAClB,SAAS,MAAM,QAAQ;GACvB;E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D;EACD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@masonjames/emdash-smtp",
3
+ "version": "0.1.0",
4
+ "description": "Trusted full-parity SMTP and transactional email plugin for EmDash",
5
+ "type": "module",
6
+ "main": "dist/index.mjs",
7
+ "types": "dist/index.d.mts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "types": "./dist/index.d.mts"
12
+ },
13
+ "./plugin": {
14
+ "import": "./dist/plugin.mjs",
15
+ "types": "./dist/plugin.d.mts"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "CHANGELOG.md"
22
+ ],
23
+ "keywords": [
24
+ "emdash",
25
+ "emdash-plugin",
26
+ "smtp",
27
+ "email",
28
+ "transactional-email"
29
+ ],
30
+ "author": "Mason James",
31
+ "dependencies": {
32
+ "@masonjames/emdash-smtp-core": "0.1.0",
33
+ "@masonjames/emdash-smtp-node-transports": "0.1.0"
34
+ },
35
+ "peerDependencies": {
36
+ "emdash": ">=0.1.0"
37
+ },
38
+ "license": "MIT",
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/masonjames/emdash-smtp.git",
45
+ "directory": "packages/emdash-smtp"
46
+ },
47
+ "homepage": "https://github.com/masonjames/emdash-smtp#readme",
48
+ "bugs": {
49
+ "url": "https://github.com/masonjames/emdash-smtp/issues"
50
+ },
51
+ "scripts": {
52
+ "build": "tsdown src/index.ts src/plugin.ts --format esm --dts --clean",
53
+ "test": "vitest run",
54
+ "typecheck": "tsc --noEmit -p tsconfig.json"
55
+ }
56
+ }