@xtandard/audit 0.0.0-stage → 0.1.0
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 +384 -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 +31935 -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-Cd-mcIwC.css +1 -0
- package/dist/ui/assets/index-DUAgpiot.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,1725 @@
|
|
|
1
|
+
const require_validation = require("./validation-lb0YXrxx.cjs");
|
|
2
|
+
const require_schema = require("./schema.cjs");
|
|
3
|
+
const require_integrity = require("./integrity-BHhjTBNk.cjs");
|
|
4
|
+
const require_context = require("./context.cjs");
|
|
5
|
+
const require_query = require("./query-ChGGtlA7.cjs");
|
|
6
|
+
const require_contract = require("./contract-DYvBNdnR.cjs");
|
|
7
|
+
//#region src/duration.ts
|
|
8
|
+
const UNIT_MS = {
|
|
9
|
+
ms: 1,
|
|
10
|
+
s: 1e3,
|
|
11
|
+
m: 6e4,
|
|
12
|
+
h: 36e5,
|
|
13
|
+
d: 864e5
|
|
14
|
+
};
|
|
15
|
+
const DURATION_RE = /^(\d+(?:\.\d+)?)(ms|s|m|h|d)$/;
|
|
16
|
+
/**
|
|
17
|
+
* Convert a {@link AuditDuration} (`5000`, `"5s"`, `"30m"`, `"2h"`, `"5d"`)
|
|
18
|
+
* to milliseconds. Throws on malformed strings or negative numbers.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { durationToMs } from "@xtandard/audit";
|
|
23
|
+
*
|
|
24
|
+
* durationToMs("5m"); // 300000
|
|
25
|
+
* durationToMs(250); // 250
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function durationToMs(duration) {
|
|
29
|
+
if (typeof duration === "number") {
|
|
30
|
+
if (!Number.isFinite(duration) || duration < 0) throw new Error(`Invalid duration: ${duration}`);
|
|
31
|
+
return duration;
|
|
32
|
+
}
|
|
33
|
+
const match = DURATION_RE.exec(duration.trim());
|
|
34
|
+
if (!match) throw new Error(`Invalid duration: "${duration}" (expected e.g. "5s", "30m", "2h")`);
|
|
35
|
+
return Number(match[1]) * UNIT_MS[match[2]];
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/keys.ts
|
|
39
|
+
var keys_exports = /* @__PURE__ */ require_validation.__exportAll({
|
|
40
|
+
ROOT: () => "aud",
|
|
41
|
+
actionIndexPrefix: () => actionIndexPrefix,
|
|
42
|
+
actionKey: () => actionKey,
|
|
43
|
+
actionsKey: () => actionsKey,
|
|
44
|
+
actorIndexPrefix: () => actorIndexPrefix,
|
|
45
|
+
checkpointKey: () => checkpointKey,
|
|
46
|
+
checkpointsPrefix: () => checkpointsPrefix,
|
|
47
|
+
decodeSegment: () => decodeSegment,
|
|
48
|
+
eventIdKey: () => eventIdKey,
|
|
49
|
+
eventKey: () => eventKey,
|
|
50
|
+
eventsPrefix: () => eventsPrefix,
|
|
51
|
+
headKey: () => headKey,
|
|
52
|
+
indexLeaf: () => indexLeaf,
|
|
53
|
+
indexRoot: () => indexRoot,
|
|
54
|
+
lastSegment: () => lastSegment,
|
|
55
|
+
padMs: () => padMs,
|
|
56
|
+
padSeq: () => padSeq,
|
|
57
|
+
parseEventKey: () => parseEventKey,
|
|
58
|
+
parseIndexLeaf: () => parseIndexLeaf,
|
|
59
|
+
streamCursorKey: () => streamCursorKey,
|
|
60
|
+
streamCursorsPrefix: () => streamCursorsPrefix,
|
|
61
|
+
streamLeaseKey: () => streamLeaseKey,
|
|
62
|
+
streamMetaKey: () => streamMetaKey,
|
|
63
|
+
targetIndexPrefix: () => targetIndexPrefix,
|
|
64
|
+
tenantPrefix: () => tenantPrefix,
|
|
65
|
+
tenantsKey: () => tenantsKey,
|
|
66
|
+
timeIndexPrefix: () => timeIndexPrefix
|
|
67
|
+
});
|
|
68
|
+
const enc = (segment) => encodeURIComponent(segment).replace(/~/g, "%7E");
|
|
69
|
+
/** Zero-pad a seq to 12 digits. */
|
|
70
|
+
const padSeq = (seq) => String(seq).padStart(12, "0");
|
|
71
|
+
/** Zero-pad epoch millis to 13 digits. */
|
|
72
|
+
const padMs = (ms) => String(Math.max(0, ms)).padStart(13, "0");
|
|
73
|
+
/** Index of all tenant keys. */
|
|
74
|
+
const tenantsKey = () => `aud/tenants`;
|
|
75
|
+
/** Action catalog index. */
|
|
76
|
+
const actionsKey = () => `aud/actions`;
|
|
77
|
+
/** One action catalog entry. */
|
|
78
|
+
const actionKey = (name) => `aud/actions/${enc(name)}`;
|
|
79
|
+
/** Prefix under which everything belonging to one tenant lives. */
|
|
80
|
+
const tenantPrefix = (tenant) => `aud/t/${enc(tenant)}/`;
|
|
81
|
+
/** The tenant's chain head. */
|
|
82
|
+
const headKey = (tenant) => `${tenantPrefix(tenant)}head`;
|
|
83
|
+
/** Prefix of the tenant's checkpoints. */
|
|
84
|
+
const checkpointsPrefix = (tenant) => `${tenantPrefix(tenant)}checkpoints/`;
|
|
85
|
+
/** One checkpoint. */
|
|
86
|
+
const checkpointKey = (tenant, id) => `${checkpointsPrefix(tenant)}${id}`;
|
|
87
|
+
/** Prefix of a stream's per-tenant cursors. */
|
|
88
|
+
const streamCursorsPrefix = (stream) => `aud/streams/${enc(stream)}/cursors/`;
|
|
89
|
+
/** One stream cursor. */
|
|
90
|
+
const streamCursorKey = (stream, tenant) => `${streamCursorsPrefix(stream)}${enc(tenant)}`;
|
|
91
|
+
/** A stream's metadata (first-run marker). */
|
|
92
|
+
const streamMetaKey = (stream) => `aud/streams/${enc(stream)}/meta`;
|
|
93
|
+
/** A stream's runner lease. */
|
|
94
|
+
const streamLeaseKey = (stream) => `aud/streams/${enc(stream)}/lease`;
|
|
95
|
+
/** Prefix of the tenant's events (by seq). */
|
|
96
|
+
const eventsPrefix = (tenant) => `${tenantPrefix(tenant)}events/`;
|
|
97
|
+
/** One event, keyed by seq. */
|
|
98
|
+
const eventKey = (tenant, seq) => `${eventsPrefix(tenant)}${padSeq(seq)}`;
|
|
99
|
+
/** Event id → seq. */
|
|
100
|
+
const eventIdKey = (tenant, id) => `${tenantPrefix(tenant)}ids/${id}`;
|
|
101
|
+
/** Prefix of a tenant's secondary indexes. */
|
|
102
|
+
const indexRoot = (tenant) => `${tenantPrefix(tenant)}ix/`;
|
|
103
|
+
/** Time index prefix. */
|
|
104
|
+
const timeIndexPrefix = (tenant) => `${indexRoot(tenant)}time/`;
|
|
105
|
+
/** Actor index prefix. */
|
|
106
|
+
const actorIndexPrefix = (tenant, actorId) => `${indexRoot(tenant)}actor/${enc(actorId)}/`;
|
|
107
|
+
/** Action index prefix. */
|
|
108
|
+
const actionIndexPrefix = (tenant, action) => `${indexRoot(tenant)}action/${enc(action)}/`;
|
|
109
|
+
/** Target index prefix. */
|
|
110
|
+
const targetIndexPrefix = (tenant, type, id) => `${indexRoot(tenant)}target/${enc(type)}/${enc(id)}/`;
|
|
111
|
+
/** The `{ms}~{id}` leaf of every index key. */
|
|
112
|
+
const indexLeaf = (occurredAtMs, id) => `${padMs(occurredAtMs)}~${id}`;
|
|
113
|
+
/** Parse an index key's leaf back into `(occurredAtMs, id)`. */
|
|
114
|
+
const parseIndexLeaf = (key) => {
|
|
115
|
+
const leaf = lastSegment(key);
|
|
116
|
+
const sep = leaf.indexOf("~");
|
|
117
|
+
if (sep === -1) return null;
|
|
118
|
+
const ms = Number(leaf.slice(0, sep));
|
|
119
|
+
const id = leaf.slice(sep + 1);
|
|
120
|
+
if (!Number.isFinite(ms) || id.length === 0) return null;
|
|
121
|
+
return {
|
|
122
|
+
ms,
|
|
123
|
+
id
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/** Parse a seq from an event key. */
|
|
127
|
+
const parseEventKey = (key) => {
|
|
128
|
+
const n = Number(lastSegment(key));
|
|
129
|
+
return Number.isInteger(n) && n > 0 ? n : null;
|
|
130
|
+
};
|
|
131
|
+
/** Extract the trailing segment from a key. */
|
|
132
|
+
const lastSegment = (key) => {
|
|
133
|
+
const parts = key.split("/");
|
|
134
|
+
return parts[parts.length - 1] ?? "";
|
|
135
|
+
};
|
|
136
|
+
/** Decode an escaped key segment. */
|
|
137
|
+
const decodeSegment = (segment) => decodeURIComponent(segment);
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/event-log.ts
|
|
140
|
+
/**
|
|
141
|
+
* The event log the core talks to: the storage's native
|
|
142
|
+
* {@link ./storage/contract.EventLogStorage} when it has one, otherwise the
|
|
143
|
+
* **generic KV fallback** implemented here over the four-method contract
|
|
144
|
+
* (ADR 0005).
|
|
145
|
+
*
|
|
146
|
+
* The fallback stores each event under `aud/t/{tenant}/events/{seq}` plus
|
|
147
|
+
* secondary index keys (`ix/time`, `ix/actor`, `ix/action`, `ix/target`, see
|
|
148
|
+
* {@link ./keys}). A query picks the most selective index, walks its keys in
|
|
149
|
+
* `(occurredAt, id)` order, loads candidates, and applies the in-memory matcher
|
|
150
|
+
* until the page is full. That is O(index size) key listing per query — fine
|
|
151
|
+
* for development and modest volumes; use a native driver (Postgres, SQLite,
|
|
152
|
+
* libSQL, MongoDB, Drizzle) at scale.
|
|
153
|
+
*
|
|
154
|
+
* Atomicity: an append writes the event keys one by one. Chain integrity across
|
|
155
|
+
* processes is guarded by the core (compare-and-swap on the head when the
|
|
156
|
+
* storage supports it); see docs/STORAGE.md.
|
|
157
|
+
*
|
|
158
|
+
* @module
|
|
159
|
+
*/
|
|
160
|
+
/** Resolve the event log for a storage: native capability or the KV fallback. */
|
|
161
|
+
function resolveEventLog(storage) {
|
|
162
|
+
if (require_contract.hasEventLog(storage)) return {
|
|
163
|
+
native: true,
|
|
164
|
+
appendEvents: (t, e, o) => storage.appendEvents(t, e, o),
|
|
165
|
+
getEvent: (t, id) => storage.getEvent(t, id),
|
|
166
|
+
lastEvent: (t) => storage.lastEvent(t),
|
|
167
|
+
eventsBySeq: (t, o) => storage.eventsBySeq(t, o),
|
|
168
|
+
queryEvents: (q) => storage.queryEvents(q),
|
|
169
|
+
replaceEvent: (e) => storage.replaceEvent(e),
|
|
170
|
+
deleteEventsThrough: (t, s) => storage.deleteEventsThrough(t, s),
|
|
171
|
+
countEvents: (t) => storage.countEvents(t),
|
|
172
|
+
listEventTenants: () => storage.listEventTenants()
|
|
173
|
+
};
|
|
174
|
+
return createKvEventLog(storage);
|
|
175
|
+
}
|
|
176
|
+
/** Every index key an event occupies (time, actor, action, each target). */
|
|
177
|
+
function indexKeysFor(event) {
|
|
178
|
+
const leaf = indexLeaf(Date.parse(event.occurredAt), event.id);
|
|
179
|
+
const keys = [
|
|
180
|
+
`${timeIndexPrefix(event.tenant)}${leaf}`,
|
|
181
|
+
`${actorIndexPrefix(event.tenant, event.actor.id)}${leaf}`,
|
|
182
|
+
`${actionIndexPrefix(event.tenant, event.action)}${leaf}`
|
|
183
|
+
];
|
|
184
|
+
const seen = /* @__PURE__ */ new Set();
|
|
185
|
+
for (const t of event.targets) {
|
|
186
|
+
const k = `${targetIndexPrefix(event.tenant, t.type, t.id)}${leaf}`;
|
|
187
|
+
if (!seen.has(k)) {
|
|
188
|
+
seen.add(k);
|
|
189
|
+
keys.push(k);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return keys;
|
|
193
|
+
}
|
|
194
|
+
/** Choose the index prefix to scan for a query within one tenant. */
|
|
195
|
+
function indexPrefixFor(tenant, q) {
|
|
196
|
+
if (q.actorId !== void 0) return actorIndexPrefix(tenant, q.actorId);
|
|
197
|
+
if (q.targetType !== void 0 && q.targetId !== void 0) return targetIndexPrefix(tenant, q.targetType, q.targetId);
|
|
198
|
+
if (q.actions.length === 1 && q.actionPrefixes.length === 0) return actionIndexPrefix(tenant, q.actions[0]);
|
|
199
|
+
return timeIndexPrefix(tenant);
|
|
200
|
+
}
|
|
201
|
+
/** The generic event log over the four-method KV contract. */
|
|
202
|
+
function createKvEventLog(storage) {
|
|
203
|
+
async function seqKeys(tenant) {
|
|
204
|
+
return (await storage.getKeys(eventsPrefix(tenant))).map(parseEventKey).filter((n) => n !== null).sort((a, b) => a - b);
|
|
205
|
+
}
|
|
206
|
+
async function tenants() {
|
|
207
|
+
return await storage.getItem(tenantsKey()) ?? [];
|
|
208
|
+
}
|
|
209
|
+
async function removeEvent(event) {
|
|
210
|
+
for (const k of indexKeysFor(event)) await storage.removeItem(k);
|
|
211
|
+
await storage.removeItem(eventIdKey(event.tenant, event.id));
|
|
212
|
+
await storage.removeItem(eventKey(event.tenant, event.seq));
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
native: false,
|
|
216
|
+
async appendEvents(tenant, events, { expectedSeq }) {
|
|
217
|
+
const first = events[0];
|
|
218
|
+
if (!first) return;
|
|
219
|
+
if (first.seq !== expectedSeq + 1) throw new require_contract.ChainConflictError(tenant, expectedSeq);
|
|
220
|
+
if (await storage.getItem(eventKey(tenant, first.seq)) !== null) throw new require_contract.ChainConflictError(tenant, expectedSeq);
|
|
221
|
+
for (const event of events) {
|
|
222
|
+
await storage.setItem(eventKey(tenant, event.seq), event);
|
|
223
|
+
await storage.setItem(eventIdKey(tenant, event.id), event.seq);
|
|
224
|
+
for (const k of indexKeysFor(event)) await storage.setItem(k, event.seq);
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
async getEvent(tenant, id) {
|
|
228
|
+
const seq = await storage.getItem(eventIdKey(tenant, id));
|
|
229
|
+
if (seq === null) return null;
|
|
230
|
+
return storage.getItem(eventKey(tenant, seq));
|
|
231
|
+
},
|
|
232
|
+
async lastEvent(tenant) {
|
|
233
|
+
const seqs = await seqKeys(tenant);
|
|
234
|
+
const last = seqs[seqs.length - 1];
|
|
235
|
+
return last === void 0 ? null : storage.getItem(eventKey(tenant, last));
|
|
236
|
+
},
|
|
237
|
+
async eventsBySeq(tenant, { afterSeq, limit }) {
|
|
238
|
+
const seqs = (await seqKeys(tenant)).filter((s) => s > afterSeq).slice(0, limit);
|
|
239
|
+
const out = [];
|
|
240
|
+
for (const s of seqs) {
|
|
241
|
+
const e = await storage.getItem(eventKey(tenant, s));
|
|
242
|
+
if (e) out.push(e);
|
|
243
|
+
}
|
|
244
|
+
return out;
|
|
245
|
+
},
|
|
246
|
+
async queryEvents(q) {
|
|
247
|
+
const scope = q.tenant !== void 0 ? [q.tenant] : await tenants();
|
|
248
|
+
const candidates = [];
|
|
249
|
+
for (const tenant of scope) {
|
|
250
|
+
const prefix = indexPrefixFor(tenant, q);
|
|
251
|
+
for (const key of await storage.getKeys(prefix)) {
|
|
252
|
+
if (key.slice(prefix.length).includes("/")) continue;
|
|
253
|
+
const leaf = parseIndexLeaf(key);
|
|
254
|
+
if (!leaf) continue;
|
|
255
|
+
const occurredAt = new Date(leaf.ms).toISOString();
|
|
256
|
+
if (q.from !== void 0 && occurredAt < q.from) continue;
|
|
257
|
+
if (q.to !== void 0 && occurredAt >= q.to) continue;
|
|
258
|
+
const pos = {
|
|
259
|
+
occurredAt,
|
|
260
|
+
id: leaf.id
|
|
261
|
+
};
|
|
262
|
+
if (q.after && !require_query.isAfter(pos, q.after, q.order)) continue;
|
|
263
|
+
candidates.push({
|
|
264
|
+
tenant,
|
|
265
|
+
...pos,
|
|
266
|
+
key
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
candidates.sort((a, b) => q.order === "desc" ? require_query.compareEvents(b, a) : require_query.compareEvents(a, b));
|
|
271
|
+
const items = [];
|
|
272
|
+
for (const c of candidates) {
|
|
273
|
+
const seq = await storage.getItem(c.key);
|
|
274
|
+
if (seq === null) continue;
|
|
275
|
+
const event = await storage.getItem(eventKey(c.tenant, seq));
|
|
276
|
+
if (!event || !require_query.matchesQuery(event, q)) continue;
|
|
277
|
+
if (items.length === q.limit) return {
|
|
278
|
+
items,
|
|
279
|
+
hasMore: true
|
|
280
|
+
};
|
|
281
|
+
items.push(event);
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
items,
|
|
285
|
+
hasMore: false
|
|
286
|
+
};
|
|
287
|
+
},
|
|
288
|
+
async replaceEvent(event) {
|
|
289
|
+
const existing = await storage.getItem(eventKey(event.tenant, event.seq));
|
|
290
|
+
if (!existing || existing.id !== event.id) return;
|
|
291
|
+
for (const k of indexKeysFor(existing)) await storage.removeItem(k);
|
|
292
|
+
await storage.setItem(eventKey(event.tenant, event.seq), event);
|
|
293
|
+
for (const k of indexKeysFor(event)) await storage.setItem(k, event.seq);
|
|
294
|
+
},
|
|
295
|
+
async deleteEventsThrough(tenant, throughSeq) {
|
|
296
|
+
let removed = 0;
|
|
297
|
+
for (const s of await seqKeys(tenant)) {
|
|
298
|
+
if (s > throughSeq) break;
|
|
299
|
+
const event = await storage.getItem(eventKey(tenant, s));
|
|
300
|
+
if (event) await removeEvent(event);
|
|
301
|
+
else await storage.removeItem(eventKey(tenant, s));
|
|
302
|
+
removed++;
|
|
303
|
+
}
|
|
304
|
+
return removed;
|
|
305
|
+
},
|
|
306
|
+
async countEvents(tenant) {
|
|
307
|
+
const scope = tenant !== void 0 ? [tenant] : await tenants();
|
|
308
|
+
let n = 0;
|
|
309
|
+
for (const t of scope) n += (await storage.getKeys(eventsPrefix(t))).length;
|
|
310
|
+
return n;
|
|
311
|
+
},
|
|
312
|
+
async listEventTenants() {
|
|
313
|
+
return tenants();
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/hooks/contract.ts
|
|
319
|
+
/**
|
|
320
|
+
* Thrown from a {@link AuditHooks.before} handler to **deny** a mutation with
|
|
321
|
+
* a clean HTTP status (default `403`). Any thrown error denies the mutation,
|
|
322
|
+
* but a plain `Error` maps to `500` at the API layer (treated as an unexpected
|
|
323
|
+
* bug); throw this to signal a deliberate policy rejection (`403`, or a custom
|
|
324
|
+
* `status` such as `409`/`422`).
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* before(event) {
|
|
329
|
+
* if (event.type === "event.record" && overQuota(event.tenant)) {
|
|
330
|
+
* throw new HookDeniedError("Monthly audit quota exceeded.", { status: 429 });
|
|
331
|
+
* }
|
|
332
|
+
* }
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
var HookDeniedError = class extends Error {
|
|
336
|
+
/** HTTP status the API layer should respond with. Default `403`. */
|
|
337
|
+
status;
|
|
338
|
+
constructor(message, options) {
|
|
339
|
+
super(message, options?.cause !== void 0 ? { cause: options.cause } : void 0);
|
|
340
|
+
this.name = "HookDeniedError";
|
|
341
|
+
this.status = options?.status ?? 403;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
/** Normalize the `hooks` option into a flat array (empty when unset). */
|
|
345
|
+
function normalizeHooks(input) {
|
|
346
|
+
if (!input) return [];
|
|
347
|
+
return Array.isArray(input) ? [...input] : [input];
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Run every `before` hook sequentially, in order. The first hook to throw
|
|
351
|
+
* aborts: the error propagates to the caller (denying the mutation) and no
|
|
352
|
+
* later hook runs. A no-op when there are no `before` hooks.
|
|
353
|
+
*/
|
|
354
|
+
async function runBefore(hooks, event) {
|
|
355
|
+
for (const hook of hooks) if (hook.before) await hook.before(event);
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Run every `after` hook, isolating failures. The mutation has already
|
|
359
|
+
* committed, so a throwing hook must not fail the operation — its error is
|
|
360
|
+
* routed to `onError` and swallowed. Remaining hooks still run.
|
|
361
|
+
*/
|
|
362
|
+
async function runAfter(hooks, event, onError) {
|
|
363
|
+
await Promise.all(hooks.map(async (hook) => {
|
|
364
|
+
if (!hook.after) return;
|
|
365
|
+
try {
|
|
366
|
+
await hook.after(event);
|
|
367
|
+
} catch (error) {
|
|
368
|
+
onError(error, event);
|
|
369
|
+
}
|
|
370
|
+
}));
|
|
371
|
+
}
|
|
372
|
+
/** Default `after`-hook error reporter: warn, but never throw. */
|
|
373
|
+
const defaultHookErrorReporter = (error, event) => {
|
|
374
|
+
console.warn(`[@xtandard/audit] after-hook for "${event.type}" threw:`, error);
|
|
375
|
+
};
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/id.ts
|
|
378
|
+
const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
379
|
+
const TIME_LEN = 10;
|
|
380
|
+
const RANDOM_LEN = 16;
|
|
381
|
+
let lastTime = -1;
|
|
382
|
+
let lastRandom = [];
|
|
383
|
+
function encodeTime(ms) {
|
|
384
|
+
let out = "";
|
|
385
|
+
let value = ms;
|
|
386
|
+
for (let i = 0; i < TIME_LEN; i++) {
|
|
387
|
+
out = ENCODING[value % 32] + out;
|
|
388
|
+
value = Math.floor(value / 32);
|
|
389
|
+
}
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
392
|
+
function randomDigits() {
|
|
393
|
+
const bytes = new Uint8Array(RANDOM_LEN);
|
|
394
|
+
crypto.getRandomValues(bytes);
|
|
395
|
+
return Array.from(bytes, (b) => b % 32);
|
|
396
|
+
}
|
|
397
|
+
/** Increment a base32 digit array by one (carry to the left). */
|
|
398
|
+
function increment(digits) {
|
|
399
|
+
const next = digits.slice();
|
|
400
|
+
for (let i = next.length - 1; i >= 0; i--) {
|
|
401
|
+
if (next[i] < 31) {
|
|
402
|
+
next[i] = next[i] + 1;
|
|
403
|
+
return next;
|
|
404
|
+
}
|
|
405
|
+
next[i] = 0;
|
|
406
|
+
}
|
|
407
|
+
return randomDigits();
|
|
408
|
+
}
|
|
409
|
+
/** A raw 26-char time-sortable value for `ms` (defaults to now). */
|
|
410
|
+
function sortableId(ms = Date.now()) {
|
|
411
|
+
ms = Math.floor(ms);
|
|
412
|
+
let random;
|
|
413
|
+
if (ms <= lastTime) {
|
|
414
|
+
random = increment(lastRandom);
|
|
415
|
+
ms = lastTime;
|
|
416
|
+
} else {
|
|
417
|
+
random = randomDigits();
|
|
418
|
+
lastTime = ms;
|
|
419
|
+
}
|
|
420
|
+
lastRandom = random;
|
|
421
|
+
return encodeTime(ms) + random.map((d) => ENCODING[d]).join("");
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Generate a new id, e.g. `newId("evt")` → `"evt_01JD…"`.
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* ```ts
|
|
428
|
+
* import { newId } from "@xtandard/audit";
|
|
429
|
+
*
|
|
430
|
+
* const id = newId("evt"); // "evt_01JD3Z…" — sorts by creation time
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
function newId(prefix, ms) {
|
|
434
|
+
return `${prefix}_${sortableId(ms)}`;
|
|
435
|
+
}
|
|
436
|
+
/** Regex an id of the given prefix must match. */
|
|
437
|
+
function idPattern(prefix) {
|
|
438
|
+
return new RegExp(`^${prefix}_[0-9A-HJKMNP-TV-Z]{26}$`);
|
|
439
|
+
}
|
|
440
|
+
/** Decode the millisecond timestamp embedded in a time-sortable id, or `null`. */
|
|
441
|
+
function idTime(id) {
|
|
442
|
+
const raw = id.slice(id.indexOf("_") + 1, id.indexOf("_") + 1 + TIME_LEN);
|
|
443
|
+
if (raw.length !== TIME_LEN) return null;
|
|
444
|
+
let ms = 0;
|
|
445
|
+
for (const ch of raw) {
|
|
446
|
+
const d = ENCODING.indexOf(ch);
|
|
447
|
+
if (d === -1) return null;
|
|
448
|
+
ms = ms * 32 + d;
|
|
449
|
+
}
|
|
450
|
+
return ms;
|
|
451
|
+
}
|
|
452
|
+
//#endregion
|
|
453
|
+
//#region src/standard-schema.ts
|
|
454
|
+
/**
|
|
455
|
+
* Declare the typed action catalog. Identity at runtime; preserves the literal
|
|
456
|
+
* types so `core.record()` can infer action names and metadata shapes.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* import * as v from "valibot";
|
|
461
|
+
* import { createAuditCore, defineActions } from "@xtandard/audit";
|
|
462
|
+
*
|
|
463
|
+
* const actions = defineActions({
|
|
464
|
+
* "invoice.paid": {
|
|
465
|
+
* metadata: v.object({ invoiceId: v.string(), amount: v.number() }),
|
|
466
|
+
* targets: ["invoice"],
|
|
467
|
+
* description: "An invoice was paid",
|
|
468
|
+
* },
|
|
469
|
+
* "member.removed": { targets: ["user"] },
|
|
470
|
+
* });
|
|
471
|
+
*
|
|
472
|
+
* const audit = createAuditCore({ storage, actions });
|
|
473
|
+
* await audit.record({
|
|
474
|
+
* tenant: "acme",
|
|
475
|
+
* action: "invoice.paid", // ← autocompletes; typos are compile errors
|
|
476
|
+
* actor: { id: "user_1" },
|
|
477
|
+
* metadata: { invoiceId: "inv_1", amount: 4200 }, // ← typed
|
|
478
|
+
* });
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
function defineActions(actions) {
|
|
482
|
+
return actions;
|
|
483
|
+
}
|
|
484
|
+
/** Run a Standard Schema validator; returns the output or the issue messages. */
|
|
485
|
+
async function runStandardSchema(schema, value) {
|
|
486
|
+
const result = await schema["~standard"].validate(value);
|
|
487
|
+
if (result.issues) return {
|
|
488
|
+
ok: false,
|
|
489
|
+
issues: result.issues.map((i) => ({
|
|
490
|
+
path: (i.path ?? []).map((p) => typeof p === "object" && p !== null ? String(p.key) : String(p)).join("."),
|
|
491
|
+
message: i.message
|
|
492
|
+
}))
|
|
493
|
+
};
|
|
494
|
+
return {
|
|
495
|
+
ok: true,
|
|
496
|
+
value: result.value
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/transforms.ts
|
|
501
|
+
/** Replacement value used by {@link redact}. */
|
|
502
|
+
const REDACTED = "[REDACTED]";
|
|
503
|
+
/** Apply `fn` to every value at `path` (dot-separated, `*` wildcard); `undefined` deletes. */
|
|
504
|
+
async function mapPath(root, segments, fn) {
|
|
505
|
+
if (root === null || typeof root !== "object" || segments.length === 0) return;
|
|
506
|
+
const [head, ...rest] = segments;
|
|
507
|
+
const container = root;
|
|
508
|
+
const keys = head === "*" ? Object.keys(container) : [head];
|
|
509
|
+
for (const key of keys) {
|
|
510
|
+
if (!(key in container)) continue;
|
|
511
|
+
if (rest.length > 0) {
|
|
512
|
+
await mapPath(container[key], rest, fn);
|
|
513
|
+
continue;
|
|
514
|
+
}
|
|
515
|
+
const current = container[key];
|
|
516
|
+
if (current === void 0 || current === null) continue;
|
|
517
|
+
const next = await fn(current);
|
|
518
|
+
if (next === void 0) if (Array.isArray(container)) container.splice(Number(key), 1);
|
|
519
|
+
else delete container[key];
|
|
520
|
+
else container[key] = next;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
function pathTransform(paths, fn) {
|
|
524
|
+
const split = paths.map((p) => p.split("."));
|
|
525
|
+
return async (event) => {
|
|
526
|
+
const copy = structuredClone(event);
|
|
527
|
+
for (const segments of split) await mapPath(copy, segments, fn);
|
|
528
|
+
return copy;
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/** Replace the values at `paths` with `"[REDACTED]"`. */
|
|
532
|
+
function redact(...paths) {
|
|
533
|
+
return pathTransform(paths, () => REDACTED);
|
|
534
|
+
}
|
|
535
|
+
/** Remove the values at `paths` entirely. */
|
|
536
|
+
function omit(...paths) {
|
|
537
|
+
return pathTransform(paths, () => void 0);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Partially mask string values: emails become `j***@e***.com`, short strings
|
|
541
|
+
* `****`, longer strings keep their last four characters.
|
|
542
|
+
*/
|
|
543
|
+
function mask(...paths) {
|
|
544
|
+
return pathTransform(paths, (value) => maskValue(String(value)));
|
|
545
|
+
}
|
|
546
|
+
/** The masking used by {@link mask}. */
|
|
547
|
+
function maskValue(str) {
|
|
548
|
+
if (str.includes("@")) {
|
|
549
|
+
const [local, domain] = str.split("@");
|
|
550
|
+
if (local && domain) {
|
|
551
|
+
const parts = domain.split(".");
|
|
552
|
+
const maskedDomain = (parts[0]?.[0] ?? "") + "***" + (parts.length > 1 ? "." + parts[parts.length - 1] : "");
|
|
553
|
+
return `${local[0]}***@${maskedDomain}`;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (str.length <= 4) return "****";
|
|
557
|
+
return "*".repeat(str.length - 4) + str.slice(-4);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Replace values with a SHA-256 digest (`sha256:…`). Pass a `salt` (a secret)
|
|
561
|
+
* to keep low-entropy values (emails, IPs) from being confirmed by brute force;
|
|
562
|
+
* equal inputs still produce equal digests, so you can correlate without storing.
|
|
563
|
+
*/
|
|
564
|
+
function hashValue(paths, options = {}) {
|
|
565
|
+
const salt = options.salt ?? "";
|
|
566
|
+
return pathTransform(Array.isArray(paths) ? paths : [paths], (value) => require_integrity.sha256(`${salt}${typeof value === "string" ? value : JSON.stringify(value)}`));
|
|
567
|
+
}
|
|
568
|
+
/** Run transforms in order. */
|
|
569
|
+
async function applyTransforms(event, transforms) {
|
|
570
|
+
let current = event;
|
|
571
|
+
for (const t of transforms) current = await t(current);
|
|
572
|
+
return current;
|
|
573
|
+
}
|
|
574
|
+
//#endregion
|
|
575
|
+
//#region src/core.ts
|
|
576
|
+
/**
|
|
577
|
+
* The audit core — the operations layer the API, CLI, recorder, stream runner
|
|
578
|
+
* and UI sit on.
|
|
579
|
+
*
|
|
580
|
+
* Owns the split between the **record plane** (`record()` / `recordMany()` —
|
|
581
|
+
* the hot path: validate, transform, chain, append; synchronous-commit, throws
|
|
582
|
+
* on failure, ADR 0002) and the **control plane** (query, export, verify,
|
|
583
|
+
* checkpoints, erasure, retention, the action catalog — hook-guarded and
|
|
584
|
+
* self-audited).
|
|
585
|
+
*
|
|
586
|
+
* Import from `@xtandard/audit/core` (also re-exported by the root).
|
|
587
|
+
*
|
|
588
|
+
* @module core
|
|
589
|
+
*/
|
|
590
|
+
/** Thrown by mutating operations when the core is in readonly mode. */
|
|
591
|
+
var ReadonlyError = class extends Error {
|
|
592
|
+
constructor(operation) {
|
|
593
|
+
super(`Cannot ${operation}: the audit core is readonly`);
|
|
594
|
+
this.name = "ReadonlyError";
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
/** Thrown when a referenced entity does not exist. Maps to HTTP 404. */
|
|
598
|
+
var NotFoundError = class extends Error {
|
|
599
|
+
constructor(message) {
|
|
600
|
+
super(message);
|
|
601
|
+
this.name = "NotFoundError";
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
/** Thrown when an operation conflicts with existing state. Maps to HTTP 409. */
|
|
605
|
+
var ConflictError = class extends Error {
|
|
606
|
+
constructor(message) {
|
|
607
|
+
super(message);
|
|
608
|
+
this.name = "ConflictError";
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
/** Thrown when an operation needs a signer and none is configured. Maps to HTTP 409. */
|
|
612
|
+
var SignerRequiredError = class extends Error {
|
|
613
|
+
constructor() {
|
|
614
|
+
super("No signer configured: pass `signer` (ed25519Signer / hmacSigner) to the audit core");
|
|
615
|
+
this.name = "SignerRequiredError";
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
/** Self-audit action names (always accepted, even with `strictActions`). */
|
|
619
|
+
const SELF_AUDIT_ACTIONS = [
|
|
620
|
+
"audit_log.exported",
|
|
621
|
+
"audit_log.erased",
|
|
622
|
+
"audit_log.pruned",
|
|
623
|
+
"audit_log.action_upserted",
|
|
624
|
+
"audit_log.action_deleted"
|
|
625
|
+
];
|
|
626
|
+
const DEFAULT_CHECKPOINTS = {
|
|
627
|
+
every: 1e3,
|
|
628
|
+
interval: "1h"
|
|
629
|
+
};
|
|
630
|
+
const MAX_CHAIN_RETRIES = 8;
|
|
631
|
+
const PRUNE_PAGE = 500;
|
|
632
|
+
const VERIFY_PAGE = 1e3;
|
|
633
|
+
let warnedSingleWriter = false;
|
|
634
|
+
const isoNow = (now) => new Date(now()).toISOString();
|
|
635
|
+
/**
|
|
636
|
+
* Create the audit core.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```ts
|
|
640
|
+
* import { createAuditCore } from "@xtandard/audit";
|
|
641
|
+
* import { createMemoryStorage } from "@xtandard/audit/storage/memory";
|
|
642
|
+
*
|
|
643
|
+
* const audit = createAuditCore({ storage: createMemoryStorage() });
|
|
644
|
+
*
|
|
645
|
+
* await audit.record({
|
|
646
|
+
* tenant: "acme",
|
|
647
|
+
* action: "invoice.paid",
|
|
648
|
+
* actor: { id: "user_1", name: "Ada" },
|
|
649
|
+
* targets: [{ type: "invoice", id: "inv_1" }],
|
|
650
|
+
* metadata: { amount: 4200 },
|
|
651
|
+
* });
|
|
652
|
+
*
|
|
653
|
+
* const page = await audit.query({ tenant: "acme", actions: ["invoice.*"] });
|
|
654
|
+
* ```
|
|
655
|
+
*/
|
|
656
|
+
function createAuditCore(options) {
|
|
657
|
+
const storage = options.storage;
|
|
658
|
+
const log = resolveEventLog(storage);
|
|
659
|
+
const now = options.now ?? Date.now;
|
|
660
|
+
const hooks = normalizeHooks(options.hooks);
|
|
661
|
+
const onHookError = options.onHookError ?? defaultHookErrorReporter;
|
|
662
|
+
const actions = options.actions;
|
|
663
|
+
const strictActions = options.strictActions ?? actions !== void 0;
|
|
664
|
+
const transforms = options.transforms ?? [];
|
|
665
|
+
const useContext = options.context ?? true;
|
|
666
|
+
const selfAudit = options.selfAudit ?? true;
|
|
667
|
+
const systemTenant = options.systemTenant ?? "_system";
|
|
668
|
+
const readonly = options.readonly ?? false;
|
|
669
|
+
const signer = options.signer;
|
|
670
|
+
const checkpointOpts = options.checkpoints === false ? false : options.checkpoints ?? (signer ? DEFAULT_CHECKPOINTS : false);
|
|
671
|
+
const cas = require_contract.isCompareAndSwap(storage) ? storage : null;
|
|
672
|
+
if (!log.native && !cas && !warnedSingleWriter) {
|
|
673
|
+
warnedSingleWriter = true;
|
|
674
|
+
console.warn("[@xtandard/audit] This storage has neither a native event log nor compareAndSwap: run a single writer per tenant, or two processes may fork a tenant's hash chain. Use a native driver (postgres, sqlite, libsql, mongodb, drizzle) or redis/memory. See docs/STORAGE.md.");
|
|
675
|
+
}
|
|
676
|
+
const floors = /* @__PURE__ */ new Set();
|
|
677
|
+
const locks = /* @__PURE__ */ new Map();
|
|
678
|
+
function withTenantLock(tenant, fn) {
|
|
679
|
+
const run = (locks.get(tenant) ?? Promise.resolve()).then(fn, fn);
|
|
680
|
+
const tail = run.catch(() => void 0);
|
|
681
|
+
locks.set(tenant, tail);
|
|
682
|
+
tail.then(() => {
|
|
683
|
+
if (locks.get(tenant) === tail) locks.delete(tenant);
|
|
684
|
+
});
|
|
685
|
+
return run;
|
|
686
|
+
}
|
|
687
|
+
/** Last head this process stored (the exact KV value, for compare-and-swap). */
|
|
688
|
+
const storedHeads = /* @__PURE__ */ new Map();
|
|
689
|
+
async function readHead(tenant) {
|
|
690
|
+
const stored = await storage.getItem(headKey(tenant));
|
|
691
|
+
let head = stored ?? {
|
|
692
|
+
tenant,
|
|
693
|
+
seq: 0,
|
|
694
|
+
hash: require_integrity.GENESIS_HASH
|
|
695
|
+
};
|
|
696
|
+
if (log.native) {
|
|
697
|
+
const last = await log.lastEvent(tenant);
|
|
698
|
+
if (last && last.seq > head.seq) head = {
|
|
699
|
+
...head,
|
|
700
|
+
seq: last.seq,
|
|
701
|
+
hash: last.integrity.hash
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
storedHeads.set(tenant, stored);
|
|
705
|
+
return {
|
|
706
|
+
head,
|
|
707
|
+
stored
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
async function writeHead(tenant, expected, next) {
|
|
711
|
+
if (cas && !log.native) {
|
|
712
|
+
const ok = await cas.compareAndSwap({
|
|
713
|
+
key: headKey(tenant),
|
|
714
|
+
expected,
|
|
715
|
+
next
|
|
716
|
+
});
|
|
717
|
+
if (ok) storedHeads.set(tenant, next);
|
|
718
|
+
return ok;
|
|
719
|
+
}
|
|
720
|
+
await storage.setItem(headKey(tenant), next);
|
|
721
|
+
storedHeads.set(tenant, next);
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
async function ensureTenantIndexed(tenant) {
|
|
725
|
+
const list = await storage.getItem(tenantsKey()) ?? [];
|
|
726
|
+
if (list.includes(tenant)) return;
|
|
727
|
+
await storage.setItem(tenantsKey(), [...list, tenant].sort());
|
|
728
|
+
}
|
|
729
|
+
async function prepare(input, internal) {
|
|
730
|
+
const raw = input;
|
|
731
|
+
const scope = useContext ? require_context.getAuditContext() : null;
|
|
732
|
+
const tenant = raw.tenant ?? scope?.tenant;
|
|
733
|
+
const actor = raw.actor ?? scope?.actor;
|
|
734
|
+
require_validation.assertValid(require_validation.validateEventInput({
|
|
735
|
+
...raw,
|
|
736
|
+
tenant,
|
|
737
|
+
...actor ? { actor } : {}
|
|
738
|
+
}, { maxEventBytes: options.maxEventBytes }));
|
|
739
|
+
if (!actor) throw new require_validation.ValidationError([{
|
|
740
|
+
path: "event.actor",
|
|
741
|
+
message: "actor is required (pass it, or open an audit context)"
|
|
742
|
+
}]);
|
|
743
|
+
const spec = actions?.[raw.action];
|
|
744
|
+
if (!internal && strictActions && !spec) throw new require_validation.ValidationError([{
|
|
745
|
+
path: "event.action",
|
|
746
|
+
message: `unknown action "${raw.action}"`
|
|
747
|
+
}]);
|
|
748
|
+
let metadata = raw.metadata ?? {};
|
|
749
|
+
if (spec?.metadata) {
|
|
750
|
+
const result = await runStandardSchema(spec.metadata, raw.metadata ?? {});
|
|
751
|
+
if (!result.ok) throw new require_validation.ValidationError(result.issues.map((i) => ({
|
|
752
|
+
path: i.path ? `event.metadata.${i.path}` : "event.metadata",
|
|
753
|
+
message: i.message
|
|
754
|
+
})));
|
|
755
|
+
const value = result.value;
|
|
756
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new require_validation.ValidationError([{
|
|
757
|
+
path: "event.metadata",
|
|
758
|
+
message: "the action's metadata schema must produce an object"
|
|
759
|
+
}]);
|
|
760
|
+
metadata = value;
|
|
761
|
+
}
|
|
762
|
+
const occurredAt = raw.occurredAt === void 0 ? isoNow(now) : new Date(raw.occurredAt instanceof Date ? raw.occurredAt.getTime() : Date.parse(raw.occurredAt)).toISOString();
|
|
763
|
+
const context = {
|
|
764
|
+
...scope?.context,
|
|
765
|
+
...raw.context
|
|
766
|
+
};
|
|
767
|
+
for (const k of Object.keys(context)) if (context[k] === void 0) delete context[k];
|
|
768
|
+
const outcome = raw.outcome ?? spec?.outcome;
|
|
769
|
+
const prepared = {
|
|
770
|
+
id: raw.id ?? newId("evt", now()),
|
|
771
|
+
tenant,
|
|
772
|
+
action: raw.action,
|
|
773
|
+
occurredAt,
|
|
774
|
+
actor: structuredClone(actor),
|
|
775
|
+
targets: structuredClone(raw.targets ?? []),
|
|
776
|
+
context: structuredClone(context),
|
|
777
|
+
metadata: structuredClone(metadata),
|
|
778
|
+
...outcome ? { outcome } : {},
|
|
779
|
+
...raw.description !== void 0 ? { description: raw.description } : {}
|
|
780
|
+
};
|
|
781
|
+
for (const s of require_schema.AUDIT_SECTIONS) try {
|
|
782
|
+
require_integrity.canonicalStringify(require_integrity.sectionValue({
|
|
783
|
+
...prepared,
|
|
784
|
+
seq: 0,
|
|
785
|
+
recordedAt: ""
|
|
786
|
+
}, s));
|
|
787
|
+
} catch (err) {
|
|
788
|
+
throw new require_validation.ValidationError([{
|
|
789
|
+
path: `event.${s}`,
|
|
790
|
+
message: err.message
|
|
791
|
+
}]);
|
|
792
|
+
}
|
|
793
|
+
return transforms.length ? await applyTransforms(prepared, transforms) : prepared;
|
|
794
|
+
}
|
|
795
|
+
/** Same logical content (for idempotent re-record by explicit id). */
|
|
796
|
+
function sameContent(a, b) {
|
|
797
|
+
const pick = (e) => require_integrity.canonicalStringify({
|
|
798
|
+
action: e.action,
|
|
799
|
+
occurredAt: e.occurredAt,
|
|
800
|
+
actor: e.actor,
|
|
801
|
+
targets: e.targets,
|
|
802
|
+
context: e.context,
|
|
803
|
+
metadata: e.metadata,
|
|
804
|
+
outcome: e.outcome ?? null,
|
|
805
|
+
description: e.description ?? null
|
|
806
|
+
});
|
|
807
|
+
return pick(a) === pick(b);
|
|
808
|
+
}
|
|
809
|
+
async function appendForTenant(tenant, batch) {
|
|
810
|
+
return withTenantLock(tenant, async () => {
|
|
811
|
+
const existing = /* @__PURE__ */ new Map();
|
|
812
|
+
for (const p of batch) {
|
|
813
|
+
const found = await log.getEvent(tenant, p.id);
|
|
814
|
+
if (found) {
|
|
815
|
+
if (!sameContent(p, found)) throw new ConflictError(`Event ${p.id} already exists with different content`);
|
|
816
|
+
existing.set(p.id, found);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
const fresh = batch.filter((p) => !existing.has(p.id));
|
|
820
|
+
let sealed = [];
|
|
821
|
+
if (fresh.length > 0) {
|
|
822
|
+
for (let attempt = 0;; attempt++) {
|
|
823
|
+
const { head, stored } = await readHead(tenant);
|
|
824
|
+
const recordedAt = isoNow(now);
|
|
825
|
+
sealed = await require_integrity.sealChain(fresh.map((p, i) => ({
|
|
826
|
+
...p,
|
|
827
|
+
seq: head.seq + i + 1,
|
|
828
|
+
recordedAt
|
|
829
|
+
})), head.hash);
|
|
830
|
+
const last = sealed[sealed.length - 1];
|
|
831
|
+
const next = {
|
|
832
|
+
...head,
|
|
833
|
+
tenant,
|
|
834
|
+
seq: last.seq,
|
|
835
|
+
hash: last.integrity.hash,
|
|
836
|
+
updatedAt: recordedAt
|
|
837
|
+
};
|
|
838
|
+
try {
|
|
839
|
+
if (!log.native) {
|
|
840
|
+
if (!await writeHead(tenant, stored, next)) throw new require_contract.ChainConflictError(tenant, head.seq);
|
|
841
|
+
await log.appendEvents(tenant, sealed, { expectedSeq: head.seq });
|
|
842
|
+
} else {
|
|
843
|
+
await log.appendEvents(tenant, sealed, { expectedSeq: head.seq });
|
|
844
|
+
await writeHead(tenant, stored, next);
|
|
845
|
+
}
|
|
846
|
+
break;
|
|
847
|
+
} catch (err) {
|
|
848
|
+
if (err instanceof require_contract.ChainConflictError && attempt < MAX_CHAIN_RETRIES) continue;
|
|
849
|
+
throw err;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
if (firstSeenThisProcess(tenant)) await ensureTenantIndexed(tenant);
|
|
853
|
+
}
|
|
854
|
+
return batch.map((p) => existing.get(p.id) ?? sealed.find((s) => s.id === p.id));
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
const indexedTenants = /* @__PURE__ */ new Set();
|
|
858
|
+
function firstSeenThisProcess(tenant) {
|
|
859
|
+
if (indexedTenants.has(tenant)) return false;
|
|
860
|
+
indexedTenants.add(tenant);
|
|
861
|
+
return true;
|
|
862
|
+
}
|
|
863
|
+
async function recordPrepared(prepared, internal) {
|
|
864
|
+
const byTenant = /* @__PURE__ */ new Map();
|
|
865
|
+
for (const p of prepared) {
|
|
866
|
+
const list = byTenant.get(p.tenant) ?? [];
|
|
867
|
+
list.push(p);
|
|
868
|
+
byTenant.set(p.tenant, list);
|
|
869
|
+
}
|
|
870
|
+
const results = /* @__PURE__ */ new Map();
|
|
871
|
+
for (const [tenant, batch] of byTenant) {
|
|
872
|
+
if (!internal && hooks.length) await runBefore(hooks, {
|
|
873
|
+
type: "event.record",
|
|
874
|
+
tenant,
|
|
875
|
+
actions: [...new Set(batch.map((b) => b.action))],
|
|
876
|
+
count: batch.length
|
|
877
|
+
});
|
|
878
|
+
const sealed = await appendForTenant(tenant, batch);
|
|
879
|
+
for (const e of sealed) results.set(e.id, e);
|
|
880
|
+
const at = isoNow(now);
|
|
881
|
+
if (hooks.length) runAfter(hooks, {
|
|
882
|
+
type: "events.recorded",
|
|
883
|
+
tenant,
|
|
884
|
+
events: sealed,
|
|
885
|
+
at
|
|
886
|
+
}, onHookError);
|
|
887
|
+
if (options.onRecord) try {
|
|
888
|
+
options.onRecord(sealed);
|
|
889
|
+
} catch (err) {
|
|
890
|
+
console.warn("[@xtandard/audit] onRecord threw:", err);
|
|
891
|
+
}
|
|
892
|
+
track(maybeAutoCheckpoint(tenant));
|
|
893
|
+
}
|
|
894
|
+
return prepared.map((p) => results.get(p.id));
|
|
895
|
+
}
|
|
896
|
+
async function recordInternal(input) {
|
|
897
|
+
if (!selfAudit) return null;
|
|
898
|
+
const [event] = await recordPrepared([await prepare(input, true)], true);
|
|
899
|
+
return event ?? null;
|
|
900
|
+
}
|
|
901
|
+
function actorFor(actor) {
|
|
902
|
+
return actor ? {
|
|
903
|
+
id: actor.id,
|
|
904
|
+
type: actor.id.startsWith("portal:") ? "portal" : "operator",
|
|
905
|
+
...actor.name ? { name: actor.name } : {},
|
|
906
|
+
...actor.email ? { email: actor.email } : {}
|
|
907
|
+
} : {
|
|
908
|
+
id: "system",
|
|
909
|
+
type: "system"
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
async function listCheckpoints(tenant) {
|
|
913
|
+
const keys = (await storage.getKeys(checkpointsPrefix(tenant))).sort();
|
|
914
|
+
const out = [];
|
|
915
|
+
for (const k of keys) {
|
|
916
|
+
const cp = await storage.getItem(k);
|
|
917
|
+
if (cp) out.push(cp);
|
|
918
|
+
}
|
|
919
|
+
return out.sort((a, b) => a.seq - b.seq || (a.id < b.id ? -1 : 1));
|
|
920
|
+
}
|
|
921
|
+
async function storeCheckpoint(cp) {
|
|
922
|
+
await storage.setItem(checkpointKey(cp.tenant, cp.id), cp);
|
|
923
|
+
}
|
|
924
|
+
async function createCheckpoint(tenant, actor) {
|
|
925
|
+
if (!signer) throw new SignerRequiredError();
|
|
926
|
+
if (hooks.length) await runBefore(hooks, {
|
|
927
|
+
type: "checkpoint.create",
|
|
928
|
+
tenant,
|
|
929
|
+
actor
|
|
930
|
+
});
|
|
931
|
+
const { head } = await readHead(tenant);
|
|
932
|
+
const at = isoNow(now);
|
|
933
|
+
const cp = await require_integrity.signCheckpoint(signer, {
|
|
934
|
+
v: 1,
|
|
935
|
+
id: newId("chk", now()),
|
|
936
|
+
tenant,
|
|
937
|
+
kind: "head",
|
|
938
|
+
seq: head.seq,
|
|
939
|
+
hash: head.hash,
|
|
940
|
+
at
|
|
941
|
+
});
|
|
942
|
+
await storeCheckpoint(cp);
|
|
943
|
+
lastCheckpoint.set(tenant, {
|
|
944
|
+
seq: cp.seq,
|
|
945
|
+
at: now()
|
|
946
|
+
});
|
|
947
|
+
if (hooks.length) runAfter(hooks, {
|
|
948
|
+
type: "checkpoint.created",
|
|
949
|
+
tenant,
|
|
950
|
+
checkpoint: cp,
|
|
951
|
+
at
|
|
952
|
+
}, onHookError);
|
|
953
|
+
return cp;
|
|
954
|
+
}
|
|
955
|
+
const lastCheckpoint = /* @__PURE__ */ new Map();
|
|
956
|
+
const checkpointing = /* @__PURE__ */ new Set();
|
|
957
|
+
const recheck = /* @__PURE__ */ new Set();
|
|
958
|
+
const background = /* @__PURE__ */ new Set();
|
|
959
|
+
function track(work) {
|
|
960
|
+
background.add(work);
|
|
961
|
+
work.finally(() => background.delete(work));
|
|
962
|
+
}
|
|
963
|
+
async function maybeAutoCheckpoint(tenant) {
|
|
964
|
+
if (!signer || !checkpointOpts) return;
|
|
965
|
+
if (checkpointing.has(tenant)) {
|
|
966
|
+
recheck.add(tenant);
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
checkpointing.add(tenant);
|
|
970
|
+
try {
|
|
971
|
+
do {
|
|
972
|
+
recheck.delete(tenant);
|
|
973
|
+
let last = lastCheckpoint.get(tenant);
|
|
974
|
+
if (!last) {
|
|
975
|
+
const cps = (await listCheckpoints(tenant)).filter((c) => c.kind === "head");
|
|
976
|
+
const newest = cps[cps.length - 1];
|
|
977
|
+
last = newest ? {
|
|
978
|
+
seq: newest.seq,
|
|
979
|
+
at: Date.parse(newest.at)
|
|
980
|
+
} : {
|
|
981
|
+
seq: 0,
|
|
982
|
+
at: 0
|
|
983
|
+
};
|
|
984
|
+
lastCheckpoint.set(tenant, last);
|
|
985
|
+
}
|
|
986
|
+
const head = await withTenantLock(tenant, async () => (await readHead(tenant)).head);
|
|
987
|
+
if (head.seq <= last.seq) continue;
|
|
988
|
+
const dueByCount = checkpointOpts.every !== void 0 && head.seq - last.seq >= checkpointOpts.every;
|
|
989
|
+
const dueByTime = checkpointOpts.interval !== void 0 && now() - last.at >= durationToMs(checkpointOpts.interval);
|
|
990
|
+
if (dueByCount || dueByTime) await createCheckpoint(tenant, null);
|
|
991
|
+
} while (recheck.has(tenant));
|
|
992
|
+
} catch (err) {
|
|
993
|
+
console.warn(`[@xtandard/audit] automatic checkpoint for "${tenant}" failed:`, err);
|
|
994
|
+
} finally {
|
|
995
|
+
checkpointing.delete(tenant);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
async function verificationKeys() {
|
|
999
|
+
const keys = [...options.verificationKeys ?? []];
|
|
1000
|
+
if (signer) keys.push(await signer.verificationKey());
|
|
1001
|
+
return keys;
|
|
1002
|
+
}
|
|
1003
|
+
function ruleFor(tenant) {
|
|
1004
|
+
const r = options.retention;
|
|
1005
|
+
if (!r) return null;
|
|
1006
|
+
const rule = {
|
|
1007
|
+
...r.keepLast !== void 0 ? { keepLast: r.keepLast } : {},
|
|
1008
|
+
...r.maxAge !== void 0 ? { maxAge: r.maxAge } : {},
|
|
1009
|
+
...r.tenants?.[tenant]
|
|
1010
|
+
};
|
|
1011
|
+
return rule.keepLast === void 0 && rule.maxAge === void 0 ? null : rule;
|
|
1012
|
+
}
|
|
1013
|
+
async function pruneTenant(tenant, actor) {
|
|
1014
|
+
if (readonly) throw new ReadonlyError("prune");
|
|
1015
|
+
const rule = ruleFor(tenant);
|
|
1016
|
+
const { head } = await readHead(tenant);
|
|
1017
|
+
const baseSeq = head.baseSeq ?? 1;
|
|
1018
|
+
if (!rule || head.seq === 0) return {
|
|
1019
|
+
tenant,
|
|
1020
|
+
pruned: 0,
|
|
1021
|
+
baseSeq
|
|
1022
|
+
};
|
|
1023
|
+
const cutoff = rule.maxAge !== void 0 ? new Date(now() - durationToMs(rule.maxAge)).toISOString() : null;
|
|
1024
|
+
let limit = rule.keepLast !== void 0 ? head.seq - rule.keepLast : Infinity;
|
|
1025
|
+
limit = Math.min(limit, head.seq - 1);
|
|
1026
|
+
if (!options.retention?.ignoreStreams) for (const floor of floors) {
|
|
1027
|
+
const f = await floor(tenant);
|
|
1028
|
+
if (f !== null) limit = Math.min(limit, f);
|
|
1029
|
+
}
|
|
1030
|
+
let through = baseSeq - 1;
|
|
1031
|
+
if (cutoff === null) through = Math.max(through, limit);
|
|
1032
|
+
else {
|
|
1033
|
+
let after = baseSeq - 1;
|
|
1034
|
+
scan: for (;;) {
|
|
1035
|
+
const page = await log.eventsBySeq(tenant, {
|
|
1036
|
+
afterSeq: after,
|
|
1037
|
+
limit: PRUNE_PAGE
|
|
1038
|
+
});
|
|
1039
|
+
if (page.length === 0) break;
|
|
1040
|
+
for (const e of page) {
|
|
1041
|
+
if (e.seq > limit || e.recordedAt >= cutoff) break scan;
|
|
1042
|
+
through = e.seq;
|
|
1043
|
+
}
|
|
1044
|
+
after = page[page.length - 1].seq;
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
if (through < baseSeq) return {
|
|
1048
|
+
tenant,
|
|
1049
|
+
pruned: 0,
|
|
1050
|
+
baseSeq
|
|
1051
|
+
};
|
|
1052
|
+
if (hooks.length) await runBefore(hooks, {
|
|
1053
|
+
type: "events.prune",
|
|
1054
|
+
tenant,
|
|
1055
|
+
throughSeq: through,
|
|
1056
|
+
actor
|
|
1057
|
+
});
|
|
1058
|
+
const boundary = (await log.eventsBySeq(tenant, {
|
|
1059
|
+
afterSeq: through - 1,
|
|
1060
|
+
limit: 1
|
|
1061
|
+
}))[0];
|
|
1062
|
+
if (!boundary || boundary.seq !== through) return {
|
|
1063
|
+
tenant,
|
|
1064
|
+
pruned: 0,
|
|
1065
|
+
baseSeq
|
|
1066
|
+
};
|
|
1067
|
+
let base = null;
|
|
1068
|
+
if (signer) {
|
|
1069
|
+
base = await require_integrity.signCheckpoint(signer, {
|
|
1070
|
+
v: 1,
|
|
1071
|
+
id: newId("chk", now()),
|
|
1072
|
+
tenant,
|
|
1073
|
+
kind: "base",
|
|
1074
|
+
seq: through,
|
|
1075
|
+
hash: boundary.integrity.hash,
|
|
1076
|
+
at: isoNow(now)
|
|
1077
|
+
});
|
|
1078
|
+
await storeCheckpoint(base);
|
|
1079
|
+
}
|
|
1080
|
+
const pruned = await withTenantLock(tenant, async () => {
|
|
1081
|
+
const count = await log.deleteEventsThrough(tenant, through);
|
|
1082
|
+
const { head: current, stored } = await readHead(tenant);
|
|
1083
|
+
await writeHead(tenant, stored, {
|
|
1084
|
+
...current,
|
|
1085
|
+
baseSeq: through + 1,
|
|
1086
|
+
baseHash: boundary.integrity.hash
|
|
1087
|
+
});
|
|
1088
|
+
return count;
|
|
1089
|
+
});
|
|
1090
|
+
for (const cp of await listCheckpoints(tenant)) if (cp.seq < through) await storage.removeItem(checkpointKey(tenant, cp.id));
|
|
1091
|
+
const at = isoNow(now);
|
|
1092
|
+
if (hooks.length) runAfter(hooks, {
|
|
1093
|
+
type: "events.pruned",
|
|
1094
|
+
tenant,
|
|
1095
|
+
throughSeq: through,
|
|
1096
|
+
count: pruned,
|
|
1097
|
+
base,
|
|
1098
|
+
at
|
|
1099
|
+
}, onHookError);
|
|
1100
|
+
await recordInternal({
|
|
1101
|
+
tenant,
|
|
1102
|
+
action: "audit_log.pruned",
|
|
1103
|
+
actor: actorFor(actor),
|
|
1104
|
+
metadata: {
|
|
1105
|
+
throughSeq: through,
|
|
1106
|
+
count: pruned
|
|
1107
|
+
}
|
|
1108
|
+
});
|
|
1109
|
+
return {
|
|
1110
|
+
tenant,
|
|
1111
|
+
pruned,
|
|
1112
|
+
baseSeq: through + 1
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
let catalogSynced = false;
|
|
1116
|
+
async function syncCatalog() {
|
|
1117
|
+
if (catalogSynced || !actions) return;
|
|
1118
|
+
catalogSynced = true;
|
|
1119
|
+
const names = new Set(await storage.getItem(actionsKey()) ?? []);
|
|
1120
|
+
const at = isoNow(now);
|
|
1121
|
+
for (const [name, spec] of Object.entries(actions)) {
|
|
1122
|
+
const existing = await storage.getItem(actionKey(name));
|
|
1123
|
+
const def = {
|
|
1124
|
+
...existing,
|
|
1125
|
+
name,
|
|
1126
|
+
source: "code",
|
|
1127
|
+
...spec.description !== void 0 ? { description: spec.description } : {},
|
|
1128
|
+
...spec.group !== void 0 ? { group: spec.group } : {},
|
|
1129
|
+
...spec.targets !== void 0 ? { targets: spec.targets } : {},
|
|
1130
|
+
...spec.schema !== void 0 ? { schema: spec.schema } : {},
|
|
1131
|
+
...spec.deprecated !== void 0 ? { deprecated: spec.deprecated } : {},
|
|
1132
|
+
createdAt: existing?.createdAt ?? at,
|
|
1133
|
+
updatedAt: at
|
|
1134
|
+
};
|
|
1135
|
+
if (!existing || require_integrity.canonicalStringify({
|
|
1136
|
+
...existing,
|
|
1137
|
+
updatedAt: ""
|
|
1138
|
+
}) !== require_integrity.canonicalStringify({
|
|
1139
|
+
...def,
|
|
1140
|
+
updatedAt: ""
|
|
1141
|
+
})) await storage.setItem(actionKey(name), def);
|
|
1142
|
+
names.add(name);
|
|
1143
|
+
}
|
|
1144
|
+
await storage.setItem(actionsKey(), [...names].sort());
|
|
1145
|
+
}
|
|
1146
|
+
const core = {
|
|
1147
|
+
options: {
|
|
1148
|
+
storage,
|
|
1149
|
+
...actions ? { actions } : {},
|
|
1150
|
+
strictActions,
|
|
1151
|
+
readonly,
|
|
1152
|
+
selfAudit,
|
|
1153
|
+
systemTenant,
|
|
1154
|
+
...signer ? { signer } : {},
|
|
1155
|
+
...options.retention ? { retention: options.retention } : {},
|
|
1156
|
+
checkpoints: checkpointOpts,
|
|
1157
|
+
hooks,
|
|
1158
|
+
now
|
|
1159
|
+
},
|
|
1160
|
+
eventLog: log,
|
|
1161
|
+
async record(input) {
|
|
1162
|
+
const [event] = await recordPrepared([await prepare(input, false)], false);
|
|
1163
|
+
return event;
|
|
1164
|
+
},
|
|
1165
|
+
async recordMany(inputs) {
|
|
1166
|
+
if (inputs.length === 0) return [];
|
|
1167
|
+
const prepared = [];
|
|
1168
|
+
for (const input of inputs) prepared.push(await prepare(input, false));
|
|
1169
|
+
return recordPrepared(prepared, false);
|
|
1170
|
+
},
|
|
1171
|
+
async query(query = {}) {
|
|
1172
|
+
return require_query.toPage(await log.queryEvents(require_query.normalizeQuery(query)));
|
|
1173
|
+
},
|
|
1174
|
+
get: (tenant, id) => log.getEvent(tenant, id),
|
|
1175
|
+
eventsBySeq: (tenant, o) => log.eventsBySeq(tenant, o),
|
|
1176
|
+
count: (tenant) => log.countEvents(tenant),
|
|
1177
|
+
async listTenants() {
|
|
1178
|
+
const keys = new Set(await storage.getItem(tenantsKey()) ?? []);
|
|
1179
|
+
if (log.native) for (const t of await log.listEventTenants()) keys.add(t);
|
|
1180
|
+
const out = [];
|
|
1181
|
+
for (const key of [...keys].sort()) {
|
|
1182
|
+
const { head } = await readHead(key);
|
|
1183
|
+
out.push({
|
|
1184
|
+
key,
|
|
1185
|
+
head,
|
|
1186
|
+
count: await log.countEvents(key)
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
return out;
|
|
1190
|
+
},
|
|
1191
|
+
async head(tenant) {
|
|
1192
|
+
require_validation.assertValid(require_validation.validateTenant(tenant));
|
|
1193
|
+
return (await readHead(tenant)).head;
|
|
1194
|
+
},
|
|
1195
|
+
async verify(tenant, range = {}) {
|
|
1196
|
+
require_validation.assertValid(require_validation.validateTenant(tenant));
|
|
1197
|
+
const { head } = await readHead(tenant);
|
|
1198
|
+
const checkpoints = await listCheckpoints(tenant);
|
|
1199
|
+
const keys = await verificationKeys();
|
|
1200
|
+
const fromSeq = Math.max(range.fromSeq ?? head.baseSeq ?? 1, head.baseSeq ?? 1);
|
|
1201
|
+
const toSeq = Math.min(range.toSeq ?? head.seq, head.seq);
|
|
1202
|
+
let after = fromSeq - 1;
|
|
1203
|
+
let carry = null;
|
|
1204
|
+
let report = null;
|
|
1205
|
+
const erasureRecords = [];
|
|
1206
|
+
while (after < toSeq) {
|
|
1207
|
+
const page = (await log.eventsBySeq(tenant, {
|
|
1208
|
+
afterSeq: after,
|
|
1209
|
+
limit: VERIFY_PAGE
|
|
1210
|
+
})).filter((e) => e.seq <= toSeq);
|
|
1211
|
+
if (page.length === 0) break;
|
|
1212
|
+
const window = carry ? [carry, ...page] : page;
|
|
1213
|
+
const lo = window[0].seq;
|
|
1214
|
+
const hi = window[window.length - 1].seq;
|
|
1215
|
+
const r = await require_integrity.verifyChain(window, {
|
|
1216
|
+
checkpoints: checkpoints.filter((c) => c.seq >= (carry ? carry.seq + 1 : lo - 1) && c.seq <= hi),
|
|
1217
|
+
...keys.length ? { keys } : {},
|
|
1218
|
+
requireErasureRecords: false
|
|
1219
|
+
});
|
|
1220
|
+
for (const e of page) if (e.action === "audit_log.erased") erasureRecords.push(e);
|
|
1221
|
+
report = mergeReports(report, r, carry !== null);
|
|
1222
|
+
carry = page[page.length - 1];
|
|
1223
|
+
after = carry.seq;
|
|
1224
|
+
}
|
|
1225
|
+
if (!report) return {
|
|
1226
|
+
ok: true,
|
|
1227
|
+
tenant,
|
|
1228
|
+
checked: 0,
|
|
1229
|
+
fromSeq: null,
|
|
1230
|
+
toSeq: null,
|
|
1231
|
+
headHash: null,
|
|
1232
|
+
anchor: "none",
|
|
1233
|
+
linksChecked: true,
|
|
1234
|
+
checkpointsVerified: 0,
|
|
1235
|
+
signedThrough: null,
|
|
1236
|
+
erased: [],
|
|
1237
|
+
issues: []
|
|
1238
|
+
};
|
|
1239
|
+
if (selfAudit && report.erased.length > 0) {
|
|
1240
|
+
if (toSeq < head.seq) {
|
|
1241
|
+
let a = toSeq;
|
|
1242
|
+
for (;;) {
|
|
1243
|
+
const more = await log.eventsBySeq(tenant, {
|
|
1244
|
+
afterSeq: a,
|
|
1245
|
+
limit: VERIFY_PAGE
|
|
1246
|
+
});
|
|
1247
|
+
if (more.length === 0) break;
|
|
1248
|
+
for (const e of more) if (e.action === "audit_log.erased") erasureRecords.push(e);
|
|
1249
|
+
a = more[more.length - 1].seq;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
const extra = require_integrity.erasureIssues(report.erased, erasureRecords);
|
|
1253
|
+
if (extra.length) {
|
|
1254
|
+
report.issues.push(...extra);
|
|
1255
|
+
report.ok = false;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
if (report.toSeq !== null && report.toSeq < toSeq) {
|
|
1259
|
+
report.issues.push({
|
|
1260
|
+
kind: "seq-gap",
|
|
1261
|
+
seq: report.toSeq + 1,
|
|
1262
|
+
message: `events ${report.toSeq + 1}..${toSeq} are missing`
|
|
1263
|
+
});
|
|
1264
|
+
report.ok = false;
|
|
1265
|
+
}
|
|
1266
|
+
return report;
|
|
1267
|
+
},
|
|
1268
|
+
async checkpoint(tenant, opts = {}) {
|
|
1269
|
+
require_validation.assertValid(require_validation.validateTenant(tenant));
|
|
1270
|
+
return createCheckpoint(tenant, opts.actor ?? null);
|
|
1271
|
+
},
|
|
1272
|
+
listCheckpoints: (tenant) => listCheckpoints(tenant),
|
|
1273
|
+
async jwks() {
|
|
1274
|
+
const keys = [];
|
|
1275
|
+
const pub = await signer?.publicJwk?.();
|
|
1276
|
+
if (pub) keys.push(pub);
|
|
1277
|
+
return { keys };
|
|
1278
|
+
},
|
|
1279
|
+
async erase(tenant, eventId, input = {}, opts = {}) {
|
|
1280
|
+
if (readonly) throw new ReadonlyError("erase events");
|
|
1281
|
+
const sections = input.sections?.length ? input.sections : [...require_schema.AUDIT_SECTIONS];
|
|
1282
|
+
for (const s of sections) if (!require_schema.AUDIT_SECTIONS.includes(s)) throw new require_validation.ValidationError([{
|
|
1283
|
+
path: "sections",
|
|
1284
|
+
message: `unknown section "${s}"`
|
|
1285
|
+
}]);
|
|
1286
|
+
const actor = opts.actor ?? null;
|
|
1287
|
+
if (hooks.length) await runBefore(hooks, {
|
|
1288
|
+
type: "event.erase",
|
|
1289
|
+
tenant,
|
|
1290
|
+
eventId,
|
|
1291
|
+
sections,
|
|
1292
|
+
...input.reason !== void 0 ? { reason: input.reason } : {},
|
|
1293
|
+
actor
|
|
1294
|
+
});
|
|
1295
|
+
const updated = await withTenantLock(tenant, async () => {
|
|
1296
|
+
const event = await log.getEvent(tenant, eventId);
|
|
1297
|
+
if (!event) throw new NotFoundError(`Event ${eventId} not found in tenant "${tenant}"`);
|
|
1298
|
+
const next = eraseSections(event, sections);
|
|
1299
|
+
await log.replaceEvent(next);
|
|
1300
|
+
return next;
|
|
1301
|
+
});
|
|
1302
|
+
const at = isoNow(now);
|
|
1303
|
+
if (hooks.length) runAfter(hooks, {
|
|
1304
|
+
type: "event.erased",
|
|
1305
|
+
tenant,
|
|
1306
|
+
event: updated,
|
|
1307
|
+
sections,
|
|
1308
|
+
at
|
|
1309
|
+
}, onHookError);
|
|
1310
|
+
await recordInternal({
|
|
1311
|
+
tenant,
|
|
1312
|
+
action: "audit_log.erased",
|
|
1313
|
+
actor: actorFor(actor),
|
|
1314
|
+
targets: [{
|
|
1315
|
+
type: "audit_event",
|
|
1316
|
+
id: eventId
|
|
1317
|
+
}],
|
|
1318
|
+
metadata: {
|
|
1319
|
+
eventId,
|
|
1320
|
+
sections,
|
|
1321
|
+
...input.reason ? { reason: input.reason } : {}
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
return updated;
|
|
1325
|
+
},
|
|
1326
|
+
async eraseActor(tenant, actorId, input = {}, opts = {}) {
|
|
1327
|
+
let count = 0;
|
|
1328
|
+
let cursor;
|
|
1329
|
+
const ids = [];
|
|
1330
|
+
do {
|
|
1331
|
+
const page = await core.query({
|
|
1332
|
+
tenant,
|
|
1333
|
+
actorId,
|
|
1334
|
+
limit: 500,
|
|
1335
|
+
order: "asc",
|
|
1336
|
+
...cursor ? { cursor } : {}
|
|
1337
|
+
});
|
|
1338
|
+
ids.push(...page.items.filter((e) => !e.integrity.erased?.includes("actor")).map((e) => e.id));
|
|
1339
|
+
cursor = page.pageInfo.endCursor ?? void 0;
|
|
1340
|
+
} while (cursor);
|
|
1341
|
+
for (const id of ids) {
|
|
1342
|
+
await core.erase(tenant, id, {
|
|
1343
|
+
sections: ["actor"],
|
|
1344
|
+
...input.reason ? { reason: input.reason } : {}
|
|
1345
|
+
}, opts);
|
|
1346
|
+
count++;
|
|
1347
|
+
}
|
|
1348
|
+
return count;
|
|
1349
|
+
},
|
|
1350
|
+
async noteExport(tenant, query, format, opts = {}) {
|
|
1351
|
+
const actor = opts.actor ?? null;
|
|
1352
|
+
if (hooks.length) await runBefore(hooks, {
|
|
1353
|
+
type: "events.export",
|
|
1354
|
+
tenant,
|
|
1355
|
+
query,
|
|
1356
|
+
format,
|
|
1357
|
+
actor
|
|
1358
|
+
});
|
|
1359
|
+
if (hooks.length) runAfter(hooks, {
|
|
1360
|
+
type: "events.exported",
|
|
1361
|
+
tenant,
|
|
1362
|
+
query,
|
|
1363
|
+
format,
|
|
1364
|
+
at: isoNow(now)
|
|
1365
|
+
}, onHookError);
|
|
1366
|
+
if ((await readHead(tenant)).head.seq === 0) return;
|
|
1367
|
+
await recordInternal({
|
|
1368
|
+
tenant,
|
|
1369
|
+
action: "audit_log.exported",
|
|
1370
|
+
actor: actorFor(actor),
|
|
1371
|
+
metadata: {
|
|
1372
|
+
format,
|
|
1373
|
+
query
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1376
|
+
},
|
|
1377
|
+
async listActions() {
|
|
1378
|
+
await syncCatalog();
|
|
1379
|
+
const names = await storage.getItem(actionsKey()) ?? [];
|
|
1380
|
+
const out = [];
|
|
1381
|
+
for (const n of names) {
|
|
1382
|
+
const def = await storage.getItem(actionKey(n));
|
|
1383
|
+
if (def) out.push(def);
|
|
1384
|
+
}
|
|
1385
|
+
return out;
|
|
1386
|
+
},
|
|
1387
|
+
async getAction(name) {
|
|
1388
|
+
await syncCatalog();
|
|
1389
|
+
return storage.getItem(actionKey(name));
|
|
1390
|
+
},
|
|
1391
|
+
async upsertAction(input, opts = {}) {
|
|
1392
|
+
if (readonly) throw new ReadonlyError("upsert actions");
|
|
1393
|
+
require_validation.assertValid(require_validation.validateActionDefinition(input));
|
|
1394
|
+
await syncCatalog();
|
|
1395
|
+
const actor = opts.actor ?? null;
|
|
1396
|
+
const existing = await storage.getItem(actionKey(input.name));
|
|
1397
|
+
const at = isoNow(now);
|
|
1398
|
+
const def = {
|
|
1399
|
+
...existing,
|
|
1400
|
+
...input,
|
|
1401
|
+
source: existing?.source ?? "ui",
|
|
1402
|
+
createdAt: existing?.createdAt ?? at,
|
|
1403
|
+
updatedAt: at
|
|
1404
|
+
};
|
|
1405
|
+
if (hooks.length) await runBefore(hooks, {
|
|
1406
|
+
type: "action.upsert",
|
|
1407
|
+
action: def,
|
|
1408
|
+
actor
|
|
1409
|
+
});
|
|
1410
|
+
await storage.setItem(actionKey(def.name), def);
|
|
1411
|
+
const names = new Set(await storage.getItem(actionsKey()) ?? []);
|
|
1412
|
+
names.add(def.name);
|
|
1413
|
+
await storage.setItem(actionsKey(), [...names].sort());
|
|
1414
|
+
if (hooks.length) runAfter(hooks, {
|
|
1415
|
+
type: "action.upserted",
|
|
1416
|
+
action: def,
|
|
1417
|
+
at
|
|
1418
|
+
}, onHookError);
|
|
1419
|
+
await recordInternal({
|
|
1420
|
+
tenant: systemTenant,
|
|
1421
|
+
action: "audit_log.action_upserted",
|
|
1422
|
+
actor: actorFor(actor),
|
|
1423
|
+
targets: [{
|
|
1424
|
+
type: "audit_action",
|
|
1425
|
+
id: def.name
|
|
1426
|
+
}],
|
|
1427
|
+
metadata: { action: def }
|
|
1428
|
+
});
|
|
1429
|
+
return def;
|
|
1430
|
+
},
|
|
1431
|
+
async deleteAction(name, opts = {}) {
|
|
1432
|
+
if (readonly) throw new ReadonlyError("delete actions");
|
|
1433
|
+
await syncCatalog();
|
|
1434
|
+
const existing = await storage.getItem(actionKey(name));
|
|
1435
|
+
if (!existing) throw new NotFoundError(`Action "${name}" not found`);
|
|
1436
|
+
if (actions?.[name]) throw new ConflictError(`Action "${name}" is defined in code; remove it there`);
|
|
1437
|
+
const actor = opts.actor ?? null;
|
|
1438
|
+
if (hooks.length) await runBefore(hooks, {
|
|
1439
|
+
type: "action.delete",
|
|
1440
|
+
name,
|
|
1441
|
+
actor
|
|
1442
|
+
});
|
|
1443
|
+
await storage.removeItem(actionKey(name));
|
|
1444
|
+
const names = (await storage.getItem(actionsKey()) ?? []).filter((n) => n !== name);
|
|
1445
|
+
await storage.setItem(actionsKey(), names);
|
|
1446
|
+
if (hooks.length) runAfter(hooks, {
|
|
1447
|
+
type: "action.deleted",
|
|
1448
|
+
name,
|
|
1449
|
+
action: existing,
|
|
1450
|
+
at: isoNow(now)
|
|
1451
|
+
}, onHookError);
|
|
1452
|
+
await recordInternal({
|
|
1453
|
+
tenant: systemTenant,
|
|
1454
|
+
action: "audit_log.action_deleted",
|
|
1455
|
+
actor: actorFor(actor),
|
|
1456
|
+
targets: [{
|
|
1457
|
+
type: "audit_action",
|
|
1458
|
+
id: name
|
|
1459
|
+
}]
|
|
1460
|
+
});
|
|
1461
|
+
},
|
|
1462
|
+
async prune(opts = {}) {
|
|
1463
|
+
const results = [];
|
|
1464
|
+
for (const t of await core.listTenants()) results.push(await pruneTenant(t.key, opts.actor ?? null));
|
|
1465
|
+
return results;
|
|
1466
|
+
},
|
|
1467
|
+
pruneTenant: (tenant, opts = {}) => pruneTenant(tenant, opts.actor ?? null),
|
|
1468
|
+
async settled() {
|
|
1469
|
+
while (background.size > 0) await Promise.allSettled([...background]);
|
|
1470
|
+
},
|
|
1471
|
+
addRetentionFloor(floor) {
|
|
1472
|
+
floors.add(floor);
|
|
1473
|
+
return () => {
|
|
1474
|
+
floors.delete(floor);
|
|
1475
|
+
};
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
return core;
|
|
1479
|
+
}
|
|
1480
|
+
/** Erase sections of an event, keeping its digests (ADR 0011). */
|
|
1481
|
+
function eraseSections(event, sections) {
|
|
1482
|
+
const next = structuredClone(event);
|
|
1483
|
+
const erased = new Set(next.integrity.erased ?? []);
|
|
1484
|
+
for (const s of sections) {
|
|
1485
|
+
erased.add(s);
|
|
1486
|
+
const digest = next.integrity.digests[s] ?? "";
|
|
1487
|
+
switch (s) {
|
|
1488
|
+
case "actor":
|
|
1489
|
+
next.actor = { id: `erased:${digest.slice(7, 19)}` };
|
|
1490
|
+
break;
|
|
1491
|
+
case "targets":
|
|
1492
|
+
next.targets = [];
|
|
1493
|
+
break;
|
|
1494
|
+
case "context":
|
|
1495
|
+
next.context = { $erased: true };
|
|
1496
|
+
break;
|
|
1497
|
+
case "metadata":
|
|
1498
|
+
next.metadata = { $erased: true };
|
|
1499
|
+
break;
|
|
1500
|
+
case "description":
|
|
1501
|
+
delete next.description;
|
|
1502
|
+
break;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
next.integrity.erased = require_schema.AUDIT_SECTIONS.filter((s) => erased.has(s));
|
|
1506
|
+
return next;
|
|
1507
|
+
}
|
|
1508
|
+
/** Merge two page reports of one verification run. */
|
|
1509
|
+
function mergeReports(a, b, overlapping) {
|
|
1510
|
+
if (!a) return b;
|
|
1511
|
+
const dedupe = (issues) => {
|
|
1512
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1513
|
+
return issues.filter((i) => {
|
|
1514
|
+
const k = `${i.kind}|${i.seq}|${i.eventId}|${i.checkpointId}|${i.section}`;
|
|
1515
|
+
if (seen.has(k)) return false;
|
|
1516
|
+
seen.add(k);
|
|
1517
|
+
return true;
|
|
1518
|
+
});
|
|
1519
|
+
};
|
|
1520
|
+
const issues = dedupe([...a.issues, ...b.issues]);
|
|
1521
|
+
const erasedSeen = new Set(a.erased.map((e) => e.seq));
|
|
1522
|
+
return {
|
|
1523
|
+
ok: issues.length === 0,
|
|
1524
|
+
tenant: a.tenant ?? b.tenant,
|
|
1525
|
+
checked: a.checked + b.checked - (overlapping ? 1 : 0),
|
|
1526
|
+
fromSeq: a.fromSeq,
|
|
1527
|
+
toSeq: b.toSeq ?? a.toSeq,
|
|
1528
|
+
headHash: b.headHash ?? a.headHash,
|
|
1529
|
+
anchor: a.anchor,
|
|
1530
|
+
linksChecked: a.linksChecked && b.linksChecked,
|
|
1531
|
+
checkpointsVerified: a.checkpointsVerified + b.checkpointsVerified,
|
|
1532
|
+
signedThrough: b.signedThrough !== null || a.signedThrough !== null ? Math.max(a.signedThrough ?? 0, b.signedThrough ?? 0) : null,
|
|
1533
|
+
erased: [...a.erased, ...b.erased.filter((e) => !erasedSeen.has(e.seq))],
|
|
1534
|
+
issues
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
//#endregion
|
|
1538
|
+
Object.defineProperty(exports, "ConflictError", {
|
|
1539
|
+
enumerable: true,
|
|
1540
|
+
get: function() {
|
|
1541
|
+
return ConflictError;
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
Object.defineProperty(exports, "HookDeniedError", {
|
|
1545
|
+
enumerable: true,
|
|
1546
|
+
get: function() {
|
|
1547
|
+
return HookDeniedError;
|
|
1548
|
+
}
|
|
1549
|
+
});
|
|
1550
|
+
Object.defineProperty(exports, "NotFoundError", {
|
|
1551
|
+
enumerable: true,
|
|
1552
|
+
get: function() {
|
|
1553
|
+
return NotFoundError;
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
Object.defineProperty(exports, "REDACTED", {
|
|
1557
|
+
enumerable: true,
|
|
1558
|
+
get: function() {
|
|
1559
|
+
return REDACTED;
|
|
1560
|
+
}
|
|
1561
|
+
});
|
|
1562
|
+
Object.defineProperty(exports, "ReadonlyError", {
|
|
1563
|
+
enumerable: true,
|
|
1564
|
+
get: function() {
|
|
1565
|
+
return ReadonlyError;
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
Object.defineProperty(exports, "SELF_AUDIT_ACTIONS", {
|
|
1569
|
+
enumerable: true,
|
|
1570
|
+
get: function() {
|
|
1571
|
+
return SELF_AUDIT_ACTIONS;
|
|
1572
|
+
}
|
|
1573
|
+
});
|
|
1574
|
+
Object.defineProperty(exports, "SignerRequiredError", {
|
|
1575
|
+
enumerable: true,
|
|
1576
|
+
get: function() {
|
|
1577
|
+
return SignerRequiredError;
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
Object.defineProperty(exports, "applyTransforms", {
|
|
1581
|
+
enumerable: true,
|
|
1582
|
+
get: function() {
|
|
1583
|
+
return applyTransforms;
|
|
1584
|
+
}
|
|
1585
|
+
});
|
|
1586
|
+
Object.defineProperty(exports, "createAuditCore", {
|
|
1587
|
+
enumerable: true,
|
|
1588
|
+
get: function() {
|
|
1589
|
+
return createAuditCore;
|
|
1590
|
+
}
|
|
1591
|
+
});
|
|
1592
|
+
Object.defineProperty(exports, "createKvEventLog", {
|
|
1593
|
+
enumerable: true,
|
|
1594
|
+
get: function() {
|
|
1595
|
+
return createKvEventLog;
|
|
1596
|
+
}
|
|
1597
|
+
});
|
|
1598
|
+
Object.defineProperty(exports, "defaultHookErrorReporter", {
|
|
1599
|
+
enumerable: true,
|
|
1600
|
+
get: function() {
|
|
1601
|
+
return defaultHookErrorReporter;
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
Object.defineProperty(exports, "defineActions", {
|
|
1605
|
+
enumerable: true,
|
|
1606
|
+
get: function() {
|
|
1607
|
+
return defineActions;
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
Object.defineProperty(exports, "durationToMs", {
|
|
1611
|
+
enumerable: true,
|
|
1612
|
+
get: function() {
|
|
1613
|
+
return durationToMs;
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
Object.defineProperty(exports, "eraseSections", {
|
|
1617
|
+
enumerable: true,
|
|
1618
|
+
get: function() {
|
|
1619
|
+
return eraseSections;
|
|
1620
|
+
}
|
|
1621
|
+
});
|
|
1622
|
+
Object.defineProperty(exports, "hashValue", {
|
|
1623
|
+
enumerable: true,
|
|
1624
|
+
get: function() {
|
|
1625
|
+
return hashValue;
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
Object.defineProperty(exports, "idPattern", {
|
|
1629
|
+
enumerable: true,
|
|
1630
|
+
get: function() {
|
|
1631
|
+
return idPattern;
|
|
1632
|
+
}
|
|
1633
|
+
});
|
|
1634
|
+
Object.defineProperty(exports, "idTime", {
|
|
1635
|
+
enumerable: true,
|
|
1636
|
+
get: function() {
|
|
1637
|
+
return idTime;
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1640
|
+
Object.defineProperty(exports, "keys_exports", {
|
|
1641
|
+
enumerable: true,
|
|
1642
|
+
get: function() {
|
|
1643
|
+
return keys_exports;
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1646
|
+
Object.defineProperty(exports, "mask", {
|
|
1647
|
+
enumerable: true,
|
|
1648
|
+
get: function() {
|
|
1649
|
+
return mask;
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1652
|
+
Object.defineProperty(exports, "maskValue", {
|
|
1653
|
+
enumerable: true,
|
|
1654
|
+
get: function() {
|
|
1655
|
+
return maskValue;
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
Object.defineProperty(exports, "newId", {
|
|
1659
|
+
enumerable: true,
|
|
1660
|
+
get: function() {
|
|
1661
|
+
return newId;
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
Object.defineProperty(exports, "normalizeHooks", {
|
|
1665
|
+
enumerable: true,
|
|
1666
|
+
get: function() {
|
|
1667
|
+
return normalizeHooks;
|
|
1668
|
+
}
|
|
1669
|
+
});
|
|
1670
|
+
Object.defineProperty(exports, "omit", {
|
|
1671
|
+
enumerable: true,
|
|
1672
|
+
get: function() {
|
|
1673
|
+
return omit;
|
|
1674
|
+
}
|
|
1675
|
+
});
|
|
1676
|
+
Object.defineProperty(exports, "redact", {
|
|
1677
|
+
enumerable: true,
|
|
1678
|
+
get: function() {
|
|
1679
|
+
return redact;
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
Object.defineProperty(exports, "resolveEventLog", {
|
|
1683
|
+
enumerable: true,
|
|
1684
|
+
get: function() {
|
|
1685
|
+
return resolveEventLog;
|
|
1686
|
+
}
|
|
1687
|
+
});
|
|
1688
|
+
Object.defineProperty(exports, "runAfter", {
|
|
1689
|
+
enumerable: true,
|
|
1690
|
+
get: function() {
|
|
1691
|
+
return runAfter;
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
Object.defineProperty(exports, "runBefore", {
|
|
1695
|
+
enumerable: true,
|
|
1696
|
+
get: function() {
|
|
1697
|
+
return runBefore;
|
|
1698
|
+
}
|
|
1699
|
+
});
|
|
1700
|
+
Object.defineProperty(exports, "runStandardSchema", {
|
|
1701
|
+
enumerable: true,
|
|
1702
|
+
get: function() {
|
|
1703
|
+
return runStandardSchema;
|
|
1704
|
+
}
|
|
1705
|
+
});
|
|
1706
|
+
Object.defineProperty(exports, "streamCursorKey", {
|
|
1707
|
+
enumerable: true,
|
|
1708
|
+
get: function() {
|
|
1709
|
+
return streamCursorKey;
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
Object.defineProperty(exports, "streamLeaseKey", {
|
|
1713
|
+
enumerable: true,
|
|
1714
|
+
get: function() {
|
|
1715
|
+
return streamLeaseKey;
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
Object.defineProperty(exports, "streamMetaKey", {
|
|
1719
|
+
enumerable: true,
|
|
1720
|
+
get: function() {
|
|
1721
|
+
return streamMetaKey;
|
|
1722
|
+
}
|
|
1723
|
+
});
|
|
1724
|
+
|
|
1725
|
+
//# sourceMappingURL=core-CTr7dw0v.cjs.map
|