# @types/koa-csrf

> TypeScript definitions for koa-csrf

Latest version **5.0.4** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/koa-csrf
pnpm add @types/koa-csrf
yarn add @types/koa-csrf
bun add @types/koa-csrf
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 5.0.4 |
| Published | 2023-11-07 |
| First published | 2018-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 4.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51393 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/koa-csrf
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-csrf
- npm.io page: https://npm.io/package/@types/koa-csrf

## Dependencies (1)

- [@types/koa](https://npm.io/package/@types/koa.md) *

## Recent versions

- 5.0.4 (latest) — 2023-11-07
- 5.0.1 (ts4.2) — 2023-03-09
- 5.0.0 (ts4.0) — 2022-08-17
- 3.0.2 (ts3.6) — 2021-07-08
- 3.0.1 (ts2.3) — 2018-07-10
- 5.0.3 — 2023-10-18
- 5.0.2 — 2023-09-14
- 3.0.0 — 2018-01-02

## README

# Installation
> `npm install --save @types/koa-csrf`

# Summary
This package contains type definitions for koa-csrf (https://github.com/koajs/csrf).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-csrf.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-csrf/index.d.ts)
````ts
/* =================== USAGE ===================
import * as CSRF from "koa-csrf";
import * as Koa from "koa";
const app = new Koa();

app.use(new CSRF({
    errorHandler(ctx) {
        return ctx.throw(403, 'Invalid CSRF token');
    },
    excludedMethods: ['GET', 'HEAD', 'OPTIONS'],
    disableQuery: false,
    ignoredPathGlobs: []
}));
 =============================================== */

export = CSRF;

import { Context, Middleware } from "koa";

declare module "koa" {
    interface DefaultState {
        _csrf: string;
    }
}

declare const CSRF: {
    new(opts?: {
        errorHandler?: (ctx: Context) => never;
        excludedMethods?: string[];
        disableQuery?: boolean;
        ignoredPathGlobs?: string[];
    }): Middleware;
};

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 09:09:38 GMT
 * Dependencies: [@types/koa](https://npmjs.com/package/@types/koa)

# Credits
These definitions were written by [Haskaalo](https://github.com/haskaalo), and [Kirill Shvets](https://github.com/kirillshvets).

---
_Source: https://npm.io/package/@types/koa-csrf · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
