@astralibx/email-account-manager 10.2.0 → 10.4.0

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/README.md CHANGED
@@ -114,6 +114,26 @@ Advanced: [Capacity Selection](https://github.com/Hariprakash1997/astralib/blob/
114
114
 
115
115
  > **Important:** The warmup system requires calling `advanceDay()` daily via cron job. Without this, accounts stay in warmup indefinitely.
116
116
 
117
+ ### Redis Key Prefix (Required for Multi-Project Deployments)
118
+
119
+ > **WARNING:** If multiple projects share the same Redis server, you MUST set a unique `keyPrefix` per project. Without this, BullMQ queues will collide — Project A's worker could process Project B's emails.
120
+
121
+ ```typescript
122
+ const eam = createEmailAccountManager({
123
+ redis: {
124
+ connection: redis,
125
+ keyPrefix: 'myproject-eam:', // REQUIRED if sharing Redis
126
+ },
127
+ // ...
128
+ });
129
+ ```
130
+
131
+ | Default | Risk |
132
+ |---------|------|
133
+ | `'eam:'` | Two projects using defaults share the same `eam:email-send` and `eam:email-approved` queues |
134
+
135
+ **Always set a unique prefix** like `projectname-eam:` or `projectname:`.
136
+
117
137
  ## Security Notes
118
138
 
119
139
  **Credential storage**: SMTP and IMAP passwords (`smtp.pass`, `imap.pass`) are stored as plaintext in MongoDB. You should encrypt these values at the application layer before passing them to this library, and decrypt them after retrieval. A built-in encryption layer is planned for a future version.
package/dist/index.cjs CHANGED
@@ -2261,8 +2261,16 @@ function createAccountController(EmailAccount, capacityManager, healthTracker, w
2261
2261
  return {
2262
2262
  async list(req, res) {
2263
2263
  try {
2264
- const accounts = await EmailAccount.find().select("-smtp.pass -imap.pass").sort({ createdAt: -1 });
2265
- res.json({ success: true, data: { accounts } });
2264
+ const { status, provider, page, limit } = req.query;
2265
+ const filter = {};
2266
+ if (status) filter.status = status;
2267
+ if (provider) filter.provider = provider;
2268
+ const pageNum = Number(page) || 1;
2269
+ const limitNum = Number(limit) || 20;
2270
+ const skip = (pageNum - 1) * limitNum;
2271
+ const total = await EmailAccount.countDocuments(filter);
2272
+ const accounts = await EmailAccount.find(filter).select("-smtp.pass -imap.pass").sort({ createdAt: -1 }).skip(skip).limit(limitNum);
2273
+ res.json({ success: true, data: { accounts, total } });
2266
2274
  } catch (error) {
2267
2275
  const message = error instanceof Error ? error.message : "Unknown error";
2268
2276
  res.status(500).json({ success: false, error: message });