@kindgi/api 0.0.0-bootstrap.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +216 -1
- package/dist/adapter-binding.d.ts +177 -0
- package/dist/adapter-binding.d.ts.map +1 -0
- package/dist/adapter-binding.js +12 -0
- package/dist/adapter-binding.js.map +1 -0
- package/dist/agent-binding.d.ts +207 -0
- package/dist/agent-binding.d.ts.map +1 -0
- package/dist/agent-binding.js +4 -0
- package/dist/agent-binding.js.map +1 -0
- package/dist/app.d.ts +770 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +396 -0
- package/dist/app.js.map +1 -0
- package/dist/capability-binding.d.ts +76 -0
- package/dist/capability-binding.d.ts.map +1 -0
- package/dist/capability-binding.js +4 -0
- package/dist/capability-binding.js.map +1 -0
- package/dist/cost-binding.d.ts +175 -0
- package/dist/cost-binding.d.ts.map +1 -0
- package/dist/cost-binding.js +13 -0
- package/dist/cost-binding.js.map +1 -0
- package/dist/deployment-binding.d.ts +201 -0
- package/dist/deployment-binding.d.ts.map +1 -0
- package/dist/deployment-binding.js +4 -0
- package/dist/deployment-binding.js.map +1 -0
- package/dist/env-binding.d.ts +132 -0
- package/dist/env-binding.d.ts.map +1 -0
- package/dist/env-binding.js +4 -0
- package/dist/env-binding.js.map +1 -0
- package/dist/errors.d.ts +37 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +264 -0
- package/dist/errors.js.map +1 -0
- package/dist/eval-run-binding.d.ts +196 -0
- package/dist/eval-run-binding.d.ts.map +1 -0
- package/dist/eval-run-binding.js +16 -0
- package/dist/eval-run-binding.js.map +1 -0
- package/dist/eval-run-dispatcher.d.ts +131 -0
- package/dist/eval-run-dispatcher.d.ts.map +1 -0
- package/dist/eval-run-dispatcher.js +368 -0
- package/dist/eval-run-dispatcher.js.map +1 -0
- package/dist/eval-suite-binding.d.ts +227 -0
- package/dist/eval-suite-binding.d.ts.map +1 -0
- package/dist/eval-suite-binding.js +24 -0
- package/dist/eval-suite-binding.js.map +1 -0
- package/dist/event-bus-binding.d.ts +107 -0
- package/dist/event-bus-binding.d.ts.map +1 -0
- package/dist/event-bus-binding.js +5 -0
- package/dist/event-bus-binding.js.map +1 -0
- package/dist/flow-binding.d.ts +194 -0
- package/dist/flow-binding.d.ts.map +1 -0
- package/dist/flow-binding.js +4 -0
- package/dist/flow-binding.js.map +1 -0
- package/dist/guardrail-binding.d.ts +138 -0
- package/dist/guardrail-binding.d.ts.map +1 -0
- package/dist/guardrail-binding.js +4 -0
- package/dist/guardrail-binding.js.map +1 -0
- package/dist/handler-binding.d.ts +126 -0
- package/dist/handler-binding.d.ts.map +1 -0
- package/dist/handler-binding.js +4 -0
- package/dist/handler-binding.js.map +1 -0
- package/dist/hitl-binding.d.ts +115 -0
- package/dist/hitl-binding.d.ts.map +1 -0
- package/dist/hitl-binding.js +4 -0
- package/dist/hitl-binding.js.map +1 -0
- package/dist/identity-directory-binding.d.ts +116 -0
- package/dist/identity-directory-binding.d.ts.map +1 -0
- package/dist/identity-directory-binding.js +4 -0
- package/dist/identity-directory-binding.js.map +1 -0
- package/dist/identity-provider-binding.d.ts +184 -0
- package/dist/identity-provider-binding.d.ts.map +1 -0
- package/dist/identity-provider-binding.js +4 -0
- package/dist/identity-provider-binding.js.map +1 -0
- package/dist/image-registry-binding.d.ts +165 -0
- package/dist/image-registry-binding.d.ts.map +1 -0
- package/dist/image-registry-binding.js +4 -0
- package/dist/image-registry-binding.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/key-management-binding.d.ts +101 -0
- package/dist/key-management-binding.d.ts.map +1 -0
- package/dist/key-management-binding.js +4 -0
- package/dist/key-management-binding.js.map +1 -0
- package/dist/mcp-endpoint-binding.d.ts +312 -0
- package/dist/mcp-endpoint-binding.d.ts.map +1 -0
- package/dist/mcp-endpoint-binding.js +12 -0
- package/dist/mcp-endpoint-binding.js.map +1 -0
- package/dist/memory-binding.d.ts +209 -0
- package/dist/memory-binding.d.ts.map +1 -0
- package/dist/memory-binding.js +4 -0
- package/dist/memory-binding.js.map +1 -0
- package/dist/middleware/auth.d.ts +168 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +247 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/authorize.d.ts +26 -0
- package/dist/middleware/authorize.d.ts.map +1 -0
- package/dist/middleware/authorize.js +65 -0
- package/dist/middleware/authorize.js.map +1 -0
- package/dist/middleware/error-mapper.d.ts +13 -0
- package/dist/middleware/error-mapper.d.ts.map +1 -0
- package/dist/middleware/error-mapper.js +32 -0
- package/dist/middleware/error-mapper.js.map +1 -0
- package/dist/middleware/idempotency.d.ts +43 -0
- package/dist/middleware/idempotency.d.ts.map +1 -0
- package/dist/middleware/idempotency.js +118 -0
- package/dist/middleware/idempotency.js.map +1 -0
- package/dist/middleware/principal.d.ts +4 -0
- package/dist/middleware/principal.d.ts.map +1 -0
- package/dist/middleware/principal.js +42 -0
- package/dist/middleware/principal.js.map +1 -0
- package/dist/middleware/public-run-routes.d.ts +16 -0
- package/dist/middleware/public-run-routes.d.ts.map +1 -0
- package/dist/middleware/public-run-routes.js +43 -0
- package/dist/middleware/public-run-routes.js.map +1 -0
- package/dist/middleware/request-id.d.ts +14 -0
- package/dist/middleware/request-id.d.ts.map +1 -0
- package/dist/middleware/request-id.js +24 -0
- package/dist/middleware/request-id.js.map +1 -0
- package/dist/middleware/sigv4-verify.d.ts +64 -0
- package/dist/middleware/sigv4-verify.d.ts.map +1 -0
- package/dist/middleware/sigv4-verify.js +286 -0
- package/dist/middleware/sigv4-verify.js.map +1 -0
- package/dist/middleware/sigv4.d.ts +25 -0
- package/dist/middleware/sigv4.d.ts.map +1 -0
- package/dist/middleware/sigv4.js +120 -0
- package/dist/middleware/sigv4.js.map +1 -0
- package/dist/openapi/generate.d.ts +15 -0
- package/dist/openapi/generate.d.ts.map +1 -0
- package/dist/openapi/generate.js +241 -0
- package/dist/openapi/generate.js.map +1 -0
- package/dist/openapi/operations.d.ts +70 -0
- package/dist/openapi/operations.d.ts.map +1 -0
- package/dist/openapi/operations.js +5051 -0
- package/dist/openapi/operations.js.map +1 -0
- package/dist/openapi/schemas.d.ts +590 -0
- package/dist/openapi/schemas.d.ts.map +1 -0
- package/dist/openapi/schemas.js +5820 -0
- package/dist/openapi/schemas.js.map +1 -0
- package/dist/provenance-binding.d.ts +116 -0
- package/dist/provenance-binding.d.ts.map +1 -0
- package/dist/provenance-binding.js +31 -0
- package/dist/provenance-binding.js.map +1 -0
- package/dist/provider-binding.d.ts +174 -0
- package/dist/provider-binding.d.ts.map +1 -0
- package/dist/provider-binding.js +4 -0
- package/dist/provider-binding.js.map +1 -0
- package/dist/public-run-token.d.ts +97 -0
- package/dist/public-run-token.d.ts.map +1 -0
- package/dist/public-run-token.js +167 -0
- package/dist/public-run-token.js.map +1 -0
- package/dist/retention-binding.d.ts +69 -0
- package/dist/retention-binding.d.ts.map +1 -0
- package/dist/retention-binding.js +4 -0
- package/dist/retention-binding.js.map +1 -0
- package/dist/reviewer-binding.d.ts +84 -0
- package/dist/reviewer-binding.d.ts.map +1 -0
- package/dist/reviewer-binding.js +4 -0
- package/dist/reviewer-binding.js.map +1 -0
- package/dist/rotation-status-store.d.ts +96 -0
- package/dist/rotation-status-store.d.ts.map +1 -0
- package/dist/rotation-status-store.js +106 -0
- package/dist/rotation-status-store.js.map +1 -0
- package/dist/routes/adapters.d.ts +29 -0
- package/dist/routes/adapters.d.ts.map +1 -0
- package/dist/routes/adapters.js +230 -0
- package/dist/routes/adapters.js.map +1 -0
- package/dist/routes/agents.d.ts +17 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +342 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/approvals.d.ts +37 -0
- package/dist/routes/approvals.d.ts.map +1 -0
- package/dist/routes/approvals.js +551 -0
- package/dist/routes/approvals.js.map +1 -0
- package/dist/routes/artifacts.d.ts +25 -0
- package/dist/routes/artifacts.d.ts.map +1 -0
- package/dist/routes/artifacts.js +265 -0
- package/dist/routes/artifacts.js.map +1 -0
- package/dist/routes/audit.d.ts +6 -0
- package/dist/routes/audit.d.ts.map +1 -0
- package/dist/routes/audit.js +162 -0
- package/dist/routes/audit.js.map +1 -0
- package/dist/routes/auth.d.ts +47 -0
- package/dist/routes/auth.d.ts.map +1 -0
- package/dist/routes/auth.js +630 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/capabilities.d.ts +14 -0
- package/dist/routes/capabilities.d.ts.map +1 -0
- package/dist/routes/capabilities.js +62 -0
- package/dist/routes/capabilities.js.map +1 -0
- package/dist/routes/compliance.d.ts +37 -0
- package/dist/routes/compliance.d.ts.map +1 -0
- package/dist/routes/compliance.js +321 -0
- package/dist/routes/compliance.js.map +1 -0
- package/dist/routes/conversations.d.ts +13 -0
- package/dist/routes/conversations.d.ts.map +1 -0
- package/dist/routes/conversations.js +295 -0
- package/dist/routes/conversations.js.map +1 -0
- package/dist/routes/cost.d.ts +24 -0
- package/dist/routes/cost.d.ts.map +1 -0
- package/dist/routes/cost.js +243 -0
- package/dist/routes/cost.js.map +1 -0
- package/dist/routes/deployments.d.ts +122 -0
- package/dist/routes/deployments.d.ts.map +1 -0
- package/dist/routes/deployments.js +1036 -0
- package/dist/routes/deployments.js.map +1 -0
- package/dist/routes/env.d.ts +62 -0
- package/dist/routes/env.d.ts.map +1 -0
- package/dist/routes/env.js +311 -0
- package/dist/routes/env.js.map +1 -0
- package/dist/routes/eval-runs.d.ts +28 -0
- package/dist/routes/eval-runs.d.ts.map +1 -0
- package/dist/routes/eval-runs.js +479 -0
- package/dist/routes/eval-runs.js.map +1 -0
- package/dist/routes/eval-suites.d.ts +24 -0
- package/dist/routes/eval-suites.d.ts.map +1 -0
- package/dist/routes/eval-suites.js +381 -0
- package/dist/routes/eval-suites.js.map +1 -0
- package/dist/routes/event-triggers.d.ts +12 -0
- package/dist/routes/event-triggers.d.ts.map +1 -0
- package/dist/routes/event-triggers.js +218 -0
- package/dist/routes/event-triggers.js.map +1 -0
- package/dist/routes/flows.d.ts +23 -0
- package/dist/routes/flows.d.ts.map +1 -0
- package/dist/routes/flows.js +344 -0
- package/dist/routes/flows.js.map +1 -0
- package/dist/routes/guardrails.d.ts +33 -0
- package/dist/routes/guardrails.d.ts.map +1 -0
- package/dist/routes/guardrails.js +236 -0
- package/dist/routes/guardrails.js.map +1 -0
- package/dist/routes/identity.d.ts +39 -0
- package/dist/routes/identity.d.ts.map +1 -0
- package/dist/routes/identity.js +138 -0
- package/dist/routes/identity.js.map +1 -0
- package/dist/routes/mcp.d.ts +23 -0
- package/dist/routes/mcp.d.ts.map +1 -0
- package/dist/routes/mcp.js +727 -0
- package/dist/routes/mcp.js.map +1 -0
- package/dist/routes/memory.d.ts +16 -0
- package/dist/routes/memory.d.ts.map +1 -0
- package/dist/routes/memory.js +353 -0
- package/dist/routes/memory.js.map +1 -0
- package/dist/routes/observations.d.ts +19 -0
- package/dist/routes/observations.d.ts.map +1 -0
- package/dist/routes/observations.js +135 -0
- package/dist/routes/observations.js.map +1 -0
- package/dist/routes/orgs.d.ts +24 -0
- package/dist/routes/orgs.d.ts.map +1 -0
- package/dist/routes/orgs.js +208 -0
- package/dist/routes/orgs.js.map +1 -0
- package/dist/routes/pagination.d.ts +18 -0
- package/dist/routes/pagination.d.ts.map +1 -0
- package/dist/routes/pagination.js +35 -0
- package/dist/routes/pagination.js.map +1 -0
- package/dist/routes/policies.d.ts +23 -0
- package/dist/routes/policies.d.ts.map +1 -0
- package/dist/routes/policies.js +314 -0
- package/dist/routes/policies.js.map +1 -0
- package/dist/routes/projects.d.ts +45 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +485 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/proposals.d.ts +24 -0
- package/dist/routes/proposals.d.ts.map +1 -0
- package/dist/routes/proposals.js +581 -0
- package/dist/routes/proposals.js.map +1 -0
- package/dist/routes/provenance.d.ts +34 -0
- package/dist/routes/provenance.d.ts.map +1 -0
- package/dist/routes/provenance.js +274 -0
- package/dist/routes/provenance.js.map +1 -0
- package/dist/routes/providers.d.ts +32 -0
- package/dist/routes/providers.d.ts.map +1 -0
- package/dist/routes/providers.js +490 -0
- package/dist/routes/providers.js.map +1 -0
- package/dist/routes/public-run-tokens.d.ts +17 -0
- package/dist/routes/public-run-tokens.d.ts.map +1 -0
- package/dist/routes/public-run-tokens.js +69 -0
- package/dist/routes/public-run-tokens.js.map +1 -0
- package/dist/routes/retention.d.ts +19 -0
- package/dist/routes/retention.d.ts.map +1 -0
- package/dist/routes/retention.js +152 -0
- package/dist/routes/retention.js.map +1 -0
- package/dist/routes/reviewers.d.ts +5 -0
- package/dist/routes/reviewers.d.ts.map +1 -0
- package/dist/routes/reviewers.js +161 -0
- package/dist/routes/reviewers.js.map +1 -0
- package/dist/routes/runs.d.ts +34 -0
- package/dist/routes/runs.d.ts.map +1 -0
- package/dist/routes/runs.js +773 -0
- package/dist/routes/runs.js.map +1 -0
- package/dist/routes/s3.d.ts +31 -0
- package/dist/routes/s3.d.ts.map +1 -0
- package/dist/routes/s3.js +433 -0
- package/dist/routes/s3.js.map +1 -0
- package/dist/routes/schedules.d.ts +20 -0
- package/dist/routes/schedules.d.ts.map +1 -0
- package/dist/routes/schedules.js +234 -0
- package/dist/routes/schedules.js.map +1 -0
- package/dist/routes/scope-params.d.ts +57 -0
- package/dist/routes/scope-params.d.ts.map +1 -0
- package/dist/routes/scope-params.js +105 -0
- package/dist/routes/scope-params.js.map +1 -0
- package/dist/routes/secret-ref.d.ts +20 -0
- package/dist/routes/secret-ref.d.ts.map +1 -0
- package/dist/routes/secret-ref.js +42 -0
- package/dist/routes/secret-ref.js.map +1 -0
- package/dist/routes/secrets.d.ts +53 -0
- package/dist/routes/secrets.d.ts.map +1 -0
- package/dist/routes/secrets.js +715 -0
- package/dist/routes/secrets.js.map +1 -0
- package/dist/routes/signing-keys.d.ts +23 -0
- package/dist/routes/signing-keys.d.ts.map +1 -0
- package/dist/routes/signing-keys.js +212 -0
- package/dist/routes/signing-keys.js.map +1 -0
- package/dist/routes/sse.d.ts +58 -0
- package/dist/routes/sse.d.ts.map +1 -0
- package/dist/routes/sse.js +92 -0
- package/dist/routes/sse.js.map +1 -0
- package/dist/routes/teams.d.ts +30 -0
- package/dist/routes/teams.d.ts.map +1 -0
- package/dist/routes/teams.js +443 -0
- package/dist/routes/teams.js.map +1 -0
- package/dist/routes/tenant.d.ts +57 -0
- package/dist/routes/tenant.d.ts.map +1 -0
- package/dist/routes/tenant.js +352 -0
- package/dist/routes/tenant.js.map +1 -0
- package/dist/routes/tokens.d.ts +14 -0
- package/dist/routes/tokens.d.ts.map +1 -0
- package/dist/routes/tokens.js +231 -0
- package/dist/routes/tokens.js.map +1 -0
- package/dist/routes/tools.d.ts +33 -0
- package/dist/routes/tools.d.ts.map +1 -0
- package/dist/routes/tools.js +380 -0
- package/dist/routes/tools.js.map +1 -0
- package/dist/routes/webhook-endpoints.d.ts +10 -0
- package/dist/routes/webhook-endpoints.d.ts.map +1 -0
- package/dist/routes/webhook-endpoints.js +407 -0
- package/dist/routes/webhook-endpoints.js.map +1 -0
- package/dist/routes/webhooks.d.ts +21 -0
- package/dist/routes/webhooks.d.ts.map +1 -0
- package/dist/routes/webhooks.js +228 -0
- package/dist/routes/webhooks.js.map +1 -0
- package/dist/s3-credential-binding.d.ts +54 -0
- package/dist/s3-credential-binding.d.ts.map +1 -0
- package/dist/s3-credential-binding.js +4 -0
- package/dist/s3-credential-binding.js.map +1 -0
- package/dist/secrets-binding.d.ts +281 -0
- package/dist/secrets-binding.d.ts.map +1 -0
- package/dist/secrets-binding.js +10 -0
- package/dist/secrets-binding.js.map +1 -0
- package/dist/secrets-provider-binding.d.ts +164 -0
- package/dist/secrets-provider-binding.d.ts.map +1 -0
- package/dist/secrets-provider-binding.js +4 -0
- package/dist/secrets-provider-binding.js.map +1 -0
- package/dist/session-store-binding.d.ts +148 -0
- package/dist/session-store-binding.d.ts.map +1 -0
- package/dist/session-store-binding.js +4 -0
- package/dist/session-store-binding.js.map +1 -0
- package/dist/signing-key-binding.d.ts +210 -0
- package/dist/signing-key-binding.d.ts.map +1 -0
- package/dist/signing-key-binding.js +4 -0
- package/dist/signing-key-binding.js.map +1 -0
- package/dist/state-store-binding.d.ts +53 -0
- package/dist/state-store-binding.d.ts.map +1 -0
- package/dist/state-store-binding.js +38 -0
- package/dist/state-store-binding.js.map +1 -0
- package/dist/supervisor-binding.d.ts +526 -0
- package/dist/supervisor-binding.d.ts.map +1 -0
- package/dist/supervisor-binding.js +4 -0
- package/dist/supervisor-binding.js.map +1 -0
- package/dist/tenant-host-access.d.ts +41 -0
- package/dist/tenant-host-access.d.ts.map +1 -0
- package/dist/tenant-host-access.js +42 -0
- package/dist/tenant-host-access.js.map +1 -0
- package/dist/token-admin.d.ts +99 -0
- package/dist/token-admin.d.ts.map +1 -0
- package/dist/token-admin.js +4 -0
- package/dist/token-admin.js.map +1 -0
- package/dist/tool-binding.d.ts +247 -0
- package/dist/tool-binding.d.ts.map +1 -0
- package/dist/tool-binding.js +4 -0
- package/dist/tool-binding.js.map +1 -0
- package/dist/trigger-binding.d.ts +13 -0
- package/dist/trigger-binding.d.ts.map +1 -0
- package/dist/trigger-binding.js +4 -0
- package/dist/trigger-binding.js.map +1 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/webhook-endpoint-binding.d.ts +230 -0
- package/dist/webhook-endpoint-binding.d.ts.map +1 -0
- package/dist/webhook-endpoint-binding.js +12 -0
- package/dist/webhook-endpoint-binding.js.map +1 -0
- package/dist/xml.d.ts +79 -0
- package/dist/xml.d.ts.map +1 -0
- package/dist/xml.js +115 -0
- package/dist/xml.js.map +1 -0
- package/openapi.json +29659 -0
- package/package.json +76 -4
- package/scripts/emit-openapi.mjs +44 -0
- package/src/adapter-binding.ts +204 -0
- package/src/agent-binding.ts +231 -0
- package/src/app.ts +1285 -0
- package/src/capability-binding.ts +83 -0
- package/src/cost-binding.ts +213 -0
- package/src/deployment-binding.ts +225 -0
- package/src/env-binding.ts +140 -0
- package/src/errors.ts +291 -0
- package/src/eval-run-binding.ts +209 -0
- package/src/eval-run-dispatcher.ts +497 -0
- package/src/eval-suite-binding.ts +257 -0
- package/src/event-bus-binding.ts +127 -0
- package/src/flow-binding.ts +213 -0
- package/src/guardrail-binding.ts +151 -0
- package/src/handler-binding.ts +132 -0
- package/src/hitl-binding.ts +172 -0
- package/src/identity-directory-binding.ts +128 -0
- package/src/identity-provider-binding.ts +203 -0
- package/src/image-registry-binding.ts +193 -0
- package/src/index.ts +606 -0
- package/src/key-management-binding.ts +91 -0
- package/src/mcp-endpoint-binding.ts +311 -0
- package/src/memory-binding.ts +239 -0
- package/src/middleware/auth.ts +437 -0
- package/src/middleware/authorize.ts +125 -0
- package/src/middleware/error-mapper.ts +37 -0
- package/src/middleware/idempotency.ts +160 -0
- package/src/middleware/principal.ts +64 -0
- package/src/middleware/public-run-routes.ts +50 -0
- package/src/middleware/request-id.ts +28 -0
- package/src/middleware/sigv4-verify.ts +374 -0
- package/src/middleware/sigv4.ts +165 -0
- package/src/openapi/generate.ts +307 -0
- package/src/openapi/operations.ts +5445 -0
- package/src/openapi/schemas.ts +6363 -0
- package/src/provenance-binding.ts +169 -0
- package/src/provider-binding.ts +196 -0
- package/src/public-run-token.ts +263 -0
- package/src/retention-binding.ts +78 -0
- package/src/reviewer-binding.ts +99 -0
- package/src/rotation-status-store.ts +209 -0
- package/src/routes/adapters.ts +319 -0
- package/src/routes/agents.ts +424 -0
- package/src/routes/approvals.ts +759 -0
- package/src/routes/artifacts.ts +317 -0
- package/src/routes/audit.ts +219 -0
- package/src/routes/auth.ts +806 -0
- package/src/routes/capabilities.ts +79 -0
- package/src/routes/compliance.ts +482 -0
- package/src/routes/conversations.ts +369 -0
- package/src/routes/cost.ts +327 -0
- package/src/routes/deployments.ts +1493 -0
- package/src/routes/env.ts +429 -0
- package/src/routes/eval-runs.ts +631 -0
- package/src/routes/eval-suites.ts +490 -0
- package/src/routes/event-triggers.ts +283 -0
- package/src/routes/flows.ts +423 -0
- package/src/routes/guardrails.ts +320 -0
- package/src/routes/identity.ts +203 -0
- package/src/routes/mcp.ts +940 -0
- package/src/routes/memory.ts +430 -0
- package/src/routes/observations.ts +175 -0
- package/src/routes/orgs.ts +273 -0
- package/src/routes/pagination.ts +51 -0
- package/src/routes/policies.ts +413 -0
- package/src/routes/projects.ts +634 -0
- package/src/routes/proposals.ts +719 -0
- package/src/routes/provenance.ts +406 -0
- package/src/routes/providers.ts +624 -0
- package/src/routes/public-run-tokens.ts +104 -0
- package/src/routes/retention.ts +193 -0
- package/src/routes/reviewers.ts +209 -0
- package/src/routes/runs.ts +981 -0
- package/src/routes/s3.ts +519 -0
- package/src/routes/schedules.ts +300 -0
- package/src/routes/scope-params.ts +133 -0
- package/src/routes/secret-ref.ts +52 -0
- package/src/routes/secrets.ts +975 -0
- package/src/routes/signing-keys.ts +259 -0
- package/src/routes/sse.ts +148 -0
- package/src/routes/teams.ts +584 -0
- package/src/routes/tenant.ts +530 -0
- package/src/routes/tokens.ts +285 -0
- package/src/routes/tools.ts +491 -0
- package/src/routes/webhook-endpoints.ts +534 -0
- package/src/routes/webhooks.ts +296 -0
- package/src/s3-credential-binding.ts +58 -0
- package/src/secrets-binding.ts +308 -0
- package/src/secrets-provider-binding.ts +167 -0
- package/src/session-store-binding.ts +163 -0
- package/src/signing-key-binding.ts +235 -0
- package/src/state-store-binding.ts +84 -0
- package/src/supervisor-binding.ts +554 -0
- package/src/tenant-host-access.ts +62 -0
- package/src/token-admin.ts +104 -0
- package/src/tool-binding.ts +274 -0
- package/src/trigger-binding.ts +38 -0
- package/src/types.ts +74 -0
- package/src/webhook-endpoint-binding.ts +246 -0
- package/src/xml.ts +196 -0
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
import { Hono } from 'hono';
|
|
4
|
+
import { tuplesForCreate } from '@kindgi/authz';
|
|
5
|
+
import { statusFor, toWireError } from '../errors.js';
|
|
6
|
+
import { hasCapability, requireEnvName, requireScope, scopesEqual } from './env.js';
|
|
7
|
+
import { clampLimit } from './pagination.js';
|
|
8
|
+
import { queryScopeResourceRef, scopeResourceRef } from './scope-params.js';
|
|
9
|
+
export function secretsRouter(options) {
|
|
10
|
+
const { secretsBinding, rotationStatusStore, authorizer } = options;
|
|
11
|
+
const heartbeatMs = options.sseHeartbeatMs ?? 15_000;
|
|
12
|
+
const r = new Hono();
|
|
13
|
+
// Authorization PEP — scope-anchored.
|
|
14
|
+
// STRICT-READ: only scope-admins or explicit `reader` grantees pass
|
|
15
|
+
// `can_read` on a secret. Each check derives the scope with the same
|
|
16
|
+
// parser as its handler: `POST /` from `body.scope`; `POST /:name/rotate`
|
|
17
|
+
// from `body.scope` or the query (resolveRotateScope); every other route
|
|
18
|
+
// from `?scopeKind` + `?scopeId`.
|
|
19
|
+
if (authorizer !== undefined) {
|
|
20
|
+
const scopeFromQuery = (c) => queryScopeResourceRef((n) => c.req.query(n), { tenantId: c.get('tenantId') });
|
|
21
|
+
r.use('/', async (c, next) => {
|
|
22
|
+
if (c.req.method === 'POST') {
|
|
23
|
+
const tenantId = c.get('tenantId');
|
|
24
|
+
const mw = authorizer.authorize('admin', async () => {
|
|
25
|
+
let bodyScope;
|
|
26
|
+
try {
|
|
27
|
+
const body = await c.req.json();
|
|
28
|
+
if (body !== null && typeof body === 'object') {
|
|
29
|
+
bodyScope = body.scope;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// POST handler validates + returns 400
|
|
34
|
+
}
|
|
35
|
+
const s = validateBodyScope(bodyScope, tenantId);
|
|
36
|
+
return scopeResourceRef(s.kind === 'ok' ? s.scope : undefined, tenantId);
|
|
37
|
+
});
|
|
38
|
+
return mw(c, next);
|
|
39
|
+
}
|
|
40
|
+
if (c.req.method === 'GET') {
|
|
41
|
+
const mw = authorizer.authorize('admin', scopeFromQuery);
|
|
42
|
+
return mw(c, next);
|
|
43
|
+
}
|
|
44
|
+
return next();
|
|
45
|
+
});
|
|
46
|
+
// `/:name/*` also matches `/:name`: one check per request. The only
|
|
47
|
+
// POST below `/:name` is rotate, which may carry its scope in the body;
|
|
48
|
+
// read it with `text()`, as the handler does.
|
|
49
|
+
r.use('/:name/*', async (c, next) => {
|
|
50
|
+
if (c.req.method === 'POST') {
|
|
51
|
+
const tenantId = c.get('tenantId');
|
|
52
|
+
const mw = authorizer.authorize('admin', async () => {
|
|
53
|
+
const s = resolveRotateScope(parseJsonObject(await c.req.text()), c.req.query(), tenantId);
|
|
54
|
+
return scopeResourceRef(s.kind === 'ok' ? s.scope : undefined, tenantId);
|
|
55
|
+
});
|
|
56
|
+
return mw(c, next);
|
|
57
|
+
}
|
|
58
|
+
const mw = authorizer.authorize('admin', scopeFromQuery);
|
|
59
|
+
return mw(c, next);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// ------------------------------ GET / ------------------------------
|
|
63
|
+
r.get('/', async (c) => {
|
|
64
|
+
const requestId = c.get('requestId');
|
|
65
|
+
const tenantId = c.get('tenantId');
|
|
66
|
+
const envNameResult = requireEnvName(c.req.query('envName'));
|
|
67
|
+
if (envNameResult.kind === 'err') {
|
|
68
|
+
c.status(statusFor(envNameResult.code));
|
|
69
|
+
return c.json(toWireError({ code: envNameResult.code, message: envNameResult.message }, requestId));
|
|
70
|
+
}
|
|
71
|
+
const scopeResult = requireScope(c.req.query(), tenantId);
|
|
72
|
+
if (scopeResult.kind === 'err') {
|
|
73
|
+
c.status(statusFor(scopeResult.code));
|
|
74
|
+
return c.json(toWireError({ code: scopeResult.code, message: scopeResult.message }, requestId));
|
|
75
|
+
}
|
|
76
|
+
const limit = clampLimit(c.req.query('limit'));
|
|
77
|
+
const cursorRaw = c.req.query('cursor');
|
|
78
|
+
const namePrefix = c.req.query('namePrefix');
|
|
79
|
+
const page = await secretsBinding.list({
|
|
80
|
+
scope: scopeResult.scope,
|
|
81
|
+
envName: envNameResult.envName,
|
|
82
|
+
limit,
|
|
83
|
+
...(cursorRaw !== undefined && cursorRaw.length > 0 && { cursor: cursorRaw }),
|
|
84
|
+
...(namePrefix !== undefined && namePrefix.length > 0 && { namePrefix }),
|
|
85
|
+
});
|
|
86
|
+
return c.json({
|
|
87
|
+
data: page.data.map(serializeSecretRecord),
|
|
88
|
+
...(page.nextCursor !== undefined && { nextCursor: page.nextCursor }),
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
// ---------------------- GET /:name -----------------------------
|
|
92
|
+
r.get('/:name', async (c) => {
|
|
93
|
+
const requestId = c.get('requestId');
|
|
94
|
+
const tenantId = c.get('tenantId');
|
|
95
|
+
const name = c.req.param('name');
|
|
96
|
+
const envNameResult = requireEnvName(c.req.query('envName'));
|
|
97
|
+
if (envNameResult.kind === 'err') {
|
|
98
|
+
c.status(statusFor(envNameResult.code));
|
|
99
|
+
return c.json(toWireError({ code: envNameResult.code, message: envNameResult.message }, requestId));
|
|
100
|
+
}
|
|
101
|
+
const scopeResult = requireScope(c.req.query(), tenantId);
|
|
102
|
+
if (scopeResult.kind === 'err') {
|
|
103
|
+
c.status(statusFor(scopeResult.code));
|
|
104
|
+
return c.json(toWireError({ code: scopeResult.code, message: scopeResult.message }, requestId));
|
|
105
|
+
}
|
|
106
|
+
const rec = await secretsBinding.get({
|
|
107
|
+
scope: scopeResult.scope,
|
|
108
|
+
envName: envNameResult.envName,
|
|
109
|
+
name,
|
|
110
|
+
});
|
|
111
|
+
if (rec === null) {
|
|
112
|
+
c.status(statusFor('secret-not-found'));
|
|
113
|
+
return c.json(toWireError({ code: 'secret-not-found', message: `No secret "${name}".`, name }, requestId));
|
|
114
|
+
}
|
|
115
|
+
return c.json(serializeSecretRecord(rec));
|
|
116
|
+
});
|
|
117
|
+
// ------------------ GET /:name/versions -----------------------
|
|
118
|
+
r.get('/:name/versions', async (c) => {
|
|
119
|
+
const requestId = c.get('requestId');
|
|
120
|
+
const tenantId = c.get('tenantId');
|
|
121
|
+
const name = c.req.param('name');
|
|
122
|
+
const envNameResult = requireEnvName(c.req.query('envName'));
|
|
123
|
+
if (envNameResult.kind === 'err') {
|
|
124
|
+
c.status(statusFor(envNameResult.code));
|
|
125
|
+
return c.json(toWireError({ code: envNameResult.code, message: envNameResult.message }, requestId));
|
|
126
|
+
}
|
|
127
|
+
const scopeResult = requireScope(c.req.query(), tenantId);
|
|
128
|
+
if (scopeResult.kind === 'err') {
|
|
129
|
+
c.status(statusFor(scopeResult.code));
|
|
130
|
+
return c.json(toWireError({ code: scopeResult.code, message: scopeResult.message }, requestId));
|
|
131
|
+
}
|
|
132
|
+
const limit = clampLimit(c.req.query('limit'));
|
|
133
|
+
const cursorRaw = c.req.query('cursor');
|
|
134
|
+
const page = await secretsBinding.listVersions({
|
|
135
|
+
scope: scopeResult.scope,
|
|
136
|
+
envName: envNameResult.envName,
|
|
137
|
+
name,
|
|
138
|
+
limit,
|
|
139
|
+
...(cursorRaw !== undefined && cursorRaw.length > 0 && { cursor: cursorRaw }),
|
|
140
|
+
});
|
|
141
|
+
return c.json({
|
|
142
|
+
data: page.data.map(serializeVersion),
|
|
143
|
+
...(page.nextCursor !== undefined && { nextCursor: page.nextCursor }),
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
// -------------- GET /:name/versions/:versionId -----------------
|
|
147
|
+
r.get('/:name/versions/:versionId', async (c) => {
|
|
148
|
+
const requestId = c.get('requestId');
|
|
149
|
+
const tenantId = c.get('tenantId');
|
|
150
|
+
const name = c.req.param('name');
|
|
151
|
+
const versionIdRaw = c.req.param('versionId');
|
|
152
|
+
const versionId = Number.parseInt(versionIdRaw, 10);
|
|
153
|
+
if (!Number.isFinite(versionId) || versionId < 1) {
|
|
154
|
+
c.status(statusFor('bad-input'));
|
|
155
|
+
return c.json(toWireError({ code: 'bad-input', message: '`versionId` must be a positive integer.' }, requestId));
|
|
156
|
+
}
|
|
157
|
+
const envNameResult = requireEnvName(c.req.query('envName'));
|
|
158
|
+
if (envNameResult.kind === 'err') {
|
|
159
|
+
c.status(statusFor(envNameResult.code));
|
|
160
|
+
return c.json(toWireError({ code: envNameResult.code, message: envNameResult.message }, requestId));
|
|
161
|
+
}
|
|
162
|
+
const scopeResult = requireScope(c.req.query(), tenantId);
|
|
163
|
+
if (scopeResult.kind === 'err') {
|
|
164
|
+
c.status(statusFor(scopeResult.code));
|
|
165
|
+
return c.json(toWireError({ code: scopeResult.code, message: scopeResult.message }, requestId));
|
|
166
|
+
}
|
|
167
|
+
const rec = await secretsBinding.getVersion({
|
|
168
|
+
scope: scopeResult.scope,
|
|
169
|
+
envName: envNameResult.envName,
|
|
170
|
+
name,
|
|
171
|
+
versionId,
|
|
172
|
+
});
|
|
173
|
+
if (rec === null) {
|
|
174
|
+
c.status(statusFor('secret-version-not-found'));
|
|
175
|
+
return c.json(toWireError({
|
|
176
|
+
code: 'secret-version-not-found',
|
|
177
|
+
message: `No version ${versionId} for secret "${name}".`,
|
|
178
|
+
name,
|
|
179
|
+
versionId,
|
|
180
|
+
}, requestId));
|
|
181
|
+
}
|
|
182
|
+
return c.json(serializeVersion(rec));
|
|
183
|
+
});
|
|
184
|
+
// ------------------------- POST / -----------------------------
|
|
185
|
+
r.post('/', async (c) => {
|
|
186
|
+
const requestId = c.get('requestId');
|
|
187
|
+
const tenantId = c.get('tenantId');
|
|
188
|
+
if (!hasCapability(c, 'secrets:write')) {
|
|
189
|
+
c.status(statusFor('permission-denied'));
|
|
190
|
+
return c.json(toWireError({
|
|
191
|
+
code: 'permission-denied',
|
|
192
|
+
message: 'Bearer token is missing the `secrets:write` capability required for this route.',
|
|
193
|
+
}, requestId));
|
|
194
|
+
}
|
|
195
|
+
let body;
|
|
196
|
+
try {
|
|
197
|
+
body = await c.req.json();
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
c.status(statusFor('bad-input'));
|
|
201
|
+
return c.json(toWireError({ code: 'bad-input', message: 'Request body must be valid JSON' }, requestId));
|
|
202
|
+
}
|
|
203
|
+
if (body === null || typeof body !== 'object') {
|
|
204
|
+
c.status(statusFor('bad-input'));
|
|
205
|
+
return c.json(toWireError({ code: 'bad-input', message: 'Request body must be an object' }, requestId));
|
|
206
|
+
}
|
|
207
|
+
const b = body;
|
|
208
|
+
// Body-first envName + scope validation — POST /v1/secrets carries
|
|
209
|
+
// both entirely in the body (no path params to steer them). Query
|
|
210
|
+
// params are optional here.
|
|
211
|
+
const envNameRaw = b.envName ?? c.req.query('envName');
|
|
212
|
+
const envNameResult = requireEnvName(envNameRaw);
|
|
213
|
+
if (envNameResult.kind === 'err') {
|
|
214
|
+
c.status(statusFor(envNameResult.code));
|
|
215
|
+
return c.json(toWireError({ code: envNameResult.code, message: envNameResult.message }, requestId));
|
|
216
|
+
}
|
|
217
|
+
const bodyScope = validateBodyScope(b.scope, tenantId);
|
|
218
|
+
if (bodyScope.kind === 'err') {
|
|
219
|
+
c.status(statusFor(bodyScope.code));
|
|
220
|
+
return c.json(toWireError({ code: bodyScope.code, message: bodyScope.message }, requestId));
|
|
221
|
+
}
|
|
222
|
+
if (typeof b.name !== 'string' || b.name.length === 0) {
|
|
223
|
+
c.status(statusFor('bad-input'));
|
|
224
|
+
return c.json(toWireError({ code: 'bad-input', message: '`name` is required and must be a non-empty string' }, requestId));
|
|
225
|
+
}
|
|
226
|
+
if (typeof b.value !== 'string') {
|
|
227
|
+
c.status(statusFor('bad-input'));
|
|
228
|
+
return c.json(toWireError({ code: 'bad-input', message: '`value` is required and must be a string' }, requestId));
|
|
229
|
+
}
|
|
230
|
+
if (b.writeMode !== 'create-new' && b.writeMode !== 'add-version') {
|
|
231
|
+
c.status(statusFor('bad-input'));
|
|
232
|
+
return c.json(toWireError({
|
|
233
|
+
code: 'bad-input',
|
|
234
|
+
message: '`writeMode` must be one of `create-new` | `add-version`',
|
|
235
|
+
}, requestId));
|
|
236
|
+
}
|
|
237
|
+
if (b.ifVersion !== undefined && typeof b.ifVersion !== 'number') {
|
|
238
|
+
c.status(statusFor('bad-input'));
|
|
239
|
+
return c.json(toWireError({ code: 'bad-input', message: '`ifVersion` must be a number when present' }, requestId));
|
|
240
|
+
}
|
|
241
|
+
if (b.rotationDueAt !== undefined && typeof b.rotationDueAt !== 'string') {
|
|
242
|
+
c.status(statusFor('bad-input'));
|
|
243
|
+
return c.json(toWireError({ code: 'bad-input', message: '`rotationDueAt` must be an ISO 8601 string when present' }, requestId));
|
|
244
|
+
}
|
|
245
|
+
if (b.tags !== undefined &&
|
|
246
|
+
(b.tags === null || typeof b.tags !== 'object' || Array.isArray(b.tags))) {
|
|
247
|
+
c.status(statusFor('bad-input'));
|
|
248
|
+
return c.json(toWireError({ code: 'bad-input', message: '`tags` must be a string map when present' }, requestId));
|
|
249
|
+
}
|
|
250
|
+
const setScope = bodyScope.scope;
|
|
251
|
+
const outcome = await secretsBinding.set({
|
|
252
|
+
scope: setScope,
|
|
253
|
+
envName: envNameResult.envName,
|
|
254
|
+
name: b.name,
|
|
255
|
+
value: b.value,
|
|
256
|
+
writeMode: b.writeMode,
|
|
257
|
+
...(b.tags !== undefined && { tags: b.tags }),
|
|
258
|
+
...(b.rotationDueAt !== undefined && { rotationDueAt: b.rotationDueAt }),
|
|
259
|
+
...(b.ifVersion !== undefined && { ifVersion: b.ifVersion }),
|
|
260
|
+
// Authorization — write `secret#scope@X` tuple on fresh insert.
|
|
261
|
+
enqueueTuples: (secretRowId) => tuplesForCreate({ kind: 'secret', id: secretRowId, tenantId, scope: setScope }),
|
|
262
|
+
});
|
|
263
|
+
if (outcome.kind === 'ok') {
|
|
264
|
+
// Freshly-created secrets return 201 (`create-new` path); every
|
|
265
|
+
// subsequent version of an existing secret returns 200 (`add-version`).
|
|
266
|
+
const status = b.writeMode === 'create-new' ? 201 : 200;
|
|
267
|
+
c.status(status);
|
|
268
|
+
return c.json({
|
|
269
|
+
record: serializeSecretRecord(outcome.record),
|
|
270
|
+
versionId: outcome.versionId,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (outcome.kind === 'already-exists') {
|
|
274
|
+
c.status(statusFor('secret-write-conflict'));
|
|
275
|
+
return c.json(toWireError({
|
|
276
|
+
code: 'secret-write-conflict',
|
|
277
|
+
message: `Secret "${outcome.record.name}" already exists. Use writeMode: 'add-version' to add a new version.`,
|
|
278
|
+
currentVersion: outcome.record.currentVersion,
|
|
279
|
+
}, requestId));
|
|
280
|
+
}
|
|
281
|
+
if (outcome.kind === 'version-conflict') {
|
|
282
|
+
c.status(statusFor('secret-write-conflict'));
|
|
283
|
+
return c.json(toWireError({
|
|
284
|
+
code: 'secret-write-conflict',
|
|
285
|
+
message: `Stored version is ${outcome.currentVersion}; retry with the current value.`,
|
|
286
|
+
currentVersion: outcome.currentVersion,
|
|
287
|
+
}, requestId));
|
|
288
|
+
}
|
|
289
|
+
// error case
|
|
290
|
+
c.status(statusFor(outcome.code));
|
|
291
|
+
return c.json(toWireError({ code: outcome.code, message: outcome.message }, requestId));
|
|
292
|
+
});
|
|
293
|
+
// -------------------- POST /:name/rotate -----------------------
|
|
294
|
+
r.post('/:name/rotate', async (c) => {
|
|
295
|
+
const requestId = c.get('requestId');
|
|
296
|
+
const tenantId = c.get('tenantId');
|
|
297
|
+
const name = c.req.param('name');
|
|
298
|
+
if (!hasCapability(c, 'secrets:rotate')) {
|
|
299
|
+
c.status(statusFor('permission-denied'));
|
|
300
|
+
return c.json(toWireError({
|
|
301
|
+
code: 'permission-denied',
|
|
302
|
+
message: 'Bearer token is missing the `secrets:rotate` capability required for this route.',
|
|
303
|
+
}, requestId));
|
|
304
|
+
}
|
|
305
|
+
let body = {};
|
|
306
|
+
const raw = await c.req.text();
|
|
307
|
+
if (raw.length > 0) {
|
|
308
|
+
try {
|
|
309
|
+
body = JSON.parse(raw);
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
c.status(statusFor('bad-input'));
|
|
313
|
+
return c.json(toWireError({ code: 'bad-input', message: 'Request body must be valid JSON' }, requestId));
|
|
314
|
+
}
|
|
315
|
+
if (body === null || typeof body !== 'object') {
|
|
316
|
+
c.status(statusFor('bad-input'));
|
|
317
|
+
return c.json(toWireError({ code: 'bad-input', message: 'Request body must be an object' }, requestId));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const b = body;
|
|
321
|
+
const queryEnvName = c.req.query('envName');
|
|
322
|
+
if (b.envName !== undefined && queryEnvName !== undefined && b.envName !== queryEnvName) {
|
|
323
|
+
c.status(statusFor('env-name-mismatch'));
|
|
324
|
+
return c.json(toWireError({
|
|
325
|
+
code: 'env-name-mismatch',
|
|
326
|
+
message: `Body \`envName\` "${String(b.envName)}" does not match query envName "${queryEnvName}".`,
|
|
327
|
+
}, requestId));
|
|
328
|
+
}
|
|
329
|
+
const envNameRaw = b.envName ?? queryEnvName;
|
|
330
|
+
const envNameResult = requireEnvName(envNameRaw);
|
|
331
|
+
if (envNameResult.kind === 'err') {
|
|
332
|
+
c.status(statusFor(envNameResult.code));
|
|
333
|
+
return c.json(toWireError({ code: envNameResult.code, message: envNameResult.message }, requestId));
|
|
334
|
+
}
|
|
335
|
+
// The same resolution the authorization middleware checked.
|
|
336
|
+
const scopeResult = resolveRotateScope(b, c.req.query(), tenantId);
|
|
337
|
+
if (scopeResult.kind === 'err') {
|
|
338
|
+
c.status(statusFor(scopeResult.code));
|
|
339
|
+
return c.json(toWireError({ code: scopeResult.code, message: scopeResult.message }, requestId));
|
|
340
|
+
}
|
|
341
|
+
const scope = scopeResult.scope;
|
|
342
|
+
if (b.newValue !== undefined && typeof b.newValue !== 'string') {
|
|
343
|
+
c.status(statusFor('bad-input'));
|
|
344
|
+
return c.json(toWireError({ code: 'bad-input', message: '`newValue` must be a string when present' }, requestId));
|
|
345
|
+
}
|
|
346
|
+
if (b.revokeOldAfterMs !== undefined && typeof b.revokeOldAfterMs !== 'number') {
|
|
347
|
+
c.status(statusFor('bad-input'));
|
|
348
|
+
return c.json(toWireError({ code: 'bad-input', message: '`revokeOldAfterMs` must be a number when present' }, requestId));
|
|
349
|
+
}
|
|
350
|
+
const result = await secretsBinding.rotate({
|
|
351
|
+
scope,
|
|
352
|
+
envName: envNameResult.envName,
|
|
353
|
+
name,
|
|
354
|
+
...(b.newValue !== undefined && { newValue: b.newValue }),
|
|
355
|
+
...(b.revokeOldAfterMs !== undefined && { revokeOldAfterMs: b.revokeOldAfterMs }),
|
|
356
|
+
});
|
|
357
|
+
if (result.kind === 'err') {
|
|
358
|
+
c.status(statusFor(result.error.code));
|
|
359
|
+
return c.json(toWireError({ code: result.error.code, message: result.error.message, name }, requestId));
|
|
360
|
+
}
|
|
361
|
+
if (result.value.kind === 'ok') {
|
|
362
|
+
// Sync provider — 201 Created inline.
|
|
363
|
+
c.status(201);
|
|
364
|
+
return c.json({
|
|
365
|
+
kind: 'sync',
|
|
366
|
+
newVersionId: result.value.newVersionId,
|
|
367
|
+
oldVersionId: result.value.oldVersionId,
|
|
368
|
+
...(result.value.oldVersionRevokedAt !== undefined && {
|
|
369
|
+
oldVersionRevokedAt: result.value.oldVersionRevokedAt,
|
|
370
|
+
}),
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
// Async provider — mint a rotationId, record, return 202.
|
|
374
|
+
const { rotationId } = await rotationStatusStore.create({
|
|
375
|
+
scope,
|
|
376
|
+
envName: envNameResult.envName,
|
|
377
|
+
name,
|
|
378
|
+
provider: result.value.provider,
|
|
379
|
+
resumeToken: result.value.resumeToken,
|
|
380
|
+
});
|
|
381
|
+
const query = encodeStatusQuery(scope, envNameResult.envName);
|
|
382
|
+
const statusUrl = `/v1/secrets/${encodeURIComponent(name)}/rotations/${rotationId}?${query}`;
|
|
383
|
+
const eventsUrl = `/v1/secrets/${encodeURIComponent(name)}/rotations/${rotationId}/events?${query}`;
|
|
384
|
+
c.status(202);
|
|
385
|
+
return c.json({ kind: 'async', rotationId, statusUrl, eventsUrl });
|
|
386
|
+
});
|
|
387
|
+
// -------- GET /:name/rotations/:rotationId ----------
|
|
388
|
+
r.get('/:name/rotations/:rotationId', async (c) => {
|
|
389
|
+
const requestId = c.get('requestId');
|
|
390
|
+
const tenantId = c.get('tenantId');
|
|
391
|
+
const name = c.req.param('name');
|
|
392
|
+
const rotationId = c.req.param('rotationId');
|
|
393
|
+
const envNameResult = requireEnvName(c.req.query('envName'));
|
|
394
|
+
if (envNameResult.kind === 'err') {
|
|
395
|
+
c.status(statusFor(envNameResult.code));
|
|
396
|
+
return c.json(toWireError({ code: envNameResult.code, message: envNameResult.message }, requestId));
|
|
397
|
+
}
|
|
398
|
+
const scopeResult = requireScope(c.req.query(), tenantId);
|
|
399
|
+
if (scopeResult.kind === 'err') {
|
|
400
|
+
c.status(statusFor(scopeResult.code));
|
|
401
|
+
return c.json(toWireError({ code: scopeResult.code, message: scopeResult.message }, requestId));
|
|
402
|
+
}
|
|
403
|
+
const status = await rotationStatusStore.get({
|
|
404
|
+
scope: scopeResult.scope,
|
|
405
|
+
envName: envNameResult.envName,
|
|
406
|
+
name,
|
|
407
|
+
rotationId,
|
|
408
|
+
});
|
|
409
|
+
if (status === null) {
|
|
410
|
+
c.status(statusFor('not-found'));
|
|
411
|
+
return c.json(toWireError({
|
|
412
|
+
code: 'not-found',
|
|
413
|
+
message: `No rotation "${rotationId}" for secret "${name}".`,
|
|
414
|
+
}, requestId));
|
|
415
|
+
}
|
|
416
|
+
return c.json(serializeRotationStatus(status));
|
|
417
|
+
});
|
|
418
|
+
// -- GET /:name/rotations/:rotationId/events (SSE) --
|
|
419
|
+
r.get('/:name/rotations/:rotationId/events', async (c) => {
|
|
420
|
+
const requestId = c.get('requestId');
|
|
421
|
+
const tenantId = c.get('tenantId');
|
|
422
|
+
const name = c.req.param('name');
|
|
423
|
+
const rotationId = c.req.param('rotationId');
|
|
424
|
+
const envNameResult = requireEnvName(c.req.query('envName'));
|
|
425
|
+
if (envNameResult.kind === 'err') {
|
|
426
|
+
c.status(statusFor(envNameResult.code));
|
|
427
|
+
return c.json(toWireError({ code: envNameResult.code, message: envNameResult.message }, requestId));
|
|
428
|
+
}
|
|
429
|
+
const scopeResult = requireScope(c.req.query(), tenantId);
|
|
430
|
+
if (scopeResult.kind === 'err') {
|
|
431
|
+
c.status(statusFor(scopeResult.code));
|
|
432
|
+
return c.json(toWireError({ code: scopeResult.code, message: scopeResult.message }, requestId));
|
|
433
|
+
}
|
|
434
|
+
const existing = await rotationStatusStore.get({
|
|
435
|
+
scope: scopeResult.scope,
|
|
436
|
+
envName: envNameResult.envName,
|
|
437
|
+
name,
|
|
438
|
+
rotationId,
|
|
439
|
+
});
|
|
440
|
+
if (existing === null) {
|
|
441
|
+
c.status(statusFor('not-found'));
|
|
442
|
+
return c.json(toWireError({
|
|
443
|
+
code: 'not-found',
|
|
444
|
+
message: `No rotation "${rotationId}" for secret "${name}".`,
|
|
445
|
+
}, requestId));
|
|
446
|
+
}
|
|
447
|
+
const encoder = new TextEncoder();
|
|
448
|
+
const initialStatus = existing;
|
|
449
|
+
const body = new ReadableStream({
|
|
450
|
+
async start(controller) {
|
|
451
|
+
let closed = false;
|
|
452
|
+
const close = () => {
|
|
453
|
+
if (closed)
|
|
454
|
+
return;
|
|
455
|
+
closed = true;
|
|
456
|
+
try {
|
|
457
|
+
controller.close();
|
|
458
|
+
}
|
|
459
|
+
catch {
|
|
460
|
+
/* already closed */
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
const emit = (event, data) => {
|
|
464
|
+
if (closed)
|
|
465
|
+
return;
|
|
466
|
+
const payload = event === 'ping' ? '' : JSON.stringify(data);
|
|
467
|
+
try {
|
|
468
|
+
controller.enqueue(encoder.encode(`event: ${event}\ndata: ${payload}\n\n`));
|
|
469
|
+
}
|
|
470
|
+
catch {
|
|
471
|
+
/* already closed */
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
// Emit the initial state so a subscriber that connects after
|
|
475
|
+
// the first update still learns where the rotation stands.
|
|
476
|
+
emit('rotation-update', initialStatus);
|
|
477
|
+
if (initialStatus.status !== 'pending') {
|
|
478
|
+
close();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
let terminal = false;
|
|
482
|
+
let notifier;
|
|
483
|
+
const wakeup = () => {
|
|
484
|
+
if (notifier !== undefined) {
|
|
485
|
+
const cb = notifier;
|
|
486
|
+
notifier = undefined;
|
|
487
|
+
cb();
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
const unsub = rotationStatusStore.subscribe({
|
|
491
|
+
rotationId,
|
|
492
|
+
onUpdate: (s) => {
|
|
493
|
+
emit('rotation-update', s);
|
|
494
|
+
if (s.status !== 'pending') {
|
|
495
|
+
terminal = true;
|
|
496
|
+
}
|
|
497
|
+
wakeup();
|
|
498
|
+
},
|
|
499
|
+
});
|
|
500
|
+
const timer = setInterval(() => {
|
|
501
|
+
if (terminal)
|
|
502
|
+
return;
|
|
503
|
+
emit('ping', {});
|
|
504
|
+
}, heartbeatMs);
|
|
505
|
+
try {
|
|
506
|
+
while (!terminal) {
|
|
507
|
+
await new Promise((resolve) => {
|
|
508
|
+
notifier = resolve;
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
finally {
|
|
513
|
+
clearInterval(timer);
|
|
514
|
+
unsub();
|
|
515
|
+
close();
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
return new Response(body, {
|
|
520
|
+
status: 200,
|
|
521
|
+
headers: {
|
|
522
|
+
'Content-Type': 'text/event-stream; charset=utf-8',
|
|
523
|
+
'Cache-Control': 'no-cache',
|
|
524
|
+
'X-Accel-Buffering': 'no',
|
|
525
|
+
Connection: 'keep-alive',
|
|
526
|
+
},
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
// ------------------------ DELETE /:name -----------------------
|
|
530
|
+
r.delete('/:name', async (c) => {
|
|
531
|
+
const requestId = c.get('requestId');
|
|
532
|
+
const tenantId = c.get('tenantId');
|
|
533
|
+
const name = c.req.param('name');
|
|
534
|
+
const hardFlag = c.req.query('hard') === 'true';
|
|
535
|
+
const requiredCap = hardFlag ? 'secrets:revoke:hard' : 'secrets:revoke';
|
|
536
|
+
if (!hasCapability(c, requiredCap)) {
|
|
537
|
+
c.status(statusFor('permission-denied'));
|
|
538
|
+
return c.json(toWireError({
|
|
539
|
+
code: 'permission-denied',
|
|
540
|
+
message: `Bearer token is missing the \`${requiredCap}\` capability required for this route.`,
|
|
541
|
+
}, requestId));
|
|
542
|
+
}
|
|
543
|
+
const envNameResult = requireEnvName(c.req.query('envName'));
|
|
544
|
+
if (envNameResult.kind === 'err') {
|
|
545
|
+
c.status(statusFor(envNameResult.code));
|
|
546
|
+
return c.json(toWireError({ code: envNameResult.code, message: envNameResult.message }, requestId));
|
|
547
|
+
}
|
|
548
|
+
const scopeResult = requireScope(c.req.query(), tenantId);
|
|
549
|
+
if (scopeResult.kind === 'err') {
|
|
550
|
+
c.status(statusFor(scopeResult.code));
|
|
551
|
+
return c.json(toWireError({ code: scopeResult.code, message: scopeResult.message }, requestId));
|
|
552
|
+
}
|
|
553
|
+
const reason = c.req.query('reason');
|
|
554
|
+
const outcome = await secretsBinding.revoke({
|
|
555
|
+
scope: scopeResult.scope,
|
|
556
|
+
envName: envNameResult.envName,
|
|
557
|
+
name,
|
|
558
|
+
...(hardFlag && { hard: true }),
|
|
559
|
+
...(reason !== undefined && reason.length > 0 && { reason }),
|
|
560
|
+
});
|
|
561
|
+
if (outcome.kind === 'err') {
|
|
562
|
+
c.status(statusFor(outcome.error.code));
|
|
563
|
+
return c.json(toWireError({ code: outcome.error.code, message: outcome.error.message, name }, requestId));
|
|
564
|
+
}
|
|
565
|
+
return c.json({ revoked: outcome.value.revoked, hard: outcome.value.hard });
|
|
566
|
+
});
|
|
567
|
+
return r;
|
|
568
|
+
}
|
|
569
|
+
// --------------------------- helpers ---------------------------
|
|
570
|
+
function encodeStatusQuery(scope, envName) {
|
|
571
|
+
const params = new URLSearchParams();
|
|
572
|
+
params.set('envName', envName);
|
|
573
|
+
params.set('scopeKind', scope.kind);
|
|
574
|
+
if (scope.kind === 'org') {
|
|
575
|
+
params.set('scopeId', scope.orgId);
|
|
576
|
+
}
|
|
577
|
+
else if (scope.kind === 'project') {
|
|
578
|
+
params.set('scopeId', scope.projectId);
|
|
579
|
+
}
|
|
580
|
+
return params.toString();
|
|
581
|
+
}
|
|
582
|
+
function validateBodyScope(raw, tenantId) {
|
|
583
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
584
|
+
return {
|
|
585
|
+
kind: 'err',
|
|
586
|
+
code: 'scope-kind-required',
|
|
587
|
+
message: '`scope` is required in the request body.',
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
const obj = raw;
|
|
591
|
+
if (obj.kind !== 'tenant' && obj.kind !== 'org' && obj.kind !== 'project') {
|
|
592
|
+
return {
|
|
593
|
+
kind: 'err',
|
|
594
|
+
code: 'scope-kind-required',
|
|
595
|
+
message: '`scope.kind` must be one of `tenant` | `org` | `project`.',
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
// Cross-tenant refuse: body `tenantId` must match session tenantId.
|
|
599
|
+
if (obj.tenantId !== undefined && obj.tenantId !== tenantId) {
|
|
600
|
+
return {
|
|
601
|
+
kind: 'err',
|
|
602
|
+
code: 'scope-mismatch',
|
|
603
|
+
message: 'Body `scope.tenantId` does not match session tenantId.',
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
if (obj.kind === 'tenant') {
|
|
607
|
+
return {
|
|
608
|
+
kind: 'ok',
|
|
609
|
+
scope: { kind: 'tenant', tenantId },
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
if (obj.kind === 'org') {
|
|
613
|
+
if (typeof obj.orgId !== 'string' || obj.orgId.length === 0) {
|
|
614
|
+
return {
|
|
615
|
+
kind: 'err',
|
|
616
|
+
code: 'scope-invalid',
|
|
617
|
+
message: '`scope.orgId` is required when scope.kind is `org`.',
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
return {
|
|
621
|
+
kind: 'ok',
|
|
622
|
+
scope: { kind: 'org', tenantId, orgId: obj.orgId },
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
if (typeof obj.projectId !== 'string' || obj.projectId.length === 0) {
|
|
626
|
+
return {
|
|
627
|
+
kind: 'err',
|
|
628
|
+
code: 'scope-invalid',
|
|
629
|
+
message: '`scope.projectId` is required when scope.kind is `project`.',
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
return {
|
|
633
|
+
kind: 'ok',
|
|
634
|
+
scope: { kind: 'project', tenantId, projectId: obj.projectId },
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* The scope `POST /:name/rotate` acts on: `body.scope` when present, else
|
|
639
|
+
* the `?scopeKind` + `?scopeId` query parameters. When the body and the
|
|
640
|
+
* query both carry a scope they must name the same one (`scope-mismatch`).
|
|
641
|
+
* The authorization middleware and the handler both resolve through here.
|
|
642
|
+
*/
|
|
643
|
+
function resolveRotateScope(body, query, tenantId) {
|
|
644
|
+
const queryHasScope = query.scopeKind !== undefined || query.scopeId !== undefined;
|
|
645
|
+
const queryScope = requireScope(query, tenantId);
|
|
646
|
+
if (body.scope === undefined)
|
|
647
|
+
return queryScope;
|
|
648
|
+
const bodyScope = validateBodyScope(body.scope, tenantId);
|
|
649
|
+
if (bodyScope.kind === 'err' || !queryHasScope)
|
|
650
|
+
return bodyScope;
|
|
651
|
+
if (queryScope.kind === 'err')
|
|
652
|
+
return queryScope;
|
|
653
|
+
if (!scopesEqual(body.scope, queryScope.scope)) {
|
|
654
|
+
return {
|
|
655
|
+
kind: 'err',
|
|
656
|
+
code: 'scope-mismatch',
|
|
657
|
+
message: 'Body `scope` does not match query scopeKind/scopeId.',
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
return bodyScope;
|
|
661
|
+
}
|
|
662
|
+
/** The request body as an object; `{}` when it is empty or not a JSON object. */
|
|
663
|
+
function parseJsonObject(raw) {
|
|
664
|
+
if (raw.length === 0)
|
|
665
|
+
return {};
|
|
666
|
+
try {
|
|
667
|
+
const parsed = JSON.parse(raw);
|
|
668
|
+
return parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
669
|
+
? parsed
|
|
670
|
+
: {};
|
|
671
|
+
}
|
|
672
|
+
catch {
|
|
673
|
+
return {};
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
function serializeSecretRecord(rec) {
|
|
677
|
+
return {
|
|
678
|
+
scope: rec.scope,
|
|
679
|
+
envName: rec.envName,
|
|
680
|
+
name: rec.name,
|
|
681
|
+
currentVersion: rec.currentVersion,
|
|
682
|
+
createdAt: rec.createdAt,
|
|
683
|
+
updatedAt: rec.updatedAt,
|
|
684
|
+
...(rec.revokedAt !== undefined && { revokedAt: rec.revokedAt }),
|
|
685
|
+
...(rec.revokeReason !== undefined && { revokeReason: rec.revokeReason }),
|
|
686
|
+
...(rec.tags !== undefined && { tags: rec.tags }),
|
|
687
|
+
...(rec.rotationDueAt !== undefined && { rotationDueAt: rec.rotationDueAt }),
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
function serializeVersion(rec) {
|
|
691
|
+
return {
|
|
692
|
+
scope: rec.scope,
|
|
693
|
+
envName: rec.envName,
|
|
694
|
+
name: rec.name,
|
|
695
|
+
versionId: rec.versionId,
|
|
696
|
+
createdAt: rec.createdAt,
|
|
697
|
+
// Redaction: `value` is ALWAYS null on getVersion / listVersions.
|
|
698
|
+
// The only `value`-returning path is `resolve`, which has no HTTP
|
|
699
|
+
// surface.
|
|
700
|
+
value: null,
|
|
701
|
+
...(rec.revokedAt !== undefined && { revokedAt: rec.revokedAt }),
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
function serializeRotationStatus(s) {
|
|
705
|
+
return {
|
|
706
|
+
rotationId: s.rotationId,
|
|
707
|
+
status: s.status,
|
|
708
|
+
startedAt: s.startedAt,
|
|
709
|
+
updatedAt: s.updatedAt,
|
|
710
|
+
...(s.newVersionId !== undefined && { newVersionId: s.newVersionId }),
|
|
711
|
+
...(s.oldVersionId !== undefined && { oldVersionId: s.oldVersionId }),
|
|
712
|
+
...(s.error !== undefined && { error: s.error }),
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
//# sourceMappingURL=secrets.js.map
|