import { Filter } from '../api/request'; import { ModuleInfo } from '../module'; import { BaseStartupTask } from './'; export declare const EVENT_CSRF_TOKEN_FAILURE = "CSRF_TOKEN_FAILURE"; export declare const DEFAULT_SEND_COOKIE_NAME = "xsrf-token"; export declare const ERROR_TOKEN_INVALID = "EBADCSRFTOKEN"; export declare const PRS_CSRF_TOKEN = "$csrf.token"; export declare const PRS_VIEW_CSRF_TOKEN = "$view.context.csrf.token"; /** * CSRFTokenConf can be configured to enabled cross-site request forgery * protection. */ export interface CSRFTokenConf { /** * enable if true will enable csrf protection. */ enable?: boolean; /** * send_cookie if true will send a cookie to the client on each read * request containing the value of the current token. * Note: This is not the double submit pattern but rather a way for XHR * requests to retrieve the token. */ send_cookie?: boolean; /** * send_cookie_name if set will be used as the name of the cookie used * to send the token value. * * Defaults to DEFAULT_SEND_COOKIE_NAME. */ send_cookie_name?: string; /** * options passed on to the middleware. */ options?: object; /** * on hooks. */ on?: { /** * failure if specified will be invoked whenever a request fails CSRF * token validation. */ failure?: Filter; }; } /** * CSRFTokenSupportTask configures middleware to help protect against CSRF attacks. * * This requires app.session.enable to be set to true. */ export declare class CSRFTokenSupportTask extends BaseStartupTask { name: string; execute(mod: ModuleInfo): Promise; }