Skip to content

Beta. consent-kit is at 0.x: expect breaking changes between releases, and treat everything it generates as a draft. Report a problem or share feedback.

consent-kit audit <url> opens a running site in Chromium, operates its consent banner the way a visitor would, and compares what the browser did with what privacy.registry.yaml declares. This page lists its flags, exit codes, every check, the report formats and the programmatic API.

For a walk-through in a pipeline, see Run the audit in CI.

The audit lives in its own package, @consent-kit/audit, because it depends on Playwright. It is an optional peer dependency of consent-kit: the other commands work without it.

Terminal window
npm install --save-dev @consent-kit/audit
npx playwright install chromium

Without the package, consent-kit audit prints this hint and exits with code 2:

consent-kit: "consent-kit audit" needs the optional package @consent-kit/audit (and its browser, Playwright's Chromium), which is not installed.
Install it next to consent-kit, then run the command again:
npm install --save-dev @consent-kit/audit
npx playwright install chromium

The package also has its own bin, consent-kit-audit. It takes the same arguments. The only difference is the registry: consent-kit audit falls back to privacy.registry.yaml in the current directory, while consent-kit-audit requires --registry.

The audit needs Node.js 22 or later and drives Chromium only.

Terminal window
npx consent-kit audit http://localhost:4173

The one positional argument is the URL of the site. It must start with http:// or https://. Its origin is treated as the first party; every other origin is a third party.

The site has to be running already. The audit does not build or serve anything.

Flag Meaning Default
--registry <path> The registry of the site, resolved against the current directory. privacy.registry.yaml (consent-kit audit); required (consent-kit-audit)
--page <path> A page to audit. Repeat it for several. A path, or an absolute URL on the audited origin. /
--strict Declared artefacts that were never observed fail instead of warn. See Strict mode. off
--json Print the report as JSON instead of text. off
--check <id> Run only this check. Repeat it for several. See Running a subset. all checks
--exercise <file> An ES module that interacts with each page after it loads. See Exercise files. none
--headed Show the browser window. headless
-h, --help Print the help text and exit with code 0.

There are no flags for the banner selectors, the tolerances, the timeouts or the concurrency. Those are options of the programmatic API.

Code Meaning
0 No check failed. Warnings and skipped checks do not change the exit code.
1 At least one check failed.
2 Bad command line (no URL, a URL that is not http(s), an unknown flag or check id, an exercise file without a default-exported function), a registry file that cannot be read, a registry that is not valid, or @consent-kit/audit not installed.

A registry that fails validation is not audited. The validation errors are printed to stderr, followed by ... is not a valid registry; run "consent-kit check".

Every check runs in one or more fresh browser contexts: no cookies, no storage, no earlier decision. Up to six contexts are open at once, so the checks run in parallel.

In each context the audit records:

  • Requests. Every request the context makes, as origin plus pathname. Query strings and fragments are never recorded. A request with resource type script is observed as a script, the navigation of a frame as an iframe, anything else as a request. The audit’s own top-level navigations are not recorded.
  • Cookies and storage. After each page load and each decision, the browser’s cookie jar (HttpOnly cookies included), the localStorage and sessionStorage keys of the page, and the names of its IndexedDB databases.
  • Writes. Assignments to document.cookie and calls to Storage.prototype.setItem in the top-level page, so a key that is written and removed again between two snapshots is still seen. A cookie deletion (a max-age of zero or less, or an expires in the past) is not counted as a write.
  • Content-Security-Policy violations. Both refused requests and refused inline code.
  • The runtime guard. Whether the page’s HTML contains the inline guard, whether it installed (window.__ck_guard), and, when the guard records them in window.__ck_observed, the attempts it blocked.

After each page load the audit waits for the load event, runs the exercise function if there is one, waits until no request has started or finished for 300 ms (at most 8 seconds), and takes a snapshot.

The audit matches observations against the guard manifest compiled from the registry, the same data the runtime guard uses. So “declared” means the same thing in the audit as in the page.

  • Cookies, storage keys and IndexedDB databases match by exact name, or by a declared pattern tested against the whole key.
  • Scripts, iframes and requests match a declared origin, an absolute URL prefix or a site-relative path prefix. The origin must be equal and the path must be covered by whole segments: /collect covers /collect/x, not /collector.
  • A first-party URL that no artefact declares is ignored. These are the site’s own pages and assets.
  • Every cookie and storage key must be declared, first-party ones included.
  • What a cross-origin iframe loads inside itself is not recorded. The iframe itself is.

An artefact “needs consent” when it is bound to a purpose with basis: consent. Those purposes are the consent categories the audit switches on and off in the banner.

Every consent change is a click on the element a visitor would click. The audit expects CookieConsent v3 (vanilla-cookieconsent 3.x) and uses its markup:

Element Default selector
Banner (first layer) #cc-main .cm
Accept #cc-main .cm [data-role="all"]
Reject #cc-main .cm [data-role="necessary"]
Manage preferences #cc-main .cm [data-role="show"]
Preferences modal #cc-main .pm
Preferences link footer [data-cc="show-preferencesModal"], [role="contentinfo"] [data-cc="show-preferencesModal"]
Category toggle #cc-main .pm .pm__section-title-wrapper input.section__toggle[value="{category}"]
Save #cc-main .pm [data-role="save"]
Reject in the preferences #cc-main .pm [data-role="necessary"]

After each click the audit reads the consent cookie (cc_cookie) and waits until its categories say exactly what was clicked. Two findings come from this step and can appear under any check that drives the banner:

  • cannot-drive (error): an element was missing or could not be clicked. The message names the selector.
  • consent-not-recorded (error): the click went through, but the consent cookie was not written or holds other categories.

The audit sets navigator.webdriver to false in the page, because CookieConsent’s default hideFromBots would otherwise hide the banner from an automated browser.

There are twelve. Eight drive a browser. Four are derived from what those eight sessions observed.

A check has one of four statuses:

Status Printed as Meaning
pass PASS No findings.
warn WARN Only warnings.
fail FAIL At least one error.
skipped SKIP Not selected with --check.

A check that had less to do than usual carries a note, printed in parentheses after its title. The one note there is today is no purpose asks for consent; see Sites that ask for no consent.

A check that crashes, for example because the site is unreachable or the exercise function throws, fails with a check-error finding: the check could not complete: ....

Id Title as printed
pre-consent-silence 1. Pre-consent silence
reject-means-reject 2. Reject means reject
grant-activates-declared 3. Grant activates exactly what is declared
withdrawal-cleans-up 4. Withdrawal cleans up
gpc-honoured 5. GPC honoured
undeclared-drift 6. Undeclared drift
banner-ux 7. Banner UX
consent-receipts Consent receipts: one per decision
subject-requests Subject requests reachable
attribute-drift Coverage: attribute drift
unexercised Coverage: unexercised declarations
guard-installed Setup: runtime guard installed
csp-violations Setup: no Content-Security-Policy violations in the page itself

Checks 1 to 5 judge declared artefacts against the consent state the audit put the banner in. Anything that is not in the registry at all is reported once, by check 6.

Loads each audited page in its own fresh context and clicks nothing.

  • Fails (wrong-purpose) for every declared artefact that needs consent and was requested, written or present. A request the Content-Security-Policy blocked never left the browser and is not counted.
  • Warns (guard-blocked) when the runtime guard recorded an attempt it blocked: the page tried to use something without consent, and the guard stopped it.
  • Passes otherwise.

In one context: loads the first page, clicks Reject, then loads the other pages and the first page again. With a single audited page, the navigation is a reload of it.

If the first layer has no Reject button, the audit rejects through the preferences modal instead; the missing button is reported by banner-ux.

  • Fails (wrong-purpose) for every consent-bound artefact observed after the click, and with cannot-drive or consent-not-recorded when it could not reject.
  • Warns (guard-blocked) as in check 1.
  • Passes without opening a browser context, with the note no purpose asks for consent, when the registry has no consent purposes. There is nothing to reject, and check 1 already covers the site without a decision.

For each consent category, in its own context: loads the first page, opens the preferences, switches on that category alone, saves, then loads the other pages. The first page is not loaded a second time by the audit.

What appears after the grant must be exactly what the registry declares for the category. “Appears” means requests and writes made after the save, and cookies or keys that were not there before it.

  • Fails (wrong-purpose, message starting extra:) when granting one category also activated an artefact that needs another.
  • Fails (missing) for every artefact bound to this category alone that was not observed after the grant. An artefact bound to two consent categories is not expected here.
  • Fails with cannot-drive or consent-not-recorded when the category could not be granted.
  • Passes without opening a browser context when the registry has no consent purposes.

A missing finding often means the page that uses the artefact was not audited. This is the example site audited with the default --page / only:

FAIL 3. Grant activates exactly what is declared
error missing: iframe http://127.0.0.1:4174/embed (artefact "acme_video_embed") is declared for "media" but was not observed after granting it on /.

For each consent category that has at least one cookie, localStorage key, sessionStorage key or IndexedDB database bound to it: grants the category as in check 3, then reopens the preferences from the footer link, switches everything off and saves. It then reloads the page.

Categories that only declare scripts, iframes or endpoints leave nothing behind and are not driven.

  • Fails (not-cleaned) when a declared cookie or key of the category was still present after the withdrawal, or came back on the next page load.
  • Warns (not-verified) when a declared cookie or key was never set while the category was granted, so its cleanup could not be verified.
  • Fails with cannot-drive or consent-not-recorded when the grant or the withdrawal could not be made.

In one context that sends Sec-GPC: 1 with every request and exposes navigator.globalPrivacyControl === true: loads every page and clicks nothing.

  • Fails (wrong-purpose) for every consent-bound artefact that was used.
  • Warns (guard-blocked) as in check 1.

See Global Privacy Control.

In one context: loads every page before any decision, clicks Accept, and loads every page again.

  • Fails (undeclared) for every cookie, storage key, IndexedDB database, and third-party script, iframe or request that nothing in the registry declares. A request that the Content-Security-Policy blocked is still reported, as was attempted (and blocked by the Content-Security-Policy).
  • Warns (cannot-drive or consent-not-recorded, downgraded to a warning) when it could not accept. Only the journey before a decision was checked.

When the registry has no consent purposes there is no banner to accept, and the journey before a decision is the whole journey.

This check also collects the undeclared things that only another check’s session ran into, for example a cookie that first appears after a withdrawal. Each undeclared item is reported once.

Each finding carries a registry entry to paste. See Undeclared drift in the report.

In one context, on the first page:

  1. The banner must be visible to a visitor who has not decided.
  2. Accept and Reject must both be visible on the first layer.
  3. Accept and Reject must have equal visual weight.

Then it dismisses the banner and, on every audited page, looks for the preferences link in the footer and clicks it.

Equal visual weight is five ratios, each the smaller value divided by the larger:

Metric Must be at least
Area (width times height) 0.75
Height 0.75
Font size 0.75
Contrast of the label against the button (WCAG contrast ratio) 0.75
Contrast of the button against what is behind it 0.75

Both directions fail: a de-emphasised Accept is as unequal as a de-emphasised Reject.

  • Fails (banner-missing) when no banner is visible.
  • Fails (button-missing) for a missing Accept or Reject button.
  • Fails (unequal-weight), listing each metric out of tolerance with both values.
  • Fails (preferences-unreachable) for each page whose footer has no visible preferences link, or where clicking it does not open the preferences modal.

When the registry has no consent purposes the check is reversed: it loads every audited page and fails (banner-without-consent) for each one that shows a banner. A banner would ask for a consent that nothing needs. The check then carries the note no purpose asks for consent.

What it does depends on the receipts section of the registry.

With receipts.endpoint: in one context it loads the first page and accepts everything, then withdraws everything through the preferences. In a second context it loads the first page and rejects everything. Each of the three decisions must send exactly one POST to the endpoint (matched by origin and pathname).

The body must be a JSON object with exactly these fields: consentId, event, accepted, rejected, policyHash, revision, timestamp. The audit compares:

  • consentId with the one in the consent cookie;
  • event: first for the accept and the reject, change for the withdrawal;
  • accepted and rejected with the consent purposes and their versions, sorted by id;
  • policyHash with the hash of the audited registry;
  • revision: a non-negative integer;
  • timestamp: an ISO 8601 date and time.

Findings:

  • Fails (receipt-missing) when a decision sent no receipt.
  • Fails (receipt-duplicate) when a decision sent more than one.
  • Fails (receipt-malformed), listing every problem with the body.
  • Fails (receipts-not-stated) when the registry has consent purposes but no receipts section. consent-kit check refuses such a registry, so this is only reached through the programmatic API.
  • Warns (receipts-opted-out) when the registry opts out. No browser is driven. See Receipt opt-out.
  • Passes without a browser session when the registry has neither a receipts section nor consent purposes.

A policyHash mismatch usually means the site was built from a different registry than the one passed to the audit. See Receipts.

Only with subjectRequests; without it, it passes with the note “the registry declares no subject requests”. In one fresh context, before any consent decision:

  1. It loads the audited pages until one has a form whose action has the endpoint’s path. Failing that, it follows up to 25 same-origin links from them.
  2. The form must POST to the site’s own origin.
  3. It fills in email with audit-<time>@consent-kit.invalid (RFC 2606 reserves .invalid), picks the first type and submits. The endpoint must answer the POST with 303 See Other.
  4. The submission must make the browser contact no third party that the form page itself did not already contact.

Findings:

  • Fails (subject-request-form-missing): no page has the form or links to one that has it.
  • Fails (subject-request-form-foreign): the form posts to another origin, or not with POST.
  • Fails (subject-request-not-accepted): the form has no email field or submit button, or the endpoint did not answer 303.
  • Fails (subject-request-third-party): the submission contacted a third party.

It does not prove that the request was stored, that the mailbox was emailed, or that anyone answers. Those happen on the server, out of the browser’s sight. Against a live site it files one real request, which the controller should close as an audit test. The handler of @consent-kit/server stores and notifies it like any other, but sends no confirmation email to an .invalid address.

Derived. Compares every observed cookie that the registry declares with its declaration.

  • Duration. The lifetime is measured from the moment the audit first saw the cookie. It may differ from the declared duration by 1% of that duration, and always by one hour. A declaration above 400 days is compared against 400, because Chromium caps cookie lifetimes there. A cookie declared as session must not have an expiry, and the other way round.
  • Domain. Must equal the declared domain, or the audited host when none is declared. A leading dot is ignored.
  • SameSite. Compared only when declared.

Fails (attribute-drift) once per cookie and attribute. There are no warnings.

Derived. Lists every artefact written in the registry that no session observed.

  • Warns (unexercised) by default.
  • Fails with --strict.

A request that the Content-Security-Policy blocked does not count as observed.

WARN Coverage: unexercised declarations
warning localStorage key "theme" (artefact "theme") is declared but was never observed. Either no audited page or interaction uses it (add the page, or an "exercise" step), or the declaration is stale.

Derived. On every page load the audit notes whether the HTML contains the inline guard script and whether it installed.

Fails (guard-not-installed), once per page, when the guard is in the HTML but window.__ck_guard is not set. The message says which of two things happened: the browser refused the script because its text does not match the hash in the Content-Security-Policy, or no violation was seen and the script was most likely altered or cut short.

A page without any guard script is not reported. The guard is optional.

The usual cause is a formatter, minifier or template that changed the inlined guard.inline.js by a byte. See Runtime consent flow.

Derived. Reports what the page’s own markup and code did that its Content-Security-Policy refused, other than requests: an inline <style> element, a style attribute, an inline <script>, an inline event handler, eval, a data: or blob: resource.

Fails (csp-violation) once per page, directive and blocked thing.

Two things are left to other checks: a refused request to an undeclared third party is undeclared-drift, and a refused inline script on a page whose guard did not install is guard-installed.

This check can only fire when the server sends the Content-Security-Policy header. See Content-Security-Policy reference.

A registry in which no purpose has basis: consent describes a site with no banner. The audit then has no categories to switch on and off:

Check What it does
pre-consent-silence, gpc-honoured Run as usual. Nothing needs consent, so they can only fail by crashing.
reject-means-reject Passes without a browser session, with the note.
grant-activates-declared, withdrawal-cleans-up Pass without a browser session: there is no category to grant.
undeclared-drift Loads every page once and does not look for an Accept button.
banner-ux Fails for every page that shows a banner (banner-without-consent), with the note.
consent-receipts Passes without a browser session when the registry has no receipts section.
subject-requests Unaffected: it needs no consent decision.

The note is printed after the title, as in PASS 2. Reject means reject (no purpose asks for consent), and is the note field of the check in the JSON report.

--strict changes one thing: unexercised findings become errors, so a declared artefact that no audited page or interaction used fails the audit. The text report shows (strict) after the page list and the JSON report has "strict": true.

consent-kit audit of http://localhost:4173/
Pages: /, /video.html, /about.html (strict)
FAIL Coverage: unexercised declarations
error localStorage key "theme" (artefact "theme") is declared but was never observed. Either no audited page or interaction uses it (add the page, or an "exercise" step), or the declaration is stale.

Use it once the audit covers every page and interaction that a declaration depends on. From then on, a stale declaration fails the build.

--page names the pages the audit visits. Without it, only / is audited.

Terminal window
npx consent-kit audit http://localhost:4173 --page / --page /video.html --page /about.html

The audit does not crawl. An artefact that is only used on a page you did not list is never observed: it shows up as unexercised, and as missing in check 3 if it needs consent.

The order matters in two places. The first page is where the banner is measured and where decisions are made. Check 4 withdraws from the last page.

Some artefacts only appear after an interaction the audit cannot guess: a theme toggle that writes a localStorage key, a form that posts to an endpoint. An exercise file performs those interactions.

The contract:

  • The file is an ES module, loaded with import(). Its path is resolved against the current directory.
  • Its default export is a function. Anything else is a usage error (exit code 2).
  • The function is called as exercise(page, context) after every page load in every check, once the load event has fired and before the audit waits for the page to settle and takes its snapshot.
  • page is the Playwright Page.
  • context is { path, phase, granted }: the pathname of the page that was just loaded, a label for what the audit has done so far (for example "before any decision" or "after rejecting"), and the consent categories granted at that moment.
  • The return value is awaited and ignored.
  • If the function throws, the check that was running fails with check-error.

This is the exercise file of examples/static-site, audit-exercise.mjs:

// Passed to the audit as `--exercise`: runs after every page load, so the one
// artefact that needs a click (the `theme` localStorage key) is observed.
export default async function exercise(page) {
await page.click('#theme-toggle');
}

The function runs in every consent state, including before any decision and with the GPC signal set. That is the point: an interaction that triggers something consent-bound before consent is a finding. Do not use the exercise function to click the consent banner; the audit does that itself.

If an element exists only on some pages, branch on context.path.

--check <id> runs only the named checks; the others are reported as SKIP.

Terminal window
npx consent-kit audit http://localhost:4173 --check banner-ux --check gpc-honoured

The four derived checks (attribute-drift, unexercised, guard-installed, csp-violations) work from what the selected browser checks observed. Selected on their own, they have nothing to look at: unexercised then reports every artefact. The Coverage line and the coverage object are likewise limited to the sessions that ran.

undeclared-drift only collects other checks’ undeclared observations when it is selected itself.

This is a passing audit of examples/static-site:

Terminal window
npx consent-kit audit http://localhost:4173 \
--registry privacy.registry.yaml \
--page / --page /video.html --page /about.html \
--exercise audit-exercise.mjs
consent-kit audit of http://localhost:4173/
Pages: /, /video.html, /about.html
PASS 1. Pre-consent silence
PASS 2. Reject means reject
PASS 3. Grant activates exactly what is declared
PASS 4. Withdrawal cleans up
PASS 5. GPC honoured
PASS 6. Undeclared drift
PASS 7. Banner UX
PASS Consent receipts: one per decision
PASS Coverage: attribute drift
PASS Coverage: unexercised declarations
PASS Setup: runtime guard installed
PASS Setup: no Content-Security-Policy violations in the page itself
Coverage: 7 of 7 declared artefacts observed; 0 undeclared; 0 used without consent; 0 with attribute drift.
Content-Security-Policy (as generated from the registry): 1 deviation from strict
upgrade-insecure-requests is left out (automatic): The registry declares http: URLs (http://127.0.0.1:4174); upgrading them to https would break those declared loads. Declare https: URLs to get the directive back.
Presets:
acme-analytics@1.0.0 -> processor "acme-analytics", artefacts acme_script, acme_id, acme_last_page, acme_collect [synthetic]
Audit passed: 12 checks passed (6.7s).

The report is written to stdout. Its parts, in order:

  1. The audited URL and pages.
  2. CONSENT RECEIPTS NOT KEPT: ..., only when the registry opts out of receipts.
  3. One line per check, with its findings indented under it, each marked error or warning.
  4. The Coverage line, and an Unexercised: line listing artefact ids when there are any.
  5. The Content-Security-Policy generated from the registry: strict., or its deviations.
  6. The presets the registry adopts and the local overrides of their defaults, when there are any.
  7. The verdict: Audit passed or Audit FAILED, with the counts and the duration.

Parts 5 and 6 are informational. They do not affect the verdict or the exit code.

An undeclared finding ends with an artefact entry in registry syntax. This is the example site audited against a registry from which the theme artefact was removed:

FAIL 6. Undeclared drift
error localStorage key "theme" is not declared in the registry; it was written before any decision on /. Remove it, or add to privacy.registry.yaml:
- id: theme
kind: storage
area: local
key: "theme"
purposes: [TODO]

The entry is written from what the browser showed:

Observed Entry
Cookie kind: cookie with name, a duration from the observed expiry (session, or whole days), sameSite, and domain plus processor: TODO when the cookie’s domain is not the audited host.
localStorage, sessionStorage, IndexedDB kind: storage with area: local, session or indexeddb, and key.
Script kind: script with src.
Iframe kind: iframe with src (the origin only, for a third party).
Other request kind: pixel (an image), stylesheet, font, media, or endpoint for anything else, with url or src.

Third-party entries get processor: TODO. Every entry gets purposes: [TODO]: the audit can see what was used, not why. Fill in the TODOs, or remove the thing from the site. See Write a registry entry.

In the JSON report the same entry is the registryEntry field of the finding.

The report lists every way the policy generated from the registry is weaker than the strict default, each with its reason. Deviations the compiler decided from other declarations are marked (automatic); the others come from the csp section of the registry. A policy without deviations prints as:

Content-Security-Policy (as generated from the registry): strict.

See Loosen the CSP.

When the registry adopts presets, the report names each one with its version, the processor and artefacts it wrote, and flags such as synthetic, DRAFT: not yet verified against the live vendor or a count of unverified facts. If the registry overrides a preset default or excludes one of its artefacts, a second list follows, headed Local overrides of preset defaults (n):.

consent-kit check prints the same lines. See Presets reference.

When the registry opts out of consent receipts, the text report says so before any check:

CONSENT RECEIPTS NOT KEPT: the registry opts out. Reason given: <the reason from the registry>

The consent-receipts check is then a warning, never a silent pass. Its message starts with NOT CHECKED: and repeats the reason. The audit still exits with code 0 if nothing else fails. See Opt out of receipts.

--json prints one JSON object to stdout instead of the text report. The exit code is the same.

{
"ok": true,
"url": "http://localhost:4173/",
"pages": ["/", "/video.html", "/about.html"],
"strict": false,
"startedAt": "2026-11-28T11:58:39.899Z",
"durationMs": 6263,
"checks": [
{
"id": "pre-consent-silence",
"title": "1. Pre-consent silence",
"status": "pass",
"findings": [],
"durationMs": 953
}
],
"coverage": {
"exercised": ["acme_collect", "acme_id", "acme_last_page", "acme_script", "acme_video_embed", "cc_cookie", "theme"],
"unexercised": [],
"undeclared": [],
"wrongPurpose": [],
"attributeDrift": []
},
"summary": { "passed": 12, "warned": 0, "failed": 0, "skipped": 0 },
"csp": {
"level": "loosened",
"deviations": [
{
"directive": "upgrade-insecure-requests",
"kind": "directive-omitted",
"reason": "The registry declares http: URLs (http://127.0.0.1:4174); upgrading them to https would break those declared loads. Declare https: URLs to get the directive back.",
"origin": "automatic"
}
]
},
"receipts": { "endpoint": "/consent-receipts" },
"presets": {
"applied": [
{
"index": 0,
"preset": "acme-analytics",
"version": "1.0.0",
"status": "verified",
"synthetic": true,
"parameters": { "origin": "http://127.0.0.1:4174" },
"purposes": { "analytics": "analytics" },
"processor": { "id": "acme-analytics", "defaultId": "acme-analytics" },
"artefacts": [{ "id": "acme_script", "defaultId": "acme_script" }],
"unverified": []
}
],
"overrides": []
}
}

The output above is from the example site, with checks cut to its first entry and the preset’s artefact list cut to one.

Field Type Meaning
ok boolean true when no check failed. The exit code follows it.
url string The audited URL, normalised.
pages string[] The pages as given.
strict boolean Whether --strict was set.
startedAt string ISO 8601 timestamp.
durationMs number Duration of the whole run.
checks object[] Always all twelve, in the order of the table above.
checks[].id, .title string The check id and its printed title.
checks[].status string pass, warn, fail or skipped.
checks[].note string Only present when the check had less to do than usual: no purpose asks for consent.
checks[].findings object[] See below.
checks[].durationMs number 0 for derived and skipped checks.
coverage.exercised string[] Ids of the declared artefacts that were observed, sorted.
coverage.unexercised string[] Ids of the artefacts declared in the registry and never observed.
coverage.undeclared, .wrongPurpose, .attributeDrift object[] Findings, classified over every session of the run.
summary object Counts of checks: passed, warned, failed, skipped.
csp.level string strict or loosened.
csp.deviations object[] directive, kind (sources-added, report-only or directive-omitted), sources (for sources-added), reason, origin (registry or automatic).
receipts object or null The registry’s receipts section: the endpoint, or the opt-out with its reason. null without a section.
presets object Only present when the registry adopts presets: applied and overrides.

A finding:

Field Type Meaning
severity string error or warning.
code string One of the codes below.
message string The text printed in the report. For undeclared, it includes the registry entry after a line break.
artefact string Registry artefact id, when the finding is about a declared artefact.
kind string cookie, localStorage, sessionStorage, indexedDB, script, iframe or request.
key string Cookie name, storage key, database name or URL.
page string Pathname of the page.
phase string What the audit had done so far, for example before any decision.
category string The consent category concerned.
registryEntry string For undeclared: the entry to paste.

Only severity, code and message are always present.

Code Severity Reported by
wrong-purpose error checks 1, 2, 3, 5
guard-blocked warning checks 1, 2, 5
missing error check 3
not-cleaned error check 4
not-verified warning check 4
undeclared error check 6
banner-missing, button-missing, unequal-weight, preferences-unreachable, banner-without-consent error check 7
receipt-missing, receipt-duplicate, receipt-malformed, receipts-not-stated error consent-receipts
receipts-opted-out warning consent-receipts
attribute-drift error attribute-drift
unexercised warning; error with --strict unexercised
guard-not-installed error guard-installed
csp-violation error csp-violations
cannot-drive, consent-not-recorded error; warning in check 6 any check that drives the banner
check-error error any browser check that crashed

@consent-kit/audit exports what the command is built from.

Export What it is
runAudit(options) Runs the audit and resolves to the report object described above. It does not throw for a failing site; it throws only for unusable options (a URL that is not http(s), a page on another origin, an unknown check id).
renderReport(report) The text report, as an array of lines.
run(argv, io?) The command line. Resolves to the exit code and never calls process.exit. io takes cwd, stdout, stderr, programName and defaultRegistry.
helpText(program?, defaultRegistry?) The help text.
EXIT_OK, EXIT_FAILED, EXIT_USAGE 0, 1, 2.
CHECK_IDS, CHECK_TITLES The twelve ids in report order, and their titles.
DEFAULT_SELECTORS The banner selectors listed above.
DEFAULT_TOLERANCES { size: 0.25, contrast: 0.25, expiry: 0.01 }.
runPresetFixture(preset, options?) Runs a preset’s fixture. See below.

The types AuditOptions, AuditReport, CheckId, CheckResult, Coverage, ExerciseContext, Finding, FindingCode, GuardStatus, Observation, ObservedCookie, ObservedKind, PolicyViolation, Selectors, Tolerances, CliIo, PresetFixtureOptions and PresetFixtureResult are exported too.

import { readFileSync } from 'node:fs';
import { parseRegistry } from '@consent-kit/cli';
import { renderReport, runAudit } from '@consent-kit/audit';
const parsed = parseRegistry(readFileSync('privacy.registry.yaml', 'utf8'));
if (!parsed.ok) throw new Error('privacy.registry.yaml is not valid');
const report = await runAudit({
url: 'http://localhost:4173',
registry: parsed.registry,
presets: parsed.presets,
pages: ['/', '/video.html', '/about.html'],
exercise: async (page) => {
await page.click('#theme-toggle');
},
});
console.log(renderReport(report).join('\n'));
process.exitCode = report.ok ? 0 : 1;
Option Meaning Default
url The site. Required.
registry The parsed registry. Required.
presets The presets of the parseRegistry result. Copied into the report. none
pages As --page. ['/']
strict As --strict. false
checks As --check. all
exercise The function an exercise file exports. none
headless false is --headed. true
browser A Playwright Chromium Browser to reuse. The audit opens and closes its own contexts and leaves the browser open. launches its own
concurrency How many browser contexts may be open at once. 6
settleMs A page has settled when no request has started or finished for this long. 300
timeoutMs Limit for one navigation or one click. 8000
consentCookieName Name of CookieConsent’s consent cookie. "cc_cookie"
selectors Any of the banner selectors, merged over the defaults. DEFAULT_SELECTORS
tolerances size, contrast, expiry, merged over the defaults. DEFAULT_TOLERANCES

selectors, tolerances, concurrency, settleMs, timeoutMs, consentCookieName and browser have no command-line flag.

runPresetFixture(preset, options?) answers a different question from the audit: not “does this site respect consent” but “is this preset’s declaration complete and still true”. It is the tool for contributing a preset.

It serves the preset’s fixture (fixture.head and fixture.body, with the parameters filled in) as the only page of a throw-away server on http://localhost:<free port>/, loads it once in Chromium with every purpose treated as granted, and compares what the tool did with what the preset declares.

Option Meaning Default
with Parameter values that replace the fixture’s own, for example the origin of a local fake vendor. the fixture’s with
against 'live' or 'offline'. A label copied into the result; it does not change what runs. 'offline'
browser A Chromium Browser to reuse. launches its own
headless true
settleMs 500
timeoutMs 15000

The result:

Field Meaning
ok true when nothing is missing, nothing is undeclared and there is no attribute drift.
preset, version, against What was run.
observed Ids of the declared artefacts that were observed.
missing Ids in the fixture’s expect list that the page view did not produce. The declaration may be stale.
undeclared Findings for what the tool did that the preset does not declare, each with a registryEntry.
attributeDrift Findings for declared cookies whose observed attributes differ.

It throws only when the page cannot be served or loaded at all.

The audit reports what one browser did on the pages and interactions it was given. It is evidence about those runs, not a proof about the site.

  • Only the pages you list. There is no crawler. The default is / alone.
  • Only the interactions it knows. It clicks the banner, and whatever the exercise function clicks. Anything behind a login, a form, a scroll position or a timer that you do not exercise is not observed.
  • Only Chromium, with its defaults. Behaviour that differs in another browser, on a mobile viewport or behind an ad blocker is not seen.
  • One short visit per state. A page is considered settled after 300 ms without network activity. A script that waits longer before acting can be missed.
  • Not inside third-party iframes. The requests a cross-origin iframe makes inside itself and the storage keys it writes are not recorded. Its cookies are, because the cookie jar is read for the whole browser context.
  • Not the server side. The audit sees requests leaving the browser. It cannot see what a server does with them, what it logs, or what it forwards to someone else.
  • Not query strings or bodies. Requests are recorded as origin plus pathname. The audit does not inspect what data a declared request carries; the one body it reads is the consent receipt.
  • Not purposes. A declared artefact is judged by the purposes the registry gives it. Whether those are the real purposes is not something a browser can show.
  • Not the header. The Content-Security-Policy section of the report is computed from the registry. If the server sends a different policy, or none, the report does not say so; you only see the effects in the browser checks.
  • IndexedDB by name only, and only databases that exist at a snapshot. Writes to IndexedDB are not intercepted.
  • CookieConsent v3 markup. A banner with other markup needs other selectors, and those can only be set through the programmatic API.
  • Receipts are checked on the way out. The audit verifies that each decision sends one well-formed receipt. It does not verify that the endpoint stores it.

For what the other layers cover and what none of them does, see Threat model and limits.

consent-kit

Generate your cookie banner and privacy-policy drafts from one registry, and audit what your site really does against it.

© 2026 consent-kit · Released under the MIT licence.