Skip to content

Commit ea98705

Browse files
committed
chore(release): 4.0.0
1 parent 52b2dce commit ea98705

File tree

6 files changed

+41
-9
lines changed

6 files changed

+41
-9
lines changed

CHANGELOG.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
3+
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4+
5+
## [4.0.0](https://github.com/Psifi-Solutions/csrf-csrf/compare/v3.0.7...v4.0.0) (2025-04-27)
6+
7+
8+
### ⚠ BREAKING CHANGES
9+
10+
This list may not be an exhaustive list of breaking changes, for more information consult the [version 3 -> 4 upgrade guide](./UPGRADING.md#version-3---4) and the updated configuration documentation in the [README](./README.md).
11+
12+
* Token generation now uses `createHmac`, the format has changed significantly, see the [CSRF token format](./UPGRADING.md#csrf-token-format-has-changed) section of the upgrade guide.
13+
* `getSessionIdentifier` is now required and must return a unique identifier per-request (and per-session) - this is an essential part of CSRF token security
14+
* `getTokenFromRequest` renamed to `getCsrfTokenFromRequest`
15+
* `generateToken` renamed to `generateCsrfToken`
16+
* `overwrite` and `validateOnReuse` parameters for `generateCsrfToken` have been merged into a single object parameter which also accepts `cookieOptions`: `generateCsrfToken(req, res, options);`
17+
* Default value for `validateOnReuse` is now `false`
18+
* Default value for `cookieOptions.sameSite` is now `strict`
19+
* `cookieOptions.signed` is no longer available, CSRF tokens are inherently signed, this is redundant
20+
* `delimiter` option removed, `csrfTokenDelimiter` and `messageDelimiter` are now used for the respective purpose
21+
* `signed` option in `cookieOptions` config option removed (redundant), csrf tokens generated by csrf-csrf are inherently signed
22+
* `size` config option now sets the size of the message used to construct the hmac, now defaults to `32` instead of `64`, this is combined with the return value of `getSessionIdentifier` to construct the hmac payload
23+
* Type `CsrfTokenCookieOverrides` renamed to `CsrfTokenCookieOptions`
24+
* Type `CsrfTokenCreator` renamed to `CsrfTokenGenerator`
25+
* Type `doubleCsrfProtection` renamed to `DoubleCsrfProtection`
26+
* Type `RequestMethod` renamed to `CsrfRequestMethod`
27+
* Type `CsrfIgnoredMethods` renamed to `CsrfIgnoredRequestMethods`
28+
29+
### Features
30+
31+
* change default value of sameSite to 'strict' ([ba5973e](https://github.com/Psifi-Solutions/csrf-csrf/commit/ba5973e44ddf7fdf0baeff038855f7307a5a1cd9))
32+
* change validateOnReuse to false by default ([5fc62a9](https://github.com/Psifi-Solutions/csrf-csrf/commit/5fc62a98b797a7e1bc81a5d98a1c0509e1de4e76))
33+
* expose per token cookie settings ([#60](https://github.com/Psifi-Solutions/csrf-csrf/issues/60)) ([456b317](https://github.com/Psifi-Solutions/csrf-csrf/commit/456b3179eac02deeb90cd7112f7ddbd6377c9758))
34+
* **types:** add CsrfTokenGeneratorRequestUtil type ([72fd659](https://github.com/Psifi-Solutions/csrf-csrf/commit/72fd659f7e8ee9e82e820b1da9c393c4864dc43d))
35+
* use hmac to generate csrf tokens ([e4c5ec3](https://github.com/Psifi-Solutions/csrf-csrf/commit/e4c5ec3ec0dc801ef0fca2ef89e1e4ff79f85aad))
436

537
### [3.2.2](https://github.com/Psifi-Solutions/csrf-csrf/compare/v3.2.1...v3.2.2) (2025-04-24)
638

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<a href="#getting-started">Getting Started</a> •
2424
<a href="#configuration">Configuration</a> •
2525
<a href="#utilities">Utilities</a> •
26-
<a href="FAQ.md">FAQ</a> •
26+
<a href="./FAQ.md">FAQ</a> •
2727
<a href="#support">Support</a>
2828
</p>
2929

@@ -44,10 +44,10 @@
4444

4545
<h2 id="getting-started">Getting Started</h2>
4646

47-
<p><b>This branch is currently for the unreleased version 4, to find the README for the latest released version please see the <a href="https://github.com/Psifi-Solutions/csrf-csrf/tree/v3.x.x">v3.x.x branch</a>.</b></p>
47+
<p><b>Version 4 is now live!</b> If you are upgrading from version 3 check the <a href="./CHANGELOG.md">changelog</a>, the <a href="./UPGRADING.md">upgrade guide</a>, and the updated configuration documentation below.</p>
4848

4949
<p>
50-
Before getting started with <code>csrf-csrf</code> you should consult the <a href="FAQ.md">FAQ</a> and determine whether you need CSRF protection and whether <code>csrf-csrf</code> is the right choice.
50+
Before getting started with <code>csrf-csrf</code> you should consult the <a href="./FAQ.md">FAQ</a> and determine whether you need CSRF protection and whether <code>csrf-csrf</code> is the right choice.
5151
</p>
5252
<p>
5353
This section will guide you through using the default setup, which sufficiently implements the Double Submit Cookie Pattern. If you would like to customise the configuration, see the <a href="#configuration">configuration</a> section.

example/complete/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"license": "ISC",
1313
"dependencies": {
1414
"cookie-parser": "^1.4.6",
15-
"csrf-csrf": "file:../../csrf-csrf-3.2.0.tgz",
15+
"csrf-csrf": "4.0.0",
1616
"express": "^4.19.2",
1717
"express-session": "1.18.1"
1818
}

example/react/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"connect-redis": "8.0.3",
2525
"cookie-parser": "1.4.7",
2626
"cors": "2.8.5",
27-
"csrf-csrf": "file:./csrf-csrf-3.2.2.tgz",
27+
"csrf-csrf": "4.0.0",
2828
"ejs": "3.1.10",
2929
"express": "5.1.0",
3030
"express-session": "1.18.1",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "csrf-csrf",
3-
"version": "3.2.2",
3+
"version": "4.0.0",
44
"description": "A utility package to help implement stateless CSRF protection using the Double Submit Cookie Pattern in express.",
55
"type": "module",
66
"main": "./dist/index.cjs",

0 commit comments

Comments
 (0)