UNPKG

@gguf/claw

Version:

Multi-channel AI gateway with extensible messaging integrations

22 lines (20 loc) 1.1 kB
import { l as normalizeStringEntries } from "./dock-BZuwgj1O.js"; import { i as readChannelAllowFromStore } from "./pairing-store-CruPwgBw.js"; //#region src/security/dm-policy-shared.ts async function resolveDmAllowState(params) { const configAllowFrom = normalizeStringEntries(Array.isArray(params.allowFrom) ? params.allowFrom : void 0); const hasWildcard = configAllowFrom.includes("*"); const storeAllowFrom = await (params.readStore ?? readChannelAllowFromStore)(params.provider).catch(() => []); const normalizeEntry = params.normalizeEntry ?? ((value) => value); const normalizedCfg = configAllowFrom.filter((value) => value !== "*").map((value) => normalizeEntry(value)).map((value) => value.trim()).filter(Boolean); const normalizedStore = storeAllowFrom.map((value) => normalizeEntry(value)).map((value) => value.trim()).filter(Boolean); const allowCount = Array.from(new Set([...normalizedCfg, ...normalizedStore])).length; return { configAllowFrom, hasWildcard, allowCount, isMultiUserDm: hasWildcard || allowCount > 1 }; } //#endregion export { resolveDmAllowState as t };