wirejs-deploy-amplify-basic 0.1.175 → 0.1.176

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.
@@ -3,6 +3,6 @@
3
3
  "dependencies": {
4
4
  "jsdom": "^25.0.1",
5
5
  "wirejs-dom": "^1.0.44",
6
- "wirejs-resources": "^0.1.175"
6
+ "wirejs-resources": "^0.1.176"
7
7
  }
8
8
  }
@@ -2,6 +2,22 @@ import { SESClient, SendEmailCommand, } from '@aws-sdk/client-ses';
2
2
  import { EmailSender as BaseEmailSender, } from 'wirejs-resources';
3
3
  import { addResource } from '../resource-collector.js';
4
4
  const ses = new SESClient();
5
+ const SEND_VERIFY_ERROR = (sender, addresses) => `
6
+ Your app tried to send an email
7
+
8
+ From : ${sender}
9
+ To : ${addresses.join(', ')}
10
+
11
+ However, your AWS account is in SES sandbox mode in ${process.env.AWS_REGION}.
12
+
13
+ You must log into the AWS SES console and EITHER:
14
+
15
+ ... Verify every individual recipient (e.g., during testing),
16
+
17
+ ~~~ OR ~~~
18
+
19
+ ... Request production access.
20
+ `;
5
21
  export class EmailSender extends BaseEmailSender {
6
22
  constructor(scope, id, options) {
7
23
  super(scope, id, options);
@@ -9,16 +25,32 @@ export class EmailSender extends BaseEmailSender {
9
25
  }
10
26
  async send(message) {
11
27
  const toAddresses = Array.isArray(message.to) ? message.to : [message.to];
12
- await ses.send(new SendEmailCommand({
13
- Source: this.from,
14
- Destination: { ToAddresses: toAddresses },
15
- Message: {
16
- Subject: { Data: message.subject },
17
- Body: {
18
- Text: { Data: message.body },
19
- ...(message.html !== undefined ? { Html: { Data: message.html } } : {}),
28
+ try {
29
+ await ses.send(new SendEmailCommand({
30
+ Source: this.from,
31
+ Destination: { ToAddresses: toAddresses },
32
+ Message: {
33
+ Subject: { Data: message.subject },
34
+ Body: {
35
+ Text: { Data: message.body },
36
+ ...(message.html !== undefined ? { Html: { Data: message.html } } : {}),
37
+ },
20
38
  },
21
- },
22
- }));
39
+ }));
40
+ }
41
+ catch (e) {
42
+ if (e.message.includes('Email address is not verified')) {
43
+ await ses.send(new SendEmailCommand({
44
+ Source: this.from,
45
+ Destination: { ToAddresses: [this.from] },
46
+ Message: {
47
+ Subject: { Data: "Error Sending Email: Recipient not verified" },
48
+ Body: { Text: { Data: SEND_VERIFY_ERROR(this.from, toAddresses)
49
+ } }
50
+ }
51
+ }));
52
+ }
53
+ throw e;
54
+ }
23
55
  }
24
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wirejs-deploy-amplify-basic",
3
- "version": "0.1.175",
3
+ "version": "0.1.176",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -45,7 +45,7 @@
45
45
  "recursive-copy": "^2.0.14",
46
46
  "rimraf": "^6.0.1",
47
47
  "wirejs-dom": "^1.0.44",
48
- "wirejs-resources": "^0.1.175"
48
+ "wirejs-resources": "^0.1.176"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@aws-amplify/backend": "^1.14.0",