Records create, update and delete entries for the collections you list, noting the changed field names, the actor, the route (such as switched-in or masquerading) and the origin, but not the values. Entries are hash-chained per record and sealed across the site, and a verify function reports the first break. Writes happen in the same transaction as the change. It needs MongoDB with transactions or Postgres, and Payload 3.80 or later.
Tamper-evident audit trail for Payload: who changed which fields, from where and through whom, never the values, hash-chained per record and sealed across the site, with a verify that reports any break; an opt-in old-value log and a sink for other plugins.
Installation
npm i @extantape/payload-plugin-audit-trail0
Stars
0
Forks
0
Open Issues
1 weeks ago
Last Updated
157
Weekly Downloads
v0.2.0
npm Version
109.9 KB
Unpacked Size
0
Dependencies
00 since Nov 8
| Date | Stars |
|---|---|
| Dec 6, 2026 | 0 |
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
| Nov 28, 2026 | 0 |
| Nov 27, 2026 | 0 |
| Nov 26, 2026 | 0 |
| Nov 25, 2026 | 0 |
| Nov 24, 2026 | 0 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
| Nov 21, 2026 | 0 |
| Nov 20, 2026 | 0 |
| Nov 19, 2026 | 0 |
| Nov 18, 2026 | 0 |
| Nov 17, 2026 | 0 |
| Nov 16, 2026 | 0 |
| Nov 15, 2026 | 0 |
| Nov 14, 2026 | 0 |
| Nov 13, 2026 | 0 |
| Nov 12, 2026 | 0 |
| Nov 11, 2026 | 0 |
| Nov 10, 2026 | 0 |
| Nov 9, 2026 | 0 |
| Nov 8, 2026 | 0 |
181+181 since Nov 15
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 181 |
| Dec 5, 2026 | 236 |
| Dec 4, 2026 | 555 |
| Dec 3, 2026 | 587 |
| Dec 2, 2026 | 607 |
| Dec 1, 2026 | 626 |
| Nov 30, 2026 | 649 |
| Nov 29, 2026 | 726 |
| Nov 28, 2026 | 692 |
| Nov 27, 2026 | 368 |
| Nov 26, 2026 | 341 |
| Nov 25, 2026 | 321 |
| Nov 24, 2026 | 280 |
| Nov 23, 2026 | 244 |
| Nov 22, 2026 | 356 |
| Nov 21, 2026 | 326 |
| Nov 20, 2026 | 314 |
| Nov 19, 2026 | 283 |
| Nov 18, 2026 | 260 |
| Nov 17, 2026 | 243 |
| Nov 16, 2026 | 229 |
| Nov 15, 2026 | 0 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1453222960-root)<a href="https://payloaddirectory.dev/plugins/1453222960-root"><img src="https://payloaddirectory.dev/badge/1453222960-root.svg" alt="Payload Directory"></a>README
A tamper-evident audit trail for Payload: who changed which fields of which record, from where and through whom, never the values. Each record's entries are hash-chained, a seal chains them across the site, and a verify reports the first break.
Status: early. 0.1.0 is on npm (2026-11-13). Postgres support is on main, not released yet. The same 110 tests pass twice against a real Payload 3.92: once on an in-memory MongoDB (a replica set) and once on a throwaway PostgreSQL 18 server started by embedded-postgres, through @payloadcms/db-postgres. No other database has been tried (not SQLite, Vercel Postgres, Neon or a managed Postgres). They cover what's recorded, failing closed with and without transactions, the value log and its startup refusals, read access, drafts, autosave and restores, the sink for other plugins, retention, and the chain: 40 changes at once without a fork, two seals at once, and tampering caught each way (an entry edited, the newest deleted, one removed or forged, a whole record's chain deleted after a seal, values edited, the first entry after a prune deleted), adopting a log kept before the plugin (verify after it, each kind of tampering with adopted entries, entries written around the plugin, running it twice, and pruning), passwords recorded by name with the password, hash and salt found nowhere in the trail or the logs, hidden fields changed by hooks, restores and bulk updates, concurrent and nested writes sharing a context, and a hook fanning out several account updates at once on one request. Verify is tested a page at a time against the answer the old read-it-all verify gave, for each kind of tampering, on a made-up trail of 3,130 entries read 50 at a time, starting from a seal, stopping early, and with reads that fail or come back out of order; and pruning two and three times, with a seal removed afterwards still caught. A separate branch tests it with MFA, Hats and Masq installed from npm. It isn't in use on any site yet.
actor), how (via: switched in, a guardian, masquerading), and where from (manual, import, sync, job…).
password. It's decided from what the database holds, so a site hook that sets or strips the password counts as what really happened. The password, hash and salt never reach an entry, a hash, a log or req.context.[] on their first save, and that isn't listed as a change. Adding or removing items is. An empty string, 0 and false still count as values.onWriteError: 'log' it goes through, the log says so, and the entry lists what the saved copies show.context: { audit: false } skips bookkeeping writes. context: { audit: { origin, system, run, reason } } describes automated work. reason is free text you write: never put values in it.onWriteError: 'log'.onWriteError: 'log', a failed entry is logged and the change goes through, with the chain left as it was. A database error inside the transaction itself (a write conflict, say) can still abort the transaction, change included, as any write in it would.sealAuditTrail(payload), run from your job every sealEveryHours (default 24; hourly suits a busy site), chains every entry since the last seal into one digest.verifyAuditTrail(payload) recomputes all of it and reports the first break, or warnings for entries waiting too long for a seal.
pageSize, default 1,000) and keeps only the running state, so a very large trail doesn't have to fit in memory. A read that fails, returns more than asked or comes back out of order is a failed verification that names the place, never a pass.from: digest checks only what was written after a seal or checkpoint you've verified before (the digest onSeal gave you). That seal is recomputed first, so its end can't be moved, and the entries before it are not read. The result says so: partial: true, range, and a summary such as "No break in entries 10,001–12,400 in time order, written after seal 41 (up to 2026-11-01T00:00:00.000Z). The 10,000 entries up to it were not checked." Run a full verify now and then as well: a partial check says nothing about what's before its seal.stopAfter: n stops once n entries are read and more remain. The result is then ok: false, finished: false, with no break named: not finished is never ok.onProgress is called after each page of entries and after each seal.ok is true only when everything asked for was read and nothing was wrong.cuts lists every cut the check read (each checkpoint a prune wrote): its number, digest, the date it cut up to, the digests of the seals it removed, and when the database says it was written. Match each to a prune you ran; its digest went to onSeal. A cut you didn't make means tampering: someone who can write to the database can append a well-formed checkpoint to excuse a seal and entries they removed, and verify can't tell it from yours. Your own list of cuts can.values), such as a studbook number. It keeps their old and new values. The plugin refuses at startup to log anything hidden, read-restricted, marked secret or encrypted, inside an array, a sign-in field, on your personal list, or a link to people not in allowPeople. Values are capped at 2 KB a field, readable only by access.values (nobody by default), and hashed separately, so clearing them keeps the chain whole.recordEvent(payload, { action, subject, req, … }) writes one entry with the same rules. fromPluginEvent(mapper) adapts another plugin's onEvent in one line.
req or payload, then from { payload } if you bind one (a Payload or a function returning one), then from the one Payload the plugin started on in this process. With several running, it refuses to guess: bind one.req, so a plugin awaiting onEvent in its own transaction has its action undone. Only a write that fails with no req logs the error's name (never its message) and returns: there's no transaction to undo, and the action has already happened. { onError: 'fail' } always throws; { onError: 'log' } never does.destroy() on the first makes events without a req refuse until you bind one.pruneAuditTrail(payload, { valuesOlderThanDays, olderThanDays }) from your job; nothing is deleted without arguments. Entries are cut only at the end of a seal no later than the age you ask for, and a checkpoint seal records the cut first: the cut-off, and the digest of each seal it removes that a remaining seal links to. Verify accepts a seal whose predecessor is gone only where a checkpoint recorded that, so you can prune as often as you like and a seal removed any other way is still a break. With no such seal yet, nothing is deleted.
olderThanDays cuts anything, it runs a full verify and refuses if that finds a break or can't finish: once a range is cut, tampering in it can no longer be found. Nothing is deleted or cleared when it refuses. verify: false skips the check, for a trail you've just verified yourself.On its own: it needs MongoDB with transactions or Postgres (or onWriteError: 'log'), the collections you list, and a users collection for actors. With no other plugin, via stays empty and entries come from collection changes and your own recordEvent calls.
Needs: Payload ^3.80.0 as a peer dependency. No other EXTANT APE plugin is required.
Works with:
via resolver can use hatsStateOf(req), masqueraderOf(req) and viaGuardian(req), so an entry says how a change was made.onEvent through fromPluginEvent, and name their events in actions.onStart and onStop can call recordEvent with a masquerade action.The plugin imports none of them. The site connects them in its own config.
Color Theory: none needed. It has no screens of its own, and its collections use Payload's standard admin, which takes Color Theory's admin colors when its applyToAdmin option is on.
Family: It's part of the Compliance family (a working draft): plugins designed to sit together for records you can stand behind. The other member, Encrypted Fields, isn't built yet.
npm install @extantape/payload-plugin-audit-trail
import { auditTrail } from '@extantape/payload-plugin-audit-trail'
export default buildConfig({
plugins: [
auditTrail({
collections: ['users', 'animals', 'pages'],
actions: ['masquerade', 'export'],
access: { read: isAdmin, values: isAdmin },
// With Hats (import { hatsStateOf } from Hats in your site): the account that really signed in, when switched,
// and the hat worn, as the label. Null on a plain sign-in with every role.
via: ({ req }) => {
const s = hatsStateOf(req)
return s?.via || s?.hat ? { kind: 'hats', id: s.via ?? null, label: s.hat ?? null } : null
},
values: { animals: ['studbookNumber'] },
personal: ['email', 'name', 'location'],
onSeal: ({ digest, upTo }) => sendToOwner(`Audit seal ${upTo}: ${digest}`),
}),
],
})
onSeal, anyone with write access to the database can rewrite every entry, head and seal consistently, and verify would pass.onSeal gives you somewhere else, and verify from it. A full verify can't notice that every seal and the seal head were removed: nothing left in the database says there were any. (With the head left behind, it's a break.) A check from a digest you kept fails when that seal is gone.access.values must be at least as strict as reading the records themselves. On a multi-site install, access.read must filter by site.payload.db.*, or a database client) aren't recorded, and neither is the plugin's own bookkeeping.restored version <id> as its reason.If the collection already holds entries written before this plugin, they have no hash, and verify reports each one as a break. Run adoptExistingEntries(payload) once, as a script, after switching:
onSeal, as with any seal.@payloadcms/db-postgres) are tested. It relies on transactions and the adapter's conditional updates, so an adapter without either won't work. SQLite and the Vercel Postgres adapter aren't tested.extraFields entry that your resolver leaves empty can't be stored (the database refuses a null). With onWriteError: 'fail' the change is undone, as on MongoDB. With 'log' the change is kept and the entry is lost, and the error is logged. MongoDB stores such an entry without the field.subjectId is stored as text either way.from between full runs. Sealing reads one interval's entries at once, and adoption the whole old log.chainKey, seq) in the trail collection's indexes, so it's built wherever your site builds Payload's indexes, at startup or by your own script. Without it verify gives the same answers, but the database sorts the trail again for every page, which is slow on a large trail and can fail a read (reported as a failed verification) where the database won't sort that much.recordEvent): the loser fails closed and its change is rolled back. Changes to different records never wait on each other.npm test # Vitest, in-memory MongoDB replica set
npm run test:postgres # the same tests on a throwaway PostgreSQL server (embedded-postgres)
npm run typecheck
npm run build
MIT
audit logs
Read-only audit trail of create, update, delete and login events with field-level diffs and sensitive-field redaction
67660/wk0v3
activity log
Record create, update and delete activity on selected collections and globals in a dedicated log collection
87639/wk115v4
payload hooks
Identifier-only audit logging hooks for Payload collections, plus a helper to run callbacks after transaction commit
77225/wk3v3
payload plugin audit log
Append-only audit log of document, global and auth changes with CSV and NDJSON export
72394/wk37v3
payload plugin audit
Audit trail for Payload collections that records who created or updated documents and stores update deltas
6134/wk1v3
audit fields
Adds createdBy and lastModifiedBy fields to Payload collections and globals
922.3k/wk115v4