Loads allowlist from config, validates message sender IDs against RBAC rules โ filters unauthorized triggers.
import fs from 'fs';
import { SENDER_ALLOWLIST_PATH } from './config.js';
import { logger } from './logger.js';
export interface ChatAllowlistEntry {
allow: '*' | string[];
mode: 'trigger' | 'drop';
}
export interface SenderAllowlistConfig {
default: ChatAllowlistEntry;
chats: Record<string, ChatAllowlistEntry>;
logDenied: boolean;
}
const DEFAULT_CONFIG: SenderAllowlistConfig = {
default: { allow: '*', mode: 'trigger' },
chats: {},
logDenied: true,
};
function isValidEntry(entry: unknown): entry is ChatAllowlistEntry {
if (!entry || typeof entry !== 'object') return false;
const e = entry as Record<string, unknown>;
const validAllow =
e.allow === '*' ||
(Array.isArray(e.allow) && e.allow.every((v) => typeof v === 'string'));
const validMode = e.mode ==
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key