@auth0/auth0-mcp-server
Version:
Auth0 Model Context Protocol (MCP) Server (Beta) — A secure and extendable implementation of an MCP server that provides AI assistants with controlled access to the Auth0 Management API through natural language. This project is in beta and not intended fo
20 lines • 823 B
JavaScript
/**
* Returns a per-key rate-limit function. Each call returns `{ allowed, retryAfterMs }`.
* Timestamps older than `windowMs` are pruned on every check, so the limit is
* enforced over a rolling window rather than a fixed clock interval.
*/
export function createRateLimiter(maxCalls, windowMs) {
const calls = new Map();
return function tryConsume(key) {
const now = Date.now();
const cutoff = now - windowMs;
const timestamps = (calls.get(key) ?? []).filter((t) => t > cutoff);
if (timestamps.length >= maxCalls) {
return { allowed: false, retryAfterMs: timestamps[0] + windowMs - now };
}
timestamps.push(now);
calls.set(key, timestamps);
return { allowed: true, retryAfterMs: 0 };
};
}
//# sourceMappingURL=rate-limiter.js.map