The `expect-ct` package provides Express middleware for setting the deprecated Expect-CT HTTP response header. This header was designed to enforce Certificate Transparency (CT) requirements by instructing browsers to expect valid Signed Certificate Timestamps (SCTs) for a website's TLS certificates. However, the Expect-CT header itself has been deprecated by major browsers (e.g., Chrome removed support in version 107 in October 2022) as Certificate Transparency is now a baseline requirement enforced by default across all publicly trusted certificates. As such, this middleware, currently at version 1.0.0 (though `1.0.1` is on npm, published 3 years ago), offers minimal practical security benefit for modern web applications. The Helmet.js project, which originally included this functionality, removed `expect-ct` from its default middlewares in Helmet v5 due to its obsolescence.
npm install expect-ctVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate `expect-ct` middleware into an Express application to set the Expect-CT header, including options for `maxAge`, `enforce`, and `reportUri`.
Consider removing the `expect-ct` middleware entirely from new projects. For existing projects, its removal will likely have no adverse security impact on modern browsers.
To achieve similar (though now largely ineffective) functionality with Helmet v5+, explicitly install `expect-ct` (`npm install expect-ct`) and use `app.use(expectCt(options))` alongside Helmet.
Ensure your application is served exclusively over HTTPS for any Expect-CT policy to be considered by the browser. However, given the header's deprecation, investing in this is generally not recommended.
Be aware that any 'protection' offered by this header was limited to a subset of browsers. This further reduces its utility for broad web security.
For CommonJS: `const expectCt = require('expect-ct');`. For ESM: `import expectCt from 'expect-ct';` (without curly braces).Contact your Certificate Authority (CA) to ensure your certificates include Signed Certificate Timestamps (SCTs) and are properly logged in CT logs. This is a fundamental requirement for modern certificates, irrespective of the Expect-CT header.