> {
name: string;
phase: 'cheap' | 'heavy';
isEnabled(config: BotDetectorConfig): boolean;
run(ctx: ValidationContext, config: BotDetectorConfig): Promise<{
score: number;
reasons: Code[] | BanReasonCode[];
}> | {
score: number;
reasons: Code[] | BanReasonCode[];
};
}
//#endregion
//#region src/botDetector/types/fingerPrint.d.ts
interface userValidation {
cookie: string | null;
visitorId: string;
userAgent: string;
ipAddress: string;
country: string | null;
region: string | null;
regionName: string | null;
city: string | null;
district: string | null;
lat: string | null;
lon: string;
timezone: string | null;
currency: string | null;
isp: string | null;
org: string | null;
as: string | null;
device_type: string | null;
browser: string | null;
proxy: boolean;
hosting: boolean;
is_bot: boolean;
first_seen: string | null;
last_seen: string | null;
request_count: number;
deviceVendor?: string;
deviceModel?: string;
browserType?: string;
browserVersion?: string;
os?: string;
activity_score?: string;
}
//#endregion
//#region src/botDetector/types/batchQueue.d.ts
interface VisitorUpsertParams {
insert: userValidation;
}
interface ScoreUpdateParams {
score: number;
cookie: string;
}
interface IsBotUpdateParams {
isBot: boolean;
cookie: string;
}
interface BannedIpParams {
cookie: string;
ipAddress: string;
country: string;
user_agent: string;
info: BannedInfo;
}
interface OpParams {
visitor_upsert: VisitorUpsertParams;
score_update: ScoreUpdateParams;
is_bot_update: IsBotUpdateParams;
update_banned_ip: BannedIpParams;
}
type BatchQueueOps = 'visitor_upsert' | 'score_update' | 'is_bot_update' | 'update_banned_ip';
type Priority = 'immediate' | 'deferred';
//#endregion
//#region src/botDetector/db/batchQueue.d.ts
declare class BatchQueue {
private jobs;
private timer;
private flushPromise;
private get config();
private get log();
addQueue(canary: string, ipAddress: string, type: T, params: OpParams[T], priority?: Priority): Promise;
flush(): Promise;
private runJob;
private executeBatch;
shutdown(): Promise;
}
//#endregion
//#region src/botDetector/config/config.d.ts
/**
* @description
* The bot detector library's configuration object.
* Contains the core configuration to make the library usable client side.
* @module jwtAuth/config
* @see {@link ./jwtAuth/types/configSchema.js}
*/
declare function configuration(config: BotDetectorConfigInput): Promise;
declare function getBatchQueue(): BatchQueue;
declare function getStorage(): Storage;
declare function getDb(): Database;
declare function getDataSources(): DataSources;
//#endregion
//#region node_modules/@types/express-serve-static-core/index.d.ts
declare global {
namespace Express {
// These open interfaces may be extended in an application-specific manner via declaration merging.
// See for example method-override.d.ts (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/method-override/index.d.ts)
interface Request {}
interface Response {}
interface Locals {}
interface Application {}
}
}
interface NextFunction {
(err?: any): void;
/**
* "Break-out" of a router by calling {next('router')};
* @see {https://expressjs.com/en/guide/using-middleware.html#middleware.router}
*/
(deferToNext: "router"): void;
/**
* "Break-out" of a route by calling {next('route')};
* @see {https://expressjs.com/en/guide/using-middleware.html#middleware.application}
*/
(deferToNext: "route"): void;
}
interface ParamsDictionary {
[key: string]: string | string[];
[key: number]: string;
}
interface ParamsFlatDictionary {
[key: string | number]: string;
}
interface Locals extends Express.Locals {}
interface RequestHandler$1 = Record> {
// tslint:disable-next-line callable-types (This is extended from and can't extend from a type alias in ts<2.2)
(req: Request$1, res: Response, next: NextFunction): unknown;
}
type ErrorRequestHandler = Record> = (err: any, req: Request$1, res: Response, next: NextFunction) => unknown;
type PathParams = string | RegExp | Array;
type RequestHandlerParams = Record> = RequestHandler$1 | ErrorRequestHandler
| Array | ErrorRequestHandler>;
type RemoveTail = S extends `${infer P}${Tail}` ? P : S;
type GetRouteParameter = RemoveTail, `-${string}`>, `.${string}`>; // dprint-ignore
type RouteParameters = Route extends string ? Route extends `${infer Required}{${infer Optional}}${infer Next}` ? ParseRouteParameters & Partial> & RouteParameters : ParseRouteParameters : ParamsFlatDictionary;
type ParseRouteParameters = string extends Route ? ParamsDictionary : Route extends `${string}:${infer Rest}` ? (GetRouteParameter extends never ? ParamsDictionary : { [P in GetRouteParameter]: string }) & (Rest extends `${GetRouteParameter}${infer Next}` ? RouteParameters : unknown) : Route extends `${string}*${infer Rest}` ? (GetRouteParameter extends never ? ParamsDictionary : { [P in GetRouteParameter]: string[] }) & (Rest extends `${GetRouteParameter}${infer Next}` ? RouteParameters : unknown) : {};
/* eslint-disable @definitelytyped/no-unnecessary-generics */
interface IRouterMatcher {
, ResBody = any, ReqBody = any, ReqQuery = ParsedQs, LocalsObj extends Record = Record>(// (it's used as the default type parameter for P)
path: Route, // (This generic is meant to be passed explicitly.)
...handlers: Array>): T;
, ResBody = any, ReqBody = any, ReqQuery = ParsedQs, LocalsObj extends Record = Record>(// (it's used as the default type parameter for P)
path: Path, // (This generic is meant to be passed explicitly.)
...handlers: Array>): T;
= Record>(path: PathParams, // (This generic is meant to be passed explicitly.)
...handlers: Array>): T;
= Record>(path: PathParams, // (This generic is meant to be passed explicitly.)
...handlers: Array>): T;
(path: PathParams, subApplication: Application): T;
}
interface IRouterHandler {
(...handlers: Array>>): T;
(...handlers: Array>>): T;
, ResBody = any, ReqBody = any, ReqQuery = ParsedQs, LocalsObj extends Record = Record>(// (This generic is meant to be passed explicitly.)
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
...handlers: Array>): T;
, ResBody = any, ReqBody = any, ReqQuery = ParsedQs, LocalsObj extends Record = Record>(// (This generic is meant to be passed explicitly.)
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
...handlers: Array>): T;
= Record>(// (This generic is meant to be passed explicitly.)
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
...handlers: Array>): T;
= Record>(// (This generic is meant to be passed explicitly.)
// eslint-disable-next-line @definitelytyped/no-unnecessary-generics
...handlers: Array>): T;
}
/* eslint-enable @definitelytyped/no-unnecessary-generics */
interface IRouter extends RequestHandler$1 {
/**
* Map the given param placeholder `name`(s) to the given callback(s).
*
* Parameter mapping is used to provide pre-conditions to routes
* which use normalized placeholders. For example a _:user_id_ parameter
* could automatically load a user's information from the database without
* any additional code,
*
* The callback uses the samesignature as middleware, the only differencing
* being that the value of the placeholder is passed, in this case the _id_
* of the user. Once the `next()` function is invoked, just like middleware
* it will continue on to execute the route, or subsequent parameter functions.
*
* app.param('user_id', function(req, res, next, id){
* User.find(id, function(err, user){
* if (err) {
* next(err);
* } else if (user) {
* req.user = user;
* next();
* } else {
* next(new Error('failed to load user'));
* }
* });
* });
*/
param(name: string, handler: RequestParamHandler): this;
/**
* Special-cased "all" method, applying the given route `path`,
* middleware, and callback to _every_ HTTP method.
*/
all: IRouterMatcher;
get: IRouterMatcher;
post: IRouterMatcher;
put: IRouterMatcher;
delete: IRouterMatcher;
patch: IRouterMatcher;
options: IRouterMatcher;
head: IRouterMatcher;
checkout: IRouterMatcher;
connect: IRouterMatcher;
copy: IRouterMatcher;
lock: IRouterMatcher;
merge: IRouterMatcher;
mkactivity: IRouterMatcher;
mkcol: IRouterMatcher;
move: IRouterMatcher;
"m-search": IRouterMatcher