Skip to content

Commit 293bd18

Browse files
sohrbEvanHahn
authored andcommitted
Strict-Transport-Security: increase max-age to 1 year
See [#457] and [#459]. [#457]: #457 [#459]: #459
1 parent 898cdc4 commit 293bd18

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## 8.0.0
44

5+
### Changed
6+
7+
- **Breaking:** `Strict-Transport-Security` now has a max-age of 365 days, up from 180
8+
59
### Removed
610

711
- **Breaking:** Drop support for Node 16 and 17. Node 18+ is now required

middlewares/strict-transport-security/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { IncomingMessage, ServerResponse } from "http";
22

3-
const DEFAULT_MAX_AGE = 180 * 24 * 60 * 60;
3+
const DEFAULT_MAX_AGE = 365 * 24 * 60 * 60;
44

55
export interface StrictTransportSecurityOptions {
66
maxAge?: number;

test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe("helmet", () => {
3535
"cross-origin-resource-policy": "same-origin",
3636
"origin-agent-cluster": "?1",
3737
"referrer-policy": "no-referrer",
38-
"strict-transport-security": "max-age=15552000; includeSubDomains",
38+
"strict-transport-security": "max-age=31536000; includeSubDomains",
3939
"x-content-type-options": "nosniff",
4040
"x-dns-prefetch-control": "off",
4141
"x-download-options": "noopen",

test/strict-transport-security.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import strictTransportSecurity from "../middlewares/strict-transport-security";
33

44
describe("Strict-Transport-Security middleware", () => {
55
it('by default, sets max-age to 180 days and adds "includeSubDomains"', async () => {
6-
expect(15552000).toStrictEqual(180 * 24 * 60 * 60);
6+
expect(31536000).toStrictEqual(365 * 24 * 60 * 60);
77

88
const expectedHeaders = {
9-
"strict-transport-security": "max-age=15552000; includeSubDomains",
9+
"strict-transport-security": "max-age=31536000; includeSubDomains",
1010
};
1111

1212
await check(strictTransportSecurity(), expectedHeaders);
@@ -45,20 +45,20 @@ describe("Strict-Transport-Security middleware", () => {
4545

4646
it("disables subdomains with the includeSubDomains option", async () => {
4747
await check(strictTransportSecurity({ includeSubDomains: false }), {
48-
"strict-transport-security": "max-age=15552000",
48+
"strict-transport-security": "max-age=31536000",
4949
});
5050
});
5151

5252
it("can enable preloading", async () => {
5353
await check(strictTransportSecurity({ preload: true }), {
5454
"strict-transport-security":
55-
"max-age=15552000; includeSubDomains; preload",
55+
"max-age=31536000; includeSubDomains; preload",
5656
});
5757
});
5858

5959
it("can explicitly disable preloading", async () => {
6060
await check(strictTransportSecurity({ preload: false }), {
61-
"strict-transport-security": "max-age=15552000; includeSubDomains",
61+
"strict-transport-security": "max-age=31536000; includeSubDomains",
6262
});
6363
});
6464

0 commit comments

Comments
 (0)