openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
28 lines (27 loc) • 1.26 kB
JavaScript
import { a as resolveGlobalSingleton } from "./global-singleton-D7yf05nR.mjs";
//#region src/plugins/http-legacy-listener.ts
const forwardedRequests = resolveGlobalSingleton(Symbol.for("openclaw.pluginHttpLegacyListenerRequests"), () => /* @__PURE__ */ new WeakMap());
/** Host-owned attribution; forwarded headers never select a legacy account endpoint. */
function markPluginHttpLegacyListener(e, t) {
forwardedRequests.set(e, Object.freeze({
port: t.port,
...t.host !== void 0 ? { host: t.host } : {}
}));
}
/** Configured endpoint accepting this request, or undefined on the ordinary Gateway listener. */
function getWebhookLegacyListener(e) {
return forwardedRequests.get(e);
}
function hasEndpoint(e, t) {
return e?.some((e) => e.port === t.port && e.host === t.host) === true;
}
function isLegacyPluginRouteHandoff(e, t) {
const n = getWebhookLegacyListener(e);
return n !== void 0 && hasEndpoint(t.legacyListenerHandoffs, n);
}
function permitsLegacyPluginRoute(e, t) {
const n = getWebhookLegacyListener(e);
return !n || t.auth === "plugin" && hasEndpoint(t.legacyListeners, n);
}
//#endregion
export { permitsLegacyPluginRoute as i, isLegacyPluginRouteHandoff as n, markPluginHttpLegacyListener as r, getWebhookLegacyListener as t };