-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for ctx.state.csrf (backwards compatible), moderniz…
…e repo, require node >=14
- Loading branch information
Showing
21 changed files
with
244 additions
and
8,913 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: ['@commitlint/config-conventional'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!.*.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: CI | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
node_version: | ||
- 14 | ||
- 16 | ||
- 18 | ||
name: Node ${{ matrix.node_version }} on ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node_version }} | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Run tests | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
# OS # | ||
################### | ||
.DS_Store | ||
*.log | ||
.idea | ||
Thumbs.db | ||
tmp/ | ||
temp/ | ||
|
||
|
||
# Node.js # | ||
################### | ||
node_modules | ||
coverage | ||
.nyc_output | ||
locales/ | ||
package-lock.json | ||
npm-debug.log | ||
yarn-debug.log | ||
yarn-error.log | ||
yarn.lock | ||
|
||
|
||
# NYC # | ||
################### | ||
coverage | ||
Thumbs.db | ||
tmp/ | ||
temp/ | ||
*.lcov | ||
.nyc_output | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx --no-install commitlint --edit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx --no-install lint-staged && npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
'*.md': (filenames) => filenames.map((filename) => `remark ${filename} -qfo`), | ||
'package.json': 'fixpack', | ||
'*.js': 'xo --fix' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
singleQuote: true, | ||
bracketSpacing: true, | ||
trailingComma: 'none' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
plugins: ['preset-github'] | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
prettier: true, | ||
space: true, | ||
extends: ['xo-lass'] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
(The MIT License) | ||
The MIT License | ||
|
||
Copyright (c) 2014 Jonathan Ong <[email protected]> && Nick Baugh <[email protected]> | ||
Copyright (c) 2014 Jonathan Ong <[email protected]> & Nick Baugh <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# koa-csrf | ||
|
||
[](https://github.com/koajs/csrf/actions/workflows/ci.yml) | ||
[](https://travis-ci.com/koajs/csrf) | ||
[](https://codecov.io/gh/koajs/csrf) | ||
[](https://github.com/sindresorhus/xo) | ||
[](https://github.com/prettier/prettier) | ||
[](https://lass.js.org) | ||
|
@@ -22,20 +22,12 @@ | |
|
||
## Install | ||
|
||
> For versions of Koa <2.x please use `[email protected]` | ||
[npm][]: | ||
|
||
```sh | ||
npm install koa-csrf | ||
``` | ||
|
||
[yarn][]: | ||
|
||
```sh | ||
yarn add koa-csrf | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
|
@@ -60,7 +52,7 @@ yarn add koa-csrf | |
app.use(bodyParser()); | ||
|
||
// add the CSRF middleware | ||
app.use(CSRF({ | ||
app.use(new CSRF({ | ||
invalidTokenMessage: 'Invalid CSRF token', | ||
invalidTokenStatusCode: 403, | ||
excludedMethods: [ 'GET', 'HEAD', 'OPTIONS' ], | ||
|
@@ -72,7 +64,7 @@ yarn add koa-csrf | |
if (![ 'GET', 'POST' ].includes(ctx.method)) | ||
return next(); | ||
if (ctx.method === 'GET') { | ||
ctx.body = ctx.csrf; | ||
ctx.body = ctx.state.csrf; | ||
return; | ||
} | ||
ctx.body = 'OK'; | ||
|
@@ -132,10 +124,8 @@ yarn add koa-csrf | |
[MIT](LICENSE) © [Jonathan Ong](http://jongleberry.com) | ||
|
||
|
||
## | ||
## | ||
|
||
[@ladjs/i18n]: https://github.com/ladjs/i18n | ||
|
||
[npm]: https://www.npmjs.com/ | ||
|
||
[yarn]: https://yarnpkg.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.