Skip to content

Commit 1cd8b33

Browse files
authored
Chore/upgrade nodemailer 6 4 12 (notifme#74)
* upgrade to nodemailer 6.4.12 * fix ses tests
1 parent 7da3f1a commit 1cd8b33

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

__tests__/providers/email/ses.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test('SES success with minimal parameters.', async () => {
4545
Host: 'email.eu-west-1.amazonaws.com',
4646
'X-Amz-Content-Sha256': [expect.stringMatching(/\w*/)],
4747
'X-Amz-Date': [datetime],
48-
'Content-Length': ['425'],
48+
'Content-Length': ['445'],
4949
'Content-Type': ['application/x-www-form-urlencoded; charset=utf-8'],
5050
'User-Agent': ['notifme-sdk/v1 (+https://github.com/notifme/notifme-sdk)']
5151
})
@@ -99,7 +99,7 @@ test('SES success with all parameters.', async () => {
9999
Host: 'email.eu-west-1.amazonaws.com',
100100
'X-Amz-Content-Sha256': [expect.stringMatching(/\w*/)],
101101
'X-Amz-Date': [datetime],
102-
'Content-Length': ['1017'],
102+
'Content-Length': ['1037'],
103103
'Content-Type': ['application/x-www-form-urlencoded; charset=utf-8'],
104104
'User-Agent': ['notifme-sdk/v1 (+https://github.com/notifme/notifme-sdk)']
105105
})
@@ -121,7 +121,7 @@ test('SES should return an error if a parameter is not of the right type.', asyn
121121
expect(result).toEqual({
122122
status: 'error',
123123
errors: {
124-
email: 'The "chunk" argument must be one of type string or Buffer. Received type object'
124+
email: expect.stringContaining('The "chunk" argument must be of type string or an instance of Buffer or Uint8Array.')
125125
},
126126
channels: {
127127
email: { id: undefined, providerId: 'email-ses-provider' }

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"https-proxy-agent": "5.0.0",
2727
"node-fetch": "2.6.0",
2828
"node-pushnotifications": "1.3.0",
29-
"nodemailer": "6.4.5",
29+
"nodemailer": "6.4.12",
3030
"web-push": "3.4.3",
3131
"winston": "3.2.1"
3232
},

src/providers/email/ses.js

+15-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ export default class EmailSesProvider {
2121
}
2222

2323
async send (request: EmailRequestType): Promise<string> {
24+
if (
25+
request.text &&
26+
typeof request.text !== 'string' &&
27+
!(request.text instanceof Buffer) &&
28+
!(request.text instanceof Uint8Array)
29+
) {
30+
throw new Error(
31+
'The "chunk" argument must be of type string or an instance of Buffer or Uint8Array.'
32+
)
33+
}
34+
2435
const { region } = this.credentials
2536
const host = `email.${region}.amazonaws.com`
2637
const raw = (await this.getRaw(
@@ -56,13 +67,9 @@ export default class EmailSesProvider {
5667
}
5768
}
5869

59-
getRaw ({ customize, ...request }: EmailRequestType): Promise<Buffer> {
60-
return new Promise((resolve, reject) => {
61-
const email = new MailComposer(request).compile()
62-
email.keepBcc = true
63-
email.build((error, raw) => {
64-
error ? reject(error) : resolve(raw)
65-
})
66-
})
70+
async getRaw ({ customize, ...request }: EmailRequestType): Promise<Buffer> {
71+
const email = new MailComposer(request).compile()
72+
email.keepBcc = true
73+
return email.build()
6774
}
6875
}

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -4702,10 +4702,10 @@ nodemailer-shared@^1.1.0:
47024702
dependencies:
47034703
nodemailer-fetch "1.6.0"
47044704

4705-
nodemailer@6.4.5:
4706-
version "6.4.5"
4707-
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.4.5.tgz#45614c6454d1a947242105eeddae03df87e29916"
4708-
integrity sha512-NH7aNVQyZLAvGr2+EOto7znvz+qJ02Cb/xpou98ApUt5tEAUSVUxhvHvgV/8I5dhjKTYqUw0nasoKzLNBJKrDQ==
4705+
nodemailer@6.4.12:
4706+
version "6.4.12"
4707+
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.4.12.tgz#efb3946f3e5c5afad50af8090e070957cea1c43d"
4708+
integrity sha512-c/WplZp24Lxc+hn0w/kweNxcYGpaqtH1iecfGKTbXVmp5qx+ILApKsmCAucWWIIQiYKKH4ZA/ffSNOsai6xJGA==
47094709

47104710
nodemon@2.0.2:
47114711
version "2.0.2"

0 commit comments

Comments
 (0)