type BotConfidence = "high" | "medium" | "low"; type BotInfo = { name: string; version?: string | undefined; type: string; category: string; confidence: BotConfidence; }; /** * @typedef {Object} BotGuardOptions * @property {string[]} [allow] — categories to always allow (overrides deny) * @property {string[]} [deny] — categories to block * @property {boolean} [denyAll=false] — block all detected bots * @property {number} [status=403] — HTTP status for blocked requests * @property {(bot: import('../bots.js').BotInfo, req: unknown) => unknown} [onBlocked] * @property {(bot: import('../bots.js').BotInfo, req: unknown) => void} [onAllowed] */ /** * Express middleware that blocks bots by category. * * import { botGuard } from '@exortek/ua/middleware/bot-guard'; * * // Block AI training crawlers * app.use(botGuard({ deny: ['ai-training'] })); * * // Block everything except search engines * app.use(botGuard({ denyAll: true, allow: ['search'] })); * * // Custom blocking logic * app.use(botGuard({ * deny: ['ai-training', 'seo'], * onBlocked(bot, req) { * console.log(`Blocked ${bot.name} (${bot.category})`); * }, * })); * * @param {BotGuardOptions} [options] * @returns {Function} */ declare function botGuard(options?: BotGuardOptions): Function; type BotGuardOptions = { /** * — categories to always allow (overrides deny) */ allow?: string[] | undefined; /** * — categories to block */ deny?: string[] | undefined; /** * — block all detected bots */ denyAll?: boolean | undefined; /** * — HTTP status for blocked requests */ status?: number | undefined; onBlocked?: ((bot: BotInfo, req: unknown) => unknown) | undefined; onAllowed?: ((bot: BotInfo, req: unknown) => void) | undefined; }; export { botGuard }; export type { BotGuardOptions };