@claude-flow/cli 3.32.29 → 3.32.30
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/.claude/helpers/helpers.manifest.json +2 -2
- package/catalog-manifest.json +2 -2
- package/dist/src/init/claudemd-generator.js +53 -2
- package/dist/src/mcp-tools/capability-brain.js +22 -22
- package/dist/src/mcp-tools/guidance-tools.js +1 -1
- package/node_modules/@claude-flow/codex/.agents/skills/memory-management/SKILL.md +45 -0
- package/node_modules/@claude-flow/codex/.agents/skills/security-audit/SKILL.md +46 -0
- package/node_modules/@claude-flow/codex/.agents/skills/sparc-methodology/SKILL.md +46 -0
- package/node_modules/@claude-flow/codex/.agents/skills/swarm-orchestration/SKILL.md +53 -0
- package/node_modules/@claude-flow/codex/README.md +1044 -0
- package/node_modules/@claude-flow/codex/dist/cli.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/cli.js +686 -0
- package/node_modules/@claude-flow/codex/dist/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts +17 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js +278 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts +8 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.js +7 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts +143 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js +621 -0
- package/node_modules/@claude-flow/codex/dist/dual-mode/orchestrator.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts +12 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js +730 -0
- package/node_modules/@claude-flow/codex/dist/generators/agents-md.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts +74 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.js +922 -0
- package/node_modules/@claude-flow/codex/dist/generators/config-toml.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.js +9 -0
- package/node_modules/@claude-flow/codex/dist/generators/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts +20 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +951 -0
- package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts +46 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js +126 -0
- package/node_modules/@claude-flow/codex/dist/harness/build-evidence.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts +153 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.js +44 -0
- package/node_modules/@claude-flow/codex/dist/harness/contract.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts +33 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js +175 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-fenced-lease-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts +42 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js +140 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-inbox-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts +19 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js +79 -0
- package/node_modules/@claude-flow/codex/dist/harness/in-memory-run-receipt-reference.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.d.ts +9 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.js +9 -0
- package/node_modules/@claude-flow/codex/dist/harness/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts +8 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js +10 -0
- package/node_modules/@claude-flow/codex/dist/harness/portable-case-fold.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts +68 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.js +403 -0
- package/node_modules/@claude-flow/codex/dist/harness/repository-state.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts +3 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js +14 -0
- package/node_modules/@claude-flow/codex/dist/harness/unsigned-integer.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/index.d.ts +53 -0
- package/node_modules/@claude-flow/codex/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/index.js +54 -0
- package/node_modules/@claude-flow/codex/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/initializer.d.ts +98 -0
- package/node_modules/@claude-flow/codex/dist/initializer.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/initializer.js +795 -0
- package/node_modules/@claude-flow/codex/dist/initializer.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts +3 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.js +123 -0
- package/node_modules/@claude-flow/codex/dist/loop/cli.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.d.ts +58 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.js +230 -0
- package/node_modules/@claude-flow/codex/dist/loop/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts +28 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.js +121 -0
- package/node_modules/@claude-flow/codex/dist/mcp-config.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts +114 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.js +880 -0
- package/node_modules/@claude-flow/codex/dist/migrations/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.d.ts +92 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.js +284 -0
- package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/types.d.ts +240 -0
- package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/types.js +8 -0
- package/node_modules/@claude-flow/codex/dist/types.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.d.ts +42 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.js +929 -0
- package/node_modules/@claude-flow/codex/dist/validators/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts +37 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js +137 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/coordinator.js.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts +2 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.js +2 -0
- package/node_modules/@claude-flow/codex/dist/worktrees/index.js.map +1 -0
- package/node_modules/@claude-flow/codex/package.json +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/README.md +49 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts +130 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js +239 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/agent-card.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts +34 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js +69 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/consume.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts +46 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js +84 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/a2a/well-known.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts +27 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js +46 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/claim-checker.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts +192 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js +253 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-breaker-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts +211 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js +501 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/federation-coordinator.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts +114 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js +356 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/inbound-dispatcher.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts +41 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js +184 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/policy-engine.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts +150 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js +128 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/spend-reporter.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts +74 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js +179 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/application/trust-evaluator.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts +13 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +189 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts +7 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js +317 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/cli-commands.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts +45 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js +71 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-envelope.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts +104 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js +152 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-node.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts +55 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js +105 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/federation-session.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts +17 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js +35 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/entities/trust-level.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts +69 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js +149 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/audit-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts +68 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js +161 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/discovery-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts +58 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/handshake-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts +65 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js +208 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/pii-pipeline-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts +51 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js +147 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/routing-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts +71 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js +194 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-firewall-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts +156 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js +292 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-mesh-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts +98 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js +122 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/services/wg-witness-service.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts +89 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js +165 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-budget.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts +92 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js +100 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/federation-node-state.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts +70 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js +104 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/domain/value-objects/wg-config.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts +23 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js +24 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts +10 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js +439 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/mcp-tools.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts +19 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js +515 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/plugin.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts +72 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js +269 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/transport/midstream-aware-loader.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts +3 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.d.ts.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js +3 -0
- package/node_modules/@claude-flow/plugin-agent-federation/dist/version.js.map +1 -0
- package/node_modules/@claude-flow/plugin-agent-federation/package.json +64 -0
- package/node_modules/@claude-flow/security/README.md +292 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts +97 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js +537 -0
- package/node_modules/@claude-flow/security/dist/CVE-REMEDIATION.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/index.d.ts +7 -0
- package/node_modules/@claude-flow/security/dist/application/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/index.js +7 -0
- package/node_modules/@claude-flow/security/dist/application/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts +71 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js +153 -0
- package/node_modules/@claude-flow/security/dist/application/services/security-application-service.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts +148 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.js +182 -0
- package/node_modules/@claude-flow/security/dist/authorization/propagator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.d.ts +176 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.js +272 -0
- package/node_modules/@claude-flow/security/dist/credential-generator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts +68 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js +132 -0
- package/node_modules/@claude-flow/security/dist/domain/entities/security-context.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/index.d.ts +8 -0
- package/node_modules/@claude-flow/security/dist/domain/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/index.js +8 -0
- package/node_modules/@claude-flow/security/dist/domain/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts +71 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js +237 -0
- package/node_modules/@claude-flow/security/dist/domain/services/security-domain-service.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/index.d.ts +129 -0
- package/node_modules/@claude-flow/security/dist/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/index.js +176 -0
- package/node_modules/@claude-flow/security/dist/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts +306 -0
- package/node_modules/@claude-flow/security/dist/input-validator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/input-validator.js +393 -0
- package/node_modules/@claude-flow/security/dist/input-validator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts +48 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.js +0 -0
- package/node_modules/@claude-flow/security/dist/keychain-adapter.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts +133 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js +254 -0
- package/node_modules/@claude-flow/security/dist/mcp-composition-inspector.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts +31 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.js +55 -0
- package/node_modules/@claude-flow/security/dist/oauth/browser.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts +37 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.js +86 -0
- package/node_modules/@claude-flow/security/dist/oauth/callback-server.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.d.ts +57 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.js +120 -0
- package/node_modules/@claude-flow/security/dist/oauth/client.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts +25 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.js +36 -0
- package/node_modules/@claude-flow/security/dist/oauth/pkce.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.d.ts +128 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.js +190 -0
- package/node_modules/@claude-flow/security/dist/password-hasher.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts +148 -0
- package/node_modules/@claude-flow/security/dist/path-validator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/path-validator.js +421 -0
- package/node_modules/@claude-flow/security/dist/path-validator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts +125 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js +186 -0
- package/node_modules/@claude-flow/security/dist/plugins/integrity-verifier.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts +5 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.js +30 -0
- package/node_modules/@claude-flow/security/dist/policy/canonical.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.d.ts +34 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.js +285 -0
- package/node_modules/@claude-flow/security/dist/policy/engine.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts +9 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.js +90 -0
- package/node_modules/@claude-flow/security/dist/policy/envelope.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts +4 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.js +119 -0
- package/node_modules/@claude-flow/security/dist/policy/evaluator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/index.d.ts +7 -0
- package/node_modules/@claude-flow/security/dist/policy/index.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/index.js +7 -0
- package/node_modules/@claude-flow/security/dist/policy/index.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts +238 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.js +1022 -0
- package/node_modules/@claude-flow/security/dist/policy/product-plane.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/types.d.ts +169 -0
- package/node_modules/@claude-flow/security/dist/policy/types.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/policy/types.js +2 -0
- package/node_modules/@claude-flow/security/dist/policy/types.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.d.ts +180 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.js +390 -0
- package/node_modules/@claude-flow/security/dist/safe-executor.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/token-generator.d.ts +224 -0
- package/node_modules/@claude-flow/security/dist/token-generator.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/token-generator.js +351 -0
- package/node_modules/@claude-flow/security/dist/token-generator.js.map +1 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts +126 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.d.ts.map +1 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js +257 -0
- package/node_modules/@claude-flow/security/dist/tool-output-guardrail.js.map +1 -0
- package/node_modules/@claude-flow/security/package.json +44 -0
- package/package.json +24 -8
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for `auth.cognitum.one`'s OAuth surface (ADR-306): authorize
|
|
3
|
+
* URL construction, `POST /oauth/token` (`authorization_code` and
|
|
4
|
+
* `refresh_token` grants), and `POST /v1/oauth/code-exchange` (OOB fallback).
|
|
5
|
+
*
|
|
6
|
+
* A TypeScript port of meta-proxy's `src/oauth/client.rs`
|
|
7
|
+
* (cognitum-one/meta-proxy) — same base URL, same endpoints, same
|
|
8
|
+
* form/query parameter names, confirmed live 2026-07-16 (a real
|
|
9
|
+
* `GET /oauth/authorize?...&client_id=meta-proxy&redirect_uri=<ruflo-controlled
|
|
10
|
+
* loopback>` returns a working consent page, not a redirect_uri-mismatch
|
|
11
|
+
* error — so this client reuses meta-proxy's registered `client_id` rather
|
|
12
|
+
* than requiring a new one).
|
|
13
|
+
*
|
|
14
|
+
* Deliberately NOT `api.cognitum.one/v1/auth/*` — that's what ruflo's own
|
|
15
|
+
* checked-in OpenAPI spec (v3/docs/api/cognitum-v1.openapi.yaml, ADR-308)
|
|
16
|
+
* describes, but it does not match what the real identity server serves.
|
|
17
|
+
* This client targets the proven, live surface instead.
|
|
18
|
+
*
|
|
19
|
+
* @module v3/security/oauth/client
|
|
20
|
+
*/
|
|
21
|
+
export const CLIENT_ID = 'meta-proxy';
|
|
22
|
+
export const SCOPE = 'inference';
|
|
23
|
+
/** RFC 8252 out-of-band sentinel — the OOB/manual-paste flow's `redirect_uri`. */
|
|
24
|
+
export const OOB_REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
|
25
|
+
function authBaseUrl() {
|
|
26
|
+
const override = process.env.COGNITUM_AUTH_URL;
|
|
27
|
+
return override && override.trim() ? override : 'https://auth.cognitum.one';
|
|
28
|
+
}
|
|
29
|
+
export class OAuthError extends Error {
|
|
30
|
+
code;
|
|
31
|
+
oauthError;
|
|
32
|
+
oauthDescription;
|
|
33
|
+
constructor(message, code, oauthError, oauthDescription) {
|
|
34
|
+
super(message);
|
|
35
|
+
this.code = code;
|
|
36
|
+
this.oauthError = oauthError;
|
|
37
|
+
this.oauthDescription = oauthDescription;
|
|
38
|
+
this.name = 'OAuthError';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Builds the `/oauth/authorize` URL for the standard loopback-redirect flow. */
|
|
42
|
+
export function authorizeUrl(redirectUri, state, codeChallenge) {
|
|
43
|
+
const url = new URL(`${authBaseUrl()}/oauth/authorize`);
|
|
44
|
+
url.searchParams.set('response_type', 'code');
|
|
45
|
+
url.searchParams.set('client_id', CLIENT_ID);
|
|
46
|
+
url.searchParams.set('redirect_uri', redirectUri);
|
|
47
|
+
url.searchParams.set('scope', SCOPE);
|
|
48
|
+
url.searchParams.set('state', state);
|
|
49
|
+
url.searchParams.set('code_challenge', codeChallenge);
|
|
50
|
+
url.searchParams.set('code_challenge_method', 'S256');
|
|
51
|
+
return url.toString();
|
|
52
|
+
}
|
|
53
|
+
async function parseTokenResponse(resp) {
|
|
54
|
+
if (resp.ok) {
|
|
55
|
+
try {
|
|
56
|
+
return (await resp.json());
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
throw new OAuthError('unexpected response shape from the server', 'unexpected_shape');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const body = (await resp.json());
|
|
64
|
+
throw new OAuthError(`oauth error: ${body.error} — ${body.error_description}`, 'protocol', body.error, body.error_description);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
if (e instanceof OAuthError)
|
|
68
|
+
throw e;
|
|
69
|
+
throw new OAuthError('unexpected response shape from the server', 'unexpected_shape');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function postForm(path, form, base = authBaseUrl()) {
|
|
73
|
+
let resp;
|
|
74
|
+
try {
|
|
75
|
+
resp = await fetch(`${base}${path}`, {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
78
|
+
body: new URLSearchParams(form).toString(),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
throw new OAuthError(`network error: ${e instanceof Error ? e.message : String(e)}`, 'network');
|
|
83
|
+
}
|
|
84
|
+
return parseTokenResponse(resp);
|
|
85
|
+
}
|
|
86
|
+
/** `POST /oauth/token` with `grant_type=authorization_code`. */
|
|
87
|
+
export async function exchangeCode(code, codeVerifier, redirectUri, base = authBaseUrl()) {
|
|
88
|
+
return postForm('/oauth/token', { grant_type: 'authorization_code', code, code_verifier: codeVerifier, client_id: CLIENT_ID, redirect_uri: redirectUri }, base);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* `POST /oauth/token` with `grant_type=refresh_token`. identity rotates
|
|
92
|
+
* refresh tokens with reuse detection: presenting a refresh token returns a
|
|
93
|
+
* NEW refresh token and revokes the old one, and re-presenting a spent one
|
|
94
|
+
* revokes the whole session family. Callers MUST persist the returned
|
|
95
|
+
* `refresh_token` atomically before using the new access token, and must
|
|
96
|
+
* never retry a failed refresh with the same token.
|
|
97
|
+
*/
|
|
98
|
+
export async function refreshToken(refreshTokenValue, base = authBaseUrl()) {
|
|
99
|
+
return postForm('/oauth/token', { grant_type: 'refresh_token', refresh_token: refreshTokenValue, client_id: CLIENT_ID }, base);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* `POST /v1/oauth/code-exchange` — the OOB manual-entry fallback for
|
|
103
|
+
* headless/SSH/container environments where no browser round-trip to
|
|
104
|
+
* `127.0.0.1` is reachable.
|
|
105
|
+
*/
|
|
106
|
+
export async function exchangeManualCode(code, codeVerifier, base = authBaseUrl()) {
|
|
107
|
+
let resp;
|
|
108
|
+
try {
|
|
109
|
+
resp = await fetch(`${base}/v1/oauth/code-exchange`, {
|
|
110
|
+
method: 'POST',
|
|
111
|
+
headers: { 'content-type': 'application/json' },
|
|
112
|
+
body: JSON.stringify({ code, code_verifier: codeVerifier, client_id: CLIENT_ID }),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
throw new OAuthError(`network error: ${e instanceof Error ? e.message : String(e)}`, 'network');
|
|
117
|
+
}
|
|
118
|
+
return parseTokenResponse(resp);
|
|
119
|
+
}
|
|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,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;SAClF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,UAAU,CAAC,kBAAkB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.0 + PKCE (RFC 7636) client-side generation (ADR-306).
|
|
3
|
+
*
|
|
4
|
+
* A TypeScript port of meta-proxy's `src/oauth/pkce.rs` (cognitum-one/meta-proxy,
|
|
5
|
+
* itself ported from `dashboard/apps/cli/src/pkce.rs`) so a verifier generated
|
|
6
|
+
* here validates against the same `services/identity` authorization server
|
|
7
|
+
* meta-proxy already talks to successfully — same byte lengths, same encoding,
|
|
8
|
+
* same hash. Intentionally duplicated rather than imported from
|
|
9
|
+
* `@claude-flow/mcp/src/oauth.ts` (a different, unrelated OAuth client in this
|
|
10
|
+
* monorepo) — ADR-306 assigns PKCE ownership to this package specifically.
|
|
11
|
+
*
|
|
12
|
+
* @module v3/security/oauth/pkce
|
|
13
|
+
*/
|
|
14
|
+
export interface PkceRequest {
|
|
15
|
+
state: string;
|
|
16
|
+
codeVerifier: string;
|
|
17
|
+
codeChallenge: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function challengeFromVerifier(verifier: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Generates a fresh `state` + PKCE verifier/challenge pair for one login
|
|
22
|
+
* attempt.
|
|
23
|
+
*/
|
|
24
|
+
export declare function generate(): PkceRequest;
|
|
25
|
+
//# sourceMappingURL=pkce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../src/oauth/pkce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACvB;AAWD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,WAAW,CAKtC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.0 + PKCE (RFC 7636) client-side generation (ADR-306).
|
|
3
|
+
*
|
|
4
|
+
* A TypeScript port of meta-proxy's `src/oauth/pkce.rs` (cognitum-one/meta-proxy,
|
|
5
|
+
* itself ported from `dashboard/apps/cli/src/pkce.rs`) so a verifier generated
|
|
6
|
+
* here validates against the same `services/identity` authorization server
|
|
7
|
+
* meta-proxy already talks to successfully — same byte lengths, same encoding,
|
|
8
|
+
* same hash. Intentionally duplicated rather than imported from
|
|
9
|
+
* `@claude-flow/mcp/src/oauth.ts` (a different, unrelated OAuth client in this
|
|
10
|
+
* monorepo) — ADR-306 assigns PKCE ownership to this package specifically.
|
|
11
|
+
*
|
|
12
|
+
* @module v3/security/oauth/pkce
|
|
13
|
+
*/
|
|
14
|
+
import { randomBytes, createHash } from 'crypto';
|
|
15
|
+
/**
|
|
16
|
+
* 32 random bytes, base64url-encoded (no padding) — comfortably within RFC
|
|
17
|
+
* 7636's 43-128 character verifier length requirement (32 bytes -> 43 chars).
|
|
18
|
+
* Matches the Rust port's `random_url_safe_token(32)` exactly.
|
|
19
|
+
*/
|
|
20
|
+
function randomUrlSafeToken(byteLen) {
|
|
21
|
+
return randomBytes(byteLen).toString('base64url');
|
|
22
|
+
}
|
|
23
|
+
export function challengeFromVerifier(verifier) {
|
|
24
|
+
return createHash('sha256').update(verifier).digest('base64url');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Generates a fresh `state` + PKCE verifier/challenge pair for one login
|
|
28
|
+
* attempt.
|
|
29
|
+
*/
|
|
30
|
+
export function generate() {
|
|
31
|
+
const state = randomUrlSafeToken(32);
|
|
32
|
+
const codeVerifier = randomUrlSafeToken(32);
|
|
33
|
+
const codeChallenge = challengeFromVerifier(codeVerifier);
|
|
34
|
+
return { state, codeVerifier, codeChallenge };
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=pkce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkce.js","sourceRoot":"","sources":["../../src/oauth/pkce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQjD;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,OAAe;IACzC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ;IACtB,MAAM,KAAK,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;IACrC,MAAM,YAAY,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC5C,MAAM,aAAa,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAC1D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Password Hasher - CVE-2 Remediation
|
|
3
|
+
*
|
|
4
|
+
* Fixes weak password hashing by replacing SHA-256 with hardcoded salt
|
|
5
|
+
* with bcrypt using 12 rounds (configurable).
|
|
6
|
+
*
|
|
7
|
+
* Security Properties:
|
|
8
|
+
* - bcrypt with adaptive cost factor (12 rounds)
|
|
9
|
+
* - Automatic salt generation per password
|
|
10
|
+
* - Timing-safe comparison
|
|
11
|
+
* - Minimum password length enforcement
|
|
12
|
+
*
|
|
13
|
+
* @module v3/security/password-hasher
|
|
14
|
+
*/
|
|
15
|
+
export interface PasswordHasherConfig {
|
|
16
|
+
/**
|
|
17
|
+
* Number of bcrypt rounds (cost factor).
|
|
18
|
+
* Default: 12 (recommended minimum for production)
|
|
19
|
+
* Each increment doubles the computation time.
|
|
20
|
+
*/
|
|
21
|
+
rounds?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Minimum password length.
|
|
24
|
+
* Default: 8 characters
|
|
25
|
+
*/
|
|
26
|
+
minLength?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Maximum password length.
|
|
29
|
+
* Default: 128 characters (bcrypt limit is 72 bytes)
|
|
30
|
+
*/
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Require at least one uppercase letter.
|
|
34
|
+
* Default: true
|
|
35
|
+
*/
|
|
36
|
+
requireUppercase?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Require at least one lowercase letter.
|
|
39
|
+
* Default: true
|
|
40
|
+
*/
|
|
41
|
+
requireLowercase?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Require at least one digit.
|
|
44
|
+
* Default: true
|
|
45
|
+
*/
|
|
46
|
+
requireDigit?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Require at least one special character.
|
|
49
|
+
* Default: false
|
|
50
|
+
*/
|
|
51
|
+
requireSpecial?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface PasswordValidationResult {
|
|
54
|
+
isValid: boolean;
|
|
55
|
+
errors: string[];
|
|
56
|
+
}
|
|
57
|
+
export declare class PasswordHashError extends Error {
|
|
58
|
+
readonly code: string;
|
|
59
|
+
constructor(message: string, code: string);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Secure password hasher using bcrypt.
|
|
63
|
+
*
|
|
64
|
+
* This class replaces the vulnerable SHA-256 + hardcoded salt implementation
|
|
65
|
+
* with industry-standard bcrypt hashing.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const hasher = new PasswordHasher({ rounds: 12 });
|
|
70
|
+
* const hash = await hasher.hash('securePassword123');
|
|
71
|
+
* const isValid = await hasher.verify('securePassword123', hash);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare class PasswordHasher {
|
|
75
|
+
private readonly config;
|
|
76
|
+
constructor(config?: PasswordHasherConfig);
|
|
77
|
+
/**
|
|
78
|
+
* Validates password against configured requirements.
|
|
79
|
+
*
|
|
80
|
+
* @param password - The password to validate
|
|
81
|
+
* @returns Validation result with errors if any
|
|
82
|
+
*/
|
|
83
|
+
validate(password: string): PasswordValidationResult;
|
|
84
|
+
/**
|
|
85
|
+
* Hashes a password using bcrypt.
|
|
86
|
+
*
|
|
87
|
+
* @param password - The plaintext password to hash
|
|
88
|
+
* @returns The bcrypt hash
|
|
89
|
+
* @throws PasswordHashError if password is invalid
|
|
90
|
+
*/
|
|
91
|
+
hash(password: string): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Verifies a password against a bcrypt hash.
|
|
94
|
+
* Uses timing-safe comparison internally.
|
|
95
|
+
*
|
|
96
|
+
* @param password - The plaintext password to verify
|
|
97
|
+
* @param hash - The bcrypt hash to compare against
|
|
98
|
+
* @returns True if password matches, false otherwise
|
|
99
|
+
*/
|
|
100
|
+
verify(password: string, hash: string): Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* Checks if a hash needs to be rehashed with updated parameters.
|
|
103
|
+
* Useful for upgrading hash strength over time.
|
|
104
|
+
*
|
|
105
|
+
* @param hash - The bcrypt hash to check
|
|
106
|
+
* @returns True if hash should be updated
|
|
107
|
+
*/
|
|
108
|
+
needsRehash(hash: string): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Validates bcrypt hash format.
|
|
111
|
+
*
|
|
112
|
+
* @param hash - The hash to validate
|
|
113
|
+
* @returns True if valid bcrypt hash format
|
|
114
|
+
*/
|
|
115
|
+
private isValidBcryptHash;
|
|
116
|
+
/**
|
|
117
|
+
* Returns current configuration (without sensitive defaults).
|
|
118
|
+
*/
|
|
119
|
+
getConfig(): Readonly<Omit<Required<PasswordHasherConfig>, never>>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Factory function to create a production-ready password hasher.
|
|
123
|
+
*
|
|
124
|
+
* @param rounds - Bcrypt rounds (default: 12)
|
|
125
|
+
* @returns Configured PasswordHasher instance
|
|
126
|
+
*/
|
|
127
|
+
export declare function createPasswordHasher(rounds?: number): PasswordHasher;
|
|
128
|
+
//# sourceMappingURL=password-hasher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-hasher.d.ts","sourceRoot":"","sources":["../src/password-hasher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAWH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,qBAAa,iBAAkB,SAAQ,KAAK;aAGxB,IAAI,EAAE,MAAM;gBAD5B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM;CAK/B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;gBAE5C,MAAM,GAAE,oBAAyB;IA2B7C;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,wBAAwB;IAsCpD;;;;;;OAMG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqB7C;;;;;;;OAOG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAmB9D;;;;;;OAMG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAelC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAMzB;;OAEG;IACH,SAAS,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC,CAAC;CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,SAAK,GAAG,cAAc,CAEhE"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Password Hasher - CVE-2 Remediation
|
|
3
|
+
*
|
|
4
|
+
* Fixes weak password hashing by replacing SHA-256 with hardcoded salt
|
|
5
|
+
* with bcrypt using 12 rounds (configurable).
|
|
6
|
+
*
|
|
7
|
+
* Security Properties:
|
|
8
|
+
* - bcrypt with adaptive cost factor (12 rounds)
|
|
9
|
+
* - Automatic salt generation per password
|
|
10
|
+
* - Timing-safe comparison
|
|
11
|
+
* - Minimum password length enforcement
|
|
12
|
+
*
|
|
13
|
+
* @module v3/security/password-hasher
|
|
14
|
+
*/
|
|
15
|
+
// #1608 — switched from `bcrypt` to `bcryptjs` to drop the
|
|
16
|
+
// `@mapbox/node-pre-gyp → tar <=7.5.10` transitive chain that pulled in
|
|
17
|
+
// 6 HIGH-severity CVEs (GHSA-34x7-hfp2-rc4v, GHSA-8qq5-rm4j-mr97, etc.).
|
|
18
|
+
// `bcryptjs` is a pure-JS implementation that produces the same `$2a$` /
|
|
19
|
+
// `$2b$` hash format and exposes the same `hash()` / `compare()` API
|
|
20
|
+
// surface this module uses, so the swap is transparent to callers and to
|
|
21
|
+
// any persisted hashes.
|
|
22
|
+
import * as bcrypt from 'bcryptjs';
|
|
23
|
+
export class PasswordHashError extends Error {
|
|
24
|
+
code;
|
|
25
|
+
constructor(message, code) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.name = 'PasswordHashError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Secure password hasher using bcrypt.
|
|
33
|
+
*
|
|
34
|
+
* This class replaces the vulnerable SHA-256 + hardcoded salt implementation
|
|
35
|
+
* with industry-standard bcrypt hashing.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const hasher = new PasswordHasher({ rounds: 12 });
|
|
40
|
+
* const hash = await hasher.hash('securePassword123');
|
|
41
|
+
* const isValid = await hasher.verify('securePassword123', hash);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export class PasswordHasher {
|
|
45
|
+
config;
|
|
46
|
+
constructor(config = {}) {
|
|
47
|
+
this.config = {
|
|
48
|
+
rounds: config.rounds ?? 12,
|
|
49
|
+
minLength: config.minLength ?? 8,
|
|
50
|
+
maxLength: config.maxLength ?? 128,
|
|
51
|
+
requireUppercase: config.requireUppercase ?? true,
|
|
52
|
+
requireLowercase: config.requireLowercase ?? true,
|
|
53
|
+
requireDigit: config.requireDigit ?? true,
|
|
54
|
+
requireSpecial: config.requireSpecial ?? false,
|
|
55
|
+
};
|
|
56
|
+
// Validate configuration
|
|
57
|
+
if (this.config.rounds < 10 || this.config.rounds > 20) {
|
|
58
|
+
throw new PasswordHashError('Bcrypt rounds must be between 10 and 20 for security and performance balance', 'INVALID_ROUNDS');
|
|
59
|
+
}
|
|
60
|
+
if (this.config.minLength < 8) {
|
|
61
|
+
throw new PasswordHashError('Minimum password length must be at least 8 characters', 'INVALID_MIN_LENGTH');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Validates password against configured requirements.
|
|
66
|
+
*
|
|
67
|
+
* @param password - The password to validate
|
|
68
|
+
* @returns Validation result with errors if any
|
|
69
|
+
*/
|
|
70
|
+
validate(password) {
|
|
71
|
+
const errors = [];
|
|
72
|
+
if (!password) {
|
|
73
|
+
errors.push('Password is required');
|
|
74
|
+
return { isValid: false, errors };
|
|
75
|
+
}
|
|
76
|
+
if (password.length < this.config.minLength) {
|
|
77
|
+
errors.push(`Password must be at least ${this.config.minLength} characters`);
|
|
78
|
+
}
|
|
79
|
+
if (password.length > this.config.maxLength) {
|
|
80
|
+
errors.push(`Password must not exceed ${this.config.maxLength} characters`);
|
|
81
|
+
}
|
|
82
|
+
if (this.config.requireUppercase && !/[A-Z]/.test(password)) {
|
|
83
|
+
errors.push('Password must contain at least one uppercase letter');
|
|
84
|
+
}
|
|
85
|
+
if (this.config.requireLowercase && !/[a-z]/.test(password)) {
|
|
86
|
+
errors.push('Password must contain at least one lowercase letter');
|
|
87
|
+
}
|
|
88
|
+
if (this.config.requireDigit && !/\d/.test(password)) {
|
|
89
|
+
errors.push('Password must contain at least one digit');
|
|
90
|
+
}
|
|
91
|
+
if (this.config.requireSpecial && !/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(password)) {
|
|
92
|
+
errors.push('Password must contain at least one special character');
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
isValid: errors.length === 0,
|
|
96
|
+
errors,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Hashes a password using bcrypt.
|
|
101
|
+
*
|
|
102
|
+
* @param password - The plaintext password to hash
|
|
103
|
+
* @returns The bcrypt hash
|
|
104
|
+
* @throws PasswordHashError if password is invalid
|
|
105
|
+
*/
|
|
106
|
+
async hash(password) {
|
|
107
|
+
const validation = this.validate(password);
|
|
108
|
+
if (!validation.isValid) {
|
|
109
|
+
throw new PasswordHashError(validation.errors.join('; '), 'VALIDATION_FAILED');
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
// bcrypt automatically generates a random salt per hash
|
|
113
|
+
return await bcrypt.hash(password, this.config.rounds);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
throw new PasswordHashError('Failed to hash password', 'HASH_FAILED');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Verifies a password against a bcrypt hash.
|
|
121
|
+
* Uses timing-safe comparison internally.
|
|
122
|
+
*
|
|
123
|
+
* @param password - The plaintext password to verify
|
|
124
|
+
* @param hash - The bcrypt hash to compare against
|
|
125
|
+
* @returns True if password matches, false otherwise
|
|
126
|
+
*/
|
|
127
|
+
async verify(password, hash) {
|
|
128
|
+
if (!password || !hash) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
// Validate hash format (bcrypt hashes start with $2a$, $2b$, or $2y$)
|
|
132
|
+
if (!this.isValidBcryptHash(hash)) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
// bcrypt.compare uses timing-safe comparison
|
|
137
|
+
return await bcrypt.compare(password, hash);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
// Return false on any error to prevent timing attacks
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Checks if a hash needs to be rehashed with updated parameters.
|
|
146
|
+
* Useful for upgrading hash strength over time.
|
|
147
|
+
*
|
|
148
|
+
* @param hash - The bcrypt hash to check
|
|
149
|
+
* @returns True if hash should be updated
|
|
150
|
+
*/
|
|
151
|
+
needsRehash(hash) {
|
|
152
|
+
if (!this.isValidBcryptHash(hash)) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
// Extract rounds from hash (format: $2b$XX$...)
|
|
156
|
+
const match = hash.match(/^\$2[aby]\$(\d{2})\$/);
|
|
157
|
+
if (!match) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
const hashRounds = parseInt(match[1], 10);
|
|
161
|
+
return hashRounds < this.config.rounds;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Validates bcrypt hash format.
|
|
165
|
+
*
|
|
166
|
+
* @param hash - The hash to validate
|
|
167
|
+
* @returns True if valid bcrypt hash format
|
|
168
|
+
*/
|
|
169
|
+
isValidBcryptHash(hash) {
|
|
170
|
+
// bcrypt hash format: $2a$XX$22charsSalt31charsHash
|
|
171
|
+
// Total length: 60 characters
|
|
172
|
+
return /^\$2[aby]\$\d{2}\$[./A-Za-z0-9]{53}$/.test(hash);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Returns current configuration (without sensitive defaults).
|
|
176
|
+
*/
|
|
177
|
+
getConfig() {
|
|
178
|
+
return { ...this.config };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Factory function to create a production-ready password hasher.
|
|
183
|
+
*
|
|
184
|
+
* @param rounds - Bcrypt rounds (default: 12)
|
|
185
|
+
* @returns Configured PasswordHasher instance
|
|
186
|
+
*/
|
|
187
|
+
export function createPasswordHasher(rounds = 12) {
|
|
188
|
+
return new PasswordHasher({ rounds });
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=password-hasher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-hasher.js","sourceRoot":"","sources":["../src/password-hasher.ts"],"names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,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,gDAAgD;QAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACjD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1C,OAAO,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACK,iBAAiB,CAAC,IAAY;QACpC,oDAAoD;QACpD,8BAA8B;QAC9B,OAAO,sCAAsC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAM,GAAG,EAAE;IAC9C,OAAO,IAAI,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path Validator - HIGH-2 Remediation
|
|
3
|
+
*
|
|
4
|
+
* Fixes path traversal vulnerabilities by:
|
|
5
|
+
* - Validating all file paths against allowed prefixes
|
|
6
|
+
* - Using path.resolve() for canonicalization
|
|
7
|
+
* - Blocking traversal patterns (../, etc.)
|
|
8
|
+
* - Enforcing path length limits
|
|
9
|
+
*
|
|
10
|
+
* Security Properties:
|
|
11
|
+
* - Path canonicalization
|
|
12
|
+
* - Prefix validation
|
|
13
|
+
* - Symlink resolution (optional)
|
|
14
|
+
* - Traversal pattern detection
|
|
15
|
+
*
|
|
16
|
+
* @module v3/security/path-validator
|
|
17
|
+
*/
|
|
18
|
+
export interface PathValidatorConfig {
|
|
19
|
+
/**
|
|
20
|
+
* Allowed directory prefixes.
|
|
21
|
+
* Paths must start with one of these after resolution.
|
|
22
|
+
*/
|
|
23
|
+
allowedPrefixes: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Blocked file extensions.
|
|
26
|
+
* Files with these extensions are rejected.
|
|
27
|
+
*/
|
|
28
|
+
blockedExtensions?: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Blocked file names.
|
|
31
|
+
* Files matching these names are rejected.
|
|
32
|
+
*/
|
|
33
|
+
blockedNames?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* Maximum path length.
|
|
36
|
+
* Default: 4096 characters
|
|
37
|
+
*/
|
|
38
|
+
maxPathLength?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to resolve symlinks.
|
|
41
|
+
* Default: true
|
|
42
|
+
*/
|
|
43
|
+
resolveSymlinks?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to allow paths that don't exist.
|
|
46
|
+
* Default: true (for write operations)
|
|
47
|
+
*/
|
|
48
|
+
allowNonExistent?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Whether to allow hidden files/directories.
|
|
51
|
+
* Default: false
|
|
52
|
+
*/
|
|
53
|
+
allowHidden?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface PathValidationResult {
|
|
56
|
+
isValid: boolean;
|
|
57
|
+
resolvedPath: string;
|
|
58
|
+
relativePath: string;
|
|
59
|
+
matchedPrefix: string;
|
|
60
|
+
errors: string[];
|
|
61
|
+
}
|
|
62
|
+
export declare class PathValidatorError extends Error {
|
|
63
|
+
readonly code: string;
|
|
64
|
+
readonly path?: string | undefined;
|
|
65
|
+
constructor(message: string, code: string, path?: string | undefined);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Path validator that prevents traversal attacks.
|
|
69
|
+
*
|
|
70
|
+
* This class validates file paths to ensure they stay within
|
|
71
|
+
* allowed directories and don't access sensitive files.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const validator = new PathValidator({
|
|
76
|
+
* allowedPrefixes: ['/workspaces/project']
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* const result = await validator.validate('/workspaces/project/src/file.ts');
|
|
80
|
+
* if (result.isValid) {
|
|
81
|
+
* // Safe to use result.resolvedPath
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare class PathValidator {
|
|
86
|
+
private readonly config;
|
|
87
|
+
private readonly resolvedPrefixes;
|
|
88
|
+
constructor(config: PathValidatorConfig);
|
|
89
|
+
/**
|
|
90
|
+
* Validates a path against security rules.
|
|
91
|
+
*
|
|
92
|
+
* @param inputPath - The path to validate
|
|
93
|
+
* @returns Validation result with resolved path
|
|
94
|
+
*/
|
|
95
|
+
validate(inputPath: string): Promise<PathValidationResult>;
|
|
96
|
+
/**
|
|
97
|
+
* Validates and returns resolved path, throwing on failure.
|
|
98
|
+
*
|
|
99
|
+
* @param inputPath - The path to validate
|
|
100
|
+
* @returns Resolved path if valid
|
|
101
|
+
* @throws PathValidatorError if validation fails
|
|
102
|
+
*/
|
|
103
|
+
validateOrThrow(inputPath: string): Promise<string>;
|
|
104
|
+
/**
|
|
105
|
+
* Synchronous validation (without symlink resolution).
|
|
106
|
+
*
|
|
107
|
+
* @param inputPath - The path to validate
|
|
108
|
+
* @returns Validation result
|
|
109
|
+
*/
|
|
110
|
+
validateSync(inputPath: string): PathValidationResult;
|
|
111
|
+
/**
|
|
112
|
+
* Securely joins path segments within allowed directories.
|
|
113
|
+
*
|
|
114
|
+
* @param prefix - Base directory (must be in allowedPrefixes)
|
|
115
|
+
* @param segments - Path segments to join
|
|
116
|
+
* @returns Validated resolved path
|
|
117
|
+
*/
|
|
118
|
+
securePath(prefix: string, ...segments: string[]): Promise<string>;
|
|
119
|
+
/**
|
|
120
|
+
* Adds a prefix to the allowed list at runtime.
|
|
121
|
+
*
|
|
122
|
+
* @param prefix - Prefix to add
|
|
123
|
+
*/
|
|
124
|
+
addPrefix(prefix: string): void;
|
|
125
|
+
/**
|
|
126
|
+
* Returns the current allowed prefixes.
|
|
127
|
+
*/
|
|
128
|
+
getAllowedPrefixes(): readonly string[];
|
|
129
|
+
/**
|
|
130
|
+
* Checks if a path is within allowed prefixes (quick check).
|
|
131
|
+
*/
|
|
132
|
+
isWithinAllowed(inputPath: string): boolean;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Factory function to create a path validator for a project directory.
|
|
136
|
+
*
|
|
137
|
+
* @param projectRoot - Root directory of the project
|
|
138
|
+
* @returns Configured PathValidator
|
|
139
|
+
*/
|
|
140
|
+
export declare function createProjectPathValidator(projectRoot: string): PathValidator;
|
|
141
|
+
/**
|
|
142
|
+
* Factory function to create a path validator for the entire project.
|
|
143
|
+
*
|
|
144
|
+
* @param projectRoot - Root directory of the project
|
|
145
|
+
* @returns Configured PathValidator
|
|
146
|
+
*/
|
|
147
|
+
export declare function createFullProjectPathValidator(projectRoot: string): PathValidator;
|
|
148
|
+
//# sourceMappingURL=path-validator.d.ts.map
|