@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.
26 lines • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLoopbackHost = isLoopbackHost;
exports.assertSafeSSEBind = assertSafeSSEBind;
exports.requireBearerToken = requireBearerToken;
const node_crypto_1 = require("node:crypto");
function isLoopbackHost(host) {
return host === "127.0.0.1" || host === "localhost" || host === "::1";
}
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})`);
}
}
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 || !(0, node_crypto_1.timingSafeEqual)(actual, expected)) {
res.status(401).send("Unauthorized");
return;
}
next();
};
}
//# sourceMappingURL=sse-security.js.map