Skip to content

Commit 47d1a2a

Browse files
committed
style(smtp): normalize arrow callback formatting 🎨
- Normalize arrow callbacks to parenthesized single parameters - Tidy DKIM header prefix line break formatting - Tidy Message-ID match expression line break formatting
1 parent f42549a commit 47d1a2a

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

src/smtp/Client.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,14 @@ export class SmtpClient {
175175
const smtpSafeMessage = this.toSmtpDataStream(dkimSignedMessage)
176176
await this.commands.sendData(smtpSafeMessage)
177177
const dataResponse = await this.commands.sendCommand('.')
178-
const messageIdMatch =
179-
dkimSignedMessage.match(/\r\nMessage-ID:\s*(<[^>\r\n]+>)/i) ||
178+
const messageIdMatch = dkimSignedMessage.match(/\r\nMessage-ID:\s*(<[^>\r\n]+>)/i) ||
180179
dkimSignedMessage.match(/^Message-ID:\s*(<[^>\r\n]+>)/i)
181180
const messageId = messageIdMatch ? (messageIdMatch[1] ?? '') : ''
182181
return {
183182
acceptedRecipients,
184183
envelope: {
185184
from: senderEmail,
186-
to: allRecipients.map(recipient => recipient.email)
185+
to: allRecipients.map((recipient) => recipient.email)
187186
},
188187
messageId,
189188
rejectedRecipients,
@@ -216,21 +215,21 @@ export class SmtpClient {
216215
const rawHeaderLines = rawHeaderSection.split('\r\n')
217216
const selectedHeaderNames =
218217
this.config.dkim.headerFieldNames && this.config.dkim.headerFieldNames.length > 0
219-
? this.config.dkim.headerFieldNames.map(headerName => headerName.toLowerCase())
218+
? this.config.dkim.headerFieldNames.map((headerName) => headerName.toLowerCase())
220219
: ['from', 'to', 'subject', 'date', 'message-id', 'mime-version', 'content-type']
221-
const selectedHeaderLines = rawHeaderLines.filter(headerLine => {
220+
const selectedHeaderLines = rawHeaderLines.filter((headerLine) => {
222221
const separatorIndex = headerLine.indexOf(':')
223222
if (separatorIndex < 1) {
224223
return false
225224
}
226225
const headerName = headerLine.slice(0, separatorIndex).trim().toLowerCase()
227226
return selectedHeaderNames.includes(headerName)
228227
})
229-
const signedHeaderNames = selectedHeaderLines.map(headerLine => {
228+
const signedHeaderNames = selectedHeaderLines.map((headerLine) => {
230229
const separatorIndex = headerLine.indexOf(':')
231230
return headerLine.slice(0, separatorIndex).trim().toLowerCase()
232231
})
233-
const canonicalizedHeaderLines = selectedHeaderLines.map(headerLine => {
232+
const canonicalizedHeaderLines = selectedHeaderLines.map((headerLine) => {
234233
const separatorIndex = headerLine.indexOf(':')
235234
const headerName = headerLine.slice(0, separatorIndex).trim().toLowerCase()
236235
const headerValue = headerLine
@@ -249,14 +248,15 @@ export class SmtpClient {
249248
const domainName = this.config.dkim.domainName
250249
const keySelector = this.config.dkim.keySelector
251250
const signedHeaderList = signedHeaderNames.join(':')
252-
const dkimHeaderPrefix = `v=1; a=rsa-sha256; c=relaxed/relaxed; d=${domainName}; s=${keySelector}; h=${signedHeaderList}; bh=${bodyHashBase64}; b=`
251+
const dkimHeaderPrefix =
252+
`v=1; a=rsa-sha256; c=relaxed/relaxed; d=${domainName}; s=${keySelector}; h=${signedHeaderList}; bh=${bodyHashBase64}; b=`
253253
const dkimSigningLine = `dkim-signature:${dkimHeaderPrefix}`
254254
const signingPayload = [...canonicalizedHeaderLines, dkimSigningLine].join('\r\n')
255255
const pemBody = this.config.dkim.privateKey
256256
.replace('-----BEGIN PRIVATE KEY-----', '')
257257
.replace('-----END PRIVATE KEY-----', '')
258258
.replace(/\s+/g, '')
259-
const binaryDer = Uint8Array.from(atob(pemBody), char => char.charCodeAt(0))
259+
const binaryDer = Uint8Array.from(atob(pemBody), (char) => char.charCodeAt(0))
260260
const cryptoKey = await crypto.subtle.importKey(
261261
'pkcs8',
262262
binaryDer,

src/smtp/Command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class SmtpCommand {
4040
throw new Error('Connection closed')
4141
}
4242
response += decoder.decode(buffer.subarray(0, bytesRead))
43-
const completeLines = response.split('\r\n').filter(line => line.length > 0)
43+
const completeLines = response.split('\r\n').filter((line) => line.length > 0)
4444
const lastLine = completeLines[completeLines.length - 1]
4545
if (!lastLine) {
4646
continue
@@ -49,7 +49,7 @@ export class SmtpCommand {
4949
break
5050
}
5151
}
52-
const finalLines = response.split('\r\n').filter(line => line.length > 0)
52+
const finalLines = response.split('\r\n').filter((line) => line.length > 0)
5353
const finalLine = finalLines[finalLines.length - 1] ?? response
5454
const statusCode = finalLine.substring(0, 3)
5555
if (!finalLine.startsWith('2') && !finalLine.startsWith('3')) {

src/smtp/Message.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class SmtpMessage {
8484
): string[] {
8585
const headers = [
8686
`From: ${SMTP.SmtpAddress.formatAddressForHeader(fromAddress)}`,
87-
`To: ${toAddresses.map(addr => SMTP.SmtpAddress.formatAddressForHeader(addr)).join(', ')}`,
87+
`To: ${toAddresses.map((addr) => SMTP.SmtpAddress.formatAddressForHeader(addr)).join(', ')}`,
8888
`Subject: ${message.subject}`,
8989
`Date: ${new Date().toUTCString()}`,
9090
`Message-ID: <${Date.now()}@${this.config.host}>`,
@@ -93,7 +93,7 @@ export class SmtpMessage {
9393
if (message.cc) {
9494
const ccAddresses = SMTP.SmtpAddress.parseAddressList(message.cc)
9595
headers.push(
96-
`Cc: ${ccAddresses.map(addr => SMTP.SmtpAddress.formatAddressForHeader(addr)).join(', ')}`
96+
`Cc: ${ccAddresses.map((addr) => SMTP.SmtpAddress.formatAddressForHeader(addr)).join(', ')}`
9797
)
9898
}
9999
const replyToAddress = message.replyTo

0 commit comments

Comments
 (0)