openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
35 lines (34 loc) • 2.03 kB
JavaScript
import { t as GATEWAY_OWNER_PROFILE_ID } from "./user-profile-constants-Bj3FwpfE.mjs";
import { o as getGatewayToolCallerIdentity } from "./gateway-caller-context-BNidAW8G.mjs";
//#region src/gateway/server-methods/gateway-personal-caller.ts
function isSyntheticGatewayCaller(e) {
return Boolean(e?.internal?.syntheticClient || e?.internal?.agentToolCaller || e?.internal?.agentRuntimeIdentity || getGatewayToolCallerIdentity());
}
/** Handshake-attested person identity; callers still own current request and target authority. */
function resolveAuthenticatedPersonalGatewayProfileId(e) {
const t = e?.authenticatedUserProfile?.profileId;
return e?.internal?.authenticatedOperator === true && e.connect.role === "operator" && !isSyntheticGatewayCaller(e) && t && t !== "gateway-owner" ? t : void 0;
}
function isIneligiblePersonalGatewayCaller(e) {
const t = e.internal?.operatorRoleActor;
const n = e.internal?.remoteIngressPrincipal;
if (n) {
try {
n.signal.throwIfAborted();
n.assertCurrent();
} catch {
return true;
}
if (e.authenticatedUserProfile?.profileId !== n.authenticatedUserProfile.profileId) return true;
const r = n.operatorRoleActor;
return isSyntheticGatewayCaller(e) || (r.kind === "operator" ? t?.kind !== "operator" || t.profileId !== r.profileId : t?.kind !== "system");
}
return isSyntheticGatewayCaller(e) || Boolean(t && (t.kind !== "system" || !e.authenticatedUserProfile));
}
/** Personal actions retain either the exact registered socket or the live host-bound grant. */
function hasCurrentPersonalGatewaySource(e, t) {
if (!e || e.invalidated || e.connectionSignal?.aborted || e.connect.role !== "operator" || isIneligiblePersonalGatewayCaller(e)) return false;
return Boolean(e.internal?.remoteIngressPrincipal || e.connId && t.getClientConnIds?.((t) => t === e).has(e.connId));
}
//#endregion
export { resolveAuthenticatedPersonalGatewayProfileId as i, isIneligiblePersonalGatewayCaller as n, isSyntheticGatewayCaller as r, hasCurrentPersonalGatewaySource as t };