@remit/smtp-worker 0.0.28 → 0.0.29
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remit/smtp-worker",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"@remit/domain-enums": "*",
|
|
33
33
|
"@remit/mail-oauth-service": "*",
|
|
34
34
|
"@remit/mailbox-service": "*",
|
|
35
|
-
"@aws-sdk/client-sqs": "
|
|
36
|
-
"expect-env": "
|
|
37
|
-
"@types/aws-lambda": "
|
|
35
|
+
"@aws-sdk/client-sqs": "^3.1090.0",
|
|
36
|
+
"expect-env": "^1.0.1",
|
|
37
|
+
"@types/aws-lambda": "^8.10.162"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"esbuild": "^0.28.1"
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "@aws-sdk/client-sqs";
|
|
7
7
|
import { createLogger } from "@remit/logger";
|
|
8
8
|
import { installNodeLogger } from "@remit/logger-lambda/node";
|
|
9
|
-
import {
|
|
9
|
+
import { createSqsClient } from "@remit/sqs-client/producer";
|
|
10
10
|
import type { Context, SQSBatchResponse, SQSEvent } from "aws-lambda";
|
|
11
11
|
import { env } from "expect-env";
|
|
12
12
|
import { handler } from "./index.js";
|
|
@@ -34,7 +34,7 @@ const queueUrl = env.SQS_QUEUE_URL_SMTP;
|
|
|
34
34
|
const queueName = new URL(queueUrl).pathname.split("/").pop();
|
|
35
35
|
const log = createLogger().child({ queue: queueName });
|
|
36
36
|
|
|
37
|
-
const sqs =
|
|
37
|
+
const sqs = createSqsClient({ queueUrl });
|
|
38
38
|
|
|
39
39
|
const maxMessages = 10;
|
|
40
40
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { SendMessageCommand } from "@aws-sdk/client-sqs";
|
|
3
2
|
import { deriveAddressId, deriveMessageId } from "@remit/data-ports/id";
|
|
4
3
|
import type { ConnectionState } from "@remit/domain-enums";
|
|
5
4
|
import type { Logger } from "@remit/logger";
|
|
@@ -15,10 +14,8 @@ import {
|
|
|
15
14
|
type AccountCredentialsDeps,
|
|
16
15
|
resolveConnectionCredentials,
|
|
17
16
|
} from "@remit/mailbox-service/account-credentials";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
createSecretsService,
|
|
21
|
-
} from "@remit/secrets-service";
|
|
17
|
+
import { createSecretsService } from "@remit/secrets-service";
|
|
18
|
+
import { createKmsDataKeyProvider } from "@remit/secrets-service/kms";
|
|
22
19
|
import { sendMail } from "@remit/smtp-service";
|
|
23
20
|
import { createQueueProducer } from "@remit/sqs-client/producer";
|
|
24
21
|
import { createStorageService } from "@remit/storage-service/s3";
|
|
@@ -67,29 +64,31 @@ const getTokenService = () => {
|
|
|
67
64
|
|
|
68
65
|
// APPEND_SENT_MESSAGE is processed by the IMAP worker via the
|
|
69
66
|
// message-management queue (see remit-imap-worker/src/emit.ts).
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
interface AppendSentMessageEvent {
|
|
68
|
+
type: "APPEND_SENT_MESSAGE";
|
|
69
|
+
accountId: string;
|
|
70
|
+
outboxMessageId: string;
|
|
71
|
+
eventId: string;
|
|
72
|
+
timestamp: number;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const messageMgmtQueue = createQueueProducer<AppendSentMessageEvent>({
|
|
76
|
+
queueUrl: env.SQS_QUEUE_URL_MESSAGE_MGMT,
|
|
73
77
|
});
|
|
74
78
|
|
|
75
79
|
const emitAppendSentMessage = async (
|
|
76
80
|
accountId: string,
|
|
77
81
|
outboxMessageId: string,
|
|
78
82
|
): Promise<void> => {
|
|
79
|
-
const event = {
|
|
80
|
-
type: "APPEND_SENT_MESSAGE"
|
|
83
|
+
const event: AppendSentMessageEvent = {
|
|
84
|
+
type: "APPEND_SENT_MESSAGE",
|
|
81
85
|
accountId,
|
|
82
86
|
outboxMessageId,
|
|
83
87
|
eventId: randomUUID(),
|
|
84
88
|
timestamp: Date.now(),
|
|
85
89
|
};
|
|
86
90
|
|
|
87
|
-
await
|
|
88
|
-
new SendMessageCommand({
|
|
89
|
-
QueueUrl: messageMgmtQueueUrl,
|
|
90
|
-
MessageBody: JSON.stringify(event),
|
|
91
|
-
}),
|
|
92
|
-
);
|
|
91
|
+
await messageMgmtQueue.send({ body: event });
|
|
93
92
|
};
|
|
94
93
|
|
|
95
94
|
const findMessageByHeader = async (
|