type BotConfidence = "high" | "medium" | "low"; type BotInfo = { name: string; version?: string | undefined; type: string; category: string; confidence: BotConfidence; }; /** * @typedef {Object} UAPluginOptions * @property {boolean} [clientHints=true] * @property {boolean} [sendAcceptCH=true] * @property {boolean} [detectBots=true] * @property {string} [property='ua'] * @property {(ua: string) => void} [onUnknown] * @property {(bot: import('../bots.js').BotInfo, req: unknown) => boolean|void} [onBot] * @property {(result: object, req: unknown) => void} [onParsed] */ /** * Fastify plugin that parses the User-Agent and attaches * the result to `request.ua` (configurable via `options.property`). * * import { uaPlugin } from '@exortek/ua/middleware/fastify'; * * await app.register(uaPlugin, { detectBots: true }); * * app.get('/', async (request) => { * console.log(request.ua.browser.name); // 'Chrome' * console.log(request.ua.bot); // null or { name, type, category } * }); * * @param {import('fastify').FastifyInstance} fastify * @param {UAPluginOptions} options */ declare const uaPlugin: Function; type UAPluginOptions = { clientHints?: boolean | undefined; sendAcceptCH?: boolean | undefined; detectBots?: boolean | undefined; property?: string | undefined; onUnknown?: ((ua: string) => void) | undefined; onBot?: ((bot: BotInfo, req: unknown) => boolean | void) | undefined; onParsed?: ((result: object, req: unknown) => void) | undefined; }; export { uaPlugin as default, uaPlugin }; export type { UAPluginOptions };