@molecule/api-emails-inbound-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 +115 -0
- package/dist/browser-guard.d.ts +2 -0
- package/dist/browser-guard.d.ts.map +1 -0
- package/dist/browser-guard.js +19 -0
- package/dist/browser-guard.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +92 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +378 -0
- package/dist/provider.js.map +1 -0
- package/dist/secrets.d.ts +16 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +51 -0
- package/dist/secrets.js.map +1 -0
- package/dist/types.d.ts +121 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/dist/utilities.d.ts +121 -0
- package/dist/utilities.d.ts.map +1 -0
- package/dist/utilities.js +324 -0
- package/dist/utilities.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal utilities for the AWS SES inbound-email provider.
|
|
3
|
+
*
|
|
4
|
+
* Kept out of `provider.ts` so the parsing helpers can be unit-tested in
|
|
5
|
+
* isolation without touching the bond singleton.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { Buffer } from 'node:buffer';
|
|
10
|
+
import './secrets.js';
|
|
11
|
+
import type { InboundEmail } from '@molecule/api-emails-inbound';
|
|
12
|
+
/**
|
|
13
|
+
* Coerces an HTTP header value (which may be `string`, `string[]`, or
|
|
14
|
+
* `undefined`) to a single string. Multi-value headers are joined with
|
|
15
|
+
* `, ` per RFC 9110 §5.2.
|
|
16
|
+
*
|
|
17
|
+
* @param value - The header value to coerce.
|
|
18
|
+
* @returns The header value as a single string, or `undefined` when the
|
|
19
|
+
* header was not present.
|
|
20
|
+
*/
|
|
21
|
+
export declare const headerToString: (value: string | string[] | undefined) => string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the value of `headers[name]` (case-insensitive) coerced to a
|
|
24
|
+
* single string.
|
|
25
|
+
*
|
|
26
|
+
* @param headers - The headers object.
|
|
27
|
+
* @param name - The header name (case-insensitive).
|
|
28
|
+
* @returns The header value as a single string, or `undefined` if absent.
|
|
29
|
+
*/
|
|
30
|
+
export declare const getHeader: (headers: Record<string, string | string[] | undefined>, name: string) => string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Coerces the request body into a UTF-8 string. SNS POSTs JSON as UTF-8.
|
|
33
|
+
*
|
|
34
|
+
* @param body - The raw body.
|
|
35
|
+
* @returns The body as a UTF-8 string.
|
|
36
|
+
*/
|
|
37
|
+
export declare const bodyToString: (body: Buffer | string) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Parses a Buffer/string/object body as an SNS JSON payload. Throws
|
|
40
|
+
* (caught by the caller) when the body is not valid JSON.
|
|
41
|
+
*
|
|
42
|
+
* @param body - The raw body.
|
|
43
|
+
* @returns The parsed object.
|
|
44
|
+
*/
|
|
45
|
+
export declare const parseJsonBody: (body: Buffer | string | Record<string, unknown>) => unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the configured allowlist of hostname suffixes for the SNS
|
|
48
|
+
* `SigningCertURL`. Defaults to {@link SNS_SIGNING_CERT_HOSTNAME_SUFFIXES}
|
|
49
|
+
* when the env override is unset.
|
|
50
|
+
*
|
|
51
|
+
* @returns The allowlist of hostname suffixes.
|
|
52
|
+
*/
|
|
53
|
+
export declare const getSigningCertHostnameSuffixes: () => readonly string[];
|
|
54
|
+
/**
|
|
55
|
+
* Validates that an SNS `SigningCertURL` is HTTPS and its hostname matches
|
|
56
|
+
* an entry in the allowlist. Defends against SSRF and certificate
|
|
57
|
+
* substitution attacks where an attacker tricks the verifier into fetching
|
|
58
|
+
* a cert from a host they control.
|
|
59
|
+
*
|
|
60
|
+
* @param url - The candidate URL string.
|
|
61
|
+
* @returns `true` when the URL is acceptable.
|
|
62
|
+
*/
|
|
63
|
+
export declare const isAllowedSigningCertUrl: (url: string) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Builds the canonical string SNS signs for the supplied notification.
|
|
66
|
+
* The exact field order is mandated by the SNS message-and-signature
|
|
67
|
+
* format; the canonical string is built from key/value pairs separated by
|
|
68
|
+
* `\n`, with a trailing `\n` after the last value.
|
|
69
|
+
*
|
|
70
|
+
* @param payload - The SNS notification payload.
|
|
71
|
+
* @returns The canonical string suitable for HMAC verification.
|
|
72
|
+
*
|
|
73
|
+
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-verify-signature-of-message.html
|
|
74
|
+
*/
|
|
75
|
+
export declare const buildSnsCanonicalString: (payload: {
|
|
76
|
+
Type?: string;
|
|
77
|
+
Message?: string;
|
|
78
|
+
MessageId?: string;
|
|
79
|
+
Subject?: string;
|
|
80
|
+
SubscribeURL?: string;
|
|
81
|
+
Timestamp?: string;
|
|
82
|
+
Token?: string;
|
|
83
|
+
TopicArn?: string;
|
|
84
|
+
}) => string;
|
|
85
|
+
/**
|
|
86
|
+
* Splits a `References:` header (whitespace-separated `<message-id>`
|
|
87
|
+
* tokens) into individual values, preserving the angle brackets.
|
|
88
|
+
*
|
|
89
|
+
* @param value - The raw header value.
|
|
90
|
+
* @returns Array of message-id tokens (with angle brackets) or empty.
|
|
91
|
+
*/
|
|
92
|
+
export declare const splitReferences: (value: string | undefined) => string[];
|
|
93
|
+
/**
|
|
94
|
+
* Strips surrounding angle brackets from a `Message-ID` value.
|
|
95
|
+
*
|
|
96
|
+
* @param value - The raw value (with or without angle brackets).
|
|
97
|
+
* @returns The value without angle brackets, or `undefined` if input was empty.
|
|
98
|
+
*/
|
|
99
|
+
export declare const unwrapMessageId: (value: string | undefined) => string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Decodes a base64 string into a Node `Buffer`.
|
|
102
|
+
*
|
|
103
|
+
* @param value - The base64 string.
|
|
104
|
+
* @returns The decoded buffer.
|
|
105
|
+
*/
|
|
106
|
+
export declare const base64ToBuffer: (value: string) => Buffer;
|
|
107
|
+
/**
|
|
108
|
+
* Parses a raw RFC 822 MIME message into a normalized {@link InboundEmail}.
|
|
109
|
+
*
|
|
110
|
+
* Used internally by `parseWebhookPayload` after the SES `content` field
|
|
111
|
+
* has been base64-decoded. Exposed so that applications using SES's
|
|
112
|
+
* S3-only delivery mode can reuse the same parser by fetching the S3
|
|
113
|
+
* object themselves and calling this helper.
|
|
114
|
+
*
|
|
115
|
+
* @param raw - The raw RFC 822 message bytes.
|
|
116
|
+
* @param overrides - Optional fields to override on the parsed result
|
|
117
|
+
* (e.g. an SES-assigned `id` or `receivedAt` timestamp).
|
|
118
|
+
* @returns The normalized inbound email.
|
|
119
|
+
*/
|
|
120
|
+
export declare const parseRawMimeContent: (raw: Buffer | string, overrides?: Partial<InboundEmail>) => Promise<InboundEmail>;
|
|
121
|
+
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKpC,OAAO,cAAc,CAAA;AAGrB,OAAO,KAAK,EAAE,YAAY,EAA0B,MAAM,8BAA8B,CAAA;AAIxF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,KAAG,MAAM,GAAG,SAG9E,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GACpB,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,EACtD,MAAM,MAAM,KACX,MAAM,GAAG,SAQX,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY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+
*
|
|
4
|
+
* Kept out of `provider.ts` so the parsing helpers can be unit-tested in
|
|
5
|
+
* isolation without touching the bond singleton.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { Buffer } from 'node:buffer';
|
|
10
|
+
// Side-effect import: registers this bond's secret definitions so the
|
|
11
|
+
// runtime registry is populated even when utilities.js is imported directly
|
|
12
|
+
// (not through the package barrel).
|
|
13
|
+
import './secrets.js';
|
|
14
|
+
import { simpleParser } from 'mailparser';
|
|
15
|
+
import { SNS_SIGNING_CERT_HOSTNAME_SUFFIXES } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Coerces an HTTP header value (which may be `string`, `string[]`, or
|
|
18
|
+
* `undefined`) to a single string. Multi-value headers are joined with
|
|
19
|
+
* `, ` per RFC 9110 §5.2.
|
|
20
|
+
*
|
|
21
|
+
* @param value - The header value to coerce.
|
|
22
|
+
* @returns The header value as a single string, or `undefined` when the
|
|
23
|
+
* header was not present.
|
|
24
|
+
*/
|
|
25
|
+
export const headerToString = (value) => {
|
|
26
|
+
if (value === undefined)
|
|
27
|
+
return undefined;
|
|
28
|
+
return Array.isArray(value) ? value.join(', ') : value;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Returns the value of `headers[name]` (case-insensitive) coerced to a
|
|
32
|
+
* single string.
|
|
33
|
+
*
|
|
34
|
+
* @param headers - The headers object.
|
|
35
|
+
* @param name - The header name (case-insensitive).
|
|
36
|
+
* @returns The header value as a single string, or `undefined` if absent.
|
|
37
|
+
*/
|
|
38
|
+
export const getHeader = (headers, name) => {
|
|
39
|
+
const target = name.toLowerCase();
|
|
40
|
+
for (const key of Object.keys(headers)) {
|
|
41
|
+
if (key.toLowerCase() === target) {
|
|
42
|
+
return headerToString(headers[key]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Coerces the request body into a UTF-8 string. SNS POSTs JSON as UTF-8.
|
|
49
|
+
*
|
|
50
|
+
* @param body - The raw body.
|
|
51
|
+
* @returns The body as a UTF-8 string.
|
|
52
|
+
*/
|
|
53
|
+
export const bodyToString = (body) => {
|
|
54
|
+
return Buffer.isBuffer(body) ? body.toString('utf8') : body;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Parses a Buffer/string/object body as an SNS JSON payload. Throws
|
|
58
|
+
* (caught by the caller) when the body is not valid JSON.
|
|
59
|
+
*
|
|
60
|
+
* @param body - The raw body.
|
|
61
|
+
* @returns The parsed object.
|
|
62
|
+
*/
|
|
63
|
+
export const parseJsonBody = (body) => {
|
|
64
|
+
if (typeof body === 'string' || Buffer.isBuffer(body)) {
|
|
65
|
+
return JSON.parse(bodyToString(body));
|
|
66
|
+
}
|
|
67
|
+
return body;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Returns the configured allowlist of hostname suffixes for the SNS
|
|
71
|
+
* `SigningCertURL`. Defaults to {@link SNS_SIGNING_CERT_HOSTNAME_SUFFIXES}
|
|
72
|
+
* when the env override is unset.
|
|
73
|
+
*
|
|
74
|
+
* @returns The allowlist of hostname suffixes.
|
|
75
|
+
*/
|
|
76
|
+
export const getSigningCertHostnameSuffixes = () => {
|
|
77
|
+
const raw = process.env.AWS_SNS_SIGNING_CERT_HOSTNAME_SUFFIXES;
|
|
78
|
+
if (!raw)
|
|
79
|
+
return SNS_SIGNING_CERT_HOSTNAME_SUFFIXES;
|
|
80
|
+
const parts = raw
|
|
81
|
+
.split(',')
|
|
82
|
+
.map((part) => part.trim())
|
|
83
|
+
.filter((part) => part.length > 0);
|
|
84
|
+
return parts.length > 0 ? parts : SNS_SIGNING_CERT_HOSTNAME_SUFFIXES;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Validates that an SNS `SigningCertURL` is HTTPS and its hostname matches
|
|
88
|
+
* an entry in the allowlist. Defends against SSRF and certificate
|
|
89
|
+
* substitution attacks where an attacker tricks the verifier into fetching
|
|
90
|
+
* a cert from a host they control.
|
|
91
|
+
*
|
|
92
|
+
* @param url - The candidate URL string.
|
|
93
|
+
* @returns `true` when the URL is acceptable.
|
|
94
|
+
*/
|
|
95
|
+
export const isAllowedSigningCertUrl = (url) => {
|
|
96
|
+
let parsed;
|
|
97
|
+
try {
|
|
98
|
+
parsed = new URL(url);
|
|
99
|
+
}
|
|
100
|
+
catch (_error) {
|
|
101
|
+
// URL constructor throws on malformed input — a parse failure IS the
|
|
102
|
+
// validation signal; returning false is the correct, safe response.
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (parsed.protocol !== 'https:')
|
|
106
|
+
return false;
|
|
107
|
+
const host = parsed.hostname.toLowerCase();
|
|
108
|
+
for (const suffix of getSigningCertHostnameSuffixes()) {
|
|
109
|
+
const normalized = suffix.startsWith('.') ? suffix : `.${suffix}`;
|
|
110
|
+
if (host === normalized.slice(1) || host.endsWith(normalized)) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Builds the canonical string SNS signs for the supplied notification.
|
|
118
|
+
* The exact field order is mandated by the SNS message-and-signature
|
|
119
|
+
* format; the canonical string is built from key/value pairs separated by
|
|
120
|
+
* `\n`, with a trailing `\n` after the last value.
|
|
121
|
+
*
|
|
122
|
+
* @param payload - The SNS notification payload.
|
|
123
|
+
* @returns The canonical string suitable for HMAC verification.
|
|
124
|
+
*
|
|
125
|
+
* @see https://docs.aws.amazon.com/sns/latest/dg/sns-verify-signature-of-message.html
|
|
126
|
+
*/
|
|
127
|
+
export const buildSnsCanonicalString = (payload) => {
|
|
128
|
+
const orderedKeys = payload.Type === 'SubscriptionConfirmation' || payload.Type === 'UnsubscribeConfirmation'
|
|
129
|
+
? [
|
|
130
|
+
'Message',
|
|
131
|
+
'MessageId',
|
|
132
|
+
'SubscribeURL',
|
|
133
|
+
'Timestamp',
|
|
134
|
+
'Token',
|
|
135
|
+
'TopicArn',
|
|
136
|
+
'Type',
|
|
137
|
+
]
|
|
138
|
+
: ['Message', 'MessageId', 'Subject', 'Timestamp', 'TopicArn', 'Type'];
|
|
139
|
+
const parts = [];
|
|
140
|
+
for (const key of orderedKeys) {
|
|
141
|
+
const value = payload[key];
|
|
142
|
+
if (value === undefined)
|
|
143
|
+
continue;
|
|
144
|
+
parts.push(key);
|
|
145
|
+
parts.push(value);
|
|
146
|
+
}
|
|
147
|
+
return `${parts.join('\n')}\n`;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Splits a `References:` header (whitespace-separated `<message-id>`
|
|
151
|
+
* tokens) into individual values, preserving the angle brackets.
|
|
152
|
+
*
|
|
153
|
+
* @param value - The raw header value.
|
|
154
|
+
* @returns Array of message-id tokens (with angle brackets) or empty.
|
|
155
|
+
*/
|
|
156
|
+
export const splitReferences = (value) => {
|
|
157
|
+
if (!value)
|
|
158
|
+
return [];
|
|
159
|
+
return value
|
|
160
|
+
.split(/\s+/u)
|
|
161
|
+
.map((token) => token.trim())
|
|
162
|
+
.filter((token) => token.length > 0);
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Strips surrounding angle brackets from a `Message-ID` value.
|
|
166
|
+
*
|
|
167
|
+
* @param value - The raw value (with or without angle brackets).
|
|
168
|
+
* @returns The value without angle brackets, or `undefined` if input was empty.
|
|
169
|
+
*/
|
|
170
|
+
export const unwrapMessageId = (value) => {
|
|
171
|
+
if (!value)
|
|
172
|
+
return undefined;
|
|
173
|
+
const trimmed = value.trim();
|
|
174
|
+
if (trimmed.length === 0)
|
|
175
|
+
return undefined;
|
|
176
|
+
return trimmed.replace(/^<|>$/gu, '');
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Decodes a base64 string into a Node `Buffer`.
|
|
180
|
+
*
|
|
181
|
+
* @param value - The base64 string.
|
|
182
|
+
* @returns The decoded buffer.
|
|
183
|
+
*/
|
|
184
|
+
export const base64ToBuffer = (value) => Buffer.from(value, 'base64');
|
|
185
|
+
/**
|
|
186
|
+
* Parses a raw RFC 822 MIME message into a normalized {@link InboundEmail}.
|
|
187
|
+
*
|
|
188
|
+
* Used internally by `parseWebhookPayload` after the SES `content` field
|
|
189
|
+
* has been base64-decoded. Exposed so that applications using SES's
|
|
190
|
+
* S3-only delivery mode can reuse the same parser by fetching the S3
|
|
191
|
+
* object themselves and calling this helper.
|
|
192
|
+
*
|
|
193
|
+
* @param raw - The raw RFC 822 message bytes.
|
|
194
|
+
* @param overrides - Optional fields to override on the parsed result
|
|
195
|
+
* (e.g. an SES-assigned `id` or `receivedAt` timestamp).
|
|
196
|
+
* @returns The normalized inbound email.
|
|
197
|
+
*/
|
|
198
|
+
export const parseRawMimeContent = async (raw, overrides = {}) => {
|
|
199
|
+
const buffer = typeof raw === 'string' ? Buffer.from(raw, 'utf8') : raw;
|
|
200
|
+
const parsed = await simpleParser(buffer);
|
|
201
|
+
const fromText = parsed.from && typeof parsed.from === 'object' && 'text' in parsed.from
|
|
202
|
+
? (parsed.from.text ?? '')
|
|
203
|
+
: '';
|
|
204
|
+
const toAddresses = (() => {
|
|
205
|
+
const t = parsed.to;
|
|
206
|
+
if (!t)
|
|
207
|
+
return [];
|
|
208
|
+
const list = Array.isArray(t) ? t : [t];
|
|
209
|
+
const out = [];
|
|
210
|
+
for (const entry of list) {
|
|
211
|
+
if (entry && typeof entry === 'object' && 'value' in entry) {
|
|
212
|
+
for (const v of entry.value) {
|
|
213
|
+
if (v.address)
|
|
214
|
+
out.push(v.address);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
})();
|
|
220
|
+
const ccAddresses = (() => {
|
|
221
|
+
const c = parsed.cc;
|
|
222
|
+
if (!c)
|
|
223
|
+
return [];
|
|
224
|
+
const list = Array.isArray(c) ? c : [c];
|
|
225
|
+
const out = [];
|
|
226
|
+
for (const entry of list) {
|
|
227
|
+
if (entry && typeof entry === 'object' && 'value' in entry) {
|
|
228
|
+
for (const v of entry.value) {
|
|
229
|
+
if (v.address)
|
|
230
|
+
out.push(v.address);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return out;
|
|
235
|
+
})();
|
|
236
|
+
const headers = {};
|
|
237
|
+
if (parsed.headers) {
|
|
238
|
+
for (const [name, value] of parsed.headers.entries()) {
|
|
239
|
+
const lower = name.toLowerCase();
|
|
240
|
+
if (typeof value === 'string') {
|
|
241
|
+
headers[lower] = value;
|
|
242
|
+
}
|
|
243
|
+
else if (Array.isArray(value)) {
|
|
244
|
+
const strings = value.filter((v) => typeof v === 'string');
|
|
245
|
+
if (strings.length > 0)
|
|
246
|
+
headers[lower] = strings.length === 1 ? strings[0] : strings;
|
|
247
|
+
}
|
|
248
|
+
else if (value && typeof value === 'object') {
|
|
249
|
+
// mailparser returns parsed objects for some headers (Date, addresses);
|
|
250
|
+
// we serialize their `text` form when present, else JSON.
|
|
251
|
+
const obj = value;
|
|
252
|
+
if (typeof obj.text === 'string')
|
|
253
|
+
headers[lower] = obj.text;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const attachments = [];
|
|
258
|
+
if (Array.isArray(parsed.attachments)) {
|
|
259
|
+
for (const att of parsed.attachments) {
|
|
260
|
+
const name = typeof att.filename === 'string' && att.filename.length > 0 ? att.filename : 'attachment';
|
|
261
|
+
const contentType = typeof att.contentType === 'string' && att.contentType.length > 0
|
|
262
|
+
? att.contentType
|
|
263
|
+
: 'application/octet-stream';
|
|
264
|
+
const content = att.content;
|
|
265
|
+
const contentBase64 = Buffer.isBuffer(content)
|
|
266
|
+
? content.toString('base64')
|
|
267
|
+
: typeof content === 'string'
|
|
268
|
+
? Buffer.from(content, 'utf8').toString('base64')
|
|
269
|
+
: '';
|
|
270
|
+
const entry = {
|
|
271
|
+
name,
|
|
272
|
+
contentType,
|
|
273
|
+
contentBase64,
|
|
274
|
+
};
|
|
275
|
+
if (typeof att.size === 'number')
|
|
276
|
+
entry.sizeBytes = att.size;
|
|
277
|
+
const cid = att.cid ??
|
|
278
|
+
att.contentId;
|
|
279
|
+
if (typeof cid === 'string' && cid.length > 0)
|
|
280
|
+
entry.contentId = cid;
|
|
281
|
+
attachments.push(entry);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const messageId = unwrapMessageId(typeof parsed.messageId === 'string' ? parsed.messageId : undefined);
|
|
285
|
+
const inReplyTo = unwrapMessageId(typeof parsed.inReplyTo === 'string' ? parsed.inReplyTo : undefined);
|
|
286
|
+
const references = (() => {
|
|
287
|
+
const r = parsed.references;
|
|
288
|
+
if (!r)
|
|
289
|
+
return [];
|
|
290
|
+
const list = Array.isArray(r) ? r : [r];
|
|
291
|
+
return list
|
|
292
|
+
.filter((v) => typeof v === 'string')
|
|
293
|
+
.map((v) => unwrapMessageId(v) ?? v);
|
|
294
|
+
})();
|
|
295
|
+
const date = parsed.date instanceof Date
|
|
296
|
+
? parsed.date
|
|
297
|
+
: parsed.date
|
|
298
|
+
? new Date(String(parsed.date))
|
|
299
|
+
: new Date();
|
|
300
|
+
const email = {
|
|
301
|
+
id: messageId ?? `ses-${String(Date.now())}`,
|
|
302
|
+
from: fromText,
|
|
303
|
+
to: toAddresses,
|
|
304
|
+
subject: typeof parsed.subject === 'string' ? parsed.subject : '',
|
|
305
|
+
headers,
|
|
306
|
+
receivedAt: date,
|
|
307
|
+
};
|
|
308
|
+
if (ccAddresses.length > 0)
|
|
309
|
+
email.cc = ccAddresses;
|
|
310
|
+
if (typeof parsed.text === 'string')
|
|
311
|
+
email.textBody = parsed.text;
|
|
312
|
+
if (typeof parsed.html === 'string')
|
|
313
|
+
email.htmlBody = parsed.html;
|
|
314
|
+
if (attachments.length > 0)
|
|
315
|
+
email.attachments = attachments;
|
|
316
|
+
if (messageId)
|
|
317
|
+
email.messageId = messageId;
|
|
318
|
+
if (inReplyTo)
|
|
319
|
+
email.inReplyTo = inReplyTo;
|
|
320
|
+
if (references.length > 0)
|
|
321
|
+
email.references = references;
|
|
322
|
+
return { ...email, ...overrides };
|
|
323
|
+
};
|
|
324
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,sEAAsE;AACtE,4EAA4E;AAC5E,oCAAoC;AACpC,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAIzC,OAAO,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAA;AAE/D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAoC,EAAsB,EAAE;IACzF,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AACxD,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,OAAsD,EACtD,IAAY,EACQ,EAAE;IACtB,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IACjC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACvC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;YACjC,OAAO,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAqB,EAAU,EAA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,GAAiB;QAC1B,EAAE,EAAE,SAAS,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE;QAC5C,IAAI,EAAE,QAAQ;QACd,EAAE,EAAE,WAAW;QACf,OAAO,EAAE,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACjE,OAAO;QACP,UAAU,EAAE,IAAI;KACjB,CAAA;IAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,EAAE,GAAG,WAAW,CAAA;IAClD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;QAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;IACjE,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;QAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAA;IACjE,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,WAAW,GAAG,WAAW,CAAA;IAC3D,IAAI,SAAS;QAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAA;IAC1C,IAAI,SAAS;QAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAA;IAC1C,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,UAAU,GAAG,UAAU,CAAA;IAExD,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,SAAS,EAAE,CAAA;AACnC,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@molecule/api-emails-inbound-ses",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "AWS SES inbound email provider — parses SNS notification payloads carrying SES inbound messages into normalized InboundEmail.",
|
|
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
|
+
"emails",
|
|
25
|
+
"inbound",
|
|
26
|
+
"ses",
|
|
27
|
+
"aws",
|
|
28
|
+
"sns",
|
|
29
|
+
"webhook"
|
|
30
|
+
],
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"mailparser": "3.9.14"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@molecule/api-emails": "1.0.0",
|
|
37
|
+
"@molecule/api-emails-inbound": "1.0.0",
|
|
38
|
+
"@types/mailparser": "3.4.6",
|
|
39
|
+
"@types/node": "26.1.2",
|
|
40
|
+
"typescript": "6.0.3",
|
|
41
|
+
"vitest": "4.1.10"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@molecule/api-emails": "^1.0.0",
|
|
45
|
+
"@molecule/api-emails-inbound": "^1.0.0",
|
|
46
|
+
"@molecule/api-secrets": "^1.0.0"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
51
|
+
"directory": "packages/api/bonds/emails-inbound/ses"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/molecule-dev/molecule/tree/main/packages/api/bonds/emails-inbound/ses",
|
|
54
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
}
|
|
58
|
+
}
|