-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ICrowdSecHTTPMiddlewareOptions.ts
43 lines (38 loc) · 1.54 KB
/
ICrowdSecHTTPMiddlewareOptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import type { IBouncerAuthentication, ITLSAuthentication, IWatcherAuthentication } from 'crowdsec-client';
import { ICrowdSecClientOptions } from 'crowdsec-client';
import { IncomingMessage } from 'http';
import { IScenarioConstructor, IScenarioOptions } from 'crowdsec-client-scenarios';
export type logFn = (message?: any, ...optionalParams: any[]) => void;
export type logger = {
debug: logFn;
warn: logFn;
error: logFn;
info: logFn;
extend?: (name: string) => logger;
};
export type loggerOption = logger | ((name: string) => logger);
export interface ICommonOptions {
/**
* IP objects keep in cache .
* ( usefully on really high load, without multiples instances )
*/
maxIpCache?: number;
logger?: loggerOption;
}
export type ICrowdSecHTTPBouncerMiddlewareOptions = (IBouncerAuthentication | ITLSAuthentication) & {
pollingInterval?: number;
} & ICommonOptions;
export type ICrowdSecHTTPWatcherMiddlewareOptions = (IWatcherAuthentication | ITLSAuthentication) & {
heartbeat?: boolean;
scenarios?: Array<IScenarioConstructor | string>;
scenariosOptions?: IScenarioOptions;
} & ICommonOptions;
export type getCurrentIpFn = (req: IncomingMessage) => string;
export interface ICrowdSecHTTPMiddlewareOptions extends ICommonOptions {
url: ICrowdSecClientOptions['url'];
bouncer?: ICrowdSecHTTPBouncerMiddlewareOptions;
watcher?: ICrowdSecHTTPWatcherMiddlewareOptions;
clientOptions?: Omit<ICrowdSecClientOptions, 'url'>;
getCurrentIp?: getCurrentIpFn;
protectedByHeader?: boolean;
}