@stacksjs/ts-cloud 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aws/s3.d.ts +1 -1
- package/dist/bin/cli.js +223 -222
- package/dist/index.js +132 -132
- package/package.json +18 -16
- package/src/aws/acm.ts +768 -0
- package/src/aws/application-autoscaling.ts +845 -0
- package/src/aws/bedrock.ts +4074 -0
- package/src/aws/client.ts +891 -0
- package/src/aws/cloudformation.ts +896 -0
- package/src/aws/cloudfront.ts +1531 -0
- package/src/aws/cloudwatch-logs.ts +154 -0
- package/src/aws/comprehend.ts +839 -0
- package/src/aws/connect.ts +1056 -0
- package/src/aws/deploy-imap.ts +384 -0
- package/src/aws/dynamodb.ts +340 -0
- package/src/aws/ec2.ts +1385 -0
- package/src/aws/ecr.ts +621 -0
- package/src/aws/ecs.ts +615 -0
- package/src/aws/elasticache.ts +301 -0
- package/src/aws/elbv2.ts +942 -0
- package/src/aws/email.ts +928 -0
- package/src/aws/eventbridge.ts +248 -0
- package/src/aws/iam.ts +1689 -0
- package/src/aws/imap-server.ts +2100 -0
- package/src/aws/index.ts +213 -0
- package/src/aws/kendra.ts +1097 -0
- package/src/aws/lambda.ts +786 -0
- package/src/aws/opensearch.ts +158 -0
- package/src/aws/personalize.ts +977 -0
- package/src/aws/polly.ts +559 -0
- package/src/aws/rds.ts +888 -0
- package/src/aws/rekognition.ts +846 -0
- package/src/aws/route53-domains.ts +359 -0
- package/src/aws/route53.ts +1046 -0
- package/src/aws/s3.ts +2334 -0
- package/src/aws/scheduler.ts +571 -0
- package/src/aws/secrets-manager.ts +769 -0
- package/src/aws/ses.ts +1081 -0
- package/src/aws/setup-phone.ts +104 -0
- package/src/aws/setup-sms.ts +580 -0
- package/src/aws/sms.ts +1735 -0
- package/src/aws/smtp-server.ts +531 -0
- package/src/aws/sns.ts +758 -0
- package/src/aws/sqs.ts +382 -0
- package/src/aws/ssm.ts +807 -0
- package/src/aws/sts.ts +92 -0
- package/src/aws/support.ts +391 -0
- package/src/aws/test-imap.ts +86 -0
- package/src/aws/textract.ts +780 -0
- package/src/aws/transcribe.ts +108 -0
- package/src/aws/translate.ts +641 -0
- package/src/aws/voice.ts +1379 -0
- package/src/config.ts +35 -0
- package/src/deploy/index.ts +7 -0
- package/src/deploy/static-site-external-dns.ts +945 -0
- package/src/deploy/static-site.ts +1175 -0
- package/src/dns/cloudflare.ts +548 -0
- package/src/dns/godaddy.ts +412 -0
- package/src/dns/index.ts +205 -0
- package/src/dns/porkbun.ts +362 -0
- package/src/dns/route53-adapter.ts +414 -0
- package/src/dns/types.ts +119 -0
- package/src/dns/validator.ts +369 -0
- package/src/generators/index.ts +5 -0
- package/src/generators/infrastructure.ts +1660 -0
- package/src/index.ts +163 -0
- package/src/push/apns.ts +452 -0
- package/src/push/fcm.ts +506 -0
- package/src/push/index.ts +58 -0
- package/src/security/pre-deploy-scanner.ts +655 -0
- package/src/ssl/acme-client.ts +478 -0
- package/src/ssl/index.ts +7 -0
- package/src/ssl/letsencrypt.ts +747 -0
- package/src/types.ts +2 -0
- package/src/utils/cli.ts +398 -0
- package/src/validation/index.ts +5 -0
- package/src/validation/template.ts +405 -0
package/src/aws/ses.ts
ADDED
|
@@ -0,0 +1,1081 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS SES (Simple Email Service) Operations
|
|
3
|
+
* Direct API calls without AWS SDK dependency
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AWSClient } from './client'
|
|
7
|
+
|
|
8
|
+
export interface EmailIdentity {
|
|
9
|
+
IdentityType?: 'EMAIL_ADDRESS' | 'DOMAIN' | 'MANAGED_DOMAIN'
|
|
10
|
+
IdentityName?: string
|
|
11
|
+
SendingEnabled?: boolean
|
|
12
|
+
VerificationStatus?: 'PENDING' | 'SUCCESS' | 'FAILED' | 'TEMPORARY_FAILURE' | 'NOT_STARTED'
|
|
13
|
+
DkimAttributes?: {
|
|
14
|
+
SigningEnabled?: boolean
|
|
15
|
+
Status?: 'PENDING' | 'SUCCESS' | 'FAILED' | 'TEMPORARY_FAILURE' | 'NOT_STARTED'
|
|
16
|
+
Tokens?: string[]
|
|
17
|
+
SigningAttributesOrigin?: 'AWS_SES' | 'EXTERNAL'
|
|
18
|
+
}
|
|
19
|
+
MailFromAttributes?: {
|
|
20
|
+
MailFromDomain?: string
|
|
21
|
+
MailFromDomainStatus?: 'PENDING' | 'SUCCESS' | 'FAILED' | 'TEMPORARY_FAILURE'
|
|
22
|
+
BehaviorOnMxFailure?: 'USE_DEFAULT_VALUE' | 'REJECT_MESSAGE'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SendEmailResult {
|
|
27
|
+
MessageId?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* SES email service management using direct API calls
|
|
32
|
+
*/
|
|
33
|
+
export class SESClient {
|
|
34
|
+
private client: AWSClient
|
|
35
|
+
private region: string
|
|
36
|
+
|
|
37
|
+
constructor(region: string = 'us-east-1') {
|
|
38
|
+
this.region = region
|
|
39
|
+
this.client = new AWSClient()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create email identity (domain or email address)
|
|
44
|
+
* Uses SES v2 API
|
|
45
|
+
*/
|
|
46
|
+
async createEmailIdentity(params: {
|
|
47
|
+
EmailIdentity: string
|
|
48
|
+
DkimSigningAttributes?: {
|
|
49
|
+
DomainSigningSelector?: string
|
|
50
|
+
DomainSigningPrivateKey?: string
|
|
51
|
+
}
|
|
52
|
+
Tags?: Array<{ Key: string, Value: string }>
|
|
53
|
+
}): Promise<{
|
|
54
|
+
IdentityType?: string
|
|
55
|
+
VerifiedForSendingStatus?: boolean
|
|
56
|
+
DkimAttributes?: {
|
|
57
|
+
SigningEnabled?: boolean
|
|
58
|
+
Status?: string
|
|
59
|
+
Tokens?: string[]
|
|
60
|
+
SigningAttributesOrigin?: string
|
|
61
|
+
}
|
|
62
|
+
}> {
|
|
63
|
+
const result = await this.client.request({
|
|
64
|
+
service: 'email',
|
|
65
|
+
region: this.region,
|
|
66
|
+
method: 'POST',
|
|
67
|
+
path: '/v2/email/identities',
|
|
68
|
+
headers: {
|
|
69
|
+
'Content-Type': 'application/json',
|
|
70
|
+
},
|
|
71
|
+
body: JSON.stringify(params),
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
return result
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get email identity details
|
|
79
|
+
*/
|
|
80
|
+
async getEmailIdentity(emailIdentity: string): Promise<EmailIdentity> {
|
|
81
|
+
const result = await this.client.request({
|
|
82
|
+
service: 'email',
|
|
83
|
+
region: this.region,
|
|
84
|
+
method: 'GET',
|
|
85
|
+
path: `/v2/email/identities/${encodeURIComponent(emailIdentity)}`,
|
|
86
|
+
headers: {
|
|
87
|
+
'Content-Type': 'application/json',
|
|
88
|
+
},
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
IdentityType: result.IdentityType,
|
|
93
|
+
IdentityName: emailIdentity,
|
|
94
|
+
SendingEnabled: result.VerifiedForSendingStatus,
|
|
95
|
+
VerificationStatus: result.VerificationStatus,
|
|
96
|
+
DkimAttributes: result.DkimAttributes,
|
|
97
|
+
MailFromAttributes: result.MailFromAttributes,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Configure MAIL FROM domain for an email identity
|
|
103
|
+
*/
|
|
104
|
+
async putEmailIdentityMailFromAttributes(emailIdentity: string, params: {
|
|
105
|
+
MailFromDomain?: string
|
|
106
|
+
BehaviorOnMxFailure?: 'USE_DEFAULT_VALUE' | 'REJECT_MESSAGE'
|
|
107
|
+
}): Promise<void> {
|
|
108
|
+
await this.client.request({
|
|
109
|
+
service: 'email',
|
|
110
|
+
region: this.region,
|
|
111
|
+
method: 'PUT',
|
|
112
|
+
path: `/v2/email/identities/${encodeURIComponent(emailIdentity)}/mail-from`,
|
|
113
|
+
headers: {
|
|
114
|
+
'Content-Type': 'application/json',
|
|
115
|
+
},
|
|
116
|
+
body: JSON.stringify(params),
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* List email identities
|
|
122
|
+
*/
|
|
123
|
+
async listEmailIdentities(params?: {
|
|
124
|
+
PageSize?: number
|
|
125
|
+
NextToken?: string
|
|
126
|
+
}): Promise<{
|
|
127
|
+
EmailIdentities?: Array<{
|
|
128
|
+
IdentityType?: string
|
|
129
|
+
IdentityName?: string
|
|
130
|
+
SendingEnabled?: boolean
|
|
131
|
+
}>
|
|
132
|
+
NextToken?: string
|
|
133
|
+
}> {
|
|
134
|
+
let path = '/v2/email/identities'
|
|
135
|
+
const queryParams: string[] = []
|
|
136
|
+
|
|
137
|
+
if (params?.PageSize) {
|
|
138
|
+
queryParams.push(`PageSize=${params.PageSize}`)
|
|
139
|
+
}
|
|
140
|
+
if (params?.NextToken) {
|
|
141
|
+
queryParams.push(`NextToken=${encodeURIComponent(params.NextToken)}`)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (queryParams.length > 0) {
|
|
145
|
+
path += `?${queryParams.join('&')}`
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const result = await this.client.request({
|
|
149
|
+
service: 'email',
|
|
150
|
+
region: this.region,
|
|
151
|
+
method: 'GET',
|
|
152
|
+
path,
|
|
153
|
+
headers: {
|
|
154
|
+
'Content-Type': 'application/json',
|
|
155
|
+
},
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
EmailIdentities: result.EmailIdentities,
|
|
160
|
+
NextToken: result.NextToken,
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Delete email identity
|
|
166
|
+
*/
|
|
167
|
+
async deleteEmailIdentity(emailIdentity: string): Promise<void> {
|
|
168
|
+
await this.client.request({
|
|
169
|
+
service: 'email',
|
|
170
|
+
region: this.region,
|
|
171
|
+
method: 'DELETE',
|
|
172
|
+
path: `/v2/email/identities/${encodeURIComponent(emailIdentity)}`,
|
|
173
|
+
headers: {
|
|
174
|
+
'Content-Type': 'application/json',
|
|
175
|
+
},
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Enable/disable DKIM signing for identity
|
|
181
|
+
*/
|
|
182
|
+
async putEmailIdentityDkimAttributes(params: {
|
|
183
|
+
EmailIdentity: string
|
|
184
|
+
SigningEnabled: boolean
|
|
185
|
+
}): Promise<void> {
|
|
186
|
+
await this.client.request({
|
|
187
|
+
service: 'email',
|
|
188
|
+
region: this.region,
|
|
189
|
+
method: 'PUT',
|
|
190
|
+
path: `/v2/email/identities/${encodeURIComponent(params.EmailIdentity)}/dkim`,
|
|
191
|
+
headers: {
|
|
192
|
+
'Content-Type': 'application/json',
|
|
193
|
+
},
|
|
194
|
+
body: JSON.stringify({ SigningEnabled: params.SigningEnabled }),
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Send email
|
|
200
|
+
*/
|
|
201
|
+
async sendEmail(params: {
|
|
202
|
+
FromEmailAddress: string
|
|
203
|
+
Destination: {
|
|
204
|
+
ToAddresses?: string[]
|
|
205
|
+
CcAddresses?: string[]
|
|
206
|
+
BccAddresses?: string[]
|
|
207
|
+
}
|
|
208
|
+
Content: {
|
|
209
|
+
Simple?: {
|
|
210
|
+
Subject: { Data: string, Charset?: string }
|
|
211
|
+
Body: {
|
|
212
|
+
Text?: { Data: string, Charset?: string }
|
|
213
|
+
Html?: { Data: string, Charset?: string }
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
Raw?: {
|
|
217
|
+
Data: string // Base64 encoded
|
|
218
|
+
}
|
|
219
|
+
Template?: {
|
|
220
|
+
TemplateName: string
|
|
221
|
+
TemplateData?: string
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
ReplyToAddresses?: string[]
|
|
225
|
+
ConfigurationSetName?: string
|
|
226
|
+
}): Promise<SendEmailResult> {
|
|
227
|
+
const result = await this.client.request({
|
|
228
|
+
service: 'email',
|
|
229
|
+
region: this.region,
|
|
230
|
+
method: 'POST',
|
|
231
|
+
path: '/v2/email/outbound-emails',
|
|
232
|
+
headers: {
|
|
233
|
+
'Content-Type': 'application/json',
|
|
234
|
+
},
|
|
235
|
+
body: JSON.stringify(params),
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
MessageId: result.MessageId,
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Send bulk email
|
|
245
|
+
*/
|
|
246
|
+
async sendBulkEmail(params: {
|
|
247
|
+
FromEmailAddress: string
|
|
248
|
+
BulkEmailEntries: Array<{
|
|
249
|
+
Destination: {
|
|
250
|
+
ToAddresses?: string[]
|
|
251
|
+
CcAddresses?: string[]
|
|
252
|
+
BccAddresses?: string[]
|
|
253
|
+
}
|
|
254
|
+
ReplacementEmailContent?: {
|
|
255
|
+
ReplacementTemplate?: {
|
|
256
|
+
ReplacementTemplateData?: string
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}>
|
|
260
|
+
DefaultContent: {
|
|
261
|
+
Template: {
|
|
262
|
+
TemplateName: string
|
|
263
|
+
TemplateData?: string
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
ConfigurationSetName?: string
|
|
267
|
+
}): Promise<{
|
|
268
|
+
BulkEmailEntryResults?: Array<{
|
|
269
|
+
Status?: string
|
|
270
|
+
Error?: string
|
|
271
|
+
MessageId?: string
|
|
272
|
+
}>
|
|
273
|
+
}> {
|
|
274
|
+
const result = await this.client.request({
|
|
275
|
+
service: 'email',
|
|
276
|
+
region: this.region,
|
|
277
|
+
method: 'POST',
|
|
278
|
+
path: '/v2/email/outbound-bulk-emails',
|
|
279
|
+
headers: {
|
|
280
|
+
'Content-Type': 'application/json',
|
|
281
|
+
},
|
|
282
|
+
body: JSON.stringify(params),
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
return {
|
|
286
|
+
BulkEmailEntryResults: result.BulkEmailEntryResults,
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Create email template
|
|
292
|
+
*/
|
|
293
|
+
async createEmailTemplate(params: {
|
|
294
|
+
TemplateName: string
|
|
295
|
+
TemplateContent: {
|
|
296
|
+
Subject?: string
|
|
297
|
+
Text?: string
|
|
298
|
+
Html?: string
|
|
299
|
+
}
|
|
300
|
+
}): Promise<void> {
|
|
301
|
+
await this.client.request({
|
|
302
|
+
service: 'email',
|
|
303
|
+
region: this.region,
|
|
304
|
+
method: 'POST',
|
|
305
|
+
path: '/v2/email/templates',
|
|
306
|
+
headers: {
|
|
307
|
+
'Content-Type': 'application/json',
|
|
308
|
+
},
|
|
309
|
+
body: JSON.stringify(params),
|
|
310
|
+
})
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Get email template
|
|
315
|
+
*/
|
|
316
|
+
async getEmailTemplate(templateName: string): Promise<{
|
|
317
|
+
TemplateName?: string
|
|
318
|
+
TemplateContent?: {
|
|
319
|
+
Subject?: string
|
|
320
|
+
Text?: string
|
|
321
|
+
Html?: string
|
|
322
|
+
}
|
|
323
|
+
}> {
|
|
324
|
+
const result = await this.client.request({
|
|
325
|
+
service: 'email',
|
|
326
|
+
region: this.region,
|
|
327
|
+
method: 'GET',
|
|
328
|
+
path: `/v2/email/templates/${encodeURIComponent(templateName)}`,
|
|
329
|
+
headers: {
|
|
330
|
+
'Content-Type': 'application/json',
|
|
331
|
+
},
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
return result
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Delete email template
|
|
339
|
+
*/
|
|
340
|
+
async deleteEmailTemplate(templateName: string): Promise<void> {
|
|
341
|
+
await this.client.request({
|
|
342
|
+
service: 'email',
|
|
343
|
+
region: this.region,
|
|
344
|
+
method: 'DELETE',
|
|
345
|
+
path: `/v2/email/templates/${encodeURIComponent(templateName)}`,
|
|
346
|
+
headers: {
|
|
347
|
+
'Content-Type': 'application/json',
|
|
348
|
+
},
|
|
349
|
+
})
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* List email templates
|
|
354
|
+
*/
|
|
355
|
+
async listEmailTemplates(params?: {
|
|
356
|
+
PageSize?: number
|
|
357
|
+
NextToken?: string
|
|
358
|
+
}): Promise<{
|
|
359
|
+
TemplatesMetadata?: Array<{
|
|
360
|
+
TemplateName?: string
|
|
361
|
+
CreatedTimestamp?: string
|
|
362
|
+
}>
|
|
363
|
+
NextToken?: string
|
|
364
|
+
}> {
|
|
365
|
+
let path = '/v2/email/templates'
|
|
366
|
+
const queryParams: string[] = []
|
|
367
|
+
|
|
368
|
+
if (params?.PageSize) {
|
|
369
|
+
queryParams.push(`PageSize=${params.PageSize}`)
|
|
370
|
+
}
|
|
371
|
+
if (params?.NextToken) {
|
|
372
|
+
queryParams.push(`NextToken=${encodeURIComponent(params.NextToken)}`)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (queryParams.length > 0) {
|
|
376
|
+
path += `?${queryParams.join('&')}`
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const result = await this.client.request({
|
|
380
|
+
service: 'email',
|
|
381
|
+
region: this.region,
|
|
382
|
+
method: 'GET',
|
|
383
|
+
path,
|
|
384
|
+
headers: {
|
|
385
|
+
'Content-Type': 'application/json',
|
|
386
|
+
},
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
return result
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Get sending statistics
|
|
394
|
+
*/
|
|
395
|
+
async getSendStatistics(): Promise<{
|
|
396
|
+
SendDataPoints?: Array<{
|
|
397
|
+
Timestamp?: string
|
|
398
|
+
DeliveryAttempts?: number
|
|
399
|
+
Bounces?: number
|
|
400
|
+
Complaints?: number
|
|
401
|
+
Rejects?: number
|
|
402
|
+
}>
|
|
403
|
+
}> {
|
|
404
|
+
// Use legacy v1 API for this
|
|
405
|
+
const result = await this.client.request({
|
|
406
|
+
service: 'ses',
|
|
407
|
+
region: this.region,
|
|
408
|
+
method: 'POST',
|
|
409
|
+
path: '/',
|
|
410
|
+
headers: {
|
|
411
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
412
|
+
},
|
|
413
|
+
body: 'Action=GetSendStatistics&Version=2010-12-01',
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
return {
|
|
417
|
+
SendDataPoints: result.GetSendStatisticsResponse?.GetSendStatisticsResult?.SendDataPoints?.member,
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Get sending quota
|
|
423
|
+
*/
|
|
424
|
+
async getSendQuota(): Promise<{
|
|
425
|
+
Max24HourSend?: number
|
|
426
|
+
MaxSendRate?: number
|
|
427
|
+
SentLast24Hours?: number
|
|
428
|
+
}> {
|
|
429
|
+
// Use legacy v1 API for this
|
|
430
|
+
const result = await this.client.request({
|
|
431
|
+
service: 'ses',
|
|
432
|
+
region: this.region,
|
|
433
|
+
method: 'POST',
|
|
434
|
+
path: '/',
|
|
435
|
+
headers: {
|
|
436
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
437
|
+
},
|
|
438
|
+
body: 'Action=GetSendQuota&Version=2010-12-01',
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
const quota = result.GetSendQuotaResponse?.GetSendQuotaResult
|
|
442
|
+
return {
|
|
443
|
+
Max24HourSend: quota?.Max24HourSend ? Number(quota.Max24HourSend) : undefined,
|
|
444
|
+
MaxSendRate: quota?.MaxSendRate ? Number(quota.MaxSendRate) : undefined,
|
|
445
|
+
SentLast24Hours: quota?.SentLast24Hours ? Number(quota.SentLast24Hours) : undefined,
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Helper methods
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Verify a domain identity
|
|
453
|
+
*/
|
|
454
|
+
async verifyDomain(domain: string): Promise<{
|
|
455
|
+
dkimTokens?: string[]
|
|
456
|
+
verificationStatus?: string
|
|
457
|
+
}> {
|
|
458
|
+
const result = await this.createEmailIdentity({
|
|
459
|
+
EmailIdentity: domain,
|
|
460
|
+
})
|
|
461
|
+
|
|
462
|
+
return {
|
|
463
|
+
dkimTokens: result.DkimAttributes?.Tokens,
|
|
464
|
+
verificationStatus: result.DkimAttributes?.Status,
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Send a simple text email
|
|
470
|
+
*/
|
|
471
|
+
async sendSimpleEmail(params: {
|
|
472
|
+
from: string
|
|
473
|
+
to: string | string[]
|
|
474
|
+
subject: string
|
|
475
|
+
text?: string
|
|
476
|
+
html?: string
|
|
477
|
+
replyTo?: string | string[]
|
|
478
|
+
}): Promise<SendEmailResult> {
|
|
479
|
+
const toAddresses = Array.isArray(params.to) ? params.to : [params.to]
|
|
480
|
+
const replyToAddresses = params.replyTo
|
|
481
|
+
? (Array.isArray(params.replyTo) ? params.replyTo : [params.replyTo])
|
|
482
|
+
: undefined
|
|
483
|
+
|
|
484
|
+
const body: any = {}
|
|
485
|
+
if (params.text) {
|
|
486
|
+
body.Text = { Data: params.text }
|
|
487
|
+
}
|
|
488
|
+
if (params.html) {
|
|
489
|
+
body.Html = { Data: params.html }
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
return this.sendEmail({
|
|
493
|
+
FromEmailAddress: params.from,
|
|
494
|
+
Destination: {
|
|
495
|
+
ToAddresses: toAddresses,
|
|
496
|
+
},
|
|
497
|
+
Content: {
|
|
498
|
+
Simple: {
|
|
499
|
+
Subject: { Data: params.subject },
|
|
500
|
+
Body: body,
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
ReplyToAddresses: replyToAddresses,
|
|
504
|
+
})
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Send a templated email
|
|
509
|
+
*/
|
|
510
|
+
async sendTemplatedEmail(params: {
|
|
511
|
+
from: string
|
|
512
|
+
to: string | string[]
|
|
513
|
+
templateName: string
|
|
514
|
+
templateData: Record<string, any>
|
|
515
|
+
replyTo?: string | string[]
|
|
516
|
+
}): Promise<SendEmailResult> {
|
|
517
|
+
const toAddresses = Array.isArray(params.to) ? params.to : [params.to]
|
|
518
|
+
const replyToAddresses = params.replyTo
|
|
519
|
+
? (Array.isArray(params.replyTo) ? params.replyTo : [params.replyTo])
|
|
520
|
+
: undefined
|
|
521
|
+
|
|
522
|
+
return this.sendEmail({
|
|
523
|
+
FromEmailAddress: params.from,
|
|
524
|
+
Destination: {
|
|
525
|
+
ToAddresses: toAddresses,
|
|
526
|
+
},
|
|
527
|
+
Content: {
|
|
528
|
+
Template: {
|
|
529
|
+
TemplateName: params.templateName,
|
|
530
|
+
TemplateData: JSON.stringify(params.templateData),
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
ReplyToAddresses: replyToAddresses,
|
|
534
|
+
})
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Get DKIM DNS records for a domain
|
|
539
|
+
*/
|
|
540
|
+
async getDkimRecords(domain: string): Promise<Array<{
|
|
541
|
+
name: string
|
|
542
|
+
type: string
|
|
543
|
+
value: string
|
|
544
|
+
}>> {
|
|
545
|
+
const identity = await this.getEmailIdentity(domain)
|
|
546
|
+
|
|
547
|
+
if (!identity.DkimAttributes?.Tokens) {
|
|
548
|
+
return []
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
return identity.DkimAttributes.Tokens.map(token => ({
|
|
552
|
+
name: `${token}._domainkey.${domain}`,
|
|
553
|
+
type: 'CNAME',
|
|
554
|
+
value: `${token}.dkim.amazonses.com`,
|
|
555
|
+
}))
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Check if domain is verified
|
|
560
|
+
*/
|
|
561
|
+
async isDomainVerified(domain: string): Promise<boolean> {
|
|
562
|
+
try {
|
|
563
|
+
const identity = await this.getEmailIdentity(domain)
|
|
564
|
+
return identity.VerificationStatus === 'SUCCESS' && identity.SendingEnabled === true
|
|
565
|
+
}
|
|
566
|
+
catch {
|
|
567
|
+
return false
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Wait for domain verification
|
|
573
|
+
*/
|
|
574
|
+
async waitForDomainVerification(
|
|
575
|
+
domain: string,
|
|
576
|
+
maxAttempts = 60,
|
|
577
|
+
delayMs = 30000,
|
|
578
|
+
): Promise<boolean> {
|
|
579
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
580
|
+
const isVerified = await this.isDomainVerified(domain)
|
|
581
|
+
|
|
582
|
+
if (isVerified) {
|
|
583
|
+
return true
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
await new Promise(resolve => setTimeout(resolve, delayMs))
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
return false
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// ============================================
|
|
593
|
+
// SES v1 API - Receipt Rules (for inbound email)
|
|
594
|
+
// Note: Receipt rules use the legacy SES v1 API
|
|
595
|
+
// ============================================
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Build form-encoded body for SES v1 API
|
|
599
|
+
*/
|
|
600
|
+
private buildFormBody(params: Record<string, string | undefined>): string {
|
|
601
|
+
const entries = Object.entries(params)
|
|
602
|
+
.filter(([, value]) => value !== undefined)
|
|
603
|
+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value!)}`)
|
|
604
|
+
return entries.join('&')
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Create a receipt rule set
|
|
609
|
+
* Uses SES v1 API
|
|
610
|
+
*/
|
|
611
|
+
async createReceiptRuleSet(ruleSetName: string): Promise<void> {
|
|
612
|
+
await this.client.request({
|
|
613
|
+
service: 'ses',
|
|
614
|
+
region: this.region,
|
|
615
|
+
method: 'POST',
|
|
616
|
+
path: '/',
|
|
617
|
+
headers: {
|
|
618
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
619
|
+
},
|
|
620
|
+
body: this.buildFormBody({
|
|
621
|
+
Action: 'CreateReceiptRuleSet',
|
|
622
|
+
Version: '2010-12-01',
|
|
623
|
+
RuleSetName: ruleSetName,
|
|
624
|
+
}),
|
|
625
|
+
})
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Delete a receipt rule set
|
|
630
|
+
*/
|
|
631
|
+
async deleteReceiptRuleSet(ruleSetName: string): Promise<void> {
|
|
632
|
+
await this.client.request({
|
|
633
|
+
service: 'ses',
|
|
634
|
+
region: this.region,
|
|
635
|
+
method: 'POST',
|
|
636
|
+
path: '/',
|
|
637
|
+
headers: {
|
|
638
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
639
|
+
},
|
|
640
|
+
body: this.buildFormBody({
|
|
641
|
+
Action: 'DeleteReceiptRuleSet',
|
|
642
|
+
Version: '2010-12-01',
|
|
643
|
+
RuleSetName: ruleSetName,
|
|
644
|
+
}),
|
|
645
|
+
})
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Set the active receipt rule set
|
|
650
|
+
*/
|
|
651
|
+
async setActiveReceiptRuleSet(ruleSetName: string): Promise<void> {
|
|
652
|
+
await this.client.request({
|
|
653
|
+
service: 'ses',
|
|
654
|
+
region: this.region,
|
|
655
|
+
method: 'POST',
|
|
656
|
+
path: '/',
|
|
657
|
+
headers: {
|
|
658
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
659
|
+
},
|
|
660
|
+
body: this.buildFormBody({
|
|
661
|
+
Action: 'SetActiveReceiptRuleSet',
|
|
662
|
+
Version: '2010-12-01',
|
|
663
|
+
RuleSetName: ruleSetName,
|
|
664
|
+
}),
|
|
665
|
+
})
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* List receipt rule sets
|
|
670
|
+
*/
|
|
671
|
+
async listReceiptRuleSets(nextToken?: string): Promise<{
|
|
672
|
+
RuleSets?: Array<{ Name?: string, CreatedTimestamp?: string }>
|
|
673
|
+
NextToken?: string
|
|
674
|
+
}> {
|
|
675
|
+
const formParams: Record<string, string | undefined> = {
|
|
676
|
+
Action: 'ListReceiptRuleSets',
|
|
677
|
+
Version: '2010-12-01',
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
if (nextToken) {
|
|
681
|
+
formParams.NextToken = nextToken
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const result = await this.client.request({
|
|
685
|
+
service: 'ses',
|
|
686
|
+
region: this.region,
|
|
687
|
+
method: 'POST',
|
|
688
|
+
path: '/',
|
|
689
|
+
headers: {
|
|
690
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
691
|
+
},
|
|
692
|
+
body: this.buildFormBody(formParams),
|
|
693
|
+
})
|
|
694
|
+
|
|
695
|
+
// Handle both response formats (with and without Response wrapper)
|
|
696
|
+
const ruleSetsResult = result?.ListReceiptRuleSetsResponse?.ListReceiptRuleSetsResult
|
|
697
|
+
|| result?.ListReceiptRuleSetsResult
|
|
698
|
+
const ruleSets = ruleSetsResult?.RuleSets?.member
|
|
699
|
+
return {
|
|
700
|
+
RuleSets: Array.isArray(ruleSets) ? ruleSets : ruleSets ? [ruleSets] : [],
|
|
701
|
+
NextToken: ruleSetsResult?.NextToken,
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Describe a receipt rule set
|
|
707
|
+
*/
|
|
708
|
+
async describeReceiptRuleSet(ruleSetName: string): Promise<{
|
|
709
|
+
Metadata?: { Name?: string, CreatedTimestamp?: string }
|
|
710
|
+
Rules?: Array<{
|
|
711
|
+
Name?: string
|
|
712
|
+
Enabled?: boolean
|
|
713
|
+
Recipients?: string[]
|
|
714
|
+
Actions?: Array<{
|
|
715
|
+
S3Action?: { BucketName?: string, ObjectKeyPrefix?: string }
|
|
716
|
+
LambdaAction?: { FunctionArn?: string, InvocationType?: string }
|
|
717
|
+
SNSAction?: { TopicArn?: string }
|
|
718
|
+
}>
|
|
719
|
+
}>
|
|
720
|
+
}> {
|
|
721
|
+
const result = await this.client.request({
|
|
722
|
+
service: 'ses',
|
|
723
|
+
region: this.region,
|
|
724
|
+
method: 'POST',
|
|
725
|
+
path: '/',
|
|
726
|
+
headers: {
|
|
727
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
728
|
+
},
|
|
729
|
+
body: this.buildFormBody({
|
|
730
|
+
Action: 'DescribeReceiptRuleSet',
|
|
731
|
+
Version: '2010-12-01',
|
|
732
|
+
RuleSetName: ruleSetName,
|
|
733
|
+
}),
|
|
734
|
+
})
|
|
735
|
+
|
|
736
|
+
// Handle both response formats (with and without Response wrapper)
|
|
737
|
+
const response = result?.DescribeReceiptRuleSetResponse?.DescribeReceiptRuleSetResult
|
|
738
|
+
|| result?.DescribeReceiptRuleSetResult
|
|
739
|
+
const rules = response?.Rules?.member
|
|
740
|
+
return {
|
|
741
|
+
Metadata: response?.Metadata,
|
|
742
|
+
Rules: Array.isArray(rules) ? rules : rules ? [rules] : [],
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Create a receipt rule
|
|
748
|
+
*/
|
|
749
|
+
async createReceiptRule(params: {
|
|
750
|
+
RuleSetName: string
|
|
751
|
+
Rule: {
|
|
752
|
+
Name: string
|
|
753
|
+
Enabled?: boolean
|
|
754
|
+
TlsPolicy?: 'Require' | 'Optional'
|
|
755
|
+
Recipients?: string[]
|
|
756
|
+
ScanEnabled?: boolean
|
|
757
|
+
Actions: Array<{
|
|
758
|
+
S3Action?: {
|
|
759
|
+
BucketName: string
|
|
760
|
+
ObjectKeyPrefix?: string
|
|
761
|
+
KmsKeyArn?: string
|
|
762
|
+
}
|
|
763
|
+
LambdaAction?: {
|
|
764
|
+
FunctionArn: string
|
|
765
|
+
InvocationType?: 'Event' | 'RequestResponse'
|
|
766
|
+
}
|
|
767
|
+
SNSAction?: {
|
|
768
|
+
TopicArn: string
|
|
769
|
+
Encoding?: 'UTF-8' | 'Base64'
|
|
770
|
+
}
|
|
771
|
+
StopAction?: {
|
|
772
|
+
Scope: 'RuleSet'
|
|
773
|
+
TopicArn?: string
|
|
774
|
+
}
|
|
775
|
+
}>
|
|
776
|
+
}
|
|
777
|
+
After?: string
|
|
778
|
+
}): Promise<void> {
|
|
779
|
+
const formParams: Record<string, string | undefined> = {
|
|
780
|
+
Action: 'CreateReceiptRule',
|
|
781
|
+
Version: '2010-12-01',
|
|
782
|
+
RuleSetName: params.RuleSetName,
|
|
783
|
+
'Rule.Name': params.Rule.Name,
|
|
784
|
+
'Rule.Enabled': params.Rule.Enabled !== false ? 'true' : 'false',
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
if (params.Rule.TlsPolicy) {
|
|
788
|
+
formParams['Rule.TlsPolicy'] = params.Rule.TlsPolicy
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if (params.Rule.ScanEnabled !== undefined) {
|
|
792
|
+
formParams['Rule.ScanEnabled'] = params.Rule.ScanEnabled ? 'true' : 'false'
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
if (params.After) {
|
|
796
|
+
formParams.After = params.After
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// Add recipients
|
|
800
|
+
if (params.Rule.Recipients) {
|
|
801
|
+
params.Rule.Recipients.forEach((recipient, index) => {
|
|
802
|
+
formParams[`Rule.Recipients.member.${index + 1}`] = recipient
|
|
803
|
+
})
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// Add actions
|
|
807
|
+
params.Rule.Actions.forEach((action, index) => {
|
|
808
|
+
const actionNum = index + 1
|
|
809
|
+
|
|
810
|
+
if (action.S3Action) {
|
|
811
|
+
formParams[`Rule.Actions.member.${actionNum}.S3Action.BucketName`] = action.S3Action.BucketName
|
|
812
|
+
if (action.S3Action.ObjectKeyPrefix) {
|
|
813
|
+
formParams[`Rule.Actions.member.${actionNum}.S3Action.ObjectKeyPrefix`] = action.S3Action.ObjectKeyPrefix
|
|
814
|
+
}
|
|
815
|
+
if (action.S3Action.KmsKeyArn) {
|
|
816
|
+
formParams[`Rule.Actions.member.${actionNum}.S3Action.KmsKeyArn`] = action.S3Action.KmsKeyArn
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
if (action.LambdaAction) {
|
|
821
|
+
formParams[`Rule.Actions.member.${actionNum}.LambdaAction.FunctionArn`] = action.LambdaAction.FunctionArn
|
|
822
|
+
formParams[`Rule.Actions.member.${actionNum}.LambdaAction.InvocationType`] = action.LambdaAction.InvocationType || 'Event'
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
if (action.SNSAction) {
|
|
826
|
+
formParams[`Rule.Actions.member.${actionNum}.SNSAction.TopicArn`] = action.SNSAction.TopicArn
|
|
827
|
+
if (action.SNSAction.Encoding) {
|
|
828
|
+
formParams[`Rule.Actions.member.${actionNum}.SNSAction.Encoding`] = action.SNSAction.Encoding
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
if (action.StopAction) {
|
|
833
|
+
formParams[`Rule.Actions.member.${actionNum}.StopAction.Scope`] = action.StopAction.Scope
|
|
834
|
+
if (action.StopAction.TopicArn) {
|
|
835
|
+
formParams[`Rule.Actions.member.${actionNum}.StopAction.TopicArn`] = action.StopAction.TopicArn
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
})
|
|
839
|
+
|
|
840
|
+
await this.client.request({
|
|
841
|
+
service: 'ses',
|
|
842
|
+
region: this.region,
|
|
843
|
+
method: 'POST',
|
|
844
|
+
path: '/',
|
|
845
|
+
headers: {
|
|
846
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
847
|
+
},
|
|
848
|
+
body: this.buildFormBody(formParams),
|
|
849
|
+
})
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* Delete a receipt rule
|
|
854
|
+
*/
|
|
855
|
+
async deleteReceiptRule(ruleSetName: string, ruleName: string): Promise<void> {
|
|
856
|
+
await this.client.request({
|
|
857
|
+
service: 'ses',
|
|
858
|
+
region: this.region,
|
|
859
|
+
method: 'POST',
|
|
860
|
+
path: '/',
|
|
861
|
+
headers: {
|
|
862
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
863
|
+
},
|
|
864
|
+
body: this.buildFormBody({
|
|
865
|
+
Action: 'DeleteReceiptRule',
|
|
866
|
+
Version: '2010-12-01',
|
|
867
|
+
RuleSetName: ruleSetName,
|
|
868
|
+
RuleName: ruleName,
|
|
869
|
+
}),
|
|
870
|
+
})
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* Check if receipt rule set exists
|
|
875
|
+
*/
|
|
876
|
+
async receiptRuleSetExists(ruleSetName: string): Promise<boolean> {
|
|
877
|
+
try {
|
|
878
|
+
await this.describeReceiptRuleSet(ruleSetName)
|
|
879
|
+
return true
|
|
880
|
+
}
|
|
881
|
+
catch (error: any) {
|
|
882
|
+
if (error.code === 'RuleSetDoesNotExist' || error.statusCode === 400) {
|
|
883
|
+
return false
|
|
884
|
+
}
|
|
885
|
+
throw error
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Get the active receipt rule set
|
|
891
|
+
*/
|
|
892
|
+
async getActiveReceiptRuleSet(): Promise<{
|
|
893
|
+
Metadata?: { Name?: string, CreatedTimestamp?: string }
|
|
894
|
+
Rules?: Array<{
|
|
895
|
+
Name?: string
|
|
896
|
+
Enabled?: boolean
|
|
897
|
+
Recipients?: string[]
|
|
898
|
+
Actions?: Array<{
|
|
899
|
+
S3Action?: { BucketName?: string, ObjectKeyPrefix?: string }
|
|
900
|
+
LambdaAction?: { FunctionArn?: string, InvocationType?: string }
|
|
901
|
+
SNSAction?: { TopicArn?: string }
|
|
902
|
+
}>
|
|
903
|
+
}>
|
|
904
|
+
} | null> {
|
|
905
|
+
const result = await this.client.request({
|
|
906
|
+
service: 'ses',
|
|
907
|
+
region: this.region,
|
|
908
|
+
method: 'POST',
|
|
909
|
+
path: '/',
|
|
910
|
+
headers: {
|
|
911
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
912
|
+
},
|
|
913
|
+
body: this.buildFormBody({
|
|
914
|
+
Action: 'DescribeActiveReceiptRuleSet',
|
|
915
|
+
Version: '2010-12-01',
|
|
916
|
+
}),
|
|
917
|
+
})
|
|
918
|
+
|
|
919
|
+
// Handle response format
|
|
920
|
+
const response = result?.DescribeActiveReceiptRuleSetResponse?.DescribeActiveReceiptRuleSetResult
|
|
921
|
+
|| result?.DescribeActiveReceiptRuleSetResult
|
|
922
|
+
|
|
923
|
+
if (!response?.Metadata) {
|
|
924
|
+
return null // No active rule set
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
const rules = response?.Rules?.member
|
|
928
|
+
return {
|
|
929
|
+
Metadata: response?.Metadata,
|
|
930
|
+
Rules: Array.isArray(rules) ? rules : rules ? [rules] : [],
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Update a receipt rule
|
|
936
|
+
*/
|
|
937
|
+
async updateReceiptRule(params: {
|
|
938
|
+
RuleSetName: string
|
|
939
|
+
Rule: {
|
|
940
|
+
Name: string
|
|
941
|
+
Enabled?: boolean
|
|
942
|
+
TlsPolicy?: 'Require' | 'Optional'
|
|
943
|
+
Recipients?: string[]
|
|
944
|
+
ScanEnabled?: boolean
|
|
945
|
+
Actions: Array<{
|
|
946
|
+
S3Action?: {
|
|
947
|
+
BucketName: string
|
|
948
|
+
ObjectKeyPrefix?: string
|
|
949
|
+
KmsKeyArn?: string
|
|
950
|
+
}
|
|
951
|
+
LambdaAction?: {
|
|
952
|
+
FunctionArn: string
|
|
953
|
+
InvocationType?: 'Event' | 'RequestResponse'
|
|
954
|
+
}
|
|
955
|
+
SNSAction?: {
|
|
956
|
+
TopicArn: string
|
|
957
|
+
Encoding?: 'UTF-8' | 'Base64'
|
|
958
|
+
}
|
|
959
|
+
StopAction?: {
|
|
960
|
+
Scope: 'RuleSet'
|
|
961
|
+
TopicArn?: string
|
|
962
|
+
}
|
|
963
|
+
}>
|
|
964
|
+
}
|
|
965
|
+
}): Promise<void> {
|
|
966
|
+
const formParams: Record<string, string | undefined> = {
|
|
967
|
+
Action: 'UpdateReceiptRule',
|
|
968
|
+
Version: '2010-12-01',
|
|
969
|
+
RuleSetName: params.RuleSetName,
|
|
970
|
+
'Rule.Name': params.Rule.Name,
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
if (params.Rule.Enabled !== undefined) {
|
|
974
|
+
formParams['Rule.Enabled'] = params.Rule.Enabled ? 'true' : 'false'
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
if (params.Rule.TlsPolicy) {
|
|
978
|
+
formParams['Rule.TlsPolicy'] = params.Rule.TlsPolicy
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
if (params.Rule.ScanEnabled !== undefined) {
|
|
982
|
+
formParams['Rule.ScanEnabled'] = params.Rule.ScanEnabled ? 'true' : 'false'
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
// Add recipients
|
|
986
|
+
if (params.Rule.Recipients) {
|
|
987
|
+
params.Rule.Recipients.forEach((recipient, index) => {
|
|
988
|
+
formParams[`Rule.Recipients.member.${index + 1}`] = recipient
|
|
989
|
+
})
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
// Add actions
|
|
993
|
+
params.Rule.Actions.forEach((action, index) => {
|
|
994
|
+
const actionNum = index + 1
|
|
995
|
+
|
|
996
|
+
if (action.S3Action) {
|
|
997
|
+
formParams[`Rule.Actions.member.${actionNum}.S3Action.BucketName`] = action.S3Action.BucketName
|
|
998
|
+
if (action.S3Action.ObjectKeyPrefix) {
|
|
999
|
+
formParams[`Rule.Actions.member.${actionNum}.S3Action.ObjectKeyPrefix`] = action.S3Action.ObjectKeyPrefix
|
|
1000
|
+
}
|
|
1001
|
+
if (action.S3Action.KmsKeyArn) {
|
|
1002
|
+
formParams[`Rule.Actions.member.${actionNum}.S3Action.KmsKeyArn`] = action.S3Action.KmsKeyArn
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
if (action.LambdaAction) {
|
|
1007
|
+
formParams[`Rule.Actions.member.${actionNum}.LambdaAction.FunctionArn`] = action.LambdaAction.FunctionArn
|
|
1008
|
+
formParams[`Rule.Actions.member.${actionNum}.LambdaAction.InvocationType`] = action.LambdaAction.InvocationType || 'Event'
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
if (action.SNSAction) {
|
|
1012
|
+
formParams[`Rule.Actions.member.${actionNum}.SNSAction.TopicArn`] = action.SNSAction.TopicArn
|
|
1013
|
+
if (action.SNSAction.Encoding) {
|
|
1014
|
+
formParams[`Rule.Actions.member.${actionNum}.SNSAction.Encoding`] = action.SNSAction.Encoding
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
if (action.StopAction) {
|
|
1019
|
+
formParams[`Rule.Actions.member.${actionNum}.StopAction.Scope`] = action.StopAction.Scope
|
|
1020
|
+
if (action.StopAction.TopicArn) {
|
|
1021
|
+
formParams[`Rule.Actions.member.${actionNum}.StopAction.TopicArn`] = action.StopAction.TopicArn
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
})
|
|
1025
|
+
|
|
1026
|
+
await this.client.request({
|
|
1027
|
+
service: 'ses',
|
|
1028
|
+
region: this.region,
|
|
1029
|
+
method: 'POST',
|
|
1030
|
+
path: '/',
|
|
1031
|
+
headers: {
|
|
1032
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
1033
|
+
},
|
|
1034
|
+
body: this.buildFormBody(formParams),
|
|
1035
|
+
})
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Send raw email (for SMTP relay)
|
|
1040
|
+
* Uses SES v1 API SendRawEmail action
|
|
1041
|
+
*/
|
|
1042
|
+
async sendRawEmail(params: {
|
|
1043
|
+
source: string
|
|
1044
|
+
destinations: string[]
|
|
1045
|
+
rawMessage: string
|
|
1046
|
+
}): Promise<{ MessageId?: string }> {
|
|
1047
|
+
// Encode the raw message as base64
|
|
1048
|
+
const rawMessageBase64 = Buffer.from(params.rawMessage).toString('base64')
|
|
1049
|
+
|
|
1050
|
+
const formParams: Record<string, string | undefined> = {
|
|
1051
|
+
Action: 'SendRawEmail',
|
|
1052
|
+
Version: '2010-12-01',
|
|
1053
|
+
Source: params.source,
|
|
1054
|
+
'RawMessage.Data': rawMessageBase64,
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
// Add destinations
|
|
1058
|
+
params.destinations.forEach((dest, index) => {
|
|
1059
|
+
formParams[`Destinations.member.${index + 1}`] = dest
|
|
1060
|
+
})
|
|
1061
|
+
|
|
1062
|
+
const result = await this.client.request({
|
|
1063
|
+
service: 'ses',
|
|
1064
|
+
region: this.region,
|
|
1065
|
+
method: 'POST',
|
|
1066
|
+
path: '/',
|
|
1067
|
+
headers: {
|
|
1068
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
1069
|
+
},
|
|
1070
|
+
body: this.buildFormBody(formParams),
|
|
1071
|
+
})
|
|
1072
|
+
|
|
1073
|
+
// Handle response format
|
|
1074
|
+
const response = result?.SendRawEmailResponse?.SendRawEmailResult
|
|
1075
|
+
|| result?.SendRawEmailResult
|
|
1076
|
+
|
|
1077
|
+
return {
|
|
1078
|
+
MessageId: response?.MessageId,
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|