csrf-monkey
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "csrf-monkey", | ||
"version": "1.0.3", | ||
"description": "Monkeypatch xhr and fetch to automatically add csrf tokens to clientside requests", | ||
"version": "1.0.4", | ||
"description": "Automatically add CSRF headers to all clientside requests", | ||
"main": "index.js", | ||
@@ -48,4 +48,5 @@ "scripts": { | ||
"xhr", | ||
"fetch" | ||
"fetch", | ||
"monkey" | ||
] | ||
} |
@@ -6,8 +6,8 @@ [![Travis CI](https://travis-ci.org/alanclarke/csrf-monkey.svg?branch=master)](https://travis-ci.org/alanclarke/csrf-monkey) | ||
# csrf-monkey | ||
Clientside csrf made simple | ||
Automatically add CSRF headers to all clientside requests | ||
- handles both xhr and fetch | ||
- small footprint, no dependencies | ||
- configurable, testable and restorable | ||
- handles both xhr and fetch | ||
- 100% test coverage | ||
- small footprint, no dependencies | ||
@@ -34,10 +34,8 @@ ## Installation | ||
Then call `csrf-monkey` to patch xhr and window.fetch to automatically include the csrf token in all requests | ||
Then call `csrf-monkey`. This will patch xhr and window.fetch so that your csrf token is automatically included in all clientside requests | ||
```js | ||
var axios = require('axios') | ||
var csrfMonkey = require('csrf-monkey') | ||
csrfMonkey() | ||
require('csrf-monkey')() | ||
fetch('/api') // request will include csrf header ('x-csrf-token': value) | ||
@@ -47,7 +45,6 @@ axios.get('/api') // request will include csrf header ('x-csrf-token': value) | ||
## Options | ||
```js | ||
// csrfMonkey(header, token) | ||
var csrfMonkey = require('csrf-monkey') | ||
csrfMonkey(header, token) | ||
@@ -54,0 +51,0 @@ // you can also pass a custom header to csrf-monkey: |
17406
66