@launchdarkly/mcp-server
Version:
The local [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for [LaunchDarkly](https://launchdarkly.com/) federal and European Union (EU) environments.
21 lines • 819 B
JavaScript
import { timingSafeEqual } from "node:crypto";
export function isLoopbackHost(host) {
return host === "127.0.0.1" || host === "localhost" || host === "::1";
}
export function assertSafeSSEBind(host, authToken) {
if (!authToken && !isLoopbackHost(host)) {
throw new Error(`--auth-token is required when the SSE transport listens on a non-loopback host (${host})`);
}
}
export function requireBearerToken(token) {
const expected = Buffer.from(`Bearer ${token}`);
return (req, res, next) => {
const actual = Buffer.from(req.headers.authorization ?? "");
if (actual.length !== expected.length || !timingSafeEqual(actual, expected)) {
res.status(401).send("Unauthorized");
return;
}
next();
};
}
//# sourceMappingURL=sse-security.js.map