@schema-weaver/pg-connector 0.0.0-stage → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +457 -2
- package/dist/cjs/audit/chain.d.ts +365 -0
- package/dist/cjs/audit/chain.d.ts.map +1 -0
- package/dist/cjs/audit/chain.js +959 -0
- package/dist/cjs/audit/chain.js.map +1 -0
- package/dist/cjs/audit/cloud-client.d.ts +142 -0
- package/dist/cjs/audit/cloud-client.d.ts.map +1 -0
- package/dist/cjs/audit/cloud-client.js +364 -0
- package/dist/cjs/audit/cloud-client.js.map +1 -0
- package/dist/cjs/audit/cloud-writer.d.ts +57 -0
- package/dist/cjs/audit/cloud-writer.d.ts.map +1 -0
- package/dist/cjs/audit/cloud-writer.js +95 -0
- package/dist/cjs/audit/cloud-writer.js.map +1 -0
- package/dist/cjs/audit/context.d.ts +51 -0
- package/dist/cjs/audit/context.d.ts.map +1 -0
- package/dist/cjs/audit/context.js +75 -0
- package/dist/cjs/audit/context.js.map +1 -0
- package/dist/cjs/audit/files.d.ts +111 -0
- package/dist/cjs/audit/files.d.ts.map +1 -0
- package/dist/cjs/audit/files.js +406 -0
- package/dist/cjs/audit/files.js.map +1 -0
- package/dist/cjs/audit/index.d.ts +9 -0
- package/dist/cjs/audit/index.d.ts.map +1 -0
- package/dist/cjs/audit/index.js +68 -0
- package/dist/cjs/audit/index.js.map +1 -0
- package/dist/cjs/audit/local-writer.d.ts +255 -0
- package/dist/cjs/audit/local-writer.d.ts.map +1 -0
- package/dist/cjs/audit/local-writer.js +829 -0
- package/dist/cjs/audit/local-writer.js.map +1 -0
- package/dist/cjs/audit/redact.d.ts +151 -0
- package/dist/cjs/audit/redact.d.ts.map +1 -0
- package/dist/cjs/audit/redact.js +549 -0
- package/dist/cjs/audit/redact.js.map +1 -0
- package/dist/cjs/audit/sanitize.d.ts +78 -0
- package/dist/cjs/audit/sanitize.d.ts.map +1 -0
- package/dist/cjs/audit/sanitize.js +315 -0
- package/dist/cjs/audit/sanitize.js.map +1 -0
- package/dist/cjs/audit/sink.d.ts +278 -0
- package/dist/cjs/audit/sink.d.ts.map +1 -0
- package/dist/cjs/audit/sink.js +819 -0
- package/dist/cjs/audit/sink.js.map +1 -0
- package/dist/cjs/audit/types.d.ts +226 -0
- package/dist/cjs/audit/types.d.ts.map +1 -0
- package/dist/cjs/audit/types.js +3 -0
- package/dist/cjs/audit/types.js.map +1 -0
- package/dist/cjs/audit/verify-cache.d.ts +127 -0
- package/dist/cjs/audit/verify-cache.d.ts.map +1 -0
- package/dist/cjs/audit/verify-cache.js +668 -0
- package/dist/cjs/audit/verify-cache.js.map +1 -0
- package/dist/cjs/channels/agent-session.d.ts +228 -0
- package/dist/cjs/channels/agent-session.d.ts.map +1 -0
- package/dist/cjs/channels/agent-session.js +604 -0
- package/dist/cjs/channels/agent-session.js.map +1 -0
- package/dist/cjs/channels/data-channel.d.ts +181 -0
- package/dist/cjs/channels/data-channel.d.ts.map +1 -0
- package/dist/cjs/channels/data-channel.js +607 -0
- package/dist/cjs/channels/data-channel.js.map +1 -0
- package/dist/cjs/channels/reconnect.d.ts +142 -0
- package/dist/cjs/channels/reconnect.d.ts.map +1 -0
- package/dist/cjs/channels/reconnect.js +247 -0
- package/dist/cjs/channels/reconnect.js.map +1 -0
- package/dist/cjs/channels/types.d.ts +112 -0
- package/dist/cjs/channels/types.d.ts.map +1 -0
- package/dist/cjs/channels/types.js +3 -0
- package/dist/cjs/channels/types.js.map +1 -0
- package/dist/cjs/channels/wake-channel.d.ts +232 -0
- package/dist/cjs/channels/wake-channel.d.ts.map +1 -0
- package/dist/cjs/channels/wake-channel.js +752 -0
- package/dist/cjs/channels/wake-channel.js.map +1 -0
- package/dist/cjs/cli/banner.d.ts +2 -0
- package/dist/cjs/cli/banner.d.ts.map +1 -0
- package/dist/cjs/cli/banner.js +150 -0
- package/dist/cjs/cli/banner.js.map +1 -0
- package/dist/cjs/cli/commands/agent.d.ts +30 -0
- package/dist/cjs/cli/commands/agent.d.ts.map +1 -0
- package/dist/cjs/cli/commands/agent.js +214 -0
- package/dist/cjs/cli/commands/agent.js.map +1 -0
- package/dist/cjs/cli/commands/audit-verify.d.ts +19 -0
- package/dist/cjs/cli/commands/audit-verify.d.ts.map +1 -0
- package/dist/cjs/cli/commands/audit-verify.js +382 -0
- package/dist/cjs/cli/commands/audit-verify.js.map +1 -0
- package/dist/cjs/cli/commands/clean.d.ts +23 -0
- package/dist/cjs/cli/commands/clean.d.ts.map +1 -0
- package/dist/cjs/cli/commands/clean.js +272 -0
- package/dist/cjs/cli/commands/clean.js.map +1 -0
- package/dist/cjs/cli/commands/config-show.d.ts +2 -0
- package/dist/cjs/cli/commands/config-show.d.ts.map +1 -0
- package/dist/cjs/cli/commands/config-show.js +10 -0
- package/dist/cjs/cli/commands/config-show.js.map +1 -0
- package/dist/cjs/cli/commands/config.d.ts +6 -0
- package/dist/cjs/cli/commands/config.d.ts.map +1 -0
- package/dist/cjs/cli/commands/config.js +266 -0
- package/dist/cjs/cli/commands/config.js.map +1 -0
- package/dist/cjs/cli/commands/db-add.d.ts +16 -0
- package/dist/cjs/cli/commands/db-add.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-add.js +613 -0
- package/dist/cjs/cli/commands/db-add.js.map +1 -0
- package/dist/cjs/cli/commands/db-edit.d.ts +2 -0
- package/dist/cjs/cli/commands/db-edit.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-edit.js +388 -0
- package/dist/cjs/cli/commands/db-edit.js.map +1 -0
- package/dist/cjs/cli/commands/db-logs.d.ts +3 -0
- package/dist/cjs/cli/commands/db-logs.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-logs.js +67 -0
- package/dist/cjs/cli/commands/db-logs.js.map +1 -0
- package/dist/cjs/cli/commands/db-ls.d.ts +2 -0
- package/dist/cjs/cli/commands/db-ls.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-ls.js +118 -0
- package/dist/cjs/cli/commands/db-ls.js.map +1 -0
- package/dist/cjs/cli/commands/db-query.d.ts +121 -0
- package/dist/cjs/cli/commands/db-query.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-query.js +802 -0
- package/dist/cjs/cli/commands/db-query.js.map +1 -0
- package/dist/cjs/cli/commands/db-remove.d.ts +2 -0
- package/dist/cjs/cli/commands/db-remove.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-remove.js +51 -0
- package/dist/cjs/cli/commands/db-remove.js.map +1 -0
- package/dist/cjs/cli/commands/db-show.d.ts +2 -0
- package/dist/cjs/cli/commands/db-show.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-show.js +134 -0
- package/dist/cjs/cli/commands/db-show.js.map +1 -0
- package/dist/cjs/cli/commands/db-test.d.ts +3 -0
- package/dist/cjs/cli/commands/db-test.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-test.js +311 -0
- package/dist/cjs/cli/commands/db-test.js.map +1 -0
- package/dist/cjs/cli/commands/db.d.ts +11 -0
- package/dist/cjs/cli/commands/db.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db.js +90 -0
- package/dist/cjs/cli/commands/db.js.map +1 -0
- package/dist/cjs/cli/commands/debug.d.ts +2 -0
- package/dist/cjs/cli/commands/debug.d.ts.map +1 -0
- package/dist/cjs/cli/commands/debug.js +241 -0
- package/dist/cjs/cli/commands/debug.js.map +1 -0
- package/dist/cjs/cli/commands/doctor.d.ts +5 -0
- package/dist/cjs/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cjs/cli/commands/doctor.js +117 -0
- package/dist/cjs/cli/commands/doctor.js.map +1 -0
- package/dist/cjs/cli/commands/index.d.ts +10 -0
- package/dist/cjs/cli/commands/index.d.ts.map +1 -0
- package/dist/cjs/cli/commands/index.js +30 -0
- package/dist/cjs/cli/commands/index.js.map +1 -0
- package/dist/cjs/cli/commands/init.d.ts +2 -0
- package/dist/cjs/cli/commands/init.d.ts.map +1 -0
- package/dist/cjs/cli/commands/init.js +199 -0
- package/dist/cjs/cli/commands/init.js.map +1 -0
- package/dist/cjs/cli/commands/link.d.ts +5 -0
- package/dist/cjs/cli/commands/link.d.ts.map +1 -0
- package/dist/cjs/cli/commands/link.js +44 -0
- package/dist/cjs/cli/commands/link.js.map +1 -0
- package/dist/cjs/cli/commands/logs.d.ts +17 -0
- package/dist/cjs/cli/commands/logs.d.ts.map +1 -0
- package/dist/cjs/cli/commands/logs.js +314 -0
- package/dist/cjs/cli/commands/logs.js.map +1 -0
- package/dist/cjs/cli/commands/project-show.d.ts +2 -0
- package/dist/cjs/cli/commands/project-show.d.ts.map +1 -0
- package/dist/cjs/cli/commands/project-show.js +105 -0
- package/dist/cjs/cli/commands/project-show.js.map +1 -0
- package/dist/cjs/cli/commands/project.d.ts +3 -0
- package/dist/cjs/cli/commands/project.d.ts.map +1 -0
- package/dist/cjs/cli/commands/project.js +64 -0
- package/dist/cjs/cli/commands/project.js.map +1 -0
- package/dist/cjs/cli/commands/service.d.ts +123 -0
- package/dist/cjs/cli/commands/service.d.ts.map +1 -0
- package/dist/cjs/cli/commands/service.js +554 -0
- package/dist/cjs/cli/commands/service.js.map +1 -0
- package/dist/cjs/cli/commands/start.d.ts +6 -0
- package/dist/cjs/cli/commands/start.d.ts.map +1 -0
- package/dist/cjs/cli/commands/start.js +308 -0
- package/dist/cjs/cli/commands/start.js.map +1 -0
- package/dist/cjs/cli/commands/status.d.ts +2 -0
- package/dist/cjs/cli/commands/status.d.ts.map +1 -0
- package/dist/cjs/cli/commands/status.js +225 -0
- package/dist/cjs/cli/commands/status.js.map +1 -0
- package/dist/cjs/cli/commands/stop.d.ts +6 -0
- package/dist/cjs/cli/commands/stop.d.ts.map +1 -0
- package/dist/cjs/cli/commands/stop.js +99 -0
- package/dist/cjs/cli/commands/stop.js.map +1 -0
- package/dist/cjs/cli/daemon/error-tracker.d.ts +119 -0
- package/dist/cjs/cli/daemon/error-tracker.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/error-tracker.js +500 -0
- package/dist/cjs/cli/daemon/error-tracker.js.map +1 -0
- package/dist/cjs/cli/daemon/fault-shutdown.d.ts +144 -0
- package/dist/cjs/cli/daemon/fault-shutdown.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/fault-shutdown.js +312 -0
- package/dist/cjs/cli/daemon/fault-shutdown.js.map +1 -0
- package/dist/cjs/cli/daemon/index.d.ts +12 -0
- package/dist/cjs/cli/daemon/index.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/index.js +23 -0
- package/dist/cjs/cli/daemon/index.js.map +1 -0
- package/dist/cjs/cli/daemon/pid-file.d.ts +13 -0
- package/dist/cjs/cli/daemon/pid-file.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/pid-file.js +90 -0
- package/dist/cjs/cli/daemon/pid-file.js.map +1 -0
- package/dist/cjs/cli/daemon/readiness.d.ts +30 -0
- package/dist/cjs/cli/daemon/readiness.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/readiness.js +74 -0
- package/dist/cjs/cli/daemon/readiness.js.map +1 -0
- package/dist/cjs/cli/daemon/runtime.d.ts +366 -0
- package/dist/cjs/cli/daemon/runtime.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/runtime.js +1343 -0
- package/dist/cjs/cli/daemon/runtime.js.map +1 -0
- package/dist/cjs/cli/daemon/shutdown.d.ts +7 -0
- package/dist/cjs/cli/daemon/shutdown.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/shutdown.js +66 -0
- package/dist/cjs/cli/daemon/shutdown.js.map +1 -0
- package/dist/cjs/cli/daemon/signal-handlers.d.ts +3 -0
- package/dist/cjs/cli/daemon/signal-handlers.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/signal-handlers.js +27 -0
- package/dist/cjs/cli/daemon/signal-handlers.js.map +1 -0
- package/dist/cjs/cli/daemon/state.d.ts +157 -0
- package/dist/cjs/cli/daemon/state.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/state.js +397 -0
- package/dist/cjs/cli/daemon/state.js.map +1 -0
- package/dist/cjs/cli/daemon/status-file.d.ts +139 -0
- package/dist/cjs/cli/daemon/status-file.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/status-file.js +88 -0
- package/dist/cjs/cli/daemon/status-file.js.map +1 -0
- package/dist/cjs/cli/doctor/checks.d.ts +133 -0
- package/dist/cjs/cli/doctor/checks.d.ts.map +1 -0
- package/dist/cjs/cli/doctor/checks.js +677 -0
- package/dist/cjs/cli/doctor/checks.js.map +1 -0
- package/dist/cjs/cli/doctor/fixes.d.ts +9 -0
- package/dist/cjs/cli/doctor/fixes.d.ts.map +1 -0
- package/dist/cjs/cli/doctor/fixes.js +199 -0
- package/dist/cjs/cli/doctor/fixes.js.map +1 -0
- package/dist/cjs/cli/doctor/index.d.ts +7 -0
- package/dist/cjs/cli/doctor/index.d.ts.map +1 -0
- package/dist/cjs/cli/doctor/index.js +27 -0
- package/dist/cjs/cli/doctor/index.js.map +1 -0
- package/dist/cjs/cli/index.d.ts +3 -0
- package/dist/cjs/cli/index.d.ts.map +1 -0
- package/dist/cjs/cli/index.js +336 -0
- package/dist/cjs/cli/index.js.map +1 -0
- package/dist/cjs/cli/interactive.d.ts +8 -0
- package/dist/cjs/cli/interactive.d.ts.map +1 -0
- package/dist/cjs/cli/interactive.js +670 -0
- package/dist/cjs/cli/interactive.js.map +1 -0
- package/dist/cjs/cli/logs/format.d.ts +13 -0
- package/dist/cjs/cli/logs/format.d.ts.map +1 -0
- package/dist/cjs/cli/logs/format.js +178 -0
- package/dist/cjs/cli/logs/format.js.map +1 -0
- package/dist/cjs/cli/logs/index.d.ts +3 -0
- package/dist/cjs/cli/logs/index.d.ts.map +1 -0
- package/dist/cjs/cli/logs/index.js +13 -0
- package/dist/cjs/cli/logs/index.js.map +1 -0
- package/dist/cjs/cli/logs/viewer.d.ts +41 -0
- package/dist/cjs/cli/logs/viewer.d.ts.map +1 -0
- package/dist/cjs/cli/logs/viewer.js +417 -0
- package/dist/cjs/cli/logs/viewer.js.map +1 -0
- package/dist/cjs/cli/ops/operation-logger.d.ts +63 -0
- package/dist/cjs/cli/ops/operation-logger.d.ts.map +1 -0
- package/dist/cjs/cli/ops/operation-logger.js +183 -0
- package/dist/cjs/cli/ops/operation-logger.js.map +1 -0
- package/dist/cjs/cli/palette.d.ts +11 -0
- package/dist/cjs/cli/palette.d.ts.map +1 -0
- package/dist/cjs/cli/palette.js +243 -0
- package/dist/cjs/cli/palette.js.map +1 -0
- package/dist/cjs/cli/prompt.d.ts +186 -0
- package/dist/cjs/cli/prompt.d.ts.map +1 -0
- package/dist/cjs/cli/prompt.js +541 -0
- package/dist/cjs/cli/prompt.js.map +1 -0
- package/dist/cjs/cli/ui/box.d.ts +21 -0
- package/dist/cjs/cli/ui/box.d.ts.map +1 -0
- package/dist/cjs/cli/ui/box.js +72 -0
- package/dist/cjs/cli/ui/box.js.map +1 -0
- package/dist/cjs/cli/ui/clipboard.d.ts +6 -0
- package/dist/cjs/cli/ui/clipboard.d.ts.map +1 -0
- package/dist/cjs/cli/ui/clipboard.js +78 -0
- package/dist/cjs/cli/ui/clipboard.js.map +1 -0
- package/dist/cjs/cli/ui/colors.d.ts +57 -0
- package/dist/cjs/cli/ui/colors.d.ts.map +1 -0
- package/dist/cjs/cli/ui/colors.js +151 -0
- package/dist/cjs/cli/ui/colors.js.map +1 -0
- package/dist/cjs/cli/ui/index.d.ts +9 -0
- package/dist/cjs/cli/ui/index.d.ts.map +1 -0
- package/dist/cjs/cli/ui/index.js +55 -0
- package/dist/cjs/cli/ui/index.js.map +1 -0
- package/dist/cjs/cli/ui/spinner.d.ts +12 -0
- package/dist/cjs/cli/ui/spinner.d.ts.map +1 -0
- package/dist/cjs/cli/ui/spinner.js +82 -0
- package/dist/cjs/cli/ui/spinner.js.map +1 -0
- package/dist/cjs/cli/ui/symbols.d.ts +47 -0
- package/dist/cjs/cli/ui/symbols.d.ts.map +1 -0
- package/dist/cjs/cli/ui/symbols.js +112 -0
- package/dist/cjs/cli/ui/symbols.js.map +1 -0
- package/dist/cjs/cli/ui/table.d.ts +23 -0
- package/dist/cjs/cli/ui/table.d.ts.map +1 -0
- package/dist/cjs/cli/ui/table.js +160 -0
- package/dist/cjs/cli/ui/table.js.map +1 -0
- package/dist/cjs/cli/ui/terminal.d.ts +7 -0
- package/dist/cjs/cli/ui/terminal.d.ts.map +1 -0
- package/dist/cjs/cli/ui/terminal.js +40 -0
- package/dist/cjs/cli/ui/terminal.js.map +1 -0
- package/dist/cjs/config/atomic-write.d.ts +69 -0
- package/dist/cjs/config/atomic-write.d.ts.map +1 -0
- package/dist/cjs/config/atomic-write.js +289 -0
- package/dist/cjs/config/atomic-write.js.map +1 -0
- package/dist/cjs/config/db-config.d.ts +134 -0
- package/dist/cjs/config/db-config.d.ts.map +1 -0
- package/dist/cjs/config/db-config.js +594 -0
- package/dist/cjs/config/db-config.js.map +1 -0
- package/dist/cjs/config/machine-config.d.ts +85 -0
- package/dist/cjs/config/machine-config.d.ts.map +1 -0
- package/dist/cjs/config/machine-config.js +232 -0
- package/dist/cjs/config/machine-config.js.map +1 -0
- package/dist/cjs/config/paths.d.ts +64 -0
- package/dist/cjs/config/paths.d.ts.map +1 -0
- package/dist/cjs/config/paths.js +155 -0
- package/dist/cjs/config/paths.js.map +1 -0
- package/dist/cjs/config/schema.d.ts +72 -0
- package/dist/cjs/config/schema.d.ts.map +1 -0
- package/dist/cjs/config/schema.js +197 -0
- package/dist/cjs/config/schema.js.map +1 -0
- package/dist/cjs/config/token.d.ts +63 -0
- package/dist/cjs/config/token.d.ts.map +1 -0
- package/dist/cjs/config/token.js +146 -0
- package/dist/cjs/config/token.js.map +1 -0
- package/dist/cjs/execution/canceller.d.ts +41 -0
- package/dist/cjs/execution/canceller.d.ts.map +1 -0
- package/dist/cjs/execution/canceller.js +209 -0
- package/dist/cjs/execution/canceller.js.map +1 -0
- package/dist/cjs/execution/database-lookup.d.ts +56 -0
- package/dist/cjs/execution/database-lookup.d.ts.map +1 -0
- package/dist/cjs/execution/database-lookup.js +43 -0
- package/dist/cjs/execution/database-lookup.js.map +1 -0
- package/dist/cjs/execution/dispatcher.d.ts +181 -0
- package/dist/cjs/execution/dispatcher.d.ts.map +1 -0
- package/dist/cjs/execution/dispatcher.js +1296 -0
- package/dist/cjs/execution/dispatcher.js.map +1 -0
- package/dist/cjs/execution/function-effects.d.ts +209 -0
- package/dist/cjs/execution/function-effects.d.ts.map +1 -0
- package/dist/cjs/execution/function-effects.js +596 -0
- package/dist/cjs/execution/function-effects.js.map +1 -0
- package/dist/cjs/execution/introspection.d.ts +76 -0
- package/dist/cjs/execution/introspection.d.ts.map +1 -0
- package/dist/cjs/execution/introspection.js +448 -0
- package/dist/cjs/execution/introspection.js.map +1 -0
- package/dist/cjs/execution/migration-runner.d.ts +128 -0
- package/dist/cjs/execution/migration-runner.d.ts.map +1 -0
- package/dist/cjs/execution/migration-runner.js +798 -0
- package/dist/cjs/execution/migration-runner.js.map +1 -0
- package/dist/cjs/execution/non-tx-detector.d.ts +23 -0
- package/dist/cjs/execution/non-tx-detector.d.ts.map +1 -0
- package/dist/cjs/execution/non-tx-detector.js +218 -0
- package/dist/cjs/execution/non-tx-detector.js.map +1 -0
- package/dist/cjs/execution/pool.d.ts +229 -0
- package/dist/cjs/execution/pool.d.ts.map +1 -0
- package/dist/cjs/execution/pool.js +738 -0
- package/dist/cjs/execution/pool.js.map +1 -0
- package/dist/cjs/execution/query-runner.d.ts +88 -0
- package/dist/cjs/execution/query-runner.d.ts.map +1 -0
- package/dist/cjs/execution/query-runner.js +751 -0
- package/dist/cjs/execution/query-runner.js.map +1 -0
- package/dist/cjs/execution/rate-limiter.d.ts +120 -0
- package/dist/cjs/execution/rate-limiter.d.ts.map +1 -0
- package/dist/cjs/execution/rate-limiter.js +273 -0
- package/dist/cjs/execution/rate-limiter.js.map +1 -0
- package/dist/cjs/execution/search-path.d.ts +161 -0
- package/dist/cjs/execution/search-path.d.ts.map +1 -0
- package/dist/cjs/execution/search-path.js +279 -0
- package/dist/cjs/execution/search-path.js.map +1 -0
- package/dist/cjs/execution/sql-parser.d.ts +195 -0
- package/dist/cjs/execution/sql-parser.d.ts.map +1 -0
- package/dist/cjs/execution/sql-parser.js +704 -0
- package/dist/cjs/execution/sql-parser.js.map +1 -0
- package/dist/cjs/execution/statement-classifier.d.ts +103 -0
- package/dist/cjs/execution/statement-classifier.d.ts.map +1 -0
- package/dist/cjs/execution/statement-classifier.js +535 -0
- package/dist/cjs/execution/statement-classifier.js.map +1 -0
- package/dist/cjs/execution/types.d.ts +189 -0
- package/dist/cjs/execution/types.d.ts.map +1 -0
- package/dist/cjs/execution/types.js +28 -0
- package/dist/cjs/execution/types.js.map +1 -0
- package/dist/cjs/index.d.ts +34 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +98 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/permissions/auto-upgrade.d.ts +40 -0
- package/dist/cjs/permissions/auto-upgrade.d.ts.map +1 -0
- package/dist/cjs/permissions/auto-upgrade.js +168 -0
- package/dist/cjs/permissions/auto-upgrade.js.map +1 -0
- package/dist/cjs/permissions/checker.d.ts +53 -0
- package/dist/cjs/permissions/checker.d.ts.map +1 -0
- package/dist/cjs/permissions/checker.js +326 -0
- package/dist/cjs/permissions/checker.js.map +1 -0
- package/dist/cjs/permissions/manual-approval.d.ts +213 -0
- package/dist/cjs/permissions/manual-approval.d.ts.map +1 -0
- package/dist/cjs/permissions/manual-approval.js +541 -0
- package/dist/cjs/permissions/manual-approval.js.map +1 -0
- package/dist/cjs/permissions/plan-registry.d.ts +274 -0
- package/dist/cjs/permissions/plan-registry.d.ts.map +1 -0
- package/dist/cjs/permissions/plan-registry.js +454 -0
- package/dist/cjs/permissions/plan-registry.js.map +1 -0
- package/dist/cjs/permissions/role-policy.d.ts +217 -0
- package/dist/cjs/permissions/role-policy.d.ts.map +1 -0
- package/dist/cjs/permissions/role-policy.js +584 -0
- package/dist/cjs/permissions/role-policy.js.map +1 -0
- package/dist/cjs/permissions/types.d.ts +126 -0
- package/dist/cjs/permissions/types.d.ts.map +1 -0
- package/dist/cjs/permissions/types.js +3 -0
- package/dist/cjs/permissions/types.js.map +1 -0
- package/dist/cjs/protocol/constants.d.ts +72 -0
- package/dist/cjs/protocol/constants.d.ts.map +1 -0
- package/dist/cjs/protocol/constants.js +107 -0
- package/dist/cjs/protocol/constants.js.map +1 -0
- package/dist/cjs/protocol/envelope.d.ts +165 -0
- package/dist/cjs/protocol/envelope.d.ts.map +1 -0
- package/dist/cjs/protocol/envelope.js +309 -0
- package/dist/cjs/protocol/envelope.js.map +1 -0
- package/dist/cjs/protocol/errors.d.ts +33 -0
- package/dist/cjs/protocol/errors.d.ts.map +1 -0
- package/dist/cjs/protocol/errors.js +391 -0
- package/dist/cjs/protocol/errors.js.map +1 -0
- package/dist/cjs/protocol/messages.d.ts +327 -0
- package/dist/cjs/protocol/messages.d.ts.map +1 -0
- package/dist/cjs/protocol/messages.js +3 -0
- package/dist/cjs/protocol/messages.js.map +1 -0
- package/dist/cjs/protocol/serialize.d.ts +26 -0
- package/dist/cjs/protocol/serialize.d.ts.map +1 -0
- package/dist/cjs/protocol/serialize.js +71 -0
- package/dist/cjs/protocol/serialize.js.map +1 -0
- package/dist/cjs/protocol/validate.d.ts +135 -0
- package/dist/cjs/protocol/validate.d.ts.map +1 -0
- package/dist/cjs/protocol/validate.js +852 -0
- package/dist/cjs/protocol/validate.js.map +1 -0
- package/dist/esm/audit/chain.d.ts +365 -0
- package/dist/esm/audit/chain.d.ts.map +1 -0
- package/dist/esm/audit/chain.js +895 -0
- package/dist/esm/audit/chain.js.map +1 -0
- package/dist/esm/audit/cloud-client.d.ts +142 -0
- package/dist/esm/audit/cloud-client.d.ts.map +1 -0
- package/dist/esm/audit/cloud-client.js +326 -0
- package/dist/esm/audit/cloud-client.js.map +1 -0
- package/dist/esm/audit/cloud-writer.d.ts +57 -0
- package/dist/esm/audit/cloud-writer.d.ts.map +1 -0
- package/dist/esm/audit/cloud-writer.js +91 -0
- package/dist/esm/audit/cloud-writer.js.map +1 -0
- package/dist/esm/audit/context.d.ts +51 -0
- package/dist/esm/audit/context.d.ts.map +1 -0
- package/dist/esm/audit/context.js +69 -0
- package/dist/esm/audit/context.js.map +1 -0
- package/dist/esm/audit/files.d.ts +111 -0
- package/dist/esm/audit/files.d.ts.map +1 -0
- package/dist/esm/audit/files.js +361 -0
- package/dist/esm/audit/files.js.map +1 -0
- package/dist/esm/audit/index.d.ts +9 -0
- package/dist/esm/audit/index.d.ts.map +1 -0
- package/dist/esm/audit/index.js +8 -0
- package/dist/esm/audit/index.js.map +1 -0
- package/dist/esm/audit/local-writer.d.ts +255 -0
- package/dist/esm/audit/local-writer.d.ts.map +1 -0
- package/dist/esm/audit/local-writer.js +785 -0
- package/dist/esm/audit/local-writer.js.map +1 -0
- package/dist/esm/audit/redact.d.ts +151 -0
- package/dist/esm/audit/redact.d.ts.map +1 -0
- package/dist/esm/audit/redact.js +506 -0
- package/dist/esm/audit/redact.js.map +1 -0
- package/dist/esm/audit/sanitize.d.ts +78 -0
- package/dist/esm/audit/sanitize.d.ts.map +1 -0
- package/dist/esm/audit/sanitize.js +307 -0
- package/dist/esm/audit/sanitize.js.map +1 -0
- package/dist/esm/audit/sink.d.ts +278 -0
- package/dist/esm/audit/sink.d.ts.map +1 -0
- package/dist/esm/audit/sink.js +782 -0
- package/dist/esm/audit/sink.js.map +1 -0
- package/dist/esm/audit/types.d.ts +226 -0
- package/dist/esm/audit/types.d.ts.map +1 -0
- package/dist/esm/audit/types.js +2 -0
- package/dist/esm/audit/types.js.map +1 -0
- package/dist/esm/audit/verify-cache.d.ts +127 -0
- package/dist/esm/audit/verify-cache.d.ts.map +1 -0
- package/dist/esm/audit/verify-cache.js +628 -0
- package/dist/esm/audit/verify-cache.js.map +1 -0
- package/dist/esm/channels/agent-session.d.ts +228 -0
- package/dist/esm/channels/agent-session.d.ts.map +1 -0
- package/dist/esm/channels/agent-session.js +566 -0
- package/dist/esm/channels/agent-session.js.map +1 -0
- package/dist/esm/channels/data-channel.d.ts +181 -0
- package/dist/esm/channels/data-channel.d.ts.map +1 -0
- package/dist/esm/channels/data-channel.js +567 -0
- package/dist/esm/channels/data-channel.js.map +1 -0
- package/dist/esm/channels/reconnect.d.ts +142 -0
- package/dist/esm/channels/reconnect.d.ts.map +1 -0
- package/dist/esm/channels/reconnect.js +234 -0
- package/dist/esm/channels/reconnect.js.map +1 -0
- package/dist/esm/channels/types.d.ts +112 -0
- package/dist/esm/channels/types.d.ts.map +1 -0
- package/dist/esm/channels/types.js +2 -0
- package/dist/esm/channels/types.js.map +1 -0
- package/dist/esm/channels/wake-channel.d.ts +232 -0
- package/dist/esm/channels/wake-channel.d.ts.map +1 -0
- package/dist/esm/channels/wake-channel.js +715 -0
- package/dist/esm/channels/wake-channel.js.map +1 -0
- package/dist/esm/cli/banner.d.ts +2 -0
- package/dist/esm/cli/banner.d.ts.map +1 -0
- package/dist/esm/cli/banner.js +114 -0
- package/dist/esm/cli/banner.js.map +1 -0
- package/dist/esm/cli/commands/agent.d.ts +30 -0
- package/dist/esm/cli/commands/agent.d.ts.map +1 -0
- package/dist/esm/cli/commands/agent.js +204 -0
- package/dist/esm/cli/commands/agent.js.map +1 -0
- package/dist/esm/cli/commands/audit-verify.d.ts +19 -0
- package/dist/esm/cli/commands/audit-verify.d.ts.map +1 -0
- package/dist/esm/cli/commands/audit-verify.js +345 -0
- package/dist/esm/cli/commands/audit-verify.js.map +1 -0
- package/dist/esm/cli/commands/clean.d.ts +23 -0
- package/dist/esm/cli/commands/clean.d.ts.map +1 -0
- package/dist/esm/cli/commands/clean.js +235 -0
- package/dist/esm/cli/commands/clean.js.map +1 -0
- package/dist/esm/cli/commands/config-show.d.ts +2 -0
- package/dist/esm/cli/commands/config-show.d.ts.map +1 -0
- package/dist/esm/cli/commands/config-show.js +2 -0
- package/dist/esm/cli/commands/config-show.js.map +1 -0
- package/dist/esm/cli/commands/config.d.ts +6 -0
- package/dist/esm/cli/commands/config.d.ts.map +1 -0
- package/dist/esm/cli/commands/config.js +259 -0
- package/dist/esm/cli/commands/config.js.map +1 -0
- package/dist/esm/cli/commands/db-add.d.ts +16 -0
- package/dist/esm/cli/commands/db-add.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-add.js +576 -0
- package/dist/esm/cli/commands/db-add.js.map +1 -0
- package/dist/esm/cli/commands/db-edit.d.ts +2 -0
- package/dist/esm/cli/commands/db-edit.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-edit.js +352 -0
- package/dist/esm/cli/commands/db-edit.js.map +1 -0
- package/dist/esm/cli/commands/db-logs.d.ts +3 -0
- package/dist/esm/cli/commands/db-logs.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-logs.js +64 -0
- package/dist/esm/cli/commands/db-logs.js.map +1 -0
- package/dist/esm/cli/commands/db-ls.d.ts +2 -0
- package/dist/esm/cli/commands/db-ls.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-ls.js +115 -0
- package/dist/esm/cli/commands/db-ls.js.map +1 -0
- package/dist/esm/cli/commands/db-query.d.ts +121 -0
- package/dist/esm/cli/commands/db-query.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-query.js +754 -0
- package/dist/esm/cli/commands/db-query.js.map +1 -0
- package/dist/esm/cli/commands/db-remove.d.ts +2 -0
- package/dist/esm/cli/commands/db-remove.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-remove.js +48 -0
- package/dist/esm/cli/commands/db-remove.js.map +1 -0
- package/dist/esm/cli/commands/db-show.d.ts +2 -0
- package/dist/esm/cli/commands/db-show.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-show.js +131 -0
- package/dist/esm/cli/commands/db-show.js.map +1 -0
- package/dist/esm/cli/commands/db-test.d.ts +3 -0
- package/dist/esm/cli/commands/db-test.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-test.js +307 -0
- package/dist/esm/cli/commands/db-test.js.map +1 -0
- package/dist/esm/cli/commands/db.d.ts +11 -0
- package/dist/esm/cli/commands/db.d.ts.map +1 -0
- package/dist/esm/cli/commands/db.js +76 -0
- package/dist/esm/cli/commands/db.js.map +1 -0
- package/dist/esm/cli/commands/debug.d.ts +2 -0
- package/dist/esm/cli/commands/debug.d.ts.map +1 -0
- package/dist/esm/cli/commands/debug.js +205 -0
- package/dist/esm/cli/commands/debug.js.map +1 -0
- package/dist/esm/cli/commands/doctor.d.ts +5 -0
- package/dist/esm/cli/commands/doctor.d.ts.map +1 -0
- package/dist/esm/cli/commands/doctor.js +114 -0
- package/dist/esm/cli/commands/doctor.js.map +1 -0
- package/dist/esm/cli/commands/index.d.ts +10 -0
- package/dist/esm/cli/commands/index.d.ts.map +1 -0
- package/dist/esm/cli/commands/index.js +10 -0
- package/dist/esm/cli/commands/index.js.map +1 -0
- package/dist/esm/cli/commands/init.d.ts +2 -0
- package/dist/esm/cli/commands/init.d.ts.map +1 -0
- package/dist/esm/cli/commands/init.js +163 -0
- package/dist/esm/cli/commands/init.js.map +1 -0
- package/dist/esm/cli/commands/link.d.ts +5 -0
- package/dist/esm/cli/commands/link.d.ts.map +1 -0
- package/dist/esm/cli/commands/link.js +41 -0
- package/dist/esm/cli/commands/link.js.map +1 -0
- package/dist/esm/cli/commands/logs.d.ts +17 -0
- package/dist/esm/cli/commands/logs.d.ts.map +1 -0
- package/dist/esm/cli/commands/logs.js +278 -0
- package/dist/esm/cli/commands/logs.js.map +1 -0
- package/dist/esm/cli/commands/project-show.d.ts +2 -0
- package/dist/esm/cli/commands/project-show.d.ts.map +1 -0
- package/dist/esm/cli/commands/project-show.js +69 -0
- package/dist/esm/cli/commands/project-show.js.map +1 -0
- package/dist/esm/cli/commands/project.d.ts +3 -0
- package/dist/esm/cli/commands/project.d.ts.map +1 -0
- package/dist/esm/cli/commands/project.js +60 -0
- package/dist/esm/cli/commands/project.js.map +1 -0
- package/dist/esm/cli/commands/service.d.ts +123 -0
- package/dist/esm/cli/commands/service.d.ts.map +1 -0
- package/dist/esm/cli/commands/service.js +505 -0
- package/dist/esm/cli/commands/service.js.map +1 -0
- package/dist/esm/cli/commands/start.d.ts +6 -0
- package/dist/esm/cli/commands/start.d.ts.map +1 -0
- package/dist/esm/cli/commands/start.js +272 -0
- package/dist/esm/cli/commands/start.js.map +1 -0
- package/dist/esm/cli/commands/status.d.ts +2 -0
- package/dist/esm/cli/commands/status.d.ts.map +1 -0
- package/dist/esm/cli/commands/status.js +222 -0
- package/dist/esm/cli/commands/status.js.map +1 -0
- package/dist/esm/cli/commands/stop.d.ts +6 -0
- package/dist/esm/cli/commands/stop.d.ts.map +1 -0
- package/dist/esm/cli/commands/stop.js +96 -0
- package/dist/esm/cli/commands/stop.js.map +1 -0
- package/dist/esm/cli/daemon/error-tracker.d.ts +119 -0
- package/dist/esm/cli/daemon/error-tracker.d.ts.map +1 -0
- package/dist/esm/cli/daemon/error-tracker.js +451 -0
- package/dist/esm/cli/daemon/error-tracker.js.map +1 -0
- package/dist/esm/cli/daemon/fault-shutdown.d.ts +144 -0
- package/dist/esm/cli/daemon/fault-shutdown.d.ts.map +1 -0
- package/dist/esm/cli/daemon/fault-shutdown.js +273 -0
- package/dist/esm/cli/daemon/fault-shutdown.js.map +1 -0
- package/dist/esm/cli/daemon/index.d.ts +12 -0
- package/dist/esm/cli/daemon/index.d.ts.map +1 -0
- package/dist/esm/cli/daemon/index.js +7 -0
- package/dist/esm/cli/daemon/index.js.map +1 -0
- package/dist/esm/cli/daemon/pid-file.d.ts +13 -0
- package/dist/esm/cli/daemon/pid-file.d.ts.map +1 -0
- package/dist/esm/cli/daemon/pid-file.js +51 -0
- package/dist/esm/cli/daemon/pid-file.js.map +1 -0
- package/dist/esm/cli/daemon/readiness.d.ts +30 -0
- package/dist/esm/cli/daemon/readiness.d.ts.map +1 -0
- package/dist/esm/cli/daemon/readiness.js +70 -0
- package/dist/esm/cli/daemon/readiness.js.map +1 -0
- package/dist/esm/cli/daemon/runtime.d.ts +366 -0
- package/dist/esm/cli/daemon/runtime.d.ts.map +1 -0
- package/dist/esm/cli/daemon/runtime.js +1284 -0
- package/dist/esm/cli/daemon/runtime.js.map +1 -0
- package/dist/esm/cli/daemon/shutdown.d.ts +7 -0
- package/dist/esm/cli/daemon/shutdown.d.ts.map +1 -0
- package/dist/esm/cli/daemon/shutdown.js +63 -0
- package/dist/esm/cli/daemon/shutdown.js.map +1 -0
- package/dist/esm/cli/daemon/signal-handlers.d.ts +3 -0
- package/dist/esm/cli/daemon/signal-handlers.d.ts.map +1 -0
- package/dist/esm/cli/daemon/signal-handlers.js +24 -0
- package/dist/esm/cli/daemon/signal-handlers.js.map +1 -0
- package/dist/esm/cli/daemon/state.d.ts +157 -0
- package/dist/esm/cli/daemon/state.d.ts.map +1 -0
- package/dist/esm/cli/daemon/state.js +352 -0
- package/dist/esm/cli/daemon/state.js.map +1 -0
- package/dist/esm/cli/daemon/status-file.d.ts +139 -0
- package/dist/esm/cli/daemon/status-file.d.ts.map +1 -0
- package/dist/esm/cli/daemon/status-file.js +50 -0
- package/dist/esm/cli/daemon/status-file.js.map +1 -0
- package/dist/esm/cli/doctor/checks.d.ts +133 -0
- package/dist/esm/cli/doctor/checks.d.ts.map +1 -0
- package/dist/esm/cli/doctor/checks.js +624 -0
- package/dist/esm/cli/doctor/checks.js.map +1 -0
- package/dist/esm/cli/doctor/fixes.d.ts +9 -0
- package/dist/esm/cli/doctor/fixes.d.ts.map +1 -0
- package/dist/esm/cli/doctor/fixes.js +163 -0
- package/dist/esm/cli/doctor/fixes.js.map +1 -0
- package/dist/esm/cli/doctor/index.d.ts +7 -0
- package/dist/esm/cli/doctor/index.d.ts.map +1 -0
- package/dist/esm/cli/doctor/index.js +5 -0
- package/dist/esm/cli/doctor/index.js.map +1 -0
- package/dist/esm/cli/index.d.ts +3 -0
- package/dist/esm/cli/index.d.ts.map +1 -0
- package/dist/esm/cli/index.js +333 -0
- package/dist/esm/cli/index.js.map +1 -0
- package/dist/esm/cli/interactive.d.ts +8 -0
- package/dist/esm/cli/interactive.d.ts.map +1 -0
- package/dist/esm/cli/interactive.js +665 -0
- package/dist/esm/cli/interactive.js.map +1 -0
- package/dist/esm/cli/logs/format.d.ts +13 -0
- package/dist/esm/cli/logs/format.d.ts.map +1 -0
- package/dist/esm/cli/logs/format.js +169 -0
- package/dist/esm/cli/logs/format.js.map +1 -0
- package/dist/esm/cli/logs/index.d.ts +3 -0
- package/dist/esm/cli/logs/index.d.ts.map +1 -0
- package/dist/esm/cli/logs/index.js +3 -0
- package/dist/esm/cli/logs/index.js.map +1 -0
- package/dist/esm/cli/logs/viewer.d.ts +41 -0
- package/dist/esm/cli/logs/viewer.d.ts.map +1 -0
- package/dist/esm/cli/logs/viewer.js +412 -0
- package/dist/esm/cli/logs/viewer.js.map +1 -0
- package/dist/esm/cli/ops/operation-logger.d.ts +63 -0
- package/dist/esm/cli/ops/operation-logger.d.ts.map +1 -0
- package/dist/esm/cli/ops/operation-logger.js +142 -0
- package/dist/esm/cli/ops/operation-logger.js.map +1 -0
- package/dist/esm/cli/palette.d.ts +11 -0
- package/dist/esm/cli/palette.d.ts.map +1 -0
- package/dist/esm/cli/palette.js +240 -0
- package/dist/esm/cli/palette.js.map +1 -0
- package/dist/esm/cli/prompt.d.ts +186 -0
- package/dist/esm/cli/prompt.d.ts.map +1 -0
- package/dist/esm/cli/prompt.js +483 -0
- package/dist/esm/cli/prompt.js.map +1 -0
- package/dist/esm/cli/ui/box.d.ts +21 -0
- package/dist/esm/cli/ui/box.d.ts.map +1 -0
- package/dist/esm/cli/ui/box.js +60 -0
- package/dist/esm/cli/ui/box.js.map +1 -0
- package/dist/esm/cli/ui/clipboard.d.ts +6 -0
- package/dist/esm/cli/ui/clipboard.d.ts.map +1 -0
- package/dist/esm/cli/ui/clipboard.js +42 -0
- package/dist/esm/cli/ui/clipboard.js.map +1 -0
- package/dist/esm/cli/ui/colors.d.ts +57 -0
- package/dist/esm/cli/ui/colors.d.ts.map +1 -0
- package/dist/esm/cli/ui/colors.js +126 -0
- package/dist/esm/cli/ui/colors.js.map +1 -0
- package/dist/esm/cli/ui/index.d.ts +9 -0
- package/dist/esm/cli/ui/index.d.ts.map +1 -0
- package/dist/esm/cli/ui/index.js +7 -0
- package/dist/esm/cli/ui/index.js.map +1 -0
- package/dist/esm/cli/ui/spinner.d.ts +12 -0
- package/dist/esm/cli/ui/spinner.d.ts.map +1 -0
- package/dist/esm/cli/ui/spinner.js +78 -0
- package/dist/esm/cli/ui/spinner.js.map +1 -0
- package/dist/esm/cli/ui/symbols.d.ts +47 -0
- package/dist/esm/cli/ui/symbols.d.ts.map +1 -0
- package/dist/esm/cli/ui/symbols.js +109 -0
- package/dist/esm/cli/ui/symbols.js.map +1 -0
- package/dist/esm/cli/ui/table.d.ts +23 -0
- package/dist/esm/cli/ui/table.d.ts.map +1 -0
- package/dist/esm/cli/ui/table.js +156 -0
- package/dist/esm/cli/ui/table.js.map +1 -0
- package/dist/esm/cli/ui/terminal.d.ts +7 -0
- package/dist/esm/cli/ui/terminal.d.ts.map +1 -0
- package/dist/esm/cli/ui/terminal.js +32 -0
- package/dist/esm/cli/ui/terminal.js.map +1 -0
- package/dist/esm/config/atomic-write.d.ts +69 -0
- package/dist/esm/config/atomic-write.d.ts.map +1 -0
- package/dist/esm/config/atomic-write.js +246 -0
- package/dist/esm/config/atomic-write.js.map +1 -0
- package/dist/esm/config/db-config.d.ts +134 -0
- package/dist/esm/config/db-config.d.ts.map +1 -0
- package/dist/esm/config/db-config.js +542 -0
- package/dist/esm/config/db-config.js.map +1 -0
- package/dist/esm/config/machine-config.d.ts +85 -0
- package/dist/esm/config/machine-config.d.ts.map +1 -0
- package/dist/esm/config/machine-config.js +190 -0
- package/dist/esm/config/machine-config.js.map +1 -0
- package/dist/esm/config/paths.d.ts +64 -0
- package/dist/esm/config/paths.d.ts.map +1 -0
- package/dist/esm/config/paths.js +108 -0
- package/dist/esm/config/paths.js.map +1 -0
- package/dist/esm/config/schema.d.ts +72 -0
- package/dist/esm/config/schema.d.ts.map +1 -0
- package/dist/esm/config/schema.js +180 -0
- package/dist/esm/config/schema.js.map +1 -0
- package/dist/esm/config/token.d.ts +63 -0
- package/dist/esm/config/token.d.ts.map +1 -0
- package/dist/esm/config/token.js +104 -0
- package/dist/esm/config/token.js.map +1 -0
- package/dist/esm/execution/canceller.d.ts +41 -0
- package/dist/esm/execution/canceller.d.ts.map +1 -0
- package/dist/esm/execution/canceller.js +205 -0
- package/dist/esm/execution/canceller.js.map +1 -0
- package/dist/esm/execution/database-lookup.d.ts +56 -0
- package/dist/esm/execution/database-lookup.d.ts.map +1 -0
- package/dist/esm/execution/database-lookup.js +38 -0
- package/dist/esm/execution/database-lookup.js.map +1 -0
- package/dist/esm/execution/dispatcher.d.ts +181 -0
- package/dist/esm/execution/dispatcher.d.ts.map +1 -0
- package/dist/esm/execution/dispatcher.js +1258 -0
- package/dist/esm/execution/dispatcher.js.map +1 -0
- package/dist/esm/execution/function-effects.d.ts +209 -0
- package/dist/esm/execution/function-effects.d.ts.map +1 -0
- package/dist/esm/execution/function-effects.js +586 -0
- package/dist/esm/execution/function-effects.js.map +1 -0
- package/dist/esm/execution/introspection.d.ts +76 -0
- package/dist/esm/execution/introspection.d.ts.map +1 -0
- package/dist/esm/execution/introspection.js +442 -0
- package/dist/esm/execution/introspection.js.map +1 -0
- package/dist/esm/execution/migration-runner.d.ts +128 -0
- package/dist/esm/execution/migration-runner.d.ts.map +1 -0
- package/dist/esm/execution/migration-runner.js +754 -0
- package/dist/esm/execution/migration-runner.js.map +1 -0
- package/dist/esm/execution/non-tx-detector.d.ts +23 -0
- package/dist/esm/execution/non-tx-detector.d.ts.map +1 -0
- package/dist/esm/execution/non-tx-detector.js +215 -0
- package/dist/esm/execution/non-tx-detector.js.map +1 -0
- package/dist/esm/execution/pool.d.ts +229 -0
- package/dist/esm/execution/pool.d.ts.map +1 -0
- package/dist/esm/execution/pool.js +685 -0
- package/dist/esm/execution/pool.js.map +1 -0
- package/dist/esm/execution/query-runner.d.ts +88 -0
- package/dist/esm/execution/query-runner.d.ts.map +1 -0
- package/dist/esm/execution/query-runner.js +743 -0
- package/dist/esm/execution/query-runner.js.map +1 -0
- package/dist/esm/execution/rate-limiter.d.ts +120 -0
- package/dist/esm/execution/rate-limiter.d.ts.map +1 -0
- package/dist/esm/execution/rate-limiter.js +269 -0
- package/dist/esm/execution/rate-limiter.js.map +1 -0
- package/dist/esm/execution/search-path.d.ts +161 -0
- package/dist/esm/execution/search-path.d.ts.map +1 -0
- package/dist/esm/execution/search-path.js +270 -0
- package/dist/esm/execution/search-path.js.map +1 -0
- package/dist/esm/execution/sql-parser.d.ts +195 -0
- package/dist/esm/execution/sql-parser.d.ts.map +1 -0
- package/dist/esm/execution/sql-parser.js +683 -0
- package/dist/esm/execution/sql-parser.js.map +1 -0
- package/dist/esm/execution/statement-classifier.d.ts +103 -0
- package/dist/esm/execution/statement-classifier.d.ts.map +1 -0
- package/dist/esm/execution/statement-classifier.js +526 -0
- package/dist/esm/execution/statement-classifier.js.map +1 -0
- package/dist/esm/execution/types.d.ts +189 -0
- package/dist/esm/execution/types.d.ts.map +1 -0
- package/dist/esm/execution/types.js +22 -0
- package/dist/esm/execution/types.js.map +1 -0
- package/dist/esm/index.d.ts +34 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/permissions/auto-upgrade.d.ts +40 -0
- package/dist/esm/permissions/auto-upgrade.d.ts.map +1 -0
- package/dist/esm/permissions/auto-upgrade.js +164 -0
- package/dist/esm/permissions/auto-upgrade.js.map +1 -0
- package/dist/esm/permissions/checker.d.ts +53 -0
- package/dist/esm/permissions/checker.d.ts.map +1 -0
- package/dist/esm/permissions/checker.js +322 -0
- package/dist/esm/permissions/checker.js.map +1 -0
- package/dist/esm/permissions/manual-approval.d.ts +213 -0
- package/dist/esm/permissions/manual-approval.d.ts.map +1 -0
- package/dist/esm/permissions/manual-approval.js +503 -0
- package/dist/esm/permissions/manual-approval.js.map +1 -0
- package/dist/esm/permissions/plan-registry.d.ts +274 -0
- package/dist/esm/permissions/plan-registry.d.ts.map +1 -0
- package/dist/esm/permissions/plan-registry.js +450 -0
- package/dist/esm/permissions/plan-registry.js.map +1 -0
- package/dist/esm/permissions/role-policy.d.ts +217 -0
- package/dist/esm/permissions/role-policy.d.ts.map +1 -0
- package/dist/esm/permissions/role-policy.js +570 -0
- package/dist/esm/permissions/role-policy.js.map +1 -0
- package/dist/esm/permissions/types.d.ts +126 -0
- package/dist/esm/permissions/types.d.ts.map +1 -0
- package/dist/esm/permissions/types.js +2 -0
- package/dist/esm/permissions/types.js.map +1 -0
- package/dist/esm/protocol/constants.d.ts +72 -0
- package/dist/esm/protocol/constants.d.ts.map +1 -0
- package/dist/esm/protocol/constants.js +104 -0
- package/dist/esm/protocol/constants.js.map +1 -0
- package/dist/esm/protocol/envelope.d.ts +165 -0
- package/dist/esm/protocol/envelope.d.ts.map +1 -0
- package/dist/esm/protocol/envelope.js +263 -0
- package/dist/esm/protocol/envelope.js.map +1 -0
- package/dist/esm/protocol/errors.d.ts +33 -0
- package/dist/esm/protocol/errors.d.ts.map +1 -0
- package/dist/esm/protocol/errors.js +384 -0
- package/dist/esm/protocol/errors.js.map +1 -0
- package/dist/esm/protocol/messages.d.ts +327 -0
- package/dist/esm/protocol/messages.d.ts.map +1 -0
- package/dist/esm/protocol/messages.js +2 -0
- package/dist/esm/protocol/messages.js.map +1 -0
- package/dist/esm/protocol/serialize.d.ts +26 -0
- package/dist/esm/protocol/serialize.d.ts.map +1 -0
- package/dist/esm/protocol/serialize.js +63 -0
- package/dist/esm/protocol/serialize.js.map +1 -0
- package/dist/esm/protocol/validate.d.ts +135 -0
- package/dist/esm/protocol/validate.d.ts.map +1 -0
- package/dist/esm/protocol/validate.js +830 -0
- package/dist/esm/protocol/validate.js.map +1 -0
- package/dist/types/audit/chain.d.ts +365 -0
- package/dist/types/audit/chain.d.ts.map +1 -0
- package/dist/types/audit/cloud-client.d.ts +142 -0
- package/dist/types/audit/cloud-client.d.ts.map +1 -0
- package/dist/types/audit/cloud-writer.d.ts +57 -0
- package/dist/types/audit/cloud-writer.d.ts.map +1 -0
- package/dist/types/audit/context.d.ts +51 -0
- package/dist/types/audit/context.d.ts.map +1 -0
- package/dist/types/audit/files.d.ts +111 -0
- package/dist/types/audit/files.d.ts.map +1 -0
- package/dist/types/audit/index.d.ts +9 -0
- package/dist/types/audit/index.d.ts.map +1 -0
- package/dist/types/audit/local-writer.d.ts +255 -0
- package/dist/types/audit/local-writer.d.ts.map +1 -0
- package/dist/types/audit/redact.d.ts +151 -0
- package/dist/types/audit/redact.d.ts.map +1 -0
- package/dist/types/audit/sanitize.d.ts +78 -0
- package/dist/types/audit/sanitize.d.ts.map +1 -0
- package/dist/types/audit/sink.d.ts +278 -0
- package/dist/types/audit/sink.d.ts.map +1 -0
- package/dist/types/audit/types.d.ts +226 -0
- package/dist/types/audit/types.d.ts.map +1 -0
- package/dist/types/audit/verify-cache.d.ts +127 -0
- package/dist/types/audit/verify-cache.d.ts.map +1 -0
- package/dist/types/channels/agent-session.d.ts +228 -0
- package/dist/types/channels/agent-session.d.ts.map +1 -0
- package/dist/types/channels/data-channel.d.ts +181 -0
- package/dist/types/channels/data-channel.d.ts.map +1 -0
- package/dist/types/channels/reconnect.d.ts +142 -0
- package/dist/types/channels/reconnect.d.ts.map +1 -0
- package/dist/types/channels/types.d.ts +112 -0
- package/dist/types/channels/types.d.ts.map +1 -0
- package/dist/types/channels/wake-channel.d.ts +232 -0
- package/dist/types/channels/wake-channel.d.ts.map +1 -0
- package/dist/types/cli/banner.d.ts +2 -0
- package/dist/types/cli/banner.d.ts.map +1 -0
- package/dist/types/cli/commands/agent.d.ts +30 -0
- package/dist/types/cli/commands/agent.d.ts.map +1 -0
- package/dist/types/cli/commands/audit-verify.d.ts +19 -0
- package/dist/types/cli/commands/audit-verify.d.ts.map +1 -0
- package/dist/types/cli/commands/clean.d.ts +23 -0
- package/dist/types/cli/commands/clean.d.ts.map +1 -0
- package/dist/types/cli/commands/config-show.d.ts +2 -0
- package/dist/types/cli/commands/config-show.d.ts.map +1 -0
- package/dist/types/cli/commands/config.d.ts +6 -0
- package/dist/types/cli/commands/config.d.ts.map +1 -0
- package/dist/types/cli/commands/db-add.d.ts +16 -0
- package/dist/types/cli/commands/db-add.d.ts.map +1 -0
- package/dist/types/cli/commands/db-edit.d.ts +2 -0
- package/dist/types/cli/commands/db-edit.d.ts.map +1 -0
- package/dist/types/cli/commands/db-logs.d.ts +3 -0
- package/dist/types/cli/commands/db-logs.d.ts.map +1 -0
- package/dist/types/cli/commands/db-ls.d.ts +2 -0
- package/dist/types/cli/commands/db-ls.d.ts.map +1 -0
- package/dist/types/cli/commands/db-query.d.ts +121 -0
- package/dist/types/cli/commands/db-query.d.ts.map +1 -0
- package/dist/types/cli/commands/db-remove.d.ts +2 -0
- package/dist/types/cli/commands/db-remove.d.ts.map +1 -0
- package/dist/types/cli/commands/db-show.d.ts +2 -0
- package/dist/types/cli/commands/db-show.d.ts.map +1 -0
- package/dist/types/cli/commands/db-test.d.ts +3 -0
- package/dist/types/cli/commands/db-test.d.ts.map +1 -0
- package/dist/types/cli/commands/db.d.ts +11 -0
- package/dist/types/cli/commands/db.d.ts.map +1 -0
- package/dist/types/cli/commands/debug.d.ts +2 -0
- package/dist/types/cli/commands/debug.d.ts.map +1 -0
- package/dist/types/cli/commands/doctor.d.ts +5 -0
- package/dist/types/cli/commands/doctor.d.ts.map +1 -0
- package/dist/types/cli/commands/index.d.ts +10 -0
- package/dist/types/cli/commands/index.d.ts.map +1 -0
- package/dist/types/cli/commands/init.d.ts +2 -0
- package/dist/types/cli/commands/init.d.ts.map +1 -0
- package/dist/types/cli/commands/link.d.ts +5 -0
- package/dist/types/cli/commands/link.d.ts.map +1 -0
- package/dist/types/cli/commands/logs.d.ts +17 -0
- package/dist/types/cli/commands/logs.d.ts.map +1 -0
- package/dist/types/cli/commands/project-show.d.ts +2 -0
- package/dist/types/cli/commands/project-show.d.ts.map +1 -0
- package/dist/types/cli/commands/project.d.ts +3 -0
- package/dist/types/cli/commands/project.d.ts.map +1 -0
- package/dist/types/cli/commands/service.d.ts +123 -0
- package/dist/types/cli/commands/service.d.ts.map +1 -0
- package/dist/types/cli/commands/start.d.ts +6 -0
- package/dist/types/cli/commands/start.d.ts.map +1 -0
- package/dist/types/cli/commands/status.d.ts +2 -0
- package/dist/types/cli/commands/status.d.ts.map +1 -0
- package/dist/types/cli/commands/stop.d.ts +6 -0
- package/dist/types/cli/commands/stop.d.ts.map +1 -0
- package/dist/types/cli/daemon/error-tracker.d.ts +119 -0
- package/dist/types/cli/daemon/error-tracker.d.ts.map +1 -0
- package/dist/types/cli/daemon/fault-shutdown.d.ts +144 -0
- package/dist/types/cli/daemon/fault-shutdown.d.ts.map +1 -0
- package/dist/types/cli/daemon/index.d.ts +12 -0
- package/dist/types/cli/daemon/index.d.ts.map +1 -0
- package/dist/types/cli/daemon/pid-file.d.ts +13 -0
- package/dist/types/cli/daemon/pid-file.d.ts.map +1 -0
- package/dist/types/cli/daemon/readiness.d.ts +30 -0
- package/dist/types/cli/daemon/readiness.d.ts.map +1 -0
- package/dist/types/cli/daemon/runtime.d.ts +366 -0
- package/dist/types/cli/daemon/runtime.d.ts.map +1 -0
- package/dist/types/cli/daemon/shutdown.d.ts +7 -0
- package/dist/types/cli/daemon/shutdown.d.ts.map +1 -0
- package/dist/types/cli/daemon/signal-handlers.d.ts +3 -0
- package/dist/types/cli/daemon/signal-handlers.d.ts.map +1 -0
- package/dist/types/cli/daemon/state.d.ts +157 -0
- package/dist/types/cli/daemon/state.d.ts.map +1 -0
- package/dist/types/cli/daemon/status-file.d.ts +139 -0
- package/dist/types/cli/daemon/status-file.d.ts.map +1 -0
- package/dist/types/cli/doctor/checks.d.ts +133 -0
- package/dist/types/cli/doctor/checks.d.ts.map +1 -0
- package/dist/types/cli/doctor/fixes.d.ts +9 -0
- package/dist/types/cli/doctor/fixes.d.ts.map +1 -0
- package/dist/types/cli/doctor/index.d.ts +7 -0
- package/dist/types/cli/doctor/index.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/cli/interactive.d.ts +8 -0
- package/dist/types/cli/interactive.d.ts.map +1 -0
- package/dist/types/cli/logs/format.d.ts +13 -0
- package/dist/types/cli/logs/format.d.ts.map +1 -0
- package/dist/types/cli/logs/index.d.ts +3 -0
- package/dist/types/cli/logs/index.d.ts.map +1 -0
- package/dist/types/cli/logs/viewer.d.ts +41 -0
- package/dist/types/cli/logs/viewer.d.ts.map +1 -0
- package/dist/types/cli/ops/operation-logger.d.ts +63 -0
- package/dist/types/cli/ops/operation-logger.d.ts.map +1 -0
- package/dist/types/cli/palette.d.ts +11 -0
- package/dist/types/cli/palette.d.ts.map +1 -0
- package/dist/types/cli/prompt.d.ts +186 -0
- package/dist/types/cli/prompt.d.ts.map +1 -0
- package/dist/types/cli/ui/box.d.ts +21 -0
- package/dist/types/cli/ui/box.d.ts.map +1 -0
- package/dist/types/cli/ui/clipboard.d.ts +6 -0
- package/dist/types/cli/ui/clipboard.d.ts.map +1 -0
- package/dist/types/cli/ui/colors.d.ts +57 -0
- package/dist/types/cli/ui/colors.d.ts.map +1 -0
- package/dist/types/cli/ui/index.d.ts +9 -0
- package/dist/types/cli/ui/index.d.ts.map +1 -0
- package/dist/types/cli/ui/spinner.d.ts +12 -0
- package/dist/types/cli/ui/spinner.d.ts.map +1 -0
- package/dist/types/cli/ui/symbols.d.ts +47 -0
- package/dist/types/cli/ui/symbols.d.ts.map +1 -0
- package/dist/types/cli/ui/table.d.ts +23 -0
- package/dist/types/cli/ui/table.d.ts.map +1 -0
- package/dist/types/cli/ui/terminal.d.ts +7 -0
- package/dist/types/cli/ui/terminal.d.ts.map +1 -0
- package/dist/types/config/atomic-write.d.ts +69 -0
- package/dist/types/config/atomic-write.d.ts.map +1 -0
- package/dist/types/config/db-config.d.ts +134 -0
- package/dist/types/config/db-config.d.ts.map +1 -0
- package/dist/types/config/machine-config.d.ts +85 -0
- package/dist/types/config/machine-config.d.ts.map +1 -0
- package/dist/types/config/paths.d.ts +64 -0
- package/dist/types/config/paths.d.ts.map +1 -0
- package/dist/types/config/schema.d.ts +72 -0
- package/dist/types/config/schema.d.ts.map +1 -0
- package/dist/types/config/token.d.ts +63 -0
- package/dist/types/config/token.d.ts.map +1 -0
- package/dist/types/execution/canceller.d.ts +41 -0
- package/dist/types/execution/canceller.d.ts.map +1 -0
- package/dist/types/execution/database-lookup.d.ts +56 -0
- package/dist/types/execution/database-lookup.d.ts.map +1 -0
- package/dist/types/execution/dispatcher.d.ts +181 -0
- package/dist/types/execution/dispatcher.d.ts.map +1 -0
- package/dist/types/execution/function-effects.d.ts +209 -0
- package/dist/types/execution/function-effects.d.ts.map +1 -0
- package/dist/types/execution/introspection.d.ts +76 -0
- package/dist/types/execution/introspection.d.ts.map +1 -0
- package/dist/types/execution/migration-runner.d.ts +128 -0
- package/dist/types/execution/migration-runner.d.ts.map +1 -0
- package/dist/types/execution/non-tx-detector.d.ts +23 -0
- package/dist/types/execution/non-tx-detector.d.ts.map +1 -0
- package/dist/types/execution/pool.d.ts +229 -0
- package/dist/types/execution/pool.d.ts.map +1 -0
- package/dist/types/execution/query-runner.d.ts +88 -0
- package/dist/types/execution/query-runner.d.ts.map +1 -0
- package/dist/types/execution/rate-limiter.d.ts +120 -0
- package/dist/types/execution/rate-limiter.d.ts.map +1 -0
- package/dist/types/execution/search-path.d.ts +161 -0
- package/dist/types/execution/search-path.d.ts.map +1 -0
- package/dist/types/execution/sql-parser.d.ts +195 -0
- package/dist/types/execution/sql-parser.d.ts.map +1 -0
- package/dist/types/execution/statement-classifier.d.ts +103 -0
- package/dist/types/execution/statement-classifier.d.ts.map +1 -0
- package/dist/types/execution/types.d.ts +189 -0
- package/dist/types/execution/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/permissions/auto-upgrade.d.ts +40 -0
- package/dist/types/permissions/auto-upgrade.d.ts.map +1 -0
- package/dist/types/permissions/checker.d.ts +53 -0
- package/dist/types/permissions/checker.d.ts.map +1 -0
- package/dist/types/permissions/manual-approval.d.ts +213 -0
- package/dist/types/permissions/manual-approval.d.ts.map +1 -0
- package/dist/types/permissions/plan-registry.d.ts +274 -0
- package/dist/types/permissions/plan-registry.d.ts.map +1 -0
- package/dist/types/permissions/role-policy.d.ts +217 -0
- package/dist/types/permissions/role-policy.d.ts.map +1 -0
- package/dist/types/permissions/types.d.ts +126 -0
- package/dist/types/permissions/types.d.ts.map +1 -0
- package/dist/types/protocol/constants.d.ts +72 -0
- package/dist/types/protocol/constants.d.ts.map +1 -0
- package/dist/types/protocol/envelope.d.ts +165 -0
- package/dist/types/protocol/envelope.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +33 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/messages.d.ts +327 -0
- package/dist/types/protocol/messages.d.ts.map +1 -0
- package/dist/types/protocol/serialize.d.ts +26 -0
- package/dist/types/protocol/serialize.d.ts.map +1 -0
- package/dist/types/protocol/validate.d.ts +135 -0
- package/dist/types/protocol/validate.d.ts.map +1 -0
- package/package.json +116 -4
- package/scripts/generate-systemd-service.mjs +117 -0
|
@@ -0,0 +1,959 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ChainVerifier = exports.AuditKeyError = exports.AUDIT_FLOOR_SUFFIX = exports.AUDIT_HEAD_FILENAME = exports.AUDIT_KEY_FILENAME = exports.AUDIT_KEY_ENV = exports.AUDIT_KEY_BYTES = exports.GENESIS_HASH = void 0;
|
|
37
|
+
exports.isHash64 = isHash64;
|
|
38
|
+
exports.decodeKeyMaterial = decodeKeyMaterial;
|
|
39
|
+
exports.deriveChainId = deriveChainId;
|
|
40
|
+
exports.newChainId = newChainId;
|
|
41
|
+
exports.loadAuditKey = loadAuditKey;
|
|
42
|
+
exports.tryLoadAuditKey = tryLoadAuditKey;
|
|
43
|
+
exports.requireKeyBytes = requireKeyBytes;
|
|
44
|
+
exports.headPathFor = headPathFor;
|
|
45
|
+
exports.readHead = readHead;
|
|
46
|
+
exports.floorPathFor = floorPathFor;
|
|
47
|
+
exports.readHeadFloor = readHeadFloor;
|
|
48
|
+
exports.normalizeHead = normalizeHead;
|
|
49
|
+
exports.makeHead = makeHead;
|
|
50
|
+
exports.writeHead = writeHead;
|
|
51
|
+
exports.writeHeadFloor = writeHeadFloor;
|
|
52
|
+
exports.fsyncDir = fsyncDir;
|
|
53
|
+
exports.resolveAnchor = resolveAnchor;
|
|
54
|
+
exports.canonicalStringify = canonicalStringify;
|
|
55
|
+
exports.macInputOf = macInputOf;
|
|
56
|
+
exports.computeMac = computeMac;
|
|
57
|
+
exports.computeEventMac = computeMac;
|
|
58
|
+
exports.computeEventHash = computeMac;
|
|
59
|
+
exports.computeHash = computeHash;
|
|
60
|
+
exports.verifyEventMac = verifyEventMac;
|
|
61
|
+
exports.verifyChain = verifyChain;
|
|
62
|
+
exports.verifyHashChain = verifyChain;
|
|
63
|
+
exports.verifyChainAgainstHead = verifyChainAgainstHead;
|
|
64
|
+
const crypto = __importStar(require("crypto"));
|
|
65
|
+
const fs = __importStar(require("fs"));
|
|
66
|
+
const os = __importStar(require("os"));
|
|
67
|
+
const path = __importStar(require("path"));
|
|
68
|
+
const paths_1 = require("../config/paths");
|
|
69
|
+
/** The hash the first record of a chain chains from. */
|
|
70
|
+
exports.GENESIS_HASH = '0'.repeat(64);
|
|
71
|
+
/** HMAC-SHA256 key length. 32 bytes = 256 bits. */
|
|
72
|
+
exports.AUDIT_KEY_BYTES = 32;
|
|
73
|
+
/** Operator-supplied key (hex or base64). Used by tests and managed deployments. */
|
|
74
|
+
exports.AUDIT_KEY_ENV = 'SW_AGENT_AUDIT_KEY';
|
|
75
|
+
/** Machine-local key file, relative to the agent home (`~/.sw-agent/audit.key`). */
|
|
76
|
+
exports.AUDIT_KEY_FILENAME = 'audit.key';
|
|
77
|
+
/** Anchored chain head, relative to the audit directory. */
|
|
78
|
+
exports.AUDIT_HEAD_FILENAME = 'head.json';
|
|
79
|
+
/**
|
|
80
|
+
* Suffix of the monotonic floor anchor. It is appended to the audit directory's
|
|
81
|
+
* own name, so `<home>/audit` is anchored by `<home>/audit.floor.json`.
|
|
82
|
+
*
|
|
83
|
+
* The file holds the highest sequence number any writer has ever anchored. It is
|
|
84
|
+
* the second, independent claim about the same chain: `head.json` lives with the
|
|
85
|
+
* log, so anyone able to rewrite the log can rewrite the head too, and a matching
|
|
86
|
+
* pair of rolled-back files verifies as a self-consistent chain. This file is
|
|
87
|
+
* what makes that rollback visible (finding C-05, recommended fixes 2a and 3).
|
|
88
|
+
*/
|
|
89
|
+
exports.AUDIT_FLOOR_SUFFIX = '.floor.json';
|
|
90
|
+
const KEY_FILE_MODE = 0o600;
|
|
91
|
+
const KEY_DIR_MODE = 0o700;
|
|
92
|
+
const HEAD_FILE_MODE = 0o600;
|
|
93
|
+
const FLOOR_FILE_MODE = 0o600;
|
|
94
|
+
const CHAIN_ID_BYTES = 16;
|
|
95
|
+
const HASH_HEX = /^[0-9a-f]{64}$/;
|
|
96
|
+
const HEX_KEY = /^[0-9a-fA-F]{64}$/;
|
|
97
|
+
const BASE64_KEY = /^[A-Za-z0-9+/]{43}=$/;
|
|
98
|
+
class AuditKeyError extends Error {
|
|
99
|
+
code;
|
|
100
|
+
constructor(code, message) {
|
|
101
|
+
super(message);
|
|
102
|
+
this.name = 'AuditKeyError';
|
|
103
|
+
this.code = code;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.AuditKeyError = AuditKeyError;
|
|
107
|
+
function isHash64(value) {
|
|
108
|
+
return typeof value === 'string' && HASH_HEX.test(value);
|
|
109
|
+
}
|
|
110
|
+
/** True when `value` is a whole, non-negative, safe integer. */
|
|
111
|
+
function isSeq(value) {
|
|
112
|
+
return (typeof value === 'number' &&
|
|
113
|
+
Number.isInteger(value) &&
|
|
114
|
+
value >= 0 &&
|
|
115
|
+
Number.isSafeInteger(value));
|
|
116
|
+
}
|
|
117
|
+
/* ------------------------------------------------------------------ */
|
|
118
|
+
/* Key establishment */
|
|
119
|
+
/* ------------------------------------------------------------------ */
|
|
120
|
+
/**
|
|
121
|
+
* Decodes operator-supplied key material: 64 hex characters, or 44 characters
|
|
122
|
+
* of standard base64. Anything else is rejected rather than coerced — a
|
|
123
|
+
* mistyped key must not silently produce a different key than intended.
|
|
124
|
+
*/
|
|
125
|
+
function decodeKeyMaterial(raw) {
|
|
126
|
+
const trimmed = raw.trim();
|
|
127
|
+
if (trimmed.length === 0) {
|
|
128
|
+
throw new AuditKeyError('bad_key', `${exports.AUDIT_KEY_ENV} is set but empty`);
|
|
129
|
+
}
|
|
130
|
+
if (HEX_KEY.test(trimmed)) {
|
|
131
|
+
const buf = Buffer.from(trimmed, 'hex');
|
|
132
|
+
if (buf.length !== exports.AUDIT_KEY_BYTES) {
|
|
133
|
+
throw new AuditKeyError('bad_key', `${exports.AUDIT_KEY_ENV} must decode to ${exports.AUDIT_KEY_BYTES} bytes`);
|
|
134
|
+
}
|
|
135
|
+
return buf;
|
|
136
|
+
}
|
|
137
|
+
if (BASE64_KEY.test(trimmed)) {
|
|
138
|
+
const buf = Buffer.from(trimmed, 'base64');
|
|
139
|
+
if (buf.length !== exports.AUDIT_KEY_BYTES) {
|
|
140
|
+
throw new AuditKeyError('bad_key', `${exports.AUDIT_KEY_ENV} must decode to ${exports.AUDIT_KEY_BYTES} bytes`);
|
|
141
|
+
}
|
|
142
|
+
return buf;
|
|
143
|
+
}
|
|
144
|
+
throw new AuditKeyError('bad_key', `${exports.AUDIT_KEY_ENV} must be ${exports.AUDIT_KEY_BYTES} bytes as hex (${exports.AUDIT_KEY_BYTES * 2} chars) or base64`);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Deterministic chain id for a key supplied out of band (no key file to carry
|
|
148
|
+
* one). Derived with the key itself, so it is stable across restarts and reveals
|
|
149
|
+
* nothing without the key.
|
|
150
|
+
*/
|
|
151
|
+
function deriveChainId(key) {
|
|
152
|
+
return crypto
|
|
153
|
+
.createHmac('sha256', key)
|
|
154
|
+
.update('sw-agent/audit-chain-id/v1', 'utf8')
|
|
155
|
+
.digest('hex')
|
|
156
|
+
.slice(0, 32);
|
|
157
|
+
}
|
|
158
|
+
function newChainId() {
|
|
159
|
+
return crypto.randomBytes(CHAIN_ID_BYTES).toString('hex');
|
|
160
|
+
}
|
|
161
|
+
function defaultKeyPath(dir) {
|
|
162
|
+
const base = dir ?? safeAgentHome();
|
|
163
|
+
return path.join(base, exports.AUDIT_KEY_FILENAME);
|
|
164
|
+
}
|
|
165
|
+
function safeAgentHome() {
|
|
166
|
+
try {
|
|
167
|
+
return (0, paths_1.getAgentHome)();
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return path.join(os.homedir(), '.sw-agent');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function readKeyFile(keyPath) {
|
|
174
|
+
let raw;
|
|
175
|
+
try {
|
|
176
|
+
raw = fs.readFileSync(keyPath, 'utf8');
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
const code = err.code;
|
|
180
|
+
if (code === 'ENOENT')
|
|
181
|
+
return null;
|
|
182
|
+
throw new AuditKeyError('key_io', `cannot read audit key file ${keyPath}: ${String(err)}`);
|
|
183
|
+
}
|
|
184
|
+
let parsed;
|
|
185
|
+
try {
|
|
186
|
+
parsed = JSON.parse(raw);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
throw new AuditKeyError('bad_key', `audit key file ${keyPath} is not valid JSON — refusing to fall back to an unkeyed chain`);
|
|
190
|
+
}
|
|
191
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
192
|
+
throw new AuditKeyError('bad_key', `audit key file ${keyPath} is malformed`);
|
|
193
|
+
}
|
|
194
|
+
const rec = parsed;
|
|
195
|
+
if (typeof rec.key !== 'string' || typeof rec.chain_id !== 'string') {
|
|
196
|
+
throw new AuditKeyError('bad_key', `audit key file ${keyPath} is missing key/chain_id`);
|
|
197
|
+
}
|
|
198
|
+
let key;
|
|
199
|
+
try {
|
|
200
|
+
key = Buffer.from(rec.key, 'base64');
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
throw new AuditKeyError('bad_key', `audit key file ${keyPath} has undecodable key material`);
|
|
204
|
+
}
|
|
205
|
+
if (key.length !== exports.AUDIT_KEY_BYTES) {
|
|
206
|
+
throw new AuditKeyError('bad_key', `audit key file ${keyPath} does not hold a ${exports.AUDIT_KEY_BYTES}-byte key`);
|
|
207
|
+
}
|
|
208
|
+
return { key, chain_id: rec.chain_id, source: 'keyfile', origin: keyPath };
|
|
209
|
+
}
|
|
210
|
+
function createKeyFile(keyPath) {
|
|
211
|
+
const key = crypto.randomBytes(exports.AUDIT_KEY_BYTES);
|
|
212
|
+
const chain_id = newChainId();
|
|
213
|
+
const contents = {
|
|
214
|
+
v: 1,
|
|
215
|
+
chain_id,
|
|
216
|
+
key: key.toString('base64'),
|
|
217
|
+
created_at: new Date().toISOString(),
|
|
218
|
+
};
|
|
219
|
+
const dir = path.dirname(keyPath);
|
|
220
|
+
fs.mkdirSync(dir, { recursive: true, mode: KEY_DIR_MODE });
|
|
221
|
+
const tmp = `${keyPath}.${process.pid}.${crypto.randomBytes(4).toString('hex')}.tmp`;
|
|
222
|
+
try {
|
|
223
|
+
// Create with restrictive mode from the start; never briefly world-readable.
|
|
224
|
+
const fd = fs.openSync(tmp, 'wx', KEY_FILE_MODE);
|
|
225
|
+
try {
|
|
226
|
+
fs.writeFileSync(fd, JSON.stringify(contents, null, 2) + '\n', 'utf8');
|
|
227
|
+
fs.fsyncSync(fd);
|
|
228
|
+
}
|
|
229
|
+
finally {
|
|
230
|
+
fs.closeSync(fd);
|
|
231
|
+
}
|
|
232
|
+
fs.chmodSync(tmp, KEY_FILE_MODE);
|
|
233
|
+
fs.renameSync(tmp, keyPath);
|
|
234
|
+
fsyncDir(dir);
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
// eslint-disable-next-line no-empty
|
|
238
|
+
try {
|
|
239
|
+
fs.unlinkSync(tmp);
|
|
240
|
+
}
|
|
241
|
+
catch { }
|
|
242
|
+
throw new AuditKeyError('key_io', `cannot create audit key file ${keyPath}: ${String(err)}`);
|
|
243
|
+
}
|
|
244
|
+
return { key, chain_id, source: 'keyfile', origin: keyPath };
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Establishes the chain signing key, or throws.
|
|
248
|
+
*
|
|
249
|
+
* There is deliberately no unkeyed fallback. An audit chain that verifies
|
|
250
|
+
* against a public algorithm proves only internal consistency, which an
|
|
251
|
+
* attacker with write access can reproduce (audit finding C-05); silently
|
|
252
|
+
* degrading to that construction is worse than refusing to run.
|
|
253
|
+
*
|
|
254
|
+
* Precedence: `SW_AGENT_AUDIT_KEY` (operator override) → `audit.key`.
|
|
255
|
+
*
|
|
256
|
+
* `create: false` is read-only: an existing key file is still loaded. It only
|
|
257
|
+
* refuses to mint one, so verification paths can resolve the key without being
|
|
258
|
+
* able to establish a new chain.
|
|
259
|
+
*/
|
|
260
|
+
function loadAuditKey(opts = {}) {
|
|
261
|
+
const env = opts.env ?? process.env;
|
|
262
|
+
const keyPath = opts.keyPath ?? defaultKeyPath(opts.dir);
|
|
263
|
+
// Always *read* the file when present; `create` governs minting, not reading.
|
|
264
|
+
const fromFile = readKeyFile(keyPath);
|
|
265
|
+
const raw = env[exports.AUDIT_KEY_ENV];
|
|
266
|
+
if (typeof raw === 'string' && raw.trim().length > 0) {
|
|
267
|
+
const key = decodeKeyMaterial(raw);
|
|
268
|
+
const chain_id = opts.chainId ?? fromFile?.chain_id ?? deriveChainId(key);
|
|
269
|
+
return { key, chain_id, source: 'env', origin: exports.AUDIT_KEY_ENV };
|
|
270
|
+
}
|
|
271
|
+
if (fromFile)
|
|
272
|
+
return fromFile;
|
|
273
|
+
if (opts.create === false) {
|
|
274
|
+
throw new AuditKeyError('no_key', `no audit key: set ${exports.AUDIT_KEY_ENV} or create ${keyPath}. Refusing to verify an unkeyed audit chain.`);
|
|
275
|
+
}
|
|
276
|
+
return createKeyFile(keyPath);
|
|
277
|
+
}
|
|
278
|
+
/** Non-throwing variant for read-only verification paths. */
|
|
279
|
+
function tryLoadAuditKey(opts = {}) {
|
|
280
|
+
try {
|
|
281
|
+
return loadAuditKey(opts);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/** Normalises key material supplied directly by a caller. */
|
|
288
|
+
function requireKeyBytes(key) {
|
|
289
|
+
if (Buffer.isBuffer(key) && key.length === exports.AUDIT_KEY_BYTES)
|
|
290
|
+
return key;
|
|
291
|
+
if (typeof key === 'string' && key.length > 0)
|
|
292
|
+
return decodeKeyMaterial(key);
|
|
293
|
+
throw new AuditKeyError('no_key', `a ${exports.AUDIT_KEY_BYTES}-byte audit key is required; an unkeyed chain is not offered`);
|
|
294
|
+
}
|
|
295
|
+
/* ------------------------------------------------------------------ */
|
|
296
|
+
/* Head anchor */
|
|
297
|
+
/* ------------------------------------------------------------------ */
|
|
298
|
+
function headPathFor(dir) {
|
|
299
|
+
return path.join(dir, exports.AUDIT_HEAD_FILENAME);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Reads the anchored head. A missing or malformed head is reported as `null`
|
|
303
|
+
* (not as a pass): without an anchor, a log cannot be shown to be complete.
|
|
304
|
+
*/
|
|
305
|
+
function readHead(dir) {
|
|
306
|
+
return readHeadFile(headPathFor(dir));
|
|
307
|
+
}
|
|
308
|
+
/** Reads and validates one anchor file. Never throws. */
|
|
309
|
+
function readHeadFile(target) {
|
|
310
|
+
let raw;
|
|
311
|
+
try {
|
|
312
|
+
raw = fs.readFileSync(target, 'utf8');
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
try {
|
|
318
|
+
const parsed = JSON.parse(raw);
|
|
319
|
+
return normalizeHead(parsed);
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Absolute path of the monotonic floor anchor for an audit directory.
|
|
327
|
+
*
|
|
328
|
+
* It is a sibling of the audit directory, named after it, rather than a file
|
|
329
|
+
* inside it: anyone who can rewrite the log can rewrite an anchor that lives
|
|
330
|
+
* beside it, so the second claim has to sit outside the directory it vouches for.
|
|
331
|
+
* Deriving the name from the audit directory also keeps two audit directories that
|
|
332
|
+
* share a parent (two installations under one home) from sharing a floor.
|
|
333
|
+
*
|
|
334
|
+
* Because the name follows the directory, moving or renaming an audit directory
|
|
335
|
+
* orphans its floor: the moved log then has no second anchor and a rollback of it
|
|
336
|
+
* plus `head.json` is only caught if the operator still holds a copy of the head.
|
|
337
|
+
*/
|
|
338
|
+
function floorPathFor(auditDir) {
|
|
339
|
+
const resolved = path.resolve(auditDir);
|
|
340
|
+
return path.join(path.dirname(resolved), `${path.basename(resolved)}${exports.AUDIT_FLOOR_SUFFIX}`);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Reads the monotonic floor anchor, or `null` when there is none. It is a lower
|
|
344
|
+
* bound on the end of the log, not a second head: it may legitimately lag the log
|
|
345
|
+
* after a crash, but it must never be ahead of it.
|
|
346
|
+
*/
|
|
347
|
+
function readHeadFloor(auditDir) {
|
|
348
|
+
return readHeadFile(floorPathFor(auditDir));
|
|
349
|
+
}
|
|
350
|
+
function normalizeHead(value) {
|
|
351
|
+
if (typeof value !== 'object' || value === null)
|
|
352
|
+
return null;
|
|
353
|
+
const rec = value;
|
|
354
|
+
if (typeof rec.chain_id !== 'string' || rec.chain_id.length === 0)
|
|
355
|
+
return null;
|
|
356
|
+
if (!isSeq(rec.seq))
|
|
357
|
+
return null;
|
|
358
|
+
if (!isHash64(rec.last_hash))
|
|
359
|
+
return null;
|
|
360
|
+
if (typeof rec.written_at !== 'string')
|
|
361
|
+
return null;
|
|
362
|
+
const head = {
|
|
363
|
+
v: 1,
|
|
364
|
+
chain_id: rec.chain_id,
|
|
365
|
+
seq: rec.seq,
|
|
366
|
+
last_hash: rec.last_hash,
|
|
367
|
+
written_at: rec.written_at,
|
|
368
|
+
};
|
|
369
|
+
// Absent means "the whole log is retained" — the pre-rotation case.
|
|
370
|
+
if (rec.retained_from_seq === undefined || rec.retained_from_seq === null)
|
|
371
|
+
return head;
|
|
372
|
+
if (!isSeq(rec.retained_from_seq) || rec.retained_from_seq < 1)
|
|
373
|
+
return null;
|
|
374
|
+
return { ...head, retained_from_seq: rec.retained_from_seq };
|
|
375
|
+
}
|
|
376
|
+
function makeHead(seq, lastHash, chainId, retainedFromSeq) {
|
|
377
|
+
const head = {
|
|
378
|
+
v: 1,
|
|
379
|
+
chain_id: chainId,
|
|
380
|
+
seq,
|
|
381
|
+
last_hash: lastHash,
|
|
382
|
+
written_at: new Date().toISOString(),
|
|
383
|
+
};
|
|
384
|
+
if (typeof retainedFromSeq === 'number' &&
|
|
385
|
+
Number.isInteger(retainedFromSeq) &&
|
|
386
|
+
retainedFromSeq >= 1) {
|
|
387
|
+
head.retained_from_seq = retainedFromSeq;
|
|
388
|
+
}
|
|
389
|
+
return head;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Persists the head atomically: write a private temp file, rename over the old
|
|
393
|
+
* head. A reader therefore never observes a half-written head.
|
|
394
|
+
*
|
|
395
|
+
* The head is written *after* the record it describes. A crash in between
|
|
396
|
+
* leaves the head behind the log, which recovery detects and repairs; the
|
|
397
|
+
* reverse order would look exactly like a truncation.
|
|
398
|
+
*/
|
|
399
|
+
function writeHead(dir, head, opts = {}) {
|
|
400
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
401
|
+
writeJsonAtomic(headPathFor(dir), head, HEAD_FILE_MODE, opts.sync !== false, true);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Advances the floor anchor, and only ever upwards.
|
|
405
|
+
*
|
|
406
|
+
* A floor that went backwards would withdraw a claim the log has already made,
|
|
407
|
+
* which is precisely the truncation this exists to detect. The write happens
|
|
408
|
+
* after `writeHead`, so a crash can only leave the floor *behind* the log — which
|
|
409
|
+
* costs detection of nothing — never ahead of it.
|
|
410
|
+
*
|
|
411
|
+
* Refuses to write over another chain's floor: that is a key rotation or a
|
|
412
|
+
* re-initialisation, and silently discarding the old chain's claim would make
|
|
413
|
+
* the audit trail of the previous chain unverifiable.
|
|
414
|
+
*
|
|
415
|
+
* @returns true when the floor moved.
|
|
416
|
+
*/
|
|
417
|
+
function writeHeadFloor(auditDir, head, opts = {}) {
|
|
418
|
+
if (!isSeq(head.seq) || head.seq < 1)
|
|
419
|
+
return false;
|
|
420
|
+
const target = floorPathFor(auditDir);
|
|
421
|
+
const current = readHeadFile(target);
|
|
422
|
+
if (current) {
|
|
423
|
+
if (current.chain_id !== head.chain_id) {
|
|
424
|
+
throw new Error(`${target} anchors chain ${current.chain_id} at seq ${current.seq}, but this installation signs ` +
|
|
425
|
+
`chain ${head.chain_id}. Refusing to discard another chain's anchor: restore that chain, or ` +
|
|
426
|
+
`delete ${target} if the key was rotated deliberately and the old log is being abandoned.`);
|
|
427
|
+
}
|
|
428
|
+
if (current.seq >= head.seq)
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
writeJsonAtomic(target, head, FLOOR_FILE_MODE, opts.sync !== false, false);
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Writes one anchor file atomically: a private temp file, then a rename over the
|
|
436
|
+
* old one, so a reader never observes a half-written anchor.
|
|
437
|
+
*/
|
|
438
|
+
function writeJsonAtomic(target, value, mode, sync, fsyncParent) {
|
|
439
|
+
const dir = path.dirname(target);
|
|
440
|
+
const tmp = `${target}.${process.pid}.${crypto.randomBytes(4).toString('hex')}.tmp`;
|
|
441
|
+
let fd = null;
|
|
442
|
+
try {
|
|
443
|
+
fd = fs.openSync(tmp, 'wx', mode);
|
|
444
|
+
fs.writeFileSync(fd, JSON.stringify(value) + '\n', 'utf8');
|
|
445
|
+
if (sync)
|
|
446
|
+
fs.fsyncSync(fd);
|
|
447
|
+
}
|
|
448
|
+
catch (err) {
|
|
449
|
+
if (fd !== null) {
|
|
450
|
+
// eslint-disable-next-line no-empty
|
|
451
|
+
try {
|
|
452
|
+
fs.closeSync(fd);
|
|
453
|
+
}
|
|
454
|
+
catch { }
|
|
455
|
+
}
|
|
456
|
+
// eslint-disable-next-line no-empty
|
|
457
|
+
try {
|
|
458
|
+
fs.unlinkSync(tmp);
|
|
459
|
+
}
|
|
460
|
+
catch { }
|
|
461
|
+
throw err;
|
|
462
|
+
}
|
|
463
|
+
if (fd !== null)
|
|
464
|
+
fs.closeSync(fd);
|
|
465
|
+
fs.chmodSync(tmp, mode);
|
|
466
|
+
fs.renameSync(tmp, target);
|
|
467
|
+
if (sync && fsyncParent)
|
|
468
|
+
fsyncDir(dir);
|
|
469
|
+
}
|
|
470
|
+
/** fsync a directory so a rename is durable. Best effort: not supported everywhere. */
|
|
471
|
+
function fsyncDir(dir) {
|
|
472
|
+
let dfd = null;
|
|
473
|
+
try {
|
|
474
|
+
dfd = fs.openSync(dir, 'r');
|
|
475
|
+
fs.fsyncSync(dfd);
|
|
476
|
+
}
|
|
477
|
+
catch {
|
|
478
|
+
// Directory fsync is unsupported on some platforms; the rename is still atomic.
|
|
479
|
+
}
|
|
480
|
+
finally {
|
|
481
|
+
if (dfd !== null) {
|
|
482
|
+
// eslint-disable-next-line no-empty
|
|
483
|
+
try {
|
|
484
|
+
fs.closeSync(dfd);
|
|
485
|
+
}
|
|
486
|
+
catch { }
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Combines every available claim about the end of the chain.
|
|
492
|
+
*
|
|
493
|
+
* Two claims at the same `seq` that disagree on `chain_id` or `last_hash` are a
|
|
494
|
+
* contradiction, not a tie to break: the caller must fail closed rather than pick
|
|
495
|
+
* one. Different sequence numbers are not a contradiction — an older anchor is
|
|
496
|
+
* simply a weaker claim — but the retention floor is carried over from whichever
|
|
497
|
+
* claim has one, because it says where the log starts, not where it ends.
|
|
498
|
+
*/
|
|
499
|
+
function resolveAnchor(claims) {
|
|
500
|
+
let anchor = null;
|
|
501
|
+
let anchorSource = null;
|
|
502
|
+
let conflict = null;
|
|
503
|
+
const sources = [];
|
|
504
|
+
for (const { head, source } of claims) {
|
|
505
|
+
if (!head)
|
|
506
|
+
continue;
|
|
507
|
+
sources.push(source);
|
|
508
|
+
const current = anchor;
|
|
509
|
+
const floor = retentionFloorOf(current);
|
|
510
|
+
if (current !== null &&
|
|
511
|
+
head.seq === current.seq &&
|
|
512
|
+
(head.chain_id !== current.chain_id || head.last_hash !== current.last_hash)) {
|
|
513
|
+
conflict =
|
|
514
|
+
conflict ??
|
|
515
|
+
`anchors disagree at seq ${head.seq}: ${source} holds ${head.last_hash} but the chain was already ` +
|
|
516
|
+
`anchored at ${current.last_hash}`;
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
if (current === null || head.seq > current.seq) {
|
|
520
|
+
anchor = withRetentionFloor(head, floor);
|
|
521
|
+
anchorSource = source;
|
|
522
|
+
}
|
|
523
|
+
else if (floor === undefined && head.retained_from_seq !== undefined) {
|
|
524
|
+
anchor = withRetentionFloor(current, head.retained_from_seq);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return { anchor, anchorSource, conflict, sources };
|
|
528
|
+
}
|
|
529
|
+
function retentionFloorOf(head) {
|
|
530
|
+
return head === null ? undefined : head.retained_from_seq;
|
|
531
|
+
}
|
|
532
|
+
function withRetentionFloor(head, floor) {
|
|
533
|
+
return floor === undefined ? { ...head } : { ...head, retained_from_seq: floor };
|
|
534
|
+
}
|
|
535
|
+
/* ------------------------------------------------------------------ */
|
|
536
|
+
/* Record MAC */
|
|
537
|
+
/* ------------------------------------------------------------------ */
|
|
538
|
+
/**
|
|
539
|
+
* Marker for a value `JSON.stringify` has no representation for at all. It is
|
|
540
|
+
* not an encoded value: a property holding it is dropped, an array element
|
|
541
|
+
* holding it becomes `null`, exactly as the transport does.
|
|
542
|
+
*/
|
|
543
|
+
const OMITTED = Symbol('audit.canonical.omitted');
|
|
544
|
+
/** Applies `toJSON` once, as `JSON.stringify` does, before any other test. */
|
|
545
|
+
function jsonViewOf(value, key) {
|
|
546
|
+
const toJSON = value.toJSON;
|
|
547
|
+
return typeof toJSON === 'function' ? toJSON.call(value, key) : value;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* One level of the canonical encoding, keyed by the property name (or the
|
|
551
|
+
* decimal array index) so a `toJSON` that reads its key behaves as it will on
|
|
552
|
+
* disk. Returns {@link OMITTED} for a value the transport cannot carry.
|
|
553
|
+
*/
|
|
554
|
+
function canonicalEncode(value, key) {
|
|
555
|
+
const json = value !== null && typeof value === 'object' ? jsonViewOf(value, key) : value;
|
|
556
|
+
if (json === undefined || typeof json === 'function' || typeof json === 'symbol')
|
|
557
|
+
return OMITTED;
|
|
558
|
+
if (json === null)
|
|
559
|
+
return 'null';
|
|
560
|
+
if (typeof json !== 'object')
|
|
561
|
+
return JSON.stringify(json);
|
|
562
|
+
if (Array.isArray(json)) {
|
|
563
|
+
const items = [];
|
|
564
|
+
for (let i = 0; i < json.length; i++) {
|
|
565
|
+
const encoded = canonicalEncode(json[i], String(i));
|
|
566
|
+
items.push(encoded === OMITTED ? 'null' : encoded);
|
|
567
|
+
}
|
|
568
|
+
return '[' + items.join(',') + ']';
|
|
569
|
+
}
|
|
570
|
+
const record = json;
|
|
571
|
+
const pairs = [];
|
|
572
|
+
for (const k of Object.keys(record).sort()) {
|
|
573
|
+
const encoded = canonicalEncode(record[k], k);
|
|
574
|
+
if (encoded === OMITTED)
|
|
575
|
+
continue;
|
|
576
|
+
pairs.push(JSON.stringify(k) + ':' + encoded);
|
|
577
|
+
}
|
|
578
|
+
return '{' + pairs.join(',') + '}';
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Deterministic canonical JSON encoding used as MAC input.
|
|
582
|
+
*
|
|
583
|
+
* Determinism is required — writer and verifier must agree byte for byte — and
|
|
584
|
+
* it is also why naive recomputation of a chain is trivial: the algorithm is
|
|
585
|
+
* public and the input is public. That is precisely why the *key*, not this
|
|
586
|
+
* encoding, is the control. This function makes a record reproducible by a key
|
|
587
|
+
* holder and unforgeable for anyone else.
|
|
588
|
+
*
|
|
589
|
+
* The invariant this encoding exists to hold:
|
|
590
|
+
*
|
|
591
|
+
* > the bytes MACed are exactly the bytes that will be read back
|
|
592
|
+
*
|
|
593
|
+
* The log file is the transport, so wherever the canonical form and
|
|
594
|
+
* `JSON.stringify` disagreed the disagreement was resolved in favour of
|
|
595
|
+
* `JSON.stringify`:
|
|
596
|
+
* - a property whose value is `undefined` (or a function or a symbol) is
|
|
597
|
+
* **omitted**, not encoded as `''` — the key never reaches the file, so
|
|
598
|
+
* re-canonicalising the parsed record must not invent one
|
|
599
|
+
* - `undefined` in an array becomes `null`, holes included
|
|
600
|
+
* - an explicit `null` is kept, because it is a meaningful audit value and
|
|
601
|
+
* stays distinguishable from the field being absent
|
|
602
|
+
* - `toJSON` is honoured, so a `Date` encodes as the ISO string the file
|
|
603
|
+
* will hold
|
|
604
|
+
*
|
|
605
|
+
* The first two are not cosmetic. Encoding `undefined` as `''` MACs a record
|
|
606
|
+
* the JSON round trip cannot reproduce, so a correctly chained log is reported
|
|
607
|
+
* as `mac_mismatch` — a genuine artifact called tampered, which destroys the
|
|
608
|
+
* evidentiary value of the only control that says the agent did what it claims.
|
|
609
|
+
*
|
|
610
|
+
* Normalising here rather than stripping `undefined` at the call sites is what
|
|
611
|
+
* makes the invariant structural rather than a convention: {@link computeMac}
|
|
612
|
+
* is the sole producer of MAC input and it calls this function, so the writer
|
|
613
|
+
* and every verifier — including one reading an existing file — run the same
|
|
614
|
+
* code and cannot drift. A value JSON cannot represent even in principle (a
|
|
615
|
+
* `BigInt`) throws here exactly as it throws on the write path.
|
|
616
|
+
*/
|
|
617
|
+
function canonicalStringify(value) {
|
|
618
|
+
const encoded = canonicalEncode(value, '');
|
|
619
|
+
// Only reachable when called at the top level; inside a container the value
|
|
620
|
+
// is omitted from its parent rather than encoded on its own.
|
|
621
|
+
return encoded === OMITTED ? '' : encoded;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Strips the MAC fields so the remaining record can be canonicalised.
|
|
625
|
+
*
|
|
626
|
+
* `mac` and `hash` are the only fields removed here, and they are top-level by
|
|
627
|
+
* construction, so this copy is enough. Fields whose value is `undefined` are
|
|
628
|
+
* deliberately **left in place**: {@link canonicalStringify} omits them, which is
|
|
629
|
+
* the same rule `JSON.stringify` applies to the bytes on disk, so keeping them
|
|
630
|
+
* here cannot make the MAC disagree with what a verifier reads back.
|
|
631
|
+
*/
|
|
632
|
+
function macInputOf(event) {
|
|
633
|
+
const rest = { ...event };
|
|
634
|
+
delete rest.mac;
|
|
635
|
+
delete rest.hash;
|
|
636
|
+
return rest;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* `HMAC-SHA256(key, canonical(record) || prev_hash)`.
|
|
640
|
+
*
|
|
641
|
+
* Requires the installation key; there is no unkeyed variant.
|
|
642
|
+
*/
|
|
643
|
+
function computeMac(event, key) {
|
|
644
|
+
const k = requireKeyBytes(key);
|
|
645
|
+
const input = canonicalStringify(macInputOf(event)) + event.prev_hash;
|
|
646
|
+
return crypto.createHmac('sha256', k).update(input, 'utf8').digest('hex');
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Backwards-compatible alias of {@link computeMac}. Retained because it is part
|
|
650
|
+
* of the published package API. The key argument is required: there is no
|
|
651
|
+
* unkeyed fallback.
|
|
652
|
+
*/
|
|
653
|
+
function computeHash(event, key) {
|
|
654
|
+
return computeMac(event, key);
|
|
655
|
+
}
|
|
656
|
+
/** Verifies one record in place. Returns null when it verifies, else the reason. */
|
|
657
|
+
function verifyEventMac(event, key) {
|
|
658
|
+
if (!isHash64(event.mac) && typeof event.mac !== 'string')
|
|
659
|
+
return 'record has no mac';
|
|
660
|
+
if (event.hash !== event.mac)
|
|
661
|
+
return 'hash/mac alias mismatch';
|
|
662
|
+
if (!isSeq(event.seq))
|
|
663
|
+
return 'record has no usable seq';
|
|
664
|
+
if (typeof event.chain_id !== 'string' || event.chain_id.length === 0)
|
|
665
|
+
return 'record has no chain_id';
|
|
666
|
+
if (!isHash64(event.prev_hash))
|
|
667
|
+
return 'record has no prev_hash';
|
|
668
|
+
const expected = computeMac(macInputOf(event), key);
|
|
669
|
+
return expected === event.mac ? null : 'mac does not match';
|
|
670
|
+
}
|
|
671
|
+
function fail(reason, events, extra = {}) {
|
|
672
|
+
return {
|
|
673
|
+
intact: false,
|
|
674
|
+
reason,
|
|
675
|
+
events,
|
|
676
|
+
detail: extra.detail,
|
|
677
|
+
brokenAt: extra.brokenAt,
|
|
678
|
+
observed: extra.observed,
|
|
679
|
+
verified_from_seq: extra.verifiedFromSeq,
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
function resolveKey(opts) {
|
|
683
|
+
if (opts.key !== undefined && opts.key !== null) {
|
|
684
|
+
return requireKeyBytes(opts.key);
|
|
685
|
+
}
|
|
686
|
+
const found = tryLoadAuditKey({ dir: opts.dir, create: false });
|
|
687
|
+
return found ? found.key : null;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Incremental, early-exit chain verifier. Holds only the previous record's
|
|
691
|
+
* mac/seq, so memory is O(1) regardless of log size (audit finding M-06).
|
|
692
|
+
*/
|
|
693
|
+
class ChainVerifier {
|
|
694
|
+
key;
|
|
695
|
+
prev;
|
|
696
|
+
expectedSeq;
|
|
697
|
+
count = 0;
|
|
698
|
+
failure = null;
|
|
699
|
+
chainId;
|
|
700
|
+
lastSeq = 0;
|
|
701
|
+
lastMac = exports.GENESIS_HASH;
|
|
702
|
+
/** Sequence number of the first record in the window; 1 means from genesis. */
|
|
703
|
+
windowStartSeq;
|
|
704
|
+
/**
|
|
705
|
+
* True when the window starts after seq 1 and no explicit `expectedPrevHash`
|
|
706
|
+
* was supplied, so the first record's own `prev_hash` has to be adopted. The
|
|
707
|
+
* evicted prefix is gone, so its linkage cannot be re-checked — but the first
|
|
708
|
+
* record's MAC covers its own `prev_hash`, so nothing inside the window is
|
|
709
|
+
* left unverified.
|
|
710
|
+
*/
|
|
711
|
+
adoptFirstPrevHash;
|
|
712
|
+
constructor(key, opts = {}) {
|
|
713
|
+
this.key = requireKeyBytes(key);
|
|
714
|
+
this.prev = opts.expectedPrevHash ?? exports.GENESIS_HASH;
|
|
715
|
+
this.expectedSeq = opts.expectedSeq ?? 1;
|
|
716
|
+
this.windowStartSeq = this.expectedSeq;
|
|
717
|
+
this.adoptFirstPrevHash = opts.expectedPrevHash === undefined && this.expectedSeq > 1;
|
|
718
|
+
this.chainId = opts.chainId ?? null;
|
|
719
|
+
}
|
|
720
|
+
/** Records pushed so far. */
|
|
721
|
+
get events() {
|
|
722
|
+
return this.count;
|
|
723
|
+
}
|
|
724
|
+
/** True once any record has failed verification. */
|
|
725
|
+
get failed() {
|
|
726
|
+
return this.failure !== null;
|
|
727
|
+
}
|
|
728
|
+
/** Adds a record. Records after the first failure are ignored. */
|
|
729
|
+
push(event) {
|
|
730
|
+
if (this.failure)
|
|
731
|
+
return;
|
|
732
|
+
const at = this.count;
|
|
733
|
+
this.count++;
|
|
734
|
+
if (typeof event !== 'object' || event === null || Array.isArray(event)) {
|
|
735
|
+
this.failure = fail('malformed', this.count, {
|
|
736
|
+
brokenAt: at,
|
|
737
|
+
detail: 'record is not an object',
|
|
738
|
+
});
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const ev = event;
|
|
742
|
+
if (!isHash64(ev.prev_hash)) {
|
|
743
|
+
this.failure = fail('malformed', this.count, {
|
|
744
|
+
brokenAt: at,
|
|
745
|
+
detail: 'record has no prev_hash',
|
|
746
|
+
});
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
if (typeof ev.seq !== 'number' || !isSeq(ev.seq) || ev.seq < 1) {
|
|
750
|
+
this.failure = fail('malformed', this.count, {
|
|
751
|
+
brokenAt: at,
|
|
752
|
+
detail: 'record has no usable seq',
|
|
753
|
+
});
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (typeof ev.chain_id !== 'string' || ev.chain_id.length === 0) {
|
|
757
|
+
this.failure = fail('malformed', this.count, {
|
|
758
|
+
brokenAt: at,
|
|
759
|
+
detail: 'record has no chain_id',
|
|
760
|
+
});
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
if (this.chainId === null) {
|
|
764
|
+
this.chainId = ev.chain_id;
|
|
765
|
+
}
|
|
766
|
+
else if (ev.chain_id !== this.chainId) {
|
|
767
|
+
this.failure = fail('chain_id_mismatch', this.count, {
|
|
768
|
+
brokenAt: at,
|
|
769
|
+
detail: `record ${at} belongs to chain ${ev.chain_id}, expected ${this.chainId}`,
|
|
770
|
+
});
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
if (ev.seq !== this.expectedSeq) {
|
|
774
|
+
const belowWindow = ev.seq < this.windowStartSeq;
|
|
775
|
+
const regressed = belowWindow || ev.seq < this.lastSeq;
|
|
776
|
+
const reason = regressed
|
|
777
|
+
? ev.seq === this.lastSeq
|
|
778
|
+
? 'seq_duplicate'
|
|
779
|
+
: 'seq_regression'
|
|
780
|
+
: ev.seq < this.lastSeq
|
|
781
|
+
? 'seq_regression'
|
|
782
|
+
: 'seq_gap';
|
|
783
|
+
this.failure = fail(reason, this.count, {
|
|
784
|
+
brokenAt: at,
|
|
785
|
+
detail: `record ${at} carries seq ${ev.seq}, expected ${this.expectedSeq}`,
|
|
786
|
+
verifiedFromSeq: this.windowStartSeq,
|
|
787
|
+
});
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
if (this.adoptFirstPrevHash && at === 0) {
|
|
791
|
+
// Retention window: the record before this one has been evicted on purpose.
|
|
792
|
+
this.prev = ev.prev_hash;
|
|
793
|
+
}
|
|
794
|
+
else if (ev.prev_hash !== this.prev) {
|
|
795
|
+
this.failure = fail('prev_hash_mismatch', this.count, {
|
|
796
|
+
brokenAt: at,
|
|
797
|
+
detail: `record ${at} does not chain from the previous record`,
|
|
798
|
+
verifiedFromSeq: this.windowStartSeq,
|
|
799
|
+
});
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if (typeof ev.mac !== 'string' || !isHash64(ev.mac)) {
|
|
803
|
+
this.failure = fail('malformed', this.count, { brokenAt: at, detail: 'record has no mac' });
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
if (ev.hash !== ev.mac) {
|
|
807
|
+
this.failure = fail('malformed', this.count, {
|
|
808
|
+
brokenAt: at,
|
|
809
|
+
detail: 'legacy hash alias disagrees with mac',
|
|
810
|
+
});
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
let expected;
|
|
814
|
+
try {
|
|
815
|
+
expected = computeMac(macInputOf(ev), this.key);
|
|
816
|
+
}
|
|
817
|
+
catch (err) {
|
|
818
|
+
this.failure = fail('malformed', this.count, {
|
|
819
|
+
brokenAt: at,
|
|
820
|
+
detail: `record ${at} could not be verified: ${String(err)}`,
|
|
821
|
+
});
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
if (expected !== ev.mac) {
|
|
825
|
+
this.failure = fail('mac_mismatch', this.count, {
|
|
826
|
+
brokenAt: at,
|
|
827
|
+
detail: `record ${at} does not match its mac`,
|
|
828
|
+
});
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
this.prev = ev.mac;
|
|
832
|
+
this.lastSeq = ev.seq;
|
|
833
|
+
this.lastMac = ev.mac;
|
|
834
|
+
this.expectedSeq = ev.seq + 1;
|
|
835
|
+
}
|
|
836
|
+
/** The head observed so far, or `null` when nothing has been verified. */
|
|
837
|
+
observedHead() {
|
|
838
|
+
if (this.failure || this.chainId === null || this.lastSeq === 0)
|
|
839
|
+
return null;
|
|
840
|
+
return {
|
|
841
|
+
v: 1,
|
|
842
|
+
chain_id: this.chainId,
|
|
843
|
+
seq: this.lastSeq,
|
|
844
|
+
last_hash: this.lastMac,
|
|
845
|
+
written_at: '',
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Final result. When `expectedHead` is supplied the observed head must match
|
|
850
|
+
* it exactly, which is what makes truncation, deletion and rollback visible.
|
|
851
|
+
*/
|
|
852
|
+
result(expectedHead) {
|
|
853
|
+
if (this.failure)
|
|
854
|
+
return this.failure;
|
|
855
|
+
if (this.count === 0) {
|
|
856
|
+
return fail('empty', 0, { detail: 'no records to verify' });
|
|
857
|
+
}
|
|
858
|
+
const observed = this.observedHead();
|
|
859
|
+
const from = this.windowStartSeq > 1 ? this.windowStartSeq : undefined;
|
|
860
|
+
if (!expectedHead) {
|
|
861
|
+
return { intact: true, events: this.count, observed, verified_from_seq: from };
|
|
862
|
+
}
|
|
863
|
+
if (expectedHead.chain_id !== observed.chain_id) {
|
|
864
|
+
return fail('head_mismatch', this.count, {
|
|
865
|
+
detail: `head belongs to chain ${expectedHead.chain_id}, log holds ${observed.chain_id}`,
|
|
866
|
+
observed,
|
|
867
|
+
verifiedFromSeq: from,
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
if (expectedHead.seq > observed.seq) {
|
|
871
|
+
return fail('seq_regression', this.count, {
|
|
872
|
+
detail: `head expects at least seq ${expectedHead.seq} but the log ends at seq ${observed.seq}`,
|
|
873
|
+
observed,
|
|
874
|
+
verifiedFromSeq: from,
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
if (expectedHead.seq < observed.seq) {
|
|
878
|
+
return fail('head_mismatch', this.count, {
|
|
879
|
+
detail: `log ends at seq ${observed.seq}, ahead of the anchored head at ${expectedHead.seq}`,
|
|
880
|
+
observed,
|
|
881
|
+
verifiedFromSeq: from,
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
if (expectedHead.last_hash !== observed.last_hash) {
|
|
885
|
+
return fail('head_mismatch', this.count, {
|
|
886
|
+
detail: `record at seq ${observed.seq} does not match the anchored head`,
|
|
887
|
+
observed,
|
|
888
|
+
verifiedFromSeq: from,
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
return { intact: true, events: this.count, observed, verified_from_seq: from };
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
exports.ChainVerifier = ChainVerifier;
|
|
895
|
+
/**
|
|
896
|
+
* Verifies an ordered window of records across the whole log, in chronological
|
|
897
|
+
* order — never per rotated file with a fresh genesis, which is what made
|
|
898
|
+
* routine rotation look like tampering (audit finding H-13).
|
|
899
|
+
*
|
|
900
|
+
* What an intact result proves, and only this:
|
|
901
|
+
* - no record in the window was modified, inserted, removed or reordered
|
|
902
|
+
* without the installation key
|
|
903
|
+
* - the sequence numbers are contiguous, so nothing was dropped in the middle
|
|
904
|
+
* - the tail matches the supplied head, so the log was not truncated, deleted
|
|
905
|
+
* or rolled back past the anchor
|
|
906
|
+
*
|
|
907
|
+
* What it does **not** prove:
|
|
908
|
+
* - that this agent wrote the records: there is a MAC, not a signature, so any
|
|
909
|
+
* process holding the key can produce a verifying chain
|
|
910
|
+
* - legal attribution — there is no signing identity and no third-party time
|
|
911
|
+
* source, so a record cannot be tied to a person in a dispute
|
|
912
|
+
* - anything against an attacker who can write the log *and* both anchors (and
|
|
913
|
+
* who does not hold the key). Keep a copy of the head you cannot rewrite, and
|
|
914
|
+
* keep the key out of reach of the log.
|
|
915
|
+
*
|
|
916
|
+
* An empty window is **never** intact: "nothing to check" is not "verified".
|
|
917
|
+
*/
|
|
918
|
+
function verifyChain(events, opts = {}) {
|
|
919
|
+
if (!Array.isArray(events) || events.length === 0) {
|
|
920
|
+
return fail('empty', 0, { detail: 'no records to verify' });
|
|
921
|
+
}
|
|
922
|
+
let key;
|
|
923
|
+
try {
|
|
924
|
+
key = resolveKey(opts);
|
|
925
|
+
}
|
|
926
|
+
catch (err) {
|
|
927
|
+
return fail('key_unavailable', events.length, { detail: String(err) });
|
|
928
|
+
}
|
|
929
|
+
if (!key) {
|
|
930
|
+
return fail('key_unavailable', events.length, {
|
|
931
|
+
detail: `no audit key available (${exports.AUDIT_KEY_ENV} or ${exports.AUDIT_KEY_FILENAME}); cannot verify`,
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
const verifier = new ChainVerifier(key, {
|
|
935
|
+
chainId: opts.chainId,
|
|
936
|
+
expectedSeq: opts.expectedSeq ?? opts.head?.retained_from_seq ?? 1,
|
|
937
|
+
expectedPrevHash: opts.expectedPrevHash,
|
|
938
|
+
});
|
|
939
|
+
for (const event of events) {
|
|
940
|
+
verifier.push(event);
|
|
941
|
+
if (verifier.failed)
|
|
942
|
+
break;
|
|
943
|
+
}
|
|
944
|
+
return verifier.result(opts.head ?? null);
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Verifies the log against the head the operator expects (from `head.json`).
|
|
948
|
+
* Thin wrapper over {@link verifyChain} that makes the anchor mandatory in the
|
|
949
|
+
* type signature, so a caller cannot accidentally verify a log against itself.
|
|
950
|
+
*/
|
|
951
|
+
function verifyChainAgainstHead(events, head, opts = {}) {
|
|
952
|
+
if (!head) {
|
|
953
|
+
return fail('head_missing', Array.isArray(events) ? events.length : 0, {
|
|
954
|
+
detail: `no head anchor available (${exports.AUDIT_HEAD_FILENAME}); truncation and rollback cannot be detected`,
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
return verifyChain(events, { ...opts, head });
|
|
958
|
+
}
|
|
959
|
+
//# sourceMappingURL=chain.js.map
|