@adonisjs/shield
Version:
A middleware for AdonisJS to keep web applications secure from common web attacks
26 lines (25 loc) • 718 B
TypeScript
import { type PluginFn } from '@japa/runner/types';
declare const CSRF_ENABLED: unique symbol;
declare module '@japa/api-client' {
interface ApiRequest {
[CSRF_ENABLED]: boolean;
withCsrfToken(): this;
}
}
/**
* Configures the API client plugin to support CSRF tokens.
* Adds a `withCsrfToken()` method to API requests that automatically
* generates and includes CSRF tokens for testing.
*
* @example
* const plugin = shieldApiClient()
*
* test('authenticated request', async ({ client }) => {
* const response = await client
* .post('/api/users')
* .withCsrfToken()
* .json({ name: 'John' })
* })
*/
export declare const shieldApiClient: () => PluginFn;
export {};