Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions backend/src/config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const REQUIRED = [
'JWT_SECRET',
'API_KEY_PEPPER',
'PLATFORM_SECRET_KEY',
'ARBITRATOR_SECRET_KEY',
'STELLAR_NETWORK',
'STELLAR_HORIZON_URL',
'WALLET_ENCRYPTION_KEY',
Expand Down Expand Up @@ -51,6 +52,13 @@ function validateEnv() {
);
}

const arbitratorKey = process.env.ARBITRATOR_SECRET_KEY;
if (!/^S[A-Z2-7]{55}$/.test(arbitratorKey)) {
errors.push(
'ARBITRATOR_SECRET_KEY must be a valid Stellar secret seed (56 characters, starting with S)'
);
}

const portRaw = process.env.PORT;
if (portRaw && portRaw.length > 0) {
const portNum = Number(portRaw);
Expand Down
3 changes: 2 additions & 1 deletion backend/src/routes/campaignComments.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { requireAuth, authenticate } = require("../middleware/auth");
const asyncHandler = require("../utils/asyncHandler");
const logger = require("../config/logger");
const rateLimit = require("express-rate-limit");
const { ipKeyGenerator } = rateLimit;
const { createNotification } = require("../services/notifications");
const { sendCampaignCommentEmail, sendCommentReplyEmail } = require("../services/emailService");

Expand Down Expand Up @@ -39,7 +40,7 @@ const commentRateLimiter = rateLimit({
max: 5,
standardHeaders: true,
legacyHeaders: false,
keyGenerator: (req) => req.user?.userId || req.ip,
keyGenerator: (req) => req.user?.userId || ipKeyGenerator(req.ip),
message: { error: "Rate limit exceeded. You can post up to 5 comments per minute." },
});

Expand Down
Loading