Files
smom-dbis-138/services/settlement-middleware/dist/middleware/rate-limit.js
zaragoza444 5229c2d888
Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m13s
CI/CD Pipeline / Lint and Format (push) Has been cancelled
CI/CD Pipeline / Security Scanning (push) Has been cancelled
CI/CD Pipeline / Terraform Validation (push) Has been cancelled
CI/CD Pipeline / Kubernetes Validation (push) Has been cancelled
Deploy ChainID 138 / Deploy ChainID 138 (push) Has been cancelled
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Has been cancelled
Validation / validate-genesis (push) Has been cancelled
Validation / validate-terraform (push) Has been cancelled
Validation / validate-kubernetes (push) Has been cancelled
Validation / validate-smart-contracts (push) Has been cancelled
Validation / validate-security (push) Has been cancelled
Validation / validate-documentation (push) Has been cancelled
Verify Deployment / Verify Deployment (push) Has been cancelled
fix(omnl): production blockers for M0-M4 settlement stack
Exempt dashboard read APIs from anonymous rate limits, preserve nginx-injected auth, wire chain-mint and DB env through deploy/LXC scripts, resolve M3 token addresses from registry, and harden super-admin seeding.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 06:47:20 -07:00

30 lines
1.2 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.settlementRateLimiter = void 0;
const express_rate_limit_1 = __importDefault(require("express-rate-limit"));
const integration_foundation_1 = require("@dbis/integration-foundation");
function asHandler(h) {
return h;
}
exports.settlementRateLimiter = asHandler((0, express_rate_limit_1.default)({
windowMs: 60_000,
skip: (req) => (0, integration_foundation_1.isOmnlPublicEndpoint)(req.path),
max: (req) => {
if (!(0, integration_foundation_1.isProductionSecurityMode)())
return 200;
const policy = (0, integration_foundation_1.loadCustomerSecurityPolicy)();
const principal = (0, integration_foundation_1.resolveOmnlPrincipal)(req);
if (!principal)
return policy.rateLimits.anonymousPerMinute;
if (principal.role === 'customer')
return policy.rateLimits.customerPerMinute;
return policy.rateLimits.superAdminPerMinute;
},
message: { error: 'Too many requests — rate limit exceeded' },
standardHeaders: true,
legacyHeaders: false,
}));