@xtandard/audit 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +386 -2
- package/bin/xtandard-audit.mjs +3 -0
- package/dist/basic-DU_nPrWV.mjs +176 -0
- package/dist/basic-DU_nPrWV.mjs.map +1 -0
- package/dist/basic-hcXnMF9X.cjs +199 -0
- package/dist/basic-hcXnMF9X.cjs.map +1 -0
- package/dist/canonical-BOgkrX9_.d.cts +17 -0
- package/dist/canonical-CL7gfwhb.d.mts +17 -0
- package/dist/chunk-D7D4PA-g.mjs +13 -0
- package/dist/cli.cjs +773 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +46 -0
- package/dist/cli.d.mts +46 -0
- package/dist/cli.mjs +762 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/context-BtR9k9Mt.d.mts +52 -0
- package/dist/context-CJM87uG8.d.cts +52 -0
- package/dist/context-shared-AgBWIRUQ.d.mts +29 -0
- package/dist/context-shared-CUq3cSpV.d.cts +29 -0
- package/dist/context-shared-CupikwQo.mjs +39 -0
- package/dist/context-shared-CupikwQo.mjs.map +1 -0
- package/dist/context-shared-X2ulHHSB.cjs +44 -0
- package/dist/context-shared-X2ulHHSB.cjs.map +1 -0
- package/dist/context.cjs +82 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +2 -0
- package/dist/context.d.mts +2 -0
- package/dist/context.mjs +78 -0
- package/dist/context.mjs.map +1 -0
- package/dist/contract-BljSE-Hx.mjs +33 -0
- package/dist/contract-BljSE-Hx.mjs.map +1 -0
- package/dist/contract-BmwHIiMR.d.mts +150 -0
- package/dist/contract-CWJSYoJl.d.cts +150 -0
- package/dist/contract-Cht05WYQ.d.mts +159 -0
- package/dist/contract-CqYQzB6e.d.cts +49 -0
- package/dist/contract-DYvBNdnR.cjs +74 -0
- package/dist/contract-DYvBNdnR.cjs.map +1 -0
- package/dist/contract-DlTo4u2t.d.cts +30 -0
- package/dist/contract-DlTo4u2t.d.mts +30 -0
- package/dist/contract-DsVL5-gy.cjs +50 -0
- package/dist/contract-DsVL5-gy.cjs.map +1 -0
- package/dist/contract-isM9SjjQ.mjs +39 -0
- package/dist/contract-isM9SjjQ.mjs.map +1 -0
- package/dist/contract-pU3wGFmo.d.cts +159 -0
- package/dist/contract-yPNuFnVy.d.mts +49 -0
- package/dist/core-C0ceVOTk.d.cts +513 -0
- package/dist/core-CTr7dw0v.cjs +1725 -0
- package/dist/core-CTr7dw0v.cjs.map +1 -0
- package/dist/core-IdGEbYdM.mjs +1541 -0
- package/dist/core-IdGEbYdM.mjs.map +1 -0
- package/dist/core-KtEHRScZ.d.mts +513 -0
- package/dist/core.cjs +9 -0
- package/dist/core.d.cts +2 -0
- package/dist/core.d.mts +2 -0
- package/dist/core.mjs +2 -0
- package/dist/create-fetch-handler-1pXSEhGi.d.cts +311 -0
- package/dist/create-fetch-handler-BwQQ_IWf.mjs +2156 -0
- package/dist/create-fetch-handler-BwQQ_IWf.mjs.map +1 -0
- package/dist/create-fetch-handler-D8cTMVX9.cjs +2232 -0
- package/dist/create-fetch-handler-D8cTMVX9.cjs.map +1 -0
- package/dist/create-fetch-handler-zioPVS18.d.mts +311 -0
- package/dist/elysia-shared-C7geKqPP.mjs +55 -0
- package/dist/elysia-shared-C7geKqPP.mjs.map +1 -0
- package/dist/elysia-shared-DT4bfekR.d.cts +20 -0
- package/dist/elysia-shared-DXyAyGz_.cjs +66 -0
- package/dist/elysia-shared-DXyAyGz_.cjs.map +1 -0
- package/dist/elysia-shared-DoL5ab52.d.mts +20 -0
- package/dist/entry-auth-basic.cjs +5 -0
- package/dist/entry-auth-basic.d.cts +83 -0
- package/dist/entry-auth-basic.d.mts +83 -0
- package/dist/entry-auth-basic.mjs +2 -0
- package/dist/entry-auth-delegated.cjs +28 -0
- package/dist/entry-auth-delegated.cjs.map +1 -0
- package/dist/entry-auth-delegated.d.cts +36 -0
- package/dist/entry-auth-delegated.d.mts +36 -0
- package/dist/entry-auth-delegated.mjs +27 -0
- package/dist/entry-auth-delegated.mjs.map +1 -0
- package/dist/entry-auth-none.cjs +4 -0
- package/dist/entry-auth-none.d.cts +25 -0
- package/dist/entry-auth-none.d.mts +25 -0
- package/dist/entry-auth-none.mjs +2 -0
- package/dist/entry-authorization-delegated.cjs +28 -0
- package/dist/entry-authorization-delegated.cjs.map +1 -0
- package/dist/entry-authorization-delegated.d.cts +32 -0
- package/dist/entry-authorization-delegated.d.mts +32 -0
- package/dist/entry-authorization-delegated.mjs +27 -0
- package/dist/entry-authorization-delegated.mjs.map +1 -0
- package/dist/entry-authorization-none.cjs +3 -0
- package/dist/entry-authorization-none.d.cts +18 -0
- package/dist/entry-authorization-none.d.mts +18 -0
- package/dist/entry-authorization-none.mjs +2 -0
- package/dist/entry-authorization-roles.cjs +8 -0
- package/dist/entry-authorization-roles.d.cts +64 -0
- package/dist/entry-authorization-roles.d.mts +64 -0
- package/dist/entry-authorization-roles.mjs +3 -0
- package/dist/entry-bun.cjs +55 -0
- package/dist/entry-bun.cjs.map +1 -0
- package/dist/entry-bun.d.cts +29 -0
- package/dist/entry-bun.d.mts +29 -0
- package/dist/entry-bun.mjs +52 -0
- package/dist/entry-bun.mjs.map +1 -0
- package/dist/entry-drizzle-audit.cjs +191 -0
- package/dist/entry-drizzle-audit.cjs.map +1 -0
- package/dist/entry-drizzle-audit.d.cts +118 -0
- package/dist/entry-drizzle-audit.d.mts +118 -0
- package/dist/entry-drizzle-audit.mjs +186 -0
- package/dist/entry-drizzle-audit.mjs.map +1 -0
- package/dist/entry-drizzle-mysql.cjs +75 -0
- package/dist/entry-drizzle-mysql.cjs.map +1 -0
- package/dist/entry-drizzle-mysql.d.cts +42 -0
- package/dist/entry-drizzle-mysql.d.mts +42 -0
- package/dist/entry-drizzle-mysql.mjs +71 -0
- package/dist/entry-drizzle-mysql.mjs.map +1 -0
- package/dist/entry-drizzle-pg.cjs +82 -0
- package/dist/entry-drizzle-pg.cjs.map +1 -0
- package/dist/entry-drizzle-pg.d.cts +48 -0
- package/dist/entry-drizzle-pg.d.mts +48 -0
- package/dist/entry-drizzle-pg.mjs +78 -0
- package/dist/entry-drizzle-pg.mjs.map +1 -0
- package/dist/entry-drizzle-sqlite.cjs +71 -0
- package/dist/entry-drizzle-sqlite.cjs.map +1 -0
- package/dist/entry-drizzle-sqlite.d.cts +37 -0
- package/dist/entry-drizzle-sqlite.d.mts +37 -0
- package/dist/entry-drizzle-sqlite.mjs +67 -0
- package/dist/entry-drizzle-sqlite.mjs.map +1 -0
- package/dist/entry-elysia.cjs +112 -0
- package/dist/entry-elysia.cjs.map +1 -0
- package/dist/entry-elysia.d.cts +710 -0
- package/dist/entry-elysia.d.mts +710 -0
- package/dist/entry-elysia.mjs +109 -0
- package/dist/entry-elysia.mjs.map +1 -0
- package/dist/entry-elysia2.cjs +101 -0
- package/dist/entry-elysia2.cjs.map +1 -0
- package/dist/entry-elysia2.d.cts +905 -0
- package/dist/entry-elysia2.d.mts +905 -0
- package/dist/entry-elysia2.mjs +98 -0
- package/dist/entry-elysia2.mjs.map +1 -0
- package/dist/entry-express.cjs +90 -0
- package/dist/entry-express.cjs.map +1 -0
- package/dist/entry-express.d.cts +24 -0
- package/dist/entry-express.d.mts +24 -0
- package/dist/entry-express.mjs +88 -0
- package/dist/entry-express.mjs.map +1 -0
- package/dist/entry-hono.cjs +36 -0
- package/dist/entry-hono.cjs.map +1 -0
- package/dist/entry-hono.d.cts +24 -0
- package/dist/entry-hono.d.mts +24 -0
- package/dist/entry-hono.mjs +34 -0
- package/dist/entry-hono.mjs.map +1 -0
- package/dist/entry-hooks-log.cjs +22 -0
- package/dist/entry-hooks-log.cjs.map +1 -0
- package/dist/entry-hooks-log.d.cts +23 -0
- package/dist/entry-hooks-log.d.mts +23 -0
- package/dist/entry-hooks-log.mjs +21 -0
- package/dist/entry-hooks-log.mjs.map +1 -0
- package/dist/entry-sinks-console.cjs +43 -0
- package/dist/entry-sinks-console.cjs.map +1 -0
- package/dist/entry-sinks-console.d.cts +26 -0
- package/dist/entry-sinks-console.d.mts +26 -0
- package/dist/entry-sinks-console.mjs +41 -0
- package/dist/entry-sinks-console.mjs.map +1 -0
- package/dist/entry-sinks-datadog.cjs +97 -0
- package/dist/entry-sinks-datadog.cjs.map +1 -0
- package/dist/entry-sinks-datadog.d.cts +66 -0
- package/dist/entry-sinks-datadog.d.mts +66 -0
- package/dist/entry-sinks-datadog.mjs +91 -0
- package/dist/entry-sinks-datadog.mjs.map +1 -0
- package/dist/entry-sinks-file.cjs +100 -0
- package/dist/entry-sinks-file.cjs.map +1 -0
- package/dist/entry-sinks-file.d.cts +70 -0
- package/dist/entry-sinks-file.d.mts +70 -0
- package/dist/entry-sinks-file.mjs +97 -0
- package/dist/entry-sinks-file.mjs.map +1 -0
- package/dist/entry-sinks-http.cjs +63 -0
- package/dist/entry-sinks-http.cjs.map +1 -0
- package/dist/entry-sinks-http.d.cts +55 -0
- package/dist/entry-sinks-http.d.mts +55 -0
- package/dist/entry-sinks-http.mjs +60 -0
- package/dist/entry-sinks-http.mjs.map +1 -0
- package/dist/entry-sinks-s3.cjs +115 -0
- package/dist/entry-sinks-s3.cjs.map +1 -0
- package/dist/entry-sinks-s3.d.cts +79 -0
- package/dist/entry-sinks-s3.d.mts +79 -0
- package/dist/entry-sinks-s3.mjs +112 -0
- package/dist/entry-sinks-s3.mjs.map +1 -0
- package/dist/entry-sinks-splunk.cjs +80 -0
- package/dist/entry-sinks-splunk.cjs.map +1 -0
- package/dist/entry-sinks-splunk.d.cts +58 -0
- package/dist/entry-sinks-splunk.d.mts +58 -0
- package/dist/entry-sinks-splunk.mjs +77 -0
- package/dist/entry-sinks-splunk.mjs.map +1 -0
- package/dist/entry-sinks-webhook.cjs +130 -0
- package/dist/entry-sinks-webhook.cjs.map +1 -0
- package/dist/entry-sinks-webhook.d.cts +69 -0
- package/dist/entry-sinks-webhook.d.mts +69 -0
- package/dist/entry-sinks-webhook.mjs +125 -0
- package/dist/entry-sinks-webhook.mjs.map +1 -0
- package/dist/entry-sinks-xtandard-webhooks.cjs +64 -0
- package/dist/entry-sinks-xtandard-webhooks.cjs.map +1 -0
- package/dist/entry-sinks-xtandard-webhooks.d.cts +64 -0
- package/dist/entry-sinks-xtandard-webhooks.d.mts +64 -0
- package/dist/entry-sinks-xtandard-webhooks.mjs +63 -0
- package/dist/entry-sinks-xtandard-webhooks.mjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.cjs +47 -0
- package/dist/entry-storage-cloudflare-kv.cjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.d.cts +42 -0
- package/dist/entry-storage-cloudflare-kv.d.mts +42 -0
- package/dist/entry-storage-cloudflare-kv.mjs +46 -0
- package/dist/entry-storage-cloudflare-kv.mjs.map +1 -0
- package/dist/entry-storage-drizzle.cjs +228 -0
- package/dist/entry-storage-drizzle.cjs.map +1 -0
- package/dist/entry-storage-drizzle.d.cts +43 -0
- package/dist/entry-storage-drizzle.d.mts +43 -0
- package/dist/entry-storage-drizzle.mjs +227 -0
- package/dist/entry-storage-drizzle.mjs.map +1 -0
- package/dist/entry-storage-file.cjs +175 -0
- package/dist/entry-storage-file.cjs.map +1 -0
- package/dist/entry-storage-file.d.cts +41 -0
- package/dist/entry-storage-file.d.mts +41 -0
- package/dist/entry-storage-file.mjs +171 -0
- package/dist/entry-storage-file.mjs.map +1 -0
- package/dist/entry-storage-libsql.cjs +133 -0
- package/dist/entry-storage-libsql.cjs.map +1 -0
- package/dist/entry-storage-libsql.d.cts +60 -0
- package/dist/entry-storage-libsql.d.mts +60 -0
- package/dist/entry-storage-libsql.mjs +132 -0
- package/dist/entry-storage-libsql.mjs.map +1 -0
- package/dist/entry-storage-memory.cjs +3 -0
- package/dist/entry-storage-memory.d.cts +2 -0
- package/dist/entry-storage-memory.d.mts +2 -0
- package/dist/entry-storage-memory.mjs +2 -0
- package/dist/entry-storage-mongodb.cjs +306 -0
- package/dist/entry-storage-mongodb.cjs.map +1 -0
- package/dist/entry-storage-mongodb.d.cts +65 -0
- package/dist/entry-storage-mongodb.d.mts +65 -0
- package/dist/entry-storage-mongodb.mjs +304 -0
- package/dist/entry-storage-mongodb.mjs.map +1 -0
- package/dist/entry-storage-postgres.cjs +261 -0
- package/dist/entry-storage-postgres.cjs.map +1 -0
- package/dist/entry-storage-postgres.d.cts +66 -0
- package/dist/entry-storage-postgres.d.mts +66 -0
- package/dist/entry-storage-postgres.mjs +260 -0
- package/dist/entry-storage-postgres.mjs.map +1 -0
- package/dist/entry-storage-redis.cjs +223 -0
- package/dist/entry-storage-redis.cjs.map +1 -0
- package/dist/entry-storage-redis.d.cts +77 -0
- package/dist/entry-storage-redis.d.mts +77 -0
- package/dist/entry-storage-redis.mjs +221 -0
- package/dist/entry-storage-redis.mjs.map +1 -0
- package/dist/entry-storage-sqlite.cjs +85 -0
- package/dist/entry-storage-sqlite.cjs.map +1 -0
- package/dist/entry-storage-sqlite.d.cts +40 -0
- package/dist/entry-storage-sqlite.d.mts +40 -0
- package/dist/entry-storage-sqlite.mjs +84 -0
- package/dist/entry-storage-sqlite.mjs.map +1 -0
- package/dist/entry-storage-unstorage.cjs +57 -0
- package/dist/entry-storage-unstorage.cjs.map +1 -0
- package/dist/entry-storage-unstorage.d.cts +29 -0
- package/dist/entry-storage-unstorage.d.mts +29 -0
- package/dist/entry-storage-unstorage.mjs +56 -0
- package/dist/entry-storage-unstorage.mjs.map +1 -0
- package/dist/export-B9S-JeYl.mjs +239 -0
- package/dist/export-B9S-JeYl.mjs.map +1 -0
- package/dist/export-BZq0KCCn.d.mts +70 -0
- package/dist/export-DYfMd-ep.cjs +280 -0
- package/dist/export-DYfMd-ep.cjs.map +1 -0
- package/dist/export-Dh8T8I1p.d.cts +70 -0
- package/dist/index.cjs +279 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +286 -0
- package/dist/index.d.mts +284 -0
- package/dist/index.mjs +177 -0
- package/dist/index.mjs.map +1 -0
- package/dist/integrity-BHhjTBNk.cjs +614 -0
- package/dist/integrity-BHhjTBNk.cjs.map +1 -0
- package/dist/integrity-kfY2DNAi.mjs +483 -0
- package/dist/integrity-kfY2DNAi.mjs.map +1 -0
- package/dist/memory-CfykUo9W.cjs +155 -0
- package/dist/memory-CfykUo9W.cjs.map +1 -0
- package/dist/memory-DrR-Tlbf.d.mts +28 -0
- package/dist/memory-GG2Nba1D.mjs +150 -0
- package/dist/memory-GG2Nba1D.mjs.map +1 -0
- package/dist/memory-HpFdlMR_.d.cts +28 -0
- package/dist/none-Be7r6kHH.cjs +33 -0
- package/dist/none-Be7r6kHH.cjs.map +1 -0
- package/dist/none-CGmIIbI8.cjs +49 -0
- package/dist/none-CGmIIbI8.cjs.map +1 -0
- package/dist/none-CkV5mZsB.mjs +33 -0
- package/dist/none-CkV5mZsB.mjs.map +1 -0
- package/dist/none-DBeBeU0Z.mjs +23 -0
- package/dist/none-DBeBeU0Z.mjs.map +1 -0
- package/dist/query-ChGGtlA7.cjs +243 -0
- package/dist/query-ChGGtlA7.cjs.map +1 -0
- package/dist/query-LvZbyi37.mjs +172 -0
- package/dist/query-LvZbyi37.mjs.map +1 -0
- package/dist/react.css +1 -0
- package/dist/react.js +31936 -0
- package/dist/recorder-B3dG3jbd.d.mts +64 -0
- package/dist/recorder-CGY7HK29.d.cts +64 -0
- package/dist/roles-BARtYLSX.cjs +112 -0
- package/dist/roles-BARtYLSX.cjs.map +1 -0
- package/dist/roles-D7Pg89IJ.mjs +83 -0
- package/dist/roles-D7Pg89IJ.mjs.map +1 -0
- package/dist/schema-DmU7Wp0F.d.cts +251 -0
- package/dist/schema-DmU7Wp0F.d.mts +251 -0
- package/dist/schema.cjs +20 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +2 -0
- package/dist/schema.d.mts +2 -0
- package/dist/schema.mjs +17 -0
- package/dist/schema.mjs.map +1 -0
- package/dist/shared-CJOyJKqT.d.mts +20 -0
- package/dist/shared-DSDY-V0n.mjs +100 -0
- package/dist/shared-DSDY-V0n.mjs.map +1 -0
- package/dist/shared-EANCdRqn.d.cts +20 -0
- package/dist/shared-OOAq-U4S.cjs +141 -0
- package/dist/shared-OOAq-U4S.cjs.map +1 -0
- package/dist/sql-B7b6HzGy.cjs +280 -0
- package/dist/sql-B7b6HzGy.cjs.map +1 -0
- package/dist/sql-COjPyn3F.mjs +209 -0
- package/dist/sql-COjPyn3F.mjs.map +1 -0
- package/dist/sqlite-event-log-BnoG8eos.cjs +184 -0
- package/dist/sqlite-event-log-BnoG8eos.cjs.map +1 -0
- package/dist/sqlite-event-log-nXmS2DS_.mjs +179 -0
- package/dist/sqlite-event-log-nXmS2DS_.mjs.map +1 -0
- package/dist/streams-CRuxOYcb.d.cts +124 -0
- package/dist/streams-DU0_gvI8.d.mts +124 -0
- package/dist/table-BcarDd10.d.cts +48 -0
- package/dist/table-BcarDd10.d.mts +48 -0
- package/dist/testing.cjs +189 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +103 -0
- package/dist/testing.d.mts +103 -0
- package/dist/testing.mjs +185 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/types-elysia2/adapters/bun.d.ts +47 -0
- package/dist/types-elysia2/adapters/context-shared.d.ts +40 -0
- package/dist/types-elysia2/adapters/elysia-shared.d.ts +36 -0
- package/dist/types-elysia2/adapters/elysia2.d.ts +588 -0
- package/dist/types-elysia2/auth/contract.d.ts +26 -0
- package/dist/types-elysia2/authorization/contract.d.ts +54 -0
- package/dist/types-elysia2/canonical.d.ts +25 -0
- package/dist/types-elysia2/context.d.ts +61 -0
- package/dist/types-elysia2/core.d.ts +232 -0
- package/dist/types-elysia2/duration.d.ts +26 -0
- package/dist/types-elysia2/entry-elysia2.d.ts +10 -0
- package/dist/types-elysia2/event-log.d.ts +33 -0
- package/dist/types-elysia2/export.d.ts +77 -0
- package/dist/types-elysia2/hooks/contract.d.ts +177 -0
- package/dist/types-elysia2/id.d.ts +27 -0
- package/dist/types-elysia2/integrity.d.ts +193 -0
- package/dist/types-elysia2/keys.d.ts +91 -0
- package/dist/types-elysia2/portal.d.ts +137 -0
- package/dist/types-elysia2/query.d.ts +88 -0
- package/dist/types-elysia2/schema.d.ts +247 -0
- package/dist/types-elysia2/server/base-path.d.ts +15 -0
- package/dist/types-elysia2/server/cors.d.ts +36 -0
- package/dist/types-elysia2/server/create-fetch-handler.d.ts +140 -0
- package/dist/types-elysia2/server/openapi.d.ts +25 -0
- package/dist/types-elysia2/server/render-index-html.d.ts +18 -0
- package/dist/types-elysia2/server/routes.d.ts +83 -0
- package/dist/types-elysia2/server/static-assets.d.ts +13 -0
- package/dist/types-elysia2/standard-schema.d.ts +100 -0
- package/dist/types-elysia2/storage/contract.d.ts +106 -0
- package/dist/types-elysia2/streams.d.ts +134 -0
- package/dist/types-elysia2/transforms.d.ts +56 -0
- package/dist/types-elysia2/validation.d.ts +48 -0
- package/dist/types-react/canonical.d.ts +25 -0
- package/dist/types-react/context.d.ts +61 -0
- package/dist/types-react/core.d.ts +232 -0
- package/dist/types-react/duration.d.ts +26 -0
- package/dist/types-react/event-log.d.ts +33 -0
- package/dist/types-react/hooks/contract.d.ts +177 -0
- package/dist/types-react/id.d.ts +27 -0
- package/dist/types-react/integrity.d.ts +193 -0
- package/dist/types-react/keys.d.ts +91 -0
- package/dist/types-react/query.d.ts +88 -0
- package/dist/types-react/react.d.ts +114 -0
- package/dist/types-react/schema.d.ts +247 -0
- package/dist/types-react/standard-schema.d.ts +100 -0
- package/dist/types-react/storage/contract.d.ts +106 -0
- package/dist/types-react/streams.d.ts +134 -0
- package/dist/types-react/transforms.d.ts +56 -0
- package/dist/types-react/ui/App.d.ts +36 -0
- package/dist/types-react/ui/api.d.ts +61 -0
- package/dist/types-react/ui/components/ActionFilter.d.ts +17 -0
- package/dist/types-react/ui/components/ExportMenu.d.ts +13 -0
- package/dist/types-react/ui/components/JsonCodeEditor.d.ts +12 -0
- package/dist/types-react/ui/components/ThemeToggle.d.ts +2 -0
- package/dist/types-react/ui/components/Toast.d.ts +16 -0
- package/dist/types-react/ui/components/audit-bits.d.ts +91 -0
- package/dist/types-react/ui/components/integrity-bits.d.ts +19 -0
- package/dist/types-react/ui/components/primitives.d.ts +50 -0
- package/dist/types-react/ui/components/ui-bits.d.ts +22 -0
- package/dist/types-react/ui/lib/filters.d.ts +70 -0
- package/dist/types-react/ui/lib/format.d.ts +82 -0
- package/dist/types-react/ui/lib/nav-guard.d.ts +20 -0
- package/dist/types-react/ui/lib/portal-container.d.ts +24 -0
- package/dist/types-react/ui/lib/utils.d.ts +3 -0
- package/dist/types-react/ui/theme.d.ts +40 -0
- package/dist/types-react/ui/types.d.ts +67 -0
- package/dist/types-react/ui/views/ActionsView.d.ts +10 -0
- package/dist/types-react/ui/views/EventDrawer.d.ts +15 -0
- package/dist/types-react/ui/views/EventsView.d.ts +10 -0
- package/dist/types-react/ui/views/IntegrityView.d.ts +10 -0
- package/dist/types-react/ui/views/OverviewView.d.ts +9 -0
- package/dist/types-react/ui/views/StreamsView.d.ts +10 -0
- package/dist/types-react/ui/views/TenantsView.d.ts +6 -0
- package/dist/types-react/validation.d.ts +48 -0
- package/dist/ui/assets/favicon-BSj8MPnj.svg +11 -0
- package/dist/ui/assets/index-B-qrQSOM.css +1 -0
- package/dist/ui/assets/index-CemlP5hR.js +244 -0
- package/dist/ui/index.html +15 -0
- package/dist/validation-DFrLESZD.mjs +150 -0
- package/dist/validation-DFrLESZD.mjs.map +1 -0
- package/dist/validation-lb0YXrxx.cjs +235 -0
- package/dist/validation-lb0YXrxx.cjs.map +1 -0
- package/dist/verify.cjs +14 -0
- package/dist/verify.d.cts +5 -0
- package/dist/verify.d.mts +5 -0
- package/dist/verify.mjs +3 -0
- package/package.json +610 -4
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient request context (ADR 0013): open a scope per request with the actor,
|
|
3
|
+
* tenant, IP, user agent and request id, and every `record()` inside it picks
|
|
4
|
+
* them up — no threading through call sites. Pattern borrowed from
|
|
5
|
+
* `drizzle-audit`'s context.
|
|
6
|
+
*
|
|
7
|
+
* Uses `node:async_hooks` `AsyncLocalStorage` (Bun, Node, Deno, Cloudflare
|
|
8
|
+
* Workers with `nodejs_compat`). Framework adapters wrap this in an
|
|
9
|
+
* `auditContext()` middleware.
|
|
10
|
+
*
|
|
11
|
+
* Import from `@xtandard/audit/context`.
|
|
12
|
+
*
|
|
13
|
+
* @module context
|
|
14
|
+
*/
|
|
15
|
+
import type { AuditActor, AuditContext } from "./schema.ts";
|
|
16
|
+
/** What a request scope carries. */
|
|
17
|
+
export interface AuditScope {
|
|
18
|
+
/** Default actor for events recorded in this scope. */
|
|
19
|
+
actor?: AuditActor;
|
|
20
|
+
/** Default tenant for events recorded in this scope. */
|
|
21
|
+
tenant?: string;
|
|
22
|
+
/** Request context merged under each event's explicit `context`. */
|
|
23
|
+
context?: AuditContext;
|
|
24
|
+
}
|
|
25
|
+
/** The current scope, or `null` outside any scope. Never throws. */
|
|
26
|
+
export declare function getAuditContext(): AuditScope | null;
|
|
27
|
+
/**
|
|
28
|
+
* Run `fn` inside a scope. Nested scopes inherit and override the outer one
|
|
29
|
+
* (`context` keys merge).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { runWithAuditContext } from "@xtandard/audit/context";
|
|
34
|
+
*
|
|
35
|
+
* await runWithAuditContext({ actor: { id: user.id }, tenant: user.orgId }, () =>
|
|
36
|
+
* audit.record({ action: "invoice.paid", metadata: { invoiceId } }),
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function runWithAuditContext<T>(scope: AuditScope, fn: () => T): T;
|
|
41
|
+
/**
|
|
42
|
+
* Patch the current scope for the rest of the current async execution
|
|
43
|
+
* (`enterWith` semantics) — for middleware that cannot wrap `next()`, or to
|
|
44
|
+
* attach the actor once auth resolves.
|
|
45
|
+
*/
|
|
46
|
+
export declare function setAuditContext(patch: AuditScope): void;
|
|
47
|
+
/** Options for {@link auditContextFromRequest}. */
|
|
48
|
+
export interface RequestContextOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Trust proxy headers (`x-forwarded-for`, `cf-connecting-ip`, `x-real-ip`,
|
|
51
|
+
* `fly-client-ip`) for the client IP. Default `true` — set `false` when the
|
|
52
|
+
* app is reachable directly, or clients can spoof their IP.
|
|
53
|
+
*/
|
|
54
|
+
trustProxy?: boolean;
|
|
55
|
+
/** Header carrying the request id. Default: `x-request-id`, then `cf-ray`. */
|
|
56
|
+
requestIdHeader?: string;
|
|
57
|
+
/** Fallback IP when no header carries one (e.g. Bun's `server.requestIP`). */
|
|
58
|
+
ip?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Extract `{ ip, userAgent, requestId }` from a web-standard Request. */
|
|
61
|
+
export declare function auditContextFromRequest(request: Request, options?: RequestContextOptions): AuditContext;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The audit core — the operations layer the API, CLI, recorder, stream runner
|
|
3
|
+
* and UI sit on.
|
|
4
|
+
*
|
|
5
|
+
* Owns the split between the **record plane** (`record()` / `recordMany()` —
|
|
6
|
+
* the hot path: validate, transform, chain, append; synchronous-commit, throws
|
|
7
|
+
* on failure, ADR 0002) and the **control plane** (query, export, verify,
|
|
8
|
+
* checkpoints, erasure, retention, the action catalog — hook-guarded and
|
|
9
|
+
* self-audited).
|
|
10
|
+
*
|
|
11
|
+
* Import from `@xtandard/audit/core` (also re-exported by the root).
|
|
12
|
+
*
|
|
13
|
+
* @module core
|
|
14
|
+
*/
|
|
15
|
+
import { type EventLog } from "./event-log.ts";
|
|
16
|
+
import { type AuditHooks, type AuditHooksInput, type HookActor, type HookErrorReporter } from "./hooks/contract.ts";
|
|
17
|
+
import { type AuditSigner, type AuditVerificationKey, type VerifyReport } from "./integrity.ts";
|
|
18
|
+
import type { ActionDefinition, AuditCheckpoint, AuditDuration, AuditEvent, AuditEventInput, AuditPage, AuditQuery, AuditSection, AuditTenant, ChainHead } from "./schema.ts";
|
|
19
|
+
import { type ActionMap, type ActionMetadataInput } from "./standard-schema.ts";
|
|
20
|
+
import { type AuditStorage } from "./storage/contract.ts";
|
|
21
|
+
import { type AuditTransform } from "./transforms.ts";
|
|
22
|
+
/** Thrown by mutating operations when the core is in readonly mode. */
|
|
23
|
+
export declare class ReadonlyError extends Error {
|
|
24
|
+
constructor(operation: string);
|
|
25
|
+
}
|
|
26
|
+
/** Thrown when a referenced entity does not exist. Maps to HTTP 404. */
|
|
27
|
+
export declare class NotFoundError extends Error {
|
|
28
|
+
constructor(message: string);
|
|
29
|
+
}
|
|
30
|
+
/** Thrown when an operation conflicts with existing state. Maps to HTTP 409. */
|
|
31
|
+
export declare class ConflictError extends Error {
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
/** Thrown when an operation needs a signer and none is configured. Maps to HTTP 409. */
|
|
35
|
+
export declare class SignerRequiredError extends Error {
|
|
36
|
+
constructor();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One retention rule. When both fields are set an event is **kept if either
|
|
40
|
+
* rule keeps it** (union of keeps, the sibling packages' semantics): pruned only
|
|
41
|
+
* when it is outside the `keepLast` most recent AND older than `maxAge`.
|
|
42
|
+
* Retention always removes a **prefix** of a tenant's chain (by seq), anchored
|
|
43
|
+
* by a base checkpoint, so what remains still verifies (ADR 0004).
|
|
44
|
+
*/
|
|
45
|
+
export interface RetentionRule {
|
|
46
|
+
/** Keep at most the N most recent events per tenant. */
|
|
47
|
+
keepLast?: number;
|
|
48
|
+
/** Keep events recorded within this age (e.g. `"365d"`). */
|
|
49
|
+
maxAge?: AuditDuration;
|
|
50
|
+
}
|
|
51
|
+
/** Retention policy for {@link AuditCoreOptions.retention}. */
|
|
52
|
+
export interface RetentionOptions extends RetentionRule {
|
|
53
|
+
/** Per-tenant overrides (e.g. an enterprise plan with longer retention). */
|
|
54
|
+
tenants?: Record<string, RetentionRule>;
|
|
55
|
+
/**
|
|
56
|
+
* Prune even past stream cursors that have not caught up (default `false`:
|
|
57
|
+
* events a stream has not delivered yet are kept, ADR 0008).
|
|
58
|
+
*/
|
|
59
|
+
ignoreStreams?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Automatic checkpointing (requires a `signer`). */
|
|
62
|
+
export interface CheckpointOptions {
|
|
63
|
+
/** Sign the head after this many new events in a tenant. */
|
|
64
|
+
every?: number;
|
|
65
|
+
/** Sign the head when the last checkpoint is older than this (checked on record). */
|
|
66
|
+
interval?: AuditDuration;
|
|
67
|
+
}
|
|
68
|
+
/** Options for {@link createAuditCore}. */
|
|
69
|
+
export interface AuditCoreOptions<A extends ActionMap = ActionMap> {
|
|
70
|
+
/** Where everything lives (see `@xtandard/audit/storage/*`). */
|
|
71
|
+
storage: AuditStorage;
|
|
72
|
+
/** Typed action catalog from `defineActions` (ADR 0012). */
|
|
73
|
+
actions?: A;
|
|
74
|
+
/**
|
|
75
|
+
* Reject actions that are not in `actions`. Default: `true` when `actions`
|
|
76
|
+
* is given, `false` otherwise.
|
|
77
|
+
*/
|
|
78
|
+
strictActions?: boolean;
|
|
79
|
+
/** Redact / mask / hash / omit before chaining (see `@xtandard/audit` transforms). */
|
|
80
|
+
transforms?: AuditTransform[];
|
|
81
|
+
/** Merge the ambient request context (`@xtandard/audit/context`). Default `true`. */
|
|
82
|
+
context?: boolean;
|
|
83
|
+
/** Checkpoint signer (ADR 0004). Without one, checkpoints are unavailable. */
|
|
84
|
+
signer?: AuditSigner;
|
|
85
|
+
/** Extra keys `verify` accepts (e.g. retired signing keys). */
|
|
86
|
+
verificationKeys?: AuditVerificationKey[];
|
|
87
|
+
/** Automatic checkpoints. Default `{ every: 1000, interval: "1h" }` when a signer is set. */
|
|
88
|
+
checkpoints?: CheckpointOptions | false;
|
|
89
|
+
/** Retention. Pruning runs on demand ({@link AuditCore.prune}) or via the panel/CLI schedule. */
|
|
90
|
+
retention?: RetentionOptions;
|
|
91
|
+
/** Control-plane hooks (`before` may deny, `after` observes). */
|
|
92
|
+
hooks?: AuditHooksInput;
|
|
93
|
+
/** Reporter invoked when an `after` hook throws. Default `console.warn`. */
|
|
94
|
+
onHookError?: HookErrorReporter;
|
|
95
|
+
/** Fire-and-forget tap invoked with every committed batch (metrics, cache busting). */
|
|
96
|
+
onRecord?: (events: AuditEvent[]) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Record the log's own sensitive operations (exports, erasures, prunes) into
|
|
99
|
+
* the affected tenant's log, and catalog changes into `systemTenant`.
|
|
100
|
+
* Default `true`.
|
|
101
|
+
*/
|
|
102
|
+
selfAudit?: boolean;
|
|
103
|
+
/** Tenant receiving self-audit events that belong to no tenant. Default `"_system"`. */
|
|
104
|
+
systemTenant?: string;
|
|
105
|
+
/** Max serialized size of an event's free-form sections. Default 64 KiB. */
|
|
106
|
+
maxEventBytes?: number;
|
|
107
|
+
/** Block every mutation except recording when true (a read-only panel). */
|
|
108
|
+
readonly?: boolean;
|
|
109
|
+
/** Injectable clock (unix millis) for tests. Default `Date.now`. */
|
|
110
|
+
now?: () => number;
|
|
111
|
+
}
|
|
112
|
+
/** Per-call actor attribution for control-plane operations. */
|
|
113
|
+
export interface ActorOptions {
|
|
114
|
+
actor?: HookActor | null;
|
|
115
|
+
}
|
|
116
|
+
/** A record input, typed by the action map when one is given (ADR 0012). */
|
|
117
|
+
export type RecordInput<A extends ActionMap = ActionMap> = string extends keyof A ? Omit<AuditEventInput, "tenant"> & {
|
|
118
|
+
tenant?: string;
|
|
119
|
+
} : {
|
|
120
|
+
[K in keyof A & string]: Omit<AuditEventInput<K, ActionMetadataInput<A[K]>>, "tenant"> & {
|
|
121
|
+
/** Defaults to the ambient context's tenant. */
|
|
122
|
+
tenant?: string;
|
|
123
|
+
};
|
|
124
|
+
}[keyof A & string];
|
|
125
|
+
/** Input to {@link AuditCore.erase}. */
|
|
126
|
+
export interface EraseInput {
|
|
127
|
+
/** Sections to erase. Default: every section. */
|
|
128
|
+
sections?: AuditSection[];
|
|
129
|
+
/** Why (recorded in the self-audit event). */
|
|
130
|
+
reason?: string;
|
|
131
|
+
}
|
|
132
|
+
/** Result of one tenant's prune. */
|
|
133
|
+
export interface PruneResult {
|
|
134
|
+
tenant: string;
|
|
135
|
+
/** Events removed. */
|
|
136
|
+
pruned: number;
|
|
137
|
+
/** New first retained seq. */
|
|
138
|
+
baseSeq: number;
|
|
139
|
+
}
|
|
140
|
+
/** Self-audit action names (always accepted, even with `strictActions`). */
|
|
141
|
+
export declare const SELF_AUDIT_ACTIONS: readonly ["audit_log.exported", "audit_log.erased", "audit_log.pruned", "audit_log.action_upserted", "audit_log.action_deleted"];
|
|
142
|
+
/** The audit core surface. */
|
|
143
|
+
export interface AuditCore<A extends ActionMap = ActionMap> {
|
|
144
|
+
readonly options: {
|
|
145
|
+
storage: AuditStorage;
|
|
146
|
+
actions?: A;
|
|
147
|
+
strictActions: boolean;
|
|
148
|
+
readonly: boolean;
|
|
149
|
+
selfAudit: boolean;
|
|
150
|
+
systemTenant: string;
|
|
151
|
+
signer?: AuditSigner;
|
|
152
|
+
retention?: RetentionOptions;
|
|
153
|
+
checkpoints: CheckpointOptions | false;
|
|
154
|
+
hooks: AuditHooks[];
|
|
155
|
+
now: () => number;
|
|
156
|
+
};
|
|
157
|
+
/** The resolved event log (native or KV fallback). */
|
|
158
|
+
readonly eventLog: EventLog;
|
|
159
|
+
/** Validate, transform, chain and append one event. Throws on failure (ADR 0002). */
|
|
160
|
+
record(input: RecordInput<A>): Promise<AuditEvent>;
|
|
161
|
+
/** Same as {@link record} for a batch; one chain append per tenant. */
|
|
162
|
+
recordMany(inputs: RecordInput<A>[]): Promise<AuditEvent[]>;
|
|
163
|
+
query(query?: AuditQuery): Promise<AuditPage>;
|
|
164
|
+
get(tenant: string, id: string): Promise<AuditEvent | null>;
|
|
165
|
+
/** Events of a tenant with `seq > afterSeq`, ascending (streams, verification, bundles). */
|
|
166
|
+
eventsBySeq(tenant: string, options: {
|
|
167
|
+
afterSeq: number;
|
|
168
|
+
limit: number;
|
|
169
|
+
}): Promise<AuditEvent[]>;
|
|
170
|
+
count(tenant?: string): Promise<number>;
|
|
171
|
+
listTenants(): Promise<AuditTenant[]>;
|
|
172
|
+
head(tenant: string): Promise<ChainHead>;
|
|
173
|
+
/** Verify a tenant's chain (whole retained range, or `fromSeq`..`toSeq`). */
|
|
174
|
+
verify(tenant: string, range?: {
|
|
175
|
+
fromSeq?: number;
|
|
176
|
+
toSeq?: number;
|
|
177
|
+
}): Promise<VerifyReport>;
|
|
178
|
+
/** Sign the tenant's current head. Throws {@link SignerRequiredError} without a signer. */
|
|
179
|
+
checkpoint(tenant: string, options?: ActorOptions): Promise<AuditCheckpoint>;
|
|
180
|
+
listCheckpoints(tenant: string): Promise<AuditCheckpoint[]>;
|
|
181
|
+
/** The public verification keys as a JWKS (empty for HMAC signers). */
|
|
182
|
+
jwks(): Promise<{
|
|
183
|
+
keys: JsonWebKey[];
|
|
184
|
+
}>;
|
|
185
|
+
erase(tenant: string, eventId: string, input?: EraseInput, options?: ActorOptions): Promise<AuditEvent>;
|
|
186
|
+
/** Erase the `actor` section of every event by `actorId` in the tenant. Resolves to the count. */
|
|
187
|
+
eraseActor(tenant: string, actorId: string, input?: {
|
|
188
|
+
reason?: string;
|
|
189
|
+
}, options?: ActorOptions): Promise<number>;
|
|
190
|
+
/** Note an export (before hook + self-audit). The export module calls this. */
|
|
191
|
+
noteExport(tenant: string, query: AuditQuery, format: string, options?: ActorOptions): Promise<void>;
|
|
192
|
+
listActions(): Promise<ActionDefinition[]>;
|
|
193
|
+
getAction(name: string): Promise<ActionDefinition | null>;
|
|
194
|
+
upsertAction(input: ActionDefinition, options?: ActorOptions): Promise<ActionDefinition>;
|
|
195
|
+
deleteAction(name: string, options?: ActorOptions): Promise<void>;
|
|
196
|
+
prune(options?: ActorOptions): Promise<PruneResult[]>;
|
|
197
|
+
pruneTenant(tenant: string, options?: ActorOptions): Promise<PruneResult>;
|
|
198
|
+
/**
|
|
199
|
+
* Register a lower bound retention must not prune past (stream runners
|
|
200
|
+
* register their slowest cursor). Returns an unregister function.
|
|
201
|
+
*/
|
|
202
|
+
addRetentionFloor(floor: (tenant: string) => Promise<number | null>): () => void;
|
|
203
|
+
/**
|
|
204
|
+
* Resolves once background work started by recording (automatic checkpoints)
|
|
205
|
+
* has settled. Await it in tests and before shutting down.
|
|
206
|
+
*/
|
|
207
|
+
settled(): Promise<void>;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Create the audit core.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* import { createAuditCore } from "@xtandard/audit";
|
|
215
|
+
* import { createMemoryStorage } from "@xtandard/audit/storage/memory";
|
|
216
|
+
*
|
|
217
|
+
* const audit = createAuditCore({ storage: createMemoryStorage() });
|
|
218
|
+
*
|
|
219
|
+
* await audit.record({
|
|
220
|
+
* tenant: "acme",
|
|
221
|
+
* action: "invoice.paid",
|
|
222
|
+
* actor: { id: "user_1", name: "Ada" },
|
|
223
|
+
* targets: [{ type: "invoice", id: "inv_1" }],
|
|
224
|
+
* metadata: { amount: 4200 },
|
|
225
|
+
* });
|
|
226
|
+
*
|
|
227
|
+
* const page = await audit.query({ tenant: "acme", actions: ["invoice.*"] });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
export declare function createAuditCore<const A extends ActionMap = ActionMap>(options: AuditCoreOptions<A>): AuditCore<A>;
|
|
231
|
+
/** Erase sections of an event, keeping its digests (ADR 0011). */
|
|
232
|
+
export declare function eraseSections(event: AuditEvent, sections: readonly AuditSection[]): AuditEvent;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Duration parsing for {@link ./schema.AuditDuration} config values. Zero
|
|
3
|
+
* dependencies; shared by the core (retention, checkpoint intervals) and the
|
|
4
|
+
* stream runner (retry backoff).
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { AuditDuration } from "./schema.ts";
|
|
9
|
+
/**
|
|
10
|
+
* Convert a {@link AuditDuration} (`5000`, `"5s"`, `"30m"`, `"2h"`, `"5d"`)
|
|
11
|
+
* to milliseconds. Throws on malformed strings or negative numbers.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { durationToMs } from "@xtandard/audit";
|
|
16
|
+
*
|
|
17
|
+
* durationToMs("5m"); // 300000
|
|
18
|
+
* durationToMs(250); // 250
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function durationToMs(duration: AuditDuration): number;
|
|
22
|
+
/**
|
|
23
|
+
* Parse a comma-separated duration list (the `RETRY_SCHEDULE` env var format,
|
|
24
|
+
* e.g. `"0s,5s,5m,30m,2h,5h,10h"`) into a {@link AuditDuration} array.
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseDurationList(input: string): AuditDuration[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Elysia 2 adapter: the same surface as `@xtandard/audit/elysia`
|
|
3
|
+
* (`auditPanel()`, the typed `auditElysia()` plugin, `auditContext()`), built against
|
|
4
|
+
* Elysia 2 and `@elysia/eden`.
|
|
5
|
+
*
|
|
6
|
+
* Import from `@xtandard/audit/elysia2`.
|
|
7
|
+
*
|
|
8
|
+
* @module elysia2
|
|
9
|
+
*/
|
|
10
|
+
export * from "./adapters/elysia2.ts";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The event log the core talks to: the storage's native
|
|
3
|
+
* {@link ./storage/contract.EventLogStorage} when it has one, otherwise the
|
|
4
|
+
* **generic KV fallback** implemented here over the four-method contract
|
|
5
|
+
* (ADR 0005).
|
|
6
|
+
*
|
|
7
|
+
* The fallback stores each event under `aud/t/{tenant}/events/{seq}` plus
|
|
8
|
+
* secondary index keys (`ix/time`, `ix/actor`, `ix/action`, `ix/target`, see
|
|
9
|
+
* {@link ./keys}). A query picks the most selective index, walks its keys in
|
|
10
|
+
* `(occurredAt, id)` order, loads candidates, and applies the in-memory matcher
|
|
11
|
+
* until the page is full. That is O(index size) key listing per query — fine
|
|
12
|
+
* for development and modest volumes; use a native driver (Postgres, SQLite,
|
|
13
|
+
* libSQL, MongoDB, Drizzle) at scale.
|
|
14
|
+
*
|
|
15
|
+
* Atomicity: an append writes the event keys one by one. Chain integrity across
|
|
16
|
+
* processes is guarded by the core (compare-and-swap on the head when the
|
|
17
|
+
* storage supports it); see docs/STORAGE.md.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import type { AuditEvent } from "./schema.ts";
|
|
22
|
+
import { type AuditStorage, type EventLogStorage } from "./storage/contract.ts";
|
|
23
|
+
/** The event-log operations the core needs (the native capability minus KV). */
|
|
24
|
+
export type EventLog = Pick<EventLogStorage, "appendEvents" | "getEvent" | "lastEvent" | "eventsBySeq" | "queryEvents" | "replaceEvent" | "deleteEventsThrough" | "countEvents" | "listEventTenants"> & {
|
|
25
|
+
/** True when backed by the storage's native capability. */
|
|
26
|
+
readonly native: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** Resolve the event log for a storage: native capability or the KV fallback. */
|
|
29
|
+
export declare function resolveEventLog(storage: AuditStorage): EventLog;
|
|
30
|
+
/** Every index key an event occupies (time, actor, action, each target). */
|
|
31
|
+
export declare function indexKeysFor(event: AuditEvent): string[];
|
|
32
|
+
/** The generic event log over the four-method KV contract. */
|
|
33
|
+
export declare function createKvEventLog(storage: AuditStorage): EventLog;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exports: CSV, JSON and JSONL streams of a query, plus the **verifiable
|
|
3
|
+
* bundle** — a JSONL file carrying a tenant's contiguous events together with
|
|
4
|
+
* the checkpoints and public keys needed to verify it offline (ADR 0004).
|
|
5
|
+
*
|
|
6
|
+
* Every export is noted through `core.noteExport` (the `events.export` before
|
|
7
|
+
* hook can deny it; the export is self-audited into the tenant's log).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import type { ActorOptions, AuditCore } from "./core.ts";
|
|
12
|
+
import { type AuditVerificationKey, type VerifyReport } from "./integrity.ts";
|
|
13
|
+
import type { AuditCheckpoint, AuditEvent, AuditQuery } from "./schema.ts";
|
|
14
|
+
import type { ActionMap } from "./standard-schema.ts";
|
|
15
|
+
/** Export formats. */
|
|
16
|
+
export type ExportFormat = "csv" | "json" | "jsonl" | "bundle";
|
|
17
|
+
/** The MIME type of each format. */
|
|
18
|
+
export declare const EXPORT_CONTENT_TYPES: Record<ExportFormat, string>;
|
|
19
|
+
/** CSV columns, in order. */
|
|
20
|
+
export declare const CSV_COLUMNS: readonly ["id", "tenant", "seq", "occurred_at", "recorded_at", "action", "outcome", "actor_id", "actor_type", "actor_name", "actor_email", "targets", "ip", "user_agent", "request_id", "description", "metadata", "hash"];
|
|
21
|
+
/** Quote a CSV cell (RFC 4180) and neutralize spreadsheet formulas. */
|
|
22
|
+
export declare function csvCell(value: unknown): string;
|
|
23
|
+
/** One event as a CSV row. */
|
|
24
|
+
export declare function eventToCsvRow(e: AuditEvent): string;
|
|
25
|
+
/** The first line of a bundle. */
|
|
26
|
+
export interface BundleHeader {
|
|
27
|
+
type: "header";
|
|
28
|
+
format: "xtandard-audit-bundle";
|
|
29
|
+
v: 1;
|
|
30
|
+
tenant: string;
|
|
31
|
+
exportedAt: string;
|
|
32
|
+
fromSeq: number | null;
|
|
33
|
+
toSeq: number | null;
|
|
34
|
+
/** `prevHash` the first event must carry when it is not seq 1 (the prune base). */
|
|
35
|
+
baseHash?: string;
|
|
36
|
+
}
|
|
37
|
+
/** A parsed bundle. */
|
|
38
|
+
export interface ParsedBundle {
|
|
39
|
+
header: BundleHeader;
|
|
40
|
+
events: AuditEvent[];
|
|
41
|
+
checkpoints: AuditCheckpoint[];
|
|
42
|
+
jwks: {
|
|
43
|
+
keys: JsonWebKey[];
|
|
44
|
+
} | null;
|
|
45
|
+
}
|
|
46
|
+
/** Options for {@link exportEvents}. */
|
|
47
|
+
export interface ExportOptions extends ActorOptions {
|
|
48
|
+
format: ExportFormat;
|
|
49
|
+
/** Max events exported. Default 100 000. */
|
|
50
|
+
maxEvents?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Stream a query (or, for `"bundle"`, a tenant's whole retained chain) in the
|
|
54
|
+
* given format. Requires `query.tenant` for every format (exports are always
|
|
55
|
+
* per tenant).
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { exportEvents } from "@xtandard/audit";
|
|
60
|
+
*
|
|
61
|
+
* const stream = await exportEvents(audit, { tenant: "acme", from: "2026-01-01" }, { format: "csv" });
|
|
62
|
+
* return new Response(stream, { headers: { "content-type": "text/csv" } });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function exportEvents<A extends ActionMap>(core: AuditCore<A>, query: AuditQuery, options: ExportOptions): Promise<ReadableStream<Uint8Array>>;
|
|
66
|
+
/** Parse a bundle (JSONL text). Throws on a malformed bundle. */
|
|
67
|
+
export declare function parseBundle(text: string): ParsedBundle;
|
|
68
|
+
/**
|
|
69
|
+
* Verify a bundle offline. Keys default to the bundle's own JWKS — pass
|
|
70
|
+
* `keys` (from a JWKS you obtained independently, e.g. the vendor's published
|
|
71
|
+
* keys) to not trust the file for them.
|
|
72
|
+
*/
|
|
73
|
+
export declare function verifyBundle(text: string, options?: {
|
|
74
|
+
keys?: AuditVerificationKey[];
|
|
75
|
+
}): Promise<VerifyReport & {
|
|
76
|
+
bundle: BundleHeader;
|
|
77
|
+
}>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook contracts — control-plane extensibility around audit mutations.
|
|
3
|
+
*
|
|
4
|
+
* A hook is plain JavaScript wired in at {@link ../core.createAuditCore} time
|
|
5
|
+
* (never authored through the UI — that would be remote code execution). Two
|
|
6
|
+
* phases, deliberately asymmetric (identical to the sibling packages):
|
|
7
|
+
*
|
|
8
|
+
* - **`before`** runs *before* a mutation commits. Throwing **denies** the
|
|
9
|
+
* operation (the thrown error's message is the reason). Multiple `before`
|
|
10
|
+
* hooks run **sequentially in declared order**; the first throw aborts and
|
|
11
|
+
* nothing commits. Quotas, policy gates and export approvals build on this.
|
|
12
|
+
* - **`after`** runs *after* a mutation commits, for side effects. An `after`
|
|
13
|
+
* hook **must never fail the operation**, so errors are isolated and reported
|
|
14
|
+
* via `onHookError`, not rethrown.
|
|
15
|
+
*
|
|
16
|
+
* Recording is a hook event too (`event.record` / `events.recorded`), so a host
|
|
17
|
+
* can gate or observe the hot path; the cheaper per-event tap is the
|
|
18
|
+
* fire-and-forget `onRecord` option.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
import type { ActionDefinition, AuditCheckpoint, AuditEvent, AuditQuery, AuditSection } from "../schema.ts";
|
|
23
|
+
/** Who performed a control-plane operation (from the authenticated principal). */
|
|
24
|
+
export interface HookActor {
|
|
25
|
+
id: string;
|
|
26
|
+
email?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Event delivered to {@link AuditHooks.before} — the *proposed* mutation,
|
|
31
|
+
* before it commits. Throw from the handler to deny it.
|
|
32
|
+
*/
|
|
33
|
+
export type BeforeEvent = {
|
|
34
|
+
/** The record gate (quota, policy). Runs once per `record`/`recordMany` call per tenant. */
|
|
35
|
+
type: "event.record";
|
|
36
|
+
tenant: string;
|
|
37
|
+
actions: string[];
|
|
38
|
+
count: number;
|
|
39
|
+
} | {
|
|
40
|
+
type: "event.erase";
|
|
41
|
+
tenant: string;
|
|
42
|
+
eventId: string;
|
|
43
|
+
sections: AuditSection[];
|
|
44
|
+
reason?: string;
|
|
45
|
+
actor: HookActor | null;
|
|
46
|
+
} | {
|
|
47
|
+
type: "events.export";
|
|
48
|
+
tenant: string;
|
|
49
|
+
query: AuditQuery;
|
|
50
|
+
format: string;
|
|
51
|
+
actor: HookActor | null;
|
|
52
|
+
} | {
|
|
53
|
+
type: "events.prune";
|
|
54
|
+
tenant: string;
|
|
55
|
+
throughSeq: number;
|
|
56
|
+
actor: HookActor | null;
|
|
57
|
+
} | {
|
|
58
|
+
type: "action.upsert";
|
|
59
|
+
action: ActionDefinition;
|
|
60
|
+
actor: HookActor | null;
|
|
61
|
+
} | {
|
|
62
|
+
type: "action.delete";
|
|
63
|
+
name: string;
|
|
64
|
+
actor: HookActor | null;
|
|
65
|
+
} | {
|
|
66
|
+
type: "checkpoint.create";
|
|
67
|
+
tenant: string;
|
|
68
|
+
actor: HookActor | null;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Event delivered to {@link AuditHooks.after} — the *committed* mutation.
|
|
72
|
+
*/
|
|
73
|
+
export type AfterEvent = {
|
|
74
|
+
type: "events.recorded";
|
|
75
|
+
tenant: string;
|
|
76
|
+
events: AuditEvent[];
|
|
77
|
+
at: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: "event.erased";
|
|
80
|
+
tenant: string;
|
|
81
|
+
event: AuditEvent;
|
|
82
|
+
sections: AuditSection[];
|
|
83
|
+
at: string;
|
|
84
|
+
} | {
|
|
85
|
+
type: "events.exported";
|
|
86
|
+
tenant: string;
|
|
87
|
+
query: AuditQuery;
|
|
88
|
+
format: string;
|
|
89
|
+
at: string;
|
|
90
|
+
} | {
|
|
91
|
+
/** Retention removed a prefix of the chain; `base` anchors what remains. */
|
|
92
|
+
type: "events.pruned";
|
|
93
|
+
tenant: string;
|
|
94
|
+
throughSeq: number;
|
|
95
|
+
count: number;
|
|
96
|
+
base: AuditCheckpoint | null;
|
|
97
|
+
at: string;
|
|
98
|
+
} | {
|
|
99
|
+
type: "action.upserted";
|
|
100
|
+
action: ActionDefinition;
|
|
101
|
+
at: string;
|
|
102
|
+
} | {
|
|
103
|
+
type: "action.deleted";
|
|
104
|
+
name: string;
|
|
105
|
+
action: ActionDefinition;
|
|
106
|
+
at: string;
|
|
107
|
+
} | {
|
|
108
|
+
type: "checkpoint.created";
|
|
109
|
+
tenant: string;
|
|
110
|
+
checkpoint: AuditCheckpoint;
|
|
111
|
+
at: string;
|
|
112
|
+
};
|
|
113
|
+
/** The discriminant strings of {@link BeforeEvent} / {@link AfterEvent}. */
|
|
114
|
+
export type BeforeEventType = BeforeEvent["type"];
|
|
115
|
+
export type AfterEventType = AfterEvent["type"];
|
|
116
|
+
/**
|
|
117
|
+
* Thrown from a {@link AuditHooks.before} handler to **deny** a mutation with
|
|
118
|
+
* a clean HTTP status (default `403`). Any thrown error denies the mutation,
|
|
119
|
+
* but a plain `Error` maps to `500` at the API layer (treated as an unexpected
|
|
120
|
+
* bug); throw this to signal a deliberate policy rejection (`403`, or a custom
|
|
121
|
+
* `status` such as `409`/`422`).
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* before(event) {
|
|
126
|
+
* if (event.type === "event.record" && overQuota(event.tenant)) {
|
|
127
|
+
* throw new HookDeniedError("Monthly audit quota exceeded.", { status: 429 });
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export declare class HookDeniedError extends Error {
|
|
133
|
+
/** HTTP status the API layer should respond with. Default `403`. */
|
|
134
|
+
readonly status: number;
|
|
135
|
+
constructor(message: string, options?: {
|
|
136
|
+
status?: number;
|
|
137
|
+
cause?: unknown;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* A control-plane hook. Implement `before`, `after`, or both. Pass one — or an
|
|
142
|
+
* array — to {@link ../core.createAuditCore} via `hooks`.
|
|
143
|
+
*/
|
|
144
|
+
export interface AuditHooks {
|
|
145
|
+
/**
|
|
146
|
+
* Runs before a mutation commits. **Throw to deny** (the error propagates to
|
|
147
|
+
* the caller; its message is the reason). Return/resolve to allow. Must not
|
|
148
|
+
* mutate the event payload.
|
|
149
|
+
*/
|
|
150
|
+
before?(event: BeforeEvent): void | Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Runs after a mutation commits. For side effects only. Errors are isolated
|
|
153
|
+
* and reported via `onHookError` — they never fail the (already committed)
|
|
154
|
+
* operation.
|
|
155
|
+
*/
|
|
156
|
+
after?(event: AfterEvent): void | Promise<void>;
|
|
157
|
+
}
|
|
158
|
+
/** Accepts a single hook, an array, or nothing. */
|
|
159
|
+
export type AuditHooksInput = AuditHooks | readonly AuditHooks[] | undefined;
|
|
160
|
+
/** Reports an error thrown by an `after` hook. */
|
|
161
|
+
export type HookErrorReporter = (error: unknown, event: AfterEvent) => void;
|
|
162
|
+
/** Normalize the `hooks` option into a flat array (empty when unset). */
|
|
163
|
+
export declare function normalizeHooks(input: AuditHooksInput): AuditHooks[];
|
|
164
|
+
/**
|
|
165
|
+
* Run every `before` hook sequentially, in order. The first hook to throw
|
|
166
|
+
* aborts: the error propagates to the caller (denying the mutation) and no
|
|
167
|
+
* later hook runs. A no-op when there are no `before` hooks.
|
|
168
|
+
*/
|
|
169
|
+
export declare function runBefore(hooks: AuditHooks[], event: BeforeEvent): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Run every `after` hook, isolating failures. The mutation has already
|
|
172
|
+
* committed, so a throwing hook must not fail the operation — its error is
|
|
173
|
+
* routed to `onError` and swallowed. Remaining hooks still run.
|
|
174
|
+
*/
|
|
175
|
+
export declare function runAfter(hooks: AuditHooks[], event: AfterEvent, onError: HookErrorReporter): Promise<void>;
|
|
176
|
+
/** Default `after`-hook error reporter: warn, but never throw. */
|
|
177
|
+
export declare const defaultHookErrorReporter: HookErrorReporter;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Time-sortable ids (ADR 0010): `{prefix}_` + 26 Crockford base32 characters —
|
|
3
|
+
* 48 bits of unix milliseconds followed by 80 random bits, ULID-compatible.
|
|
4
|
+
* Monotonic within a process: ids minted in the same millisecond increment the
|
|
5
|
+
* random part, so lexicographic order equals creation order. Zero dependencies.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
/** Prefixes for the generated id kinds. */
|
|
10
|
+
export type IdPrefix = "evt" | "chk";
|
|
11
|
+
/** A raw 26-char time-sortable value for `ms` (defaults to now). */
|
|
12
|
+
export declare function sortableId(ms?: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generate a new id, e.g. `newId("evt")` → `"evt_01JD…"`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { newId } from "@xtandard/audit";
|
|
19
|
+
*
|
|
20
|
+
* const id = newId("evt"); // "evt_01JD3Z…" — sorts by creation time
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function newId(prefix: IdPrefix, ms?: number): string;
|
|
24
|
+
/** Regex an id of the given prefix must match. */
|
|
25
|
+
export declare function idPattern(prefix: IdPrefix): RegExp;
|
|
26
|
+
/** Decode the millisecond timestamp embedded in a time-sortable id, or `null`. */
|
|
27
|
+
export declare function idTime(id: string): number | null;
|