Skip to content

Commit

Permalink
Remove Expect-CT middleware
Browse files Browse the repository at this point in the history
See [#378](#378).
  • Loading branch information
EvanHahn committed Apr 8, 2023
1 parent f637c92 commit a2c38ee
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 276 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Removed

- **Breaking:** Drop support for Node 14 and 15. Node 16+ is now required
- **Breaking:** `Expect-CT` is no longer part of Helmet. If you still need it, you can use the [`expect-ct` package](https://www.npmjs.com/package/expect-ct). See [#378](https://github.com/helmetjs/helmet/issues/378)

## 6.1.1 - 2023-04-08

Expand Down
51 changes: 4 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ app.use(helmet.xssFilter());
<details>
<summary><code>helmet(options)</code></summary>

Helmet is the top-level middleware for this module, including all 15 others.
Helmet is the top-level middleware for this module, including all 14 others.

```js
// Includes all 15 middlewares
// Includes all 14 middlewares
app.use(helmet());
```

If you want to disable one, pass options to `helmet`. For example, to disable `frameguard`:

```js
// Includes 14 out of 15 middlewares, skipping `helmet.frameguard`
// Includes 13 out of 14 middlewares, skipping `helmet.frameguard`
app.use(
helmet({
frameguard: false,
Expand All @@ -133,7 +133,7 @@ app.use(
Most of the middlewares have options, which are documented in more detail below. For example, to pass `{ action: "deny" }` to `frameguard`:

```js
// Includes all 15 middlewares, setting an option for `helmet.frameguard`
// Includes all 14 middlewares, setting an option for `helmet.frameguard`
app.use(
helmet({
frameguard: {
Expand Down Expand Up @@ -360,49 +360,6 @@ You can install this module separately as `cross-origin-resource-policy`.

</details>

<details>
<summary><code>helmet.expectCt(options)</code></summary>

Default:

```http
Expect-CT: max-age=0
```

`helmet.expectCt` sets the `Expect-CT` header which helps mitigate misissued SSL certificates. See [MDN's article on Certificate Transparency](https://developer.mozilla.org/en-US/docs/Web/Security/Certificate_Transparency) and the [`Expect-CT` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT) for more.

`Expect-CT` is no longer useful for new browsers in 2022. Therefore, `helmet.expectCt` is deprecated and will be removed in the next major version of Helmet. However, it can still be used in this version of Helmet.

`options.maxAge` is the number of seconds to expect Certificate Transparency. It defaults to `0`.

`options.enforce` is a boolean. If `true`, the user agent (usually a browser) should refuse future connections that violate its Certificate Transparency policy. Defaults to `false`.

`options.reportUri` is a string. If set, complying user agents will report Certificate Transparency failures to this URL. Unset by default.

Examples:

```js
// Sets "Expect-CT: max-age=86400"
app.use(
helmet.expectCt({
maxAge: 86400,
})
);

// Sets "Expect-CT: max-age=86400, enforce, report-uri="https://example.com/report"
app.use(
helmet.expectCt({
maxAge: 86400,
enforce: true,
reportUri: "https://example.com/report",
})
);
```

You can install this module separately as `expect-ct`.

</details>

<details>
<summary><code>helmet.referrerPolicy(options)</code></summary>

Expand Down
10 changes: 0 additions & 10 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import crossOriginOpenerPolicy, {
import crossOriginResourcePolicy, {
CrossOriginResourcePolicyOptions,
} from "./middlewares/cross-origin-resource-policy/index.js";
import expectCt, { ExpectCtOptions } from "./middlewares/expect-ct/index.js";
import originAgentCluster from "./middlewares/origin-agent-cluster/index.js";
import referrerPolicy, {
ReferrerPolicyOptions,
Expand Down Expand Up @@ -39,7 +38,6 @@ export interface HelmetOptions {
crossOriginOpenerPolicy?: CrossOriginOpenerPolicyOptions | boolean;
crossOriginResourcePolicy?: CrossOriginResourcePolicyOptions | boolean;
dnsPrefetchControl?: XDnsPrefetchControlOptions | boolean;
expectCt?: ExpectCtOptions | boolean;
frameguard?: XFrameOptionsOptions | boolean;
hidePoweredBy?: boolean;
hsts?: StrictTransportSecurityOptions | boolean;
Expand Down Expand Up @@ -71,7 +69,6 @@ interface Helmet {
crossOriginOpenerPolicy: typeof crossOriginOpenerPolicy;
crossOriginResourcePolicy: typeof crossOriginResourcePolicy;
dnsPrefetchControl: typeof xDnsPrefetchControl;
expectCt: typeof expectCt;
frameguard: typeof xFrameOptions;
hidePoweredBy: typeof xPoweredBy;
hsts: typeof strictTransportSecurity;
Expand Down Expand Up @@ -145,11 +142,6 @@ function getMiddlewareFunctionsFromOptions(
result.push(xDnsPrefetchControl(...xDnsPrefetchControlArgs));
}

const expectCtArgs = options.expectCt && getArgs(options.expectCt);
if (expectCtArgs) {
result.push(expectCt(...expectCtArgs));
}

const xFrameOptionsArgs = getArgs(options.frameguard);
if (xFrameOptionsArgs) {
result.push(xFrameOptions(...xFrameOptionsArgs));
Expand Down Expand Up @@ -256,7 +248,6 @@ const helmet: Helmet = Object.assign(
crossOriginOpenerPolicy,
crossOriginResourcePolicy,
dnsPrefetchControl: xDnsPrefetchControl,
expectCt,
frameguard: xFrameOptions,
hidePoweredBy: xPoweredBy,
hsts: strictTransportSecurity,
Expand All @@ -276,7 +267,6 @@ export {
crossOriginEmbedderPolicy,
crossOriginOpenerPolicy,
crossOriginResourcePolicy,
expectCt,
originAgentCluster,
referrerPolicy,
strictTransportSecurity as hsts,
Expand Down
33 changes: 0 additions & 33 deletions middlewares/expect-ct/CHANGELOG.md

This file was deleted.

29 changes: 0 additions & 29 deletions middlewares/expect-ct/README.md

This file was deleted.

48 changes: 0 additions & 48 deletions middlewares/expect-ct/index.ts

This file was deleted.

11 changes: 0 additions & 11 deletions middlewares/expect-ct/package-overrides.json

This file was deleted.

78 changes: 0 additions & 78 deletions test/expect-ct.test.ts

This file was deleted.

Loading

0 comments on commit a2c38ee

Please sign in to comment.