consent-warden

Warden · privacy & compliance

consent-warden

Check that your cookie banner actually behaves: nothing non-essential loads before opt-in, Reject is as easy as Accept, and consent can be withdrawn.

npm i -D @mrlouiswright/consent-warden

Published to GitHub Packages: add @mrlouiswright:registry=https://npm.pkg.github.com to .npmrc first (installing needs a token with read:packages).

What it checks

  • Loading before opt-intracking scripts, inline SDK snippets and pixels must be blocked until consent: type="text/plain" with a category (data-category, data-cookieconsent, data-cookiecategory, ...), a consent check in the snippet…
  • Consent Modegtag("consent","default",…) granting ad_storage/analytics_storage up front, or Google tags with no default at all.
  • EmbedsYouTube, Vimeo, Google Maps, Google Fonts and social/chat widgets that load before consent (use click-to-load or self-host).
  • Banner presencepages that load trackers with no banner and no CMP (Cookiebot, OneTrust, Usercentrics, Klaro, CookieConsent, Complianz, iubenda, Osano, Termly, CookieYes are recognised).
  • Equal choiceAccept without Reject on the first layer, Reject as a link or with weaker styling than Accept, pre-ticked non-essential checkboxes, implied-consent wording ("by continuing to browse…").
  • Withdrawala persistent "Cookie settings" link or button outside the banner.

Quick usage

CLI

npx consent-warden dist
npx consent-warden dist --fail-on medium
npx consent-warden public --essential plausible --allow-embeds
npx consent-warden out --cmp-provides-withdraw --format sarif > consent.sarif

API

import { check } from "consent-warden";
const report = check("dist", { essential: ["plausible"] });
console.log(report.counts);

Every option is documented in the consent-warden docs.

CI / GitHub Action

permissions:
  contents: read
  security-events: write   # only needed for the SARIF upload
jobs:
  consent-warden:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
        with: { persist-credentials: false }
      - run: npm ci && npm run build   # produce the static site first
      - uses: MrLouisWright/consent-warden@v1
        with:
          path: dist
          fail-on: high
          sarif: consent-warden.sarif
      - uses: github/codeql-action/upload-sarif@v3
        if: always()
        with: { sarif_file: consent-warden.sarif }