type BotConfidence = "high" | "medium" | "low"; type BotInfo = { name: string; version?: string | undefined; type: string; category: string; confidence: BotConfidence; }; /** * @typedef {Object} BotGuardPluginOptions * @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] */ /** * Fastify plugin that blocks bots by category. * * import { botGuardPlugin } from '@exortek/ua/middleware/bot-guard/fastify'; * * await app.register(botGuardPlugin, { * deny: ['ai-training', 'seo'], * onBlocked(bot, req) { * console.log(`Blocked ${bot.name}`); * }, * }); * * @param {import('fastify').FastifyInstance} fastify * @param {BotGuardPluginOptions} options */ declare const botGuardPlugin: Function; type BotGuardPluginOptions = { /** * — 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 { botGuardPlugin, botGuardPlugin as default }; export type { BotGuardPluginOptions };