@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,130 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_shared = require("./shared-OOAq-U4S.cjs");
|
|
3
|
+
//#region src/sinks/webhook.ts
|
|
4
|
+
/** Prefix of a Standard Webhooks symmetric secret. */
|
|
5
|
+
const WEBHOOK_SECRET_PREFIX = "whsec_";
|
|
6
|
+
const MIN_SECRET_BYTES = 24;
|
|
7
|
+
const MAX_SECRET_BYTES = 64;
|
|
8
|
+
function base64Encode(bytes) {
|
|
9
|
+
let binary = "";
|
|
10
|
+
for (const b of bytes) binary += String.fromCharCode(b);
|
|
11
|
+
return btoa(binary);
|
|
12
|
+
}
|
|
13
|
+
/** Decode a `whsec_` secret into key bytes (24–64 bytes, as Standard Webhooks requires). */
|
|
14
|
+
function decodeSecret(secret) {
|
|
15
|
+
const body = secret.startsWith("whsec_") ? secret.slice(6) : secret;
|
|
16
|
+
let binary;
|
|
17
|
+
try {
|
|
18
|
+
binary = atob(body);
|
|
19
|
+
} catch {
|
|
20
|
+
throw new TypeError("webhookSink: secret is not valid base64 (expected whsec_…)");
|
|
21
|
+
}
|
|
22
|
+
if (binary.length < MIN_SECRET_BYTES || binary.length > MAX_SECRET_BYTES) throw new TypeError(`webhookSink: secret decodes to ${binary.length} bytes, expected ${MIN_SECRET_BYTES}–${MAX_SECRET_BYTES}`);
|
|
23
|
+
return Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sign one message: `v1,` + base64(HMAC-SHA256(key, `${id}.${timestamp}.${body}`)).
|
|
27
|
+
* `timestamp` is unix **seconds**.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { signWebhook } from "@xtandard/audit/sinks/webhook";
|
|
32
|
+
*
|
|
33
|
+
* const signature = await signWebhook("whsec_…", "evt_…", 1_720_000_000, body); // "v1,…"
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
async function signWebhook(secret, id, timestamp, body) {
|
|
37
|
+
const key = await crypto.subtle.importKey("raw", decodeSecret(secret), {
|
|
38
|
+
name: "HMAC",
|
|
39
|
+
hash: "SHA-256"
|
|
40
|
+
}, false, ["sign"]);
|
|
41
|
+
const mac = await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(`${id}.${timestamp}.${body}`));
|
|
42
|
+
return `v1,${base64Encode(new Uint8Array(mac))}`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The `webhook-id` of a batch: the item's own id when there is exactly one,
|
|
46
|
+
* otherwise `bat_` + a SHA-256 prefix over the stream, tenant and item ids —
|
|
47
|
+
* stable across re-sends of the same batch.
|
|
48
|
+
*/
|
|
49
|
+
async function batchWebhookId(batch) {
|
|
50
|
+
if (batch.items.length === 1) return require_shared.itemId(batch.items[0]);
|
|
51
|
+
const seed = [
|
|
52
|
+
batch.stream,
|
|
53
|
+
batch.tenant,
|
|
54
|
+
...batch.items.map(require_shared.itemId)
|
|
55
|
+
].join("\n");
|
|
56
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(seed)));
|
|
57
|
+
return `bat_${Array.from(digest.slice(0, 16), (b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a Standard Webhooks-signed sink.
|
|
61
|
+
*
|
|
62
|
+
* For per-tenant self-serve endpoints (customers adding their own SIEM URLs,
|
|
63
|
+
* with a portal, retries and dead-letters), use the `@xtandard/webhooks`
|
|
64
|
+
* bridge instead: `@xtandard/audit/sinks/xtandard-webhooks`.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* import { webhookSink } from "@xtandard/audit/sinks/webhook";
|
|
69
|
+
*
|
|
70
|
+
* const sink = webhookSink({
|
|
71
|
+
* url: "https://hooks.example.com/audit",
|
|
72
|
+
* secret: process.env.AUDIT_WEBHOOK_SECRET!, // "whsec_…"
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
function webhookSink(options) {
|
|
77
|
+
const secrets = Array.isArray(options.secret) ? options.secret : [options.secret];
|
|
78
|
+
if (secrets.length === 0) throw new TypeError("webhookSink: at least one secret is required");
|
|
79
|
+
for (const s of secrets) decodeSecret(s);
|
|
80
|
+
const mode = options.mode ?? "batch";
|
|
81
|
+
const now = options.now ?? Date.now;
|
|
82
|
+
const itemType = options.itemType ?? require_shared.defaultItemType;
|
|
83
|
+
async function post(batch, id, envelope) {
|
|
84
|
+
const body = JSON.stringify(envelope);
|
|
85
|
+
const timestamp = Math.floor(now() / 1e3);
|
|
86
|
+
const signatures = await Promise.all(secrets.map((s) => signWebhook(s, id, timestamp, body)));
|
|
87
|
+
await require_shared.sendRequest("webhook", options.url, {
|
|
88
|
+
method: "POST",
|
|
89
|
+
headers: {
|
|
90
|
+
"content-type": "application/json",
|
|
91
|
+
...await require_shared.resolveHeaders(options.headers, batch),
|
|
92
|
+
"webhook-id": id,
|
|
93
|
+
"webhook-timestamp": String(timestamp),
|
|
94
|
+
"webhook-signature": signatures.join(" ")
|
|
95
|
+
},
|
|
96
|
+
body
|
|
97
|
+
}, options);
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
kind: "webhook",
|
|
101
|
+
async send(batch) {
|
|
102
|
+
if (batch.items.length === 0) return;
|
|
103
|
+
if (mode === "item") {
|
|
104
|
+
for (const item of batch.items) await post(batch, require_shared.itemId(item), {
|
|
105
|
+
type: itemType(item),
|
|
106
|
+
timestamp: require_shared.itemTime(item),
|
|
107
|
+
data: item.kind === "event" ? item.event : item.checkpoint
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
await post(batch, await batchWebhookId(batch), {
|
|
112
|
+
type: options.batchType ?? "audit.batch",
|
|
113
|
+
timestamp: require_shared.itemTime(batch.items[batch.items.length - 1]),
|
|
114
|
+
data: {
|
|
115
|
+
stream: batch.stream,
|
|
116
|
+
tenant: batch.tenant,
|
|
117
|
+
items: batch.items
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
exports.SinkHttpError = require_shared.SinkHttpError;
|
|
125
|
+
exports.WEBHOOK_SECRET_PREFIX = WEBHOOK_SECRET_PREFIX;
|
|
126
|
+
exports.batchWebhookId = batchWebhookId;
|
|
127
|
+
exports.signWebhook = signWebhook;
|
|
128
|
+
exports.webhookSink = webhookSink;
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=entry-sinks-webhook.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-sinks-webhook.cjs","names":["itemId","defaultItemType","sendRequest","resolveHeaders","itemTime"],"sources":["../src/sinks/webhook.ts"],"sourcesContent":["/**\n * Standard Webhooks sink: POSTs each stream batch (or each item) as a signed\n * [Standard Webhooks](https://www.standardwebhooks.com) message, verifiable by\n * `@xtandard/webhooks/receiver`, Svix, the official `standardwebhooks`\n * libraries, or any compliant receiver.\n *\n * Wire contract:\n *\n * - body: the Standard Webhooks envelope `{ \"type\", \"timestamp\", \"data\" }`;\n * - `mode: \"batch\"` (default): `type` = `\"audit.batch\"`, `data` = `{ stream, tenant, items }`;\n * - `mode: \"item\"`: one request per item, `type` = `\"audit.<action>\"` /\n * `\"audit.checkpoint\"`, `data` = the event / checkpoint;\n * - `webhook-id`: the event / checkpoint id for single items, otherwise a\n * deterministic `bat_…` id derived from the batch's item ids — a re-sent\n * batch keeps its id, so receivers can dedupe on it;\n * - `webhook-timestamp`: unix seconds at send time;\n * - `webhook-signature`: `v1,` + base64(HMAC-SHA256(base64-decoded `whsec_`\n * secret, `${id}.${timestamp}.${body}`)); several space-separated entries\n * when several secrets are configured (rotation).\n *\n * Zero dependencies — Web Crypto + `fetch`.\n *\n * @module\n */\n\nimport type { AuditSink, StreamBatch, StreamItem } from \"../streams.ts\";\nimport {\n defaultItemType,\n itemId,\n itemTime,\n resolveHeaders,\n sendRequest,\n type SinkFetch,\n type SinkHeaders,\n} from \"./shared.ts\";\n\nexport { SinkHttpError, type SinkFetch, type SinkHeaders } from \"./shared.ts\";\n\n/** Prefix of a Standard Webhooks symmetric secret. */\nexport const WEBHOOK_SECRET_PREFIX = \"whsec_\";\n\nconst MIN_SECRET_BYTES = 24;\nconst MAX_SECRET_BYTES = 64;\n\n/** Options for {@link webhookSink}. */\nexport interface WebhookSinkOptions {\n /** Receiver URL. */\n url: string;\n /**\n * `whsec_…` secret(s). Pass several during rotation: the request carries one\n * signature per secret and receivers accept any match.\n */\n secret: string | string[];\n /** `\"batch\"` (default): one request per batch. `\"item\"`: one request per event / checkpoint. */\n mode?: \"batch\" | \"item\";\n /** Envelope `type` for batch mode. Default `\"audit.batch\"`. */\n batchType?: string;\n /** Envelope `type` for item mode. Default `audit.<action>` / `audit.checkpoint`. */\n itemType?: (item: StreamItem) => string;\n /** Extra headers, static or resolved per batch. */\n headers?: SinkHeaders;\n /** Request timeout. Default 10 000 ms. */\n timeoutMs?: number;\n /** Custom `fetch` (tests, proxies). Default `globalThis.fetch`. */\n fetch?: SinkFetch;\n /** Clock (unix millis) for `webhook-timestamp`. Default `Date.now`. */\n now?: () => number;\n}\n\nfunction base64Encode(bytes: Uint8Array): string {\n let binary = \"\";\n for (const b of bytes) binary += String.fromCharCode(b);\n return btoa(binary);\n}\n\n/** Decode a `whsec_` secret into key bytes (24–64 bytes, as Standard Webhooks requires). */\nfunction decodeSecret(secret: string): Uint8Array {\n const body = secret.startsWith(WEBHOOK_SECRET_PREFIX)\n ? secret.slice(WEBHOOK_SECRET_PREFIX.length)\n : secret;\n let binary: string;\n try {\n binary = atob(body);\n } catch {\n throw new TypeError(\"webhookSink: secret is not valid base64 (expected whsec_…)\");\n }\n if (binary.length < MIN_SECRET_BYTES || binary.length > MAX_SECRET_BYTES) {\n throw new TypeError(\n `webhookSink: secret decodes to ${binary.length} bytes, expected ${MIN_SECRET_BYTES}–${MAX_SECRET_BYTES}`,\n );\n }\n return Uint8Array.from(binary, (c) => c.charCodeAt(0));\n}\n\n/**\n * Sign one message: `v1,` + base64(HMAC-SHA256(key, `${id}.${timestamp}.${body}`)).\n * `timestamp` is unix **seconds**.\n *\n * @example\n * ```ts\n * import { signWebhook } from \"@xtandard/audit/sinks/webhook\";\n *\n * const signature = await signWebhook(\"whsec_…\", \"evt_…\", 1_720_000_000, body); // \"v1,…\"\n * ```\n */\nexport async function signWebhook(\n secret: string,\n id: string,\n timestamp: number,\n body: string,\n): Promise<string> {\n const key = await crypto.subtle.importKey(\n \"raw\",\n decodeSecret(secret) as BufferSource,\n { name: \"HMAC\", hash: \"SHA-256\" },\n false,\n [\"sign\"],\n );\n const mac = await crypto.subtle.sign(\n \"HMAC\",\n key,\n new TextEncoder().encode(`${id}.${timestamp}.${body}`),\n );\n return `v1,${base64Encode(new Uint8Array(mac))}`;\n}\n\n/**\n * The `webhook-id` of a batch: the item's own id when there is exactly one,\n * otherwise `bat_` + a SHA-256 prefix over the stream, tenant and item ids —\n * stable across re-sends of the same batch.\n */\nexport async function batchWebhookId(batch: StreamBatch): Promise<string> {\n if (batch.items.length === 1) return itemId(batch.items[0]!);\n const seed = [batch.stream, batch.tenant, ...batch.items.map(itemId)].join(\"\\n\");\n const digest = new Uint8Array(\n await crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(seed)),\n );\n return `bat_${Array.from(digest.slice(0, 16), (b) => b.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\n/**\n * Create a Standard Webhooks-signed sink.\n *\n * For per-tenant self-serve endpoints (customers adding their own SIEM URLs,\n * with a portal, retries and dead-letters), use the `@xtandard/webhooks`\n * bridge instead: `@xtandard/audit/sinks/xtandard-webhooks`.\n *\n * @example\n * ```ts\n * import { webhookSink } from \"@xtandard/audit/sinks/webhook\";\n *\n * const sink = webhookSink({\n * url: \"https://hooks.example.com/audit\",\n * secret: process.env.AUDIT_WEBHOOK_SECRET!, // \"whsec_…\"\n * });\n * ```\n */\nexport function webhookSink(options: WebhookSinkOptions): AuditSink {\n const secrets = Array.isArray(options.secret) ? options.secret : [options.secret];\n if (secrets.length === 0) throw new TypeError(\"webhookSink: at least one secret is required\");\n for (const s of secrets) decodeSecret(s); // fail fast on misconfiguration\n const mode = options.mode ?? \"batch\";\n const now = options.now ?? Date.now;\n const itemType = options.itemType ?? defaultItemType;\n\n async function post(\n batch: StreamBatch,\n id: string,\n envelope: { type: string; timestamp: string; data: unknown },\n ): Promise<void> {\n const body = JSON.stringify(envelope);\n const timestamp = Math.floor(now() / 1000);\n const signatures = await Promise.all(secrets.map((s) => signWebhook(s, id, timestamp, body)));\n await sendRequest(\n \"webhook\",\n options.url,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(await resolveHeaders(options.headers, batch)),\n \"webhook-id\": id,\n \"webhook-timestamp\": String(timestamp),\n \"webhook-signature\": signatures.join(\" \"),\n },\n body,\n },\n options,\n );\n }\n\n return {\n kind: \"webhook\",\n async send(batch) {\n if (batch.items.length === 0) return;\n if (mode === \"item\") {\n for (const item of batch.items) {\n await post(batch, itemId(item), {\n type: itemType(item),\n timestamp: itemTime(item),\n data: item.kind === \"event\" ? item.event : item.checkpoint,\n });\n }\n return;\n }\n await post(batch, await batchWebhookId(batch), {\n type: options.batchType ?? \"audit.batch\",\n // The newest item's time (not \"now\"): a re-sent batch is byte-identical.\n timestamp: itemTime(batch.items[batch.items.length - 1]!),\n data: { stream: batch.stream, tenant: batch.tenant, items: batch.items },\n });\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { a as StreamItem, n as StreamBatch, t as AuditSink } from "./streams-CRuxOYcb.cjs";
|
|
2
|
+
import { n as SinkHeaders, r as SinkHttpError, t as SinkFetch } from "./shared-EANCdRqn.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/sinks/webhook.d.ts
|
|
5
|
+
/** Prefix of a Standard Webhooks symmetric secret. */
|
|
6
|
+
declare const WEBHOOK_SECRET_PREFIX = "whsec_";
|
|
7
|
+
/** Options for {@link webhookSink}. */
|
|
8
|
+
interface WebhookSinkOptions {
|
|
9
|
+
/** Receiver URL. */
|
|
10
|
+
url: string;
|
|
11
|
+
/**
|
|
12
|
+
* `whsec_…` secret(s). Pass several during rotation: the request carries one
|
|
13
|
+
* signature per secret and receivers accept any match.
|
|
14
|
+
*/
|
|
15
|
+
secret: string | string[];
|
|
16
|
+
/** `"batch"` (default): one request per batch. `"item"`: one request per event / checkpoint. */
|
|
17
|
+
mode?: "batch" | "item";
|
|
18
|
+
/** Envelope `type` for batch mode. Default `"audit.batch"`. */
|
|
19
|
+
batchType?: string;
|
|
20
|
+
/** Envelope `type` for item mode. Default `audit.<action>` / `audit.checkpoint`. */
|
|
21
|
+
itemType?: (item: StreamItem) => string;
|
|
22
|
+
/** Extra headers, static or resolved per batch. */
|
|
23
|
+
headers?: SinkHeaders;
|
|
24
|
+
/** Request timeout. Default 10 000 ms. */
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
/** Custom `fetch` (tests, proxies). Default `globalThis.fetch`. */
|
|
27
|
+
fetch?: SinkFetch;
|
|
28
|
+
/** Clock (unix millis) for `webhook-timestamp`. Default `Date.now`. */
|
|
29
|
+
now?: () => number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Sign one message: `v1,` + base64(HMAC-SHA256(key, `${id}.${timestamp}.${body}`)).
|
|
33
|
+
* `timestamp` is unix **seconds**.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { signWebhook } from "@xtandard/audit/sinks/webhook";
|
|
38
|
+
*
|
|
39
|
+
* const signature = await signWebhook("whsec_…", "evt_…", 1_720_000_000, body); // "v1,…"
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare function signWebhook(secret: string, id: string, timestamp: number, body: string): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* The `webhook-id` of a batch: the item's own id when there is exactly one,
|
|
45
|
+
* otherwise `bat_` + a SHA-256 prefix over the stream, tenant and item ids —
|
|
46
|
+
* stable across re-sends of the same batch.
|
|
47
|
+
*/
|
|
48
|
+
declare function batchWebhookId(batch: StreamBatch): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Create a Standard Webhooks-signed sink.
|
|
51
|
+
*
|
|
52
|
+
* For per-tenant self-serve endpoints (customers adding their own SIEM URLs,
|
|
53
|
+
* with a portal, retries and dead-letters), use the `@xtandard/webhooks`
|
|
54
|
+
* bridge instead: `@xtandard/audit/sinks/xtandard-webhooks`.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { webhookSink } from "@xtandard/audit/sinks/webhook";
|
|
59
|
+
*
|
|
60
|
+
* const sink = webhookSink({
|
|
61
|
+
* url: "https://hooks.example.com/audit",
|
|
62
|
+
* secret: process.env.AUDIT_WEBHOOK_SECRET!, // "whsec_…"
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function webhookSink(options: WebhookSinkOptions): AuditSink;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { type SinkFetch, type SinkHeaders, SinkHttpError, WEBHOOK_SECRET_PREFIX, WebhookSinkOptions, batchWebhookId, signWebhook, webhookSink };
|
|
69
|
+
//# sourceMappingURL=entry-sinks-webhook.d.cts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { a as StreamItem, n as StreamBatch, t as AuditSink } from "./streams-DU0_gvI8.mjs";
|
|
2
|
+
import { n as SinkHeaders, r as SinkHttpError, t as SinkFetch } from "./shared-CJOyJKqT.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/sinks/webhook.d.ts
|
|
5
|
+
/** Prefix of a Standard Webhooks symmetric secret. */
|
|
6
|
+
declare const WEBHOOK_SECRET_PREFIX = "whsec_";
|
|
7
|
+
/** Options for {@link webhookSink}. */
|
|
8
|
+
interface WebhookSinkOptions {
|
|
9
|
+
/** Receiver URL. */
|
|
10
|
+
url: string;
|
|
11
|
+
/**
|
|
12
|
+
* `whsec_…` secret(s). Pass several during rotation: the request carries one
|
|
13
|
+
* signature per secret and receivers accept any match.
|
|
14
|
+
*/
|
|
15
|
+
secret: string | string[];
|
|
16
|
+
/** `"batch"` (default): one request per batch. `"item"`: one request per event / checkpoint. */
|
|
17
|
+
mode?: "batch" | "item";
|
|
18
|
+
/** Envelope `type` for batch mode. Default `"audit.batch"`. */
|
|
19
|
+
batchType?: string;
|
|
20
|
+
/** Envelope `type` for item mode. Default `audit.<action>` / `audit.checkpoint`. */
|
|
21
|
+
itemType?: (item: StreamItem) => string;
|
|
22
|
+
/** Extra headers, static or resolved per batch. */
|
|
23
|
+
headers?: SinkHeaders;
|
|
24
|
+
/** Request timeout. Default 10 000 ms. */
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
/** Custom `fetch` (tests, proxies). Default `globalThis.fetch`. */
|
|
27
|
+
fetch?: SinkFetch;
|
|
28
|
+
/** Clock (unix millis) for `webhook-timestamp`. Default `Date.now`. */
|
|
29
|
+
now?: () => number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Sign one message: `v1,` + base64(HMAC-SHA256(key, `${id}.${timestamp}.${body}`)).
|
|
33
|
+
* `timestamp` is unix **seconds**.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { signWebhook } from "@xtandard/audit/sinks/webhook";
|
|
38
|
+
*
|
|
39
|
+
* const signature = await signWebhook("whsec_…", "evt_…", 1_720_000_000, body); // "v1,…"
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare function signWebhook(secret: string, id: string, timestamp: number, body: string): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* The `webhook-id` of a batch: the item's own id when there is exactly one,
|
|
45
|
+
* otherwise `bat_` + a SHA-256 prefix over the stream, tenant and item ids —
|
|
46
|
+
* stable across re-sends of the same batch.
|
|
47
|
+
*/
|
|
48
|
+
declare function batchWebhookId(batch: StreamBatch): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Create a Standard Webhooks-signed sink.
|
|
51
|
+
*
|
|
52
|
+
* For per-tenant self-serve endpoints (customers adding their own SIEM URLs,
|
|
53
|
+
* with a portal, retries and dead-letters), use the `@xtandard/webhooks`
|
|
54
|
+
* bridge instead: `@xtandard/audit/sinks/xtandard-webhooks`.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { webhookSink } from "@xtandard/audit/sinks/webhook";
|
|
59
|
+
*
|
|
60
|
+
* const sink = webhookSink({
|
|
61
|
+
* url: "https://hooks.example.com/audit",
|
|
62
|
+
* secret: process.env.AUDIT_WEBHOOK_SECRET!, // "whsec_…"
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare function webhookSink(options: WebhookSinkOptions): AuditSink;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { type SinkFetch, type SinkHeaders, SinkHttpError, WEBHOOK_SECRET_PREFIX, WebhookSinkOptions, batchWebhookId, signWebhook, webhookSink };
|
|
69
|
+
//# sourceMappingURL=entry-sinks-webhook.d.mts.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { a as itemTime, i as itemId, o as resolveHeaders, r as defaultItemType, s as sendRequest, t as SinkHttpError } from "./shared-DSDY-V0n.mjs";
|
|
2
|
+
//#region src/sinks/webhook.ts
|
|
3
|
+
/** Prefix of a Standard Webhooks symmetric secret. */
|
|
4
|
+
const WEBHOOK_SECRET_PREFIX = "whsec_";
|
|
5
|
+
const MIN_SECRET_BYTES = 24;
|
|
6
|
+
const MAX_SECRET_BYTES = 64;
|
|
7
|
+
function base64Encode(bytes) {
|
|
8
|
+
let binary = "";
|
|
9
|
+
for (const b of bytes) binary += String.fromCharCode(b);
|
|
10
|
+
return btoa(binary);
|
|
11
|
+
}
|
|
12
|
+
/** Decode a `whsec_` secret into key bytes (24–64 bytes, as Standard Webhooks requires). */
|
|
13
|
+
function decodeSecret(secret) {
|
|
14
|
+
const body = secret.startsWith("whsec_") ? secret.slice(6) : secret;
|
|
15
|
+
let binary;
|
|
16
|
+
try {
|
|
17
|
+
binary = atob(body);
|
|
18
|
+
} catch {
|
|
19
|
+
throw new TypeError("webhookSink: secret is not valid base64 (expected whsec_…)");
|
|
20
|
+
}
|
|
21
|
+
if (binary.length < MIN_SECRET_BYTES || binary.length > MAX_SECRET_BYTES) throw new TypeError(`webhookSink: secret decodes to ${binary.length} bytes, expected ${MIN_SECRET_BYTES}–${MAX_SECRET_BYTES}`);
|
|
22
|
+
return Uint8Array.from(binary, (c) => c.charCodeAt(0));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sign one message: `v1,` + base64(HMAC-SHA256(key, `${id}.${timestamp}.${body}`)).
|
|
26
|
+
* `timestamp` is unix **seconds**.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { signWebhook } from "@xtandard/audit/sinks/webhook";
|
|
31
|
+
*
|
|
32
|
+
* const signature = await signWebhook("whsec_…", "evt_…", 1_720_000_000, body); // "v1,…"
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
async function signWebhook(secret, id, timestamp, body) {
|
|
36
|
+
const key = await crypto.subtle.importKey("raw", decodeSecret(secret), {
|
|
37
|
+
name: "HMAC",
|
|
38
|
+
hash: "SHA-256"
|
|
39
|
+
}, false, ["sign"]);
|
|
40
|
+
const mac = await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(`${id}.${timestamp}.${body}`));
|
|
41
|
+
return `v1,${base64Encode(new Uint8Array(mac))}`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The `webhook-id` of a batch: the item's own id when there is exactly one,
|
|
45
|
+
* otherwise `bat_` + a SHA-256 prefix over the stream, tenant and item ids —
|
|
46
|
+
* stable across re-sends of the same batch.
|
|
47
|
+
*/
|
|
48
|
+
async function batchWebhookId(batch) {
|
|
49
|
+
if (batch.items.length === 1) return itemId(batch.items[0]);
|
|
50
|
+
const seed = [
|
|
51
|
+
batch.stream,
|
|
52
|
+
batch.tenant,
|
|
53
|
+
...batch.items.map(itemId)
|
|
54
|
+
].join("\n");
|
|
55
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(seed)));
|
|
56
|
+
return `bat_${Array.from(digest.slice(0, 16), (b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Create a Standard Webhooks-signed sink.
|
|
60
|
+
*
|
|
61
|
+
* For per-tenant self-serve endpoints (customers adding their own SIEM URLs,
|
|
62
|
+
* with a portal, retries and dead-letters), use the `@xtandard/webhooks`
|
|
63
|
+
* bridge instead: `@xtandard/audit/sinks/xtandard-webhooks`.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { webhookSink } from "@xtandard/audit/sinks/webhook";
|
|
68
|
+
*
|
|
69
|
+
* const sink = webhookSink({
|
|
70
|
+
* url: "https://hooks.example.com/audit",
|
|
71
|
+
* secret: process.env.AUDIT_WEBHOOK_SECRET!, // "whsec_…"
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
function webhookSink(options) {
|
|
76
|
+
const secrets = Array.isArray(options.secret) ? options.secret : [options.secret];
|
|
77
|
+
if (secrets.length === 0) throw new TypeError("webhookSink: at least one secret is required");
|
|
78
|
+
for (const s of secrets) decodeSecret(s);
|
|
79
|
+
const mode = options.mode ?? "batch";
|
|
80
|
+
const now = options.now ?? Date.now;
|
|
81
|
+
const itemType = options.itemType ?? defaultItemType;
|
|
82
|
+
async function post(batch, id, envelope) {
|
|
83
|
+
const body = JSON.stringify(envelope);
|
|
84
|
+
const timestamp = Math.floor(now() / 1e3);
|
|
85
|
+
const signatures = await Promise.all(secrets.map((s) => signWebhook(s, id, timestamp, body)));
|
|
86
|
+
await sendRequest("webhook", options.url, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: {
|
|
89
|
+
"content-type": "application/json",
|
|
90
|
+
...await resolveHeaders(options.headers, batch),
|
|
91
|
+
"webhook-id": id,
|
|
92
|
+
"webhook-timestamp": String(timestamp),
|
|
93
|
+
"webhook-signature": signatures.join(" ")
|
|
94
|
+
},
|
|
95
|
+
body
|
|
96
|
+
}, options);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
kind: "webhook",
|
|
100
|
+
async send(batch) {
|
|
101
|
+
if (batch.items.length === 0) return;
|
|
102
|
+
if (mode === "item") {
|
|
103
|
+
for (const item of batch.items) await post(batch, itemId(item), {
|
|
104
|
+
type: itemType(item),
|
|
105
|
+
timestamp: itemTime(item),
|
|
106
|
+
data: item.kind === "event" ? item.event : item.checkpoint
|
|
107
|
+
});
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
await post(batch, await batchWebhookId(batch), {
|
|
111
|
+
type: options.batchType ?? "audit.batch",
|
|
112
|
+
timestamp: itemTime(batch.items[batch.items.length - 1]),
|
|
113
|
+
data: {
|
|
114
|
+
stream: batch.stream,
|
|
115
|
+
tenant: batch.tenant,
|
|
116
|
+
items: batch.items
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { SinkHttpError, WEBHOOK_SECRET_PREFIX, batchWebhookId, signWebhook, webhookSink };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=entry-sinks-webhook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-sinks-webhook.mjs","names":[],"sources":["../src/sinks/webhook.ts"],"sourcesContent":["/**\n * Standard Webhooks sink: POSTs each stream batch (or each item) as a signed\n * [Standard Webhooks](https://www.standardwebhooks.com) message, verifiable by\n * `@xtandard/webhooks/receiver`, Svix, the official `standardwebhooks`\n * libraries, or any compliant receiver.\n *\n * Wire contract:\n *\n * - body: the Standard Webhooks envelope `{ \"type\", \"timestamp\", \"data\" }`;\n * - `mode: \"batch\"` (default): `type` = `\"audit.batch\"`, `data` = `{ stream, tenant, items }`;\n * - `mode: \"item\"`: one request per item, `type` = `\"audit.<action>\"` /\n * `\"audit.checkpoint\"`, `data` = the event / checkpoint;\n * - `webhook-id`: the event / checkpoint id for single items, otherwise a\n * deterministic `bat_…` id derived from the batch's item ids — a re-sent\n * batch keeps its id, so receivers can dedupe on it;\n * - `webhook-timestamp`: unix seconds at send time;\n * - `webhook-signature`: `v1,` + base64(HMAC-SHA256(base64-decoded `whsec_`\n * secret, `${id}.${timestamp}.${body}`)); several space-separated entries\n * when several secrets are configured (rotation).\n *\n * Zero dependencies — Web Crypto + `fetch`.\n *\n * @module\n */\n\nimport type { AuditSink, StreamBatch, StreamItem } from \"../streams.ts\";\nimport {\n defaultItemType,\n itemId,\n itemTime,\n resolveHeaders,\n sendRequest,\n type SinkFetch,\n type SinkHeaders,\n} from \"./shared.ts\";\n\nexport { SinkHttpError, type SinkFetch, type SinkHeaders } from \"./shared.ts\";\n\n/** Prefix of a Standard Webhooks symmetric secret. */\nexport const WEBHOOK_SECRET_PREFIX = \"whsec_\";\n\nconst MIN_SECRET_BYTES = 24;\nconst MAX_SECRET_BYTES = 64;\n\n/** Options for {@link webhookSink}. */\nexport interface WebhookSinkOptions {\n /** Receiver URL. */\n url: string;\n /**\n * `whsec_…` secret(s). Pass several during rotation: the request carries one\n * signature per secret and receivers accept any match.\n */\n secret: string | string[];\n /** `\"batch\"` (default): one request per batch. `\"item\"`: one request per event / checkpoint. */\n mode?: \"batch\" | \"item\";\n /** Envelope `type` for batch mode. Default `\"audit.batch\"`. */\n batchType?: string;\n /** Envelope `type` for item mode. Default `audit.<action>` / `audit.checkpoint`. */\n itemType?: (item: StreamItem) => string;\n /** Extra headers, static or resolved per batch. */\n headers?: SinkHeaders;\n /** Request timeout. Default 10 000 ms. */\n timeoutMs?: number;\n /** Custom `fetch` (tests, proxies). Default `globalThis.fetch`. */\n fetch?: SinkFetch;\n /** Clock (unix millis) for `webhook-timestamp`. Default `Date.now`. */\n now?: () => number;\n}\n\nfunction base64Encode(bytes: Uint8Array): string {\n let binary = \"\";\n for (const b of bytes) binary += String.fromCharCode(b);\n return btoa(binary);\n}\n\n/** Decode a `whsec_` secret into key bytes (24–64 bytes, as Standard Webhooks requires). */\nfunction decodeSecret(secret: string): Uint8Array {\n const body = secret.startsWith(WEBHOOK_SECRET_PREFIX)\n ? secret.slice(WEBHOOK_SECRET_PREFIX.length)\n : secret;\n let binary: string;\n try {\n binary = atob(body);\n } catch {\n throw new TypeError(\"webhookSink: secret is not valid base64 (expected whsec_…)\");\n }\n if (binary.length < MIN_SECRET_BYTES || binary.length > MAX_SECRET_BYTES) {\n throw new TypeError(\n `webhookSink: secret decodes to ${binary.length} bytes, expected ${MIN_SECRET_BYTES}–${MAX_SECRET_BYTES}`,\n );\n }\n return Uint8Array.from(binary, (c) => c.charCodeAt(0));\n}\n\n/**\n * Sign one message: `v1,` + base64(HMAC-SHA256(key, `${id}.${timestamp}.${body}`)).\n * `timestamp` is unix **seconds**.\n *\n * @example\n * ```ts\n * import { signWebhook } from \"@xtandard/audit/sinks/webhook\";\n *\n * const signature = await signWebhook(\"whsec_…\", \"evt_…\", 1_720_000_000, body); // \"v1,…\"\n * ```\n */\nexport async function signWebhook(\n secret: string,\n id: string,\n timestamp: number,\n body: string,\n): Promise<string> {\n const key = await crypto.subtle.importKey(\n \"raw\",\n decodeSecret(secret) as BufferSource,\n { name: \"HMAC\", hash: \"SHA-256\" },\n false,\n [\"sign\"],\n );\n const mac = await crypto.subtle.sign(\n \"HMAC\",\n key,\n new TextEncoder().encode(`${id}.${timestamp}.${body}`),\n );\n return `v1,${base64Encode(new Uint8Array(mac))}`;\n}\n\n/**\n * The `webhook-id` of a batch: the item's own id when there is exactly one,\n * otherwise `bat_` + a SHA-256 prefix over the stream, tenant and item ids —\n * stable across re-sends of the same batch.\n */\nexport async function batchWebhookId(batch: StreamBatch): Promise<string> {\n if (batch.items.length === 1) return itemId(batch.items[0]!);\n const seed = [batch.stream, batch.tenant, ...batch.items.map(itemId)].join(\"\\n\");\n const digest = new Uint8Array(\n await crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(seed)),\n );\n return `bat_${Array.from(digest.slice(0, 16), (b) => b.toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n\n/**\n * Create a Standard Webhooks-signed sink.\n *\n * For per-tenant self-serve endpoints (customers adding their own SIEM URLs,\n * with a portal, retries and dead-letters), use the `@xtandard/webhooks`\n * bridge instead: `@xtandard/audit/sinks/xtandard-webhooks`.\n *\n * @example\n * ```ts\n * import { webhookSink } from \"@xtandard/audit/sinks/webhook\";\n *\n * const sink = webhookSink({\n * url: \"https://hooks.example.com/audit\",\n * secret: process.env.AUDIT_WEBHOOK_SECRET!, // \"whsec_…\"\n * });\n * ```\n */\nexport function webhookSink(options: WebhookSinkOptions): AuditSink {\n const secrets = Array.isArray(options.secret) ? options.secret : [options.secret];\n if (secrets.length === 0) throw new TypeError(\"webhookSink: at least one secret is required\");\n for (const s of secrets) decodeSecret(s); // fail fast on misconfiguration\n const mode = options.mode ?? \"batch\";\n const now = options.now ?? Date.now;\n const itemType = options.itemType ?? defaultItemType;\n\n async function post(\n batch: StreamBatch,\n id: string,\n envelope: { type: string; timestamp: string; data: unknown },\n ): Promise<void> {\n const body = JSON.stringify(envelope);\n const timestamp = Math.floor(now() / 1000);\n const signatures = await Promise.all(secrets.map((s) => signWebhook(s, id, timestamp, body)));\n await sendRequest(\n \"webhook\",\n options.url,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n ...(await resolveHeaders(options.headers, batch)),\n \"webhook-id\": id,\n \"webhook-timestamp\": String(timestamp),\n \"webhook-signature\": signatures.join(\" \"),\n },\n body,\n },\n options,\n );\n }\n\n return {\n kind: \"webhook\",\n async send(batch) {\n if (batch.items.length === 0) return;\n if (mode === \"item\") {\n for (const item of batch.items) {\n await post(batch, itemId(item), {\n type: itemType(item),\n timestamp: itemTime(item),\n data: item.kind === \"event\" ? item.event : item.checkpoint,\n });\n }\n return;\n }\n await post(batch, await batchWebhookId(batch), {\n type: options.batchType ?? \"audit.batch\",\n // The newest item's time (not \"now\"): a re-sent batch is byte-identical.\n timestamp: itemTime(batch.items[batch.items.length - 1]!),\n data: { stream: batch.stream, tenant: batch.tenant, items: batch.items },\n });\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_shared = require("./shared-OOAq-U4S.cjs");
|
|
3
|
+
//#region src/sinks/xtandard-webhooks.ts
|
|
4
|
+
/**
|
|
5
|
+
* Create a sink that publishes into an `@xtandard/webhooks` core.
|
|
6
|
+
*
|
|
7
|
+
* Each item becomes one message with `idempotencyKey` = the event /
|
|
8
|
+
* checkpoint id, so a re-sent batch is deduplicated by the webhooks core
|
|
9
|
+
* (within its retention). A re-publish whose payload changed since (an event
|
|
10
|
+
* erased under ADR 0011) is treated as already delivered — the endpoint got
|
|
11
|
+
* the original, and the erasure is itself an audit event.
|
|
12
|
+
*
|
|
13
|
+
* With `requireKnownEventTypes`, register the event types first
|
|
14
|
+
* (`audit.<action>` for each action you stream, plus `audit.checkpoint`).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { createWebhooksCore } from "@xtandard/webhooks";
|
|
19
|
+
* import { createStreamRunner } from "@xtandard/audit";
|
|
20
|
+
* import { xtandardWebhooksSink } from "@xtandard/audit/sinks/xtandard-webhooks";
|
|
21
|
+
*
|
|
22
|
+
* const webhooks = createWebhooksCore({ storage: webhooksStorage });
|
|
23
|
+
*
|
|
24
|
+
* createStreamRunner(audit, {
|
|
25
|
+
* streams: [
|
|
26
|
+
* {
|
|
27
|
+
* name: "tenant-webhooks",
|
|
28
|
+
* sink: xtandardWebhooksSink(webhooks, {
|
|
29
|
+
* // one webhooks application per audit tenant
|
|
30
|
+
* applicationKey: (tenant) => `org_${tenant}`,
|
|
31
|
+
* }),
|
|
32
|
+
* },
|
|
33
|
+
* ],
|
|
34
|
+
* }).start();
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function xtandardWebhooksSink(webhooks, options = {}) {
|
|
38
|
+
const appFor = options.applicationKey ?? ((tenant) => tenant);
|
|
39
|
+
const eventType = options.eventType ?? require_shared.defaultItemType;
|
|
40
|
+
const payloadOf = options.payload ?? ((item) => item.kind === "event" ? item.event : item.checkpoint);
|
|
41
|
+
return {
|
|
42
|
+
kind: "xtandard-webhooks",
|
|
43
|
+
async send(batch) {
|
|
44
|
+
if (batch.items.length === 0) return;
|
|
45
|
+
const app = await appFor(batch.tenant);
|
|
46
|
+
if (app === null) return;
|
|
47
|
+
for (const item of batch.items) try {
|
|
48
|
+
await webhooks.publish(app, {
|
|
49
|
+
eventType: eventType(item),
|
|
50
|
+
payload: payloadOf(item),
|
|
51
|
+
timestamp: require_shared.itemTime(item),
|
|
52
|
+
idempotencyKey: require_shared.itemId(item)
|
|
53
|
+
});
|
|
54
|
+
} catch (err) {
|
|
55
|
+
if (err instanceof Error && err.name === "IdempotencyConflictError") continue;
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
exports.xtandardWebhooksSink = xtandardWebhooksSink;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=entry-sinks-xtandard-webhooks.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-sinks-xtandard-webhooks.cjs","names":["defaultItemType","itemTime","itemId"],"sources":["../src/sinks/xtandard-webhooks.ts"],"sourcesContent":["/**\n * The `@xtandard/webhooks` bridge (ADR 0008 §6): publishes every streamed\n * event and checkpoint into a webhooks core, so each tenant can **self-serve**\n * its own SIEM / archive endpoints — in the webhooks portal, with per-endpoint\n * retries, dead-letters, replay and signing — instead of this package\n * rebuilding all of that.\n *\n * Typed structurally: there is **no dependency** on `@xtandard/webhooks`; any\n * object with a compatible `publish(applicationKey, { eventType, payload,\n * timestamp, idempotencyKey })` works.\n *\n * @module\n */\n\nimport type { JsonValue } from \"../schema.ts\";\nimport type { AuditSink, StreamItem } from \"../streams.ts\";\nimport { defaultItemType, itemId, itemTime } from \"./shared.ts\";\n\n/** The slice of an `@xtandard/webhooks` core this sink calls. */\nexport interface WebhooksPublisher {\n publish(\n applicationKey: string,\n input: {\n eventType: string;\n payload: JsonValue;\n timestamp?: string;\n idempotencyKey?: string;\n },\n ): Promise<unknown>;\n}\n\n/** Options for {@link xtandardWebhooksSink}. */\nexport interface XtandardWebhooksSinkOptions {\n /**\n * The webhooks application that receives a tenant's items, or `null` to\n * skip the tenant (e.g. it has not enabled streaming). Default: the tenant\n * key itself. The application must exist — `publish` into a missing one\n * throws and the stream backs off.\n */\n applicationKey?: (tenant: string) => string | null | Promise<string | null>;\n /** Event type per item. Default `audit.<action>` for events, `audit.checkpoint` for checkpoints. */\n eventType?: (item: StreamItem) => string;\n /** Message payload per item. Default: the full event / checkpoint (with its integrity block). */\n payload?: (item: StreamItem) => JsonValue;\n}\n\n/**\n * Create a sink that publishes into an `@xtandard/webhooks` core.\n *\n * Each item becomes one message with `idempotencyKey` = the event /\n * checkpoint id, so a re-sent batch is deduplicated by the webhooks core\n * (within its retention). A re-publish whose payload changed since (an event\n * erased under ADR 0011) is treated as already delivered — the endpoint got\n * the original, and the erasure is itself an audit event.\n *\n * With `requireKnownEventTypes`, register the event types first\n * (`audit.<action>` for each action you stream, plus `audit.checkpoint`).\n *\n * @example\n * ```ts\n * import { createWebhooksCore } from \"@xtandard/webhooks\";\n * import { createStreamRunner } from \"@xtandard/audit\";\n * import { xtandardWebhooksSink } from \"@xtandard/audit/sinks/xtandard-webhooks\";\n *\n * const webhooks = createWebhooksCore({ storage: webhooksStorage });\n *\n * createStreamRunner(audit, {\n * streams: [\n * {\n * name: \"tenant-webhooks\",\n * sink: xtandardWebhooksSink(webhooks, {\n * // one webhooks application per audit tenant\n * applicationKey: (tenant) => `org_${tenant}`,\n * }),\n * },\n * ],\n * }).start();\n * ```\n */\nexport function xtandardWebhooksSink(\n webhooks: WebhooksPublisher,\n options: XtandardWebhooksSinkOptions = {},\n): AuditSink {\n const appFor = options.applicationKey ?? ((tenant: string) => tenant);\n const eventType = options.eventType ?? defaultItemType;\n const payloadOf =\n options.payload ??\n ((item: StreamItem) =>\n (item.kind === \"event\" ? item.event : item.checkpoint) as unknown as JsonValue);\n\n return {\n kind: \"xtandard-webhooks\",\n async send(batch) {\n if (batch.items.length === 0) return;\n const app = await appFor(batch.tenant);\n if (app === null) return;\n for (const item of batch.items) {\n try {\n await webhooks.publish(app, {\n eventType: eventType(item),\n payload: payloadOf(item),\n timestamp: itemTime(item),\n idempotencyKey: itemId(item),\n });\n } catch (err) {\n // Already published with different content (erased since): delivered.\n if (err instanceof Error && err.name === \"IdempotencyConflictError\") continue;\n throw err;\n }\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,SAAgB,qBACd,UACA,UAAuC,CAAC,GAC7B;CACX,MAAM,SAAS,QAAQ,oBAAoB,WAAmB;CAC9D,MAAM,YAAY,QAAQ,aAAaA,eAAAA;CACvC,MAAM,YACJ,QAAQ,aACN,SACC,KAAK,SAAS,UAAU,KAAK,QAAQ,KAAK;CAE/C,OAAO;EACL,MAAM;EACN,MAAM,KAAK,OAAO;GAChB,IAAI,MAAM,MAAM,WAAW,GAAG;GAC9B,MAAM,MAAM,MAAM,OAAO,MAAM,MAAM;GACrC,IAAI,QAAQ,MAAM;GAClB,KAAK,MAAM,QAAQ,MAAM,OACvB,IAAI;IACF,MAAM,SAAS,QAAQ,KAAK;KAC1B,WAAW,UAAU,IAAI;KACzB,SAAS,UAAU,IAAI;KACvB,WAAWC,eAAAA,SAAS,IAAI;KACxB,gBAAgBC,eAAAA,OAAO,IAAI;IAC7B,CAAC;GACH,SAAS,KAAK;IAEZ,IAAI,eAAe,SAAS,IAAI,SAAS,4BAA4B;IACrE,MAAM;GACR;EAEJ;CACF;AACF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { y as JsonValue } from "./schema-DmU7Wp0F.cjs";
|
|
2
|
+
import { a as StreamItem, t as AuditSink } from "./streams-CRuxOYcb.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/sinks/xtandard-webhooks.d.ts
|
|
5
|
+
/** The slice of an `@xtandard/webhooks` core this sink calls. */
|
|
6
|
+
interface WebhooksPublisher {
|
|
7
|
+
publish(applicationKey: string, input: {
|
|
8
|
+
eventType: string;
|
|
9
|
+
payload: JsonValue;
|
|
10
|
+
timestamp?: string;
|
|
11
|
+
idempotencyKey?: string;
|
|
12
|
+
}): Promise<unknown>;
|
|
13
|
+
}
|
|
14
|
+
/** Options for {@link xtandardWebhooksSink}. */
|
|
15
|
+
interface XtandardWebhooksSinkOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The webhooks application that receives a tenant's items, or `null` to
|
|
18
|
+
* skip the tenant (e.g. it has not enabled streaming). Default: the tenant
|
|
19
|
+
* key itself. The application must exist — `publish` into a missing one
|
|
20
|
+
* throws and the stream backs off.
|
|
21
|
+
*/
|
|
22
|
+
applicationKey?: (tenant: string) => string | null | Promise<string | null>;
|
|
23
|
+
/** Event type per item. Default `audit.<action>` for events, `audit.checkpoint` for checkpoints. */
|
|
24
|
+
eventType?: (item: StreamItem) => string;
|
|
25
|
+
/** Message payload per item. Default: the full event / checkpoint (with its integrity block). */
|
|
26
|
+
payload?: (item: StreamItem) => JsonValue;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a sink that publishes into an `@xtandard/webhooks` core.
|
|
30
|
+
*
|
|
31
|
+
* Each item becomes one message with `idempotencyKey` = the event /
|
|
32
|
+
* checkpoint id, so a re-sent batch is deduplicated by the webhooks core
|
|
33
|
+
* (within its retention). A re-publish whose payload changed since (an event
|
|
34
|
+
* erased under ADR 0011) is treated as already delivered — the endpoint got
|
|
35
|
+
* the original, and the erasure is itself an audit event.
|
|
36
|
+
*
|
|
37
|
+
* With `requireKnownEventTypes`, register the event types first
|
|
38
|
+
* (`audit.<action>` for each action you stream, plus `audit.checkpoint`).
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { createWebhooksCore } from "@xtandard/webhooks";
|
|
43
|
+
* import { createStreamRunner } from "@xtandard/audit";
|
|
44
|
+
* import { xtandardWebhooksSink } from "@xtandard/audit/sinks/xtandard-webhooks";
|
|
45
|
+
*
|
|
46
|
+
* const webhooks = createWebhooksCore({ storage: webhooksStorage });
|
|
47
|
+
*
|
|
48
|
+
* createStreamRunner(audit, {
|
|
49
|
+
* streams: [
|
|
50
|
+
* {
|
|
51
|
+
* name: "tenant-webhooks",
|
|
52
|
+
* sink: xtandardWebhooksSink(webhooks, {
|
|
53
|
+
* // one webhooks application per audit tenant
|
|
54
|
+
* applicationKey: (tenant) => `org_${tenant}`,
|
|
55
|
+
* }),
|
|
56
|
+
* },
|
|
57
|
+
* ],
|
|
58
|
+
* }).start();
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare function xtandardWebhooksSink(webhooks: WebhooksPublisher, options?: XtandardWebhooksSinkOptions): AuditSink;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { WebhooksPublisher, XtandardWebhooksSinkOptions, xtandardWebhooksSink };
|
|
64
|
+
//# sourceMappingURL=entry-sinks-xtandard-webhooks.d.cts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { y as JsonValue } from "./schema-DmU7Wp0F.mjs";
|
|
2
|
+
import { a as StreamItem, t as AuditSink } from "./streams-DU0_gvI8.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/sinks/xtandard-webhooks.d.ts
|
|
5
|
+
/** The slice of an `@xtandard/webhooks` core this sink calls. */
|
|
6
|
+
interface WebhooksPublisher {
|
|
7
|
+
publish(applicationKey: string, input: {
|
|
8
|
+
eventType: string;
|
|
9
|
+
payload: JsonValue;
|
|
10
|
+
timestamp?: string;
|
|
11
|
+
idempotencyKey?: string;
|
|
12
|
+
}): Promise<unknown>;
|
|
13
|
+
}
|
|
14
|
+
/** Options for {@link xtandardWebhooksSink}. */
|
|
15
|
+
interface XtandardWebhooksSinkOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The webhooks application that receives a tenant's items, or `null` to
|
|
18
|
+
* skip the tenant (e.g. it has not enabled streaming). Default: the tenant
|
|
19
|
+
* key itself. The application must exist — `publish` into a missing one
|
|
20
|
+
* throws and the stream backs off.
|
|
21
|
+
*/
|
|
22
|
+
applicationKey?: (tenant: string) => string | null | Promise<string | null>;
|
|
23
|
+
/** Event type per item. Default `audit.<action>` for events, `audit.checkpoint` for checkpoints. */
|
|
24
|
+
eventType?: (item: StreamItem) => string;
|
|
25
|
+
/** Message payload per item. Default: the full event / checkpoint (with its integrity block). */
|
|
26
|
+
payload?: (item: StreamItem) => JsonValue;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a sink that publishes into an `@xtandard/webhooks` core.
|
|
30
|
+
*
|
|
31
|
+
* Each item becomes one message with `idempotencyKey` = the event /
|
|
32
|
+
* checkpoint id, so a re-sent batch is deduplicated by the webhooks core
|
|
33
|
+
* (within its retention). A re-publish whose payload changed since (an event
|
|
34
|
+
* erased under ADR 0011) is treated as already delivered — the endpoint got
|
|
35
|
+
* the original, and the erasure is itself an audit event.
|
|
36
|
+
*
|
|
37
|
+
* With `requireKnownEventTypes`, register the event types first
|
|
38
|
+
* (`audit.<action>` for each action you stream, plus `audit.checkpoint`).
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { createWebhooksCore } from "@xtandard/webhooks";
|
|
43
|
+
* import { createStreamRunner } from "@xtandard/audit";
|
|
44
|
+
* import { xtandardWebhooksSink } from "@xtandard/audit/sinks/xtandard-webhooks";
|
|
45
|
+
*
|
|
46
|
+
* const webhooks = createWebhooksCore({ storage: webhooksStorage });
|
|
47
|
+
*
|
|
48
|
+
* createStreamRunner(audit, {
|
|
49
|
+
* streams: [
|
|
50
|
+
* {
|
|
51
|
+
* name: "tenant-webhooks",
|
|
52
|
+
* sink: xtandardWebhooksSink(webhooks, {
|
|
53
|
+
* // one webhooks application per audit tenant
|
|
54
|
+
* applicationKey: (tenant) => `org_${tenant}`,
|
|
55
|
+
* }),
|
|
56
|
+
* },
|
|
57
|
+
* ],
|
|
58
|
+
* }).start();
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare function xtandardWebhooksSink(webhooks: WebhooksPublisher, options?: XtandardWebhooksSinkOptions): AuditSink;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { WebhooksPublisher, XtandardWebhooksSinkOptions, xtandardWebhooksSink };
|
|
64
|
+
//# sourceMappingURL=entry-sinks-xtandard-webhooks.d.mts.map
|