openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.09 kB
JavaScript
import{f as normalizeStringEntries}from"./string-normalization-D_oBUpO3.mjs";
//!src/channels/allow-from.ts
const ACCESS_GROUP_ALLOW_FROM_PREFIX=`accessGroup:`;function parseAccessGroupAllowFromEntry(e){const t=e.trim();if(!t.startsWith(`accessGroup:`))return null;const n=t.slice(12).trim();return n.length>0?n:null}function mergeDmAllowFromSources(e){const t=e.dmPolicy===`allowlist`||e.dmPolicy===`open`?[]:e.storeAllowFrom??[];return normalizeStringEntries([...e.allowFrom??[],...t])}function resolveGroupAllowFromSources(e){const t=Array.isArray(e.groupAllowFrom)&&e.groupAllowFrom.length>0?e.groupAllowFrom:void 0;const n=t?t:e.fallbackToAllowFrom===false?[]:e.allowFrom??[];return normalizeStringEntries(n)}function firstDefined(...e){return e.find(e=>e!==void 0)}function isSenderIdAllowed(e,t,n){if(!e.hasEntries)return n;if(e.hasWildcard)return true;if(!t)return false;return e.entries.includes(t)}export{parseAccessGroupAllowFromEntry as a,mergeDmAllowFromSources as i,firstDefined as n,resolveGroupAllowFromSources as o,isSenderIdAllowed as r,ACCESS_GROUP_ALLOW_FROM_PREFIX as t};