type BotConfidence = "high" | "medium" | "low"; type BotInfo = { name: string; version?: string | undefined; type: string; category: string; confidence: BotConfidence; }; /** * @typedef {Object} UAMiddlewareOptions * @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] */ /** * Express middleware that parses the User-Agent and attaches * the result to `req.ua` (configurable via `options.property`). * * import { uaMiddleware } from '@exortek/ua/middleware/express'; * * // Route-level (recommended) * app.get('/', uaMiddleware(), (req, res) => { * console.log(req.ua.browser.name); // 'Chrome' * console.log(req.ua.bot); // null or { name, type, category } * }); * * // Or global * app.use(uaMiddleware()); * * @param {UAMiddlewareOptions} [options] * @returns {Function} */ declare function uaMiddleware(options?: UAMiddlewareOptions): Function; type UAMiddlewareOptions = { 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 { uaMiddleware }; export type { UAMiddlewareOptions };