openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
33 lines (32 loc) • 1.47 kB
JavaScript
import { n as sha256Hex } from "./node-crypto-B6yuTjmm.mjs";
import { n as parseConversationRouteContext } from "./conversation-route-context-xtLW3fJF.mjs";
//#region src/config/sessions/conversation-route-fingerprint.ts
/** Binds queued authority to the exact route facts admitted by the Gateway. */
function resolveConversationRouteFingerprint(e) {
const t = e.routeContext ? parseConversationRouteContext(e.routeContext) : void 0;
return sha256Hex(JSON.stringify([
e.channel,
e.accountId,
e.kind,
e.peerId,
e.target,
e.parentConversationRef ?? null,
e.threadId ?? null,
e.nativeChannelId ?? null,
e.nativeDirectUserId ?? null,
e.routeContextObserved === true,
t ?? null
]));
}
//#endregion
//#region src/config/sessions/conversation-authority.ts
/** The reader or transaction supplies current rows; captured fingerprints alone grant nothing. */
function assertConversationAuthority(e, t) {
if (!e || e.conversationRef !== t.conversationRef || resolveConversationRouteFingerprint(e) !== t.expectedRouteFingerprint || t.expectedSessionId !== void 0 && e.sessionId !== t.expectedSessionId || t.expectedSessionKey !== void 0 && e.sessionKey !== t.expectedSessionKey) {
const e = /* @__PURE__ */ new Error(`Conversation is no longer available to this agent: ${t.conversationRef}`);
e.name = "ConversationAuthorityError";
throw e;
}
}
//#endregion
export { resolveConversationRouteFingerprint as n, assertConversationAuthority as t };