@apexops/cli 0.10.0-next.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/assets/capability-packs/azure-governance-discovery/source/scripts/discover.py +1189 -0
- package/assets/capability-packs/azure-governance-discovery/source/scripts/render_governance.py +676 -0
- package/assets/capability-packs/registry.v1.json +73 -0
- package/assets/client-projection-metadata/copilot-cli-agent-tools.json +92 -0
- package/assets/client-projections/github-copilot-cli/.github/agents/apex-architect.agent.md +78 -0
- package/assets/client-projections/github-copilot-cli/.github/agents/apex-operator.agent.md +71 -0
- package/assets/client-projections/github-copilot-cli/.github/agents/apex-planner.agent.md +79 -0
- package/assets/client-projections/github-copilot-cli/.github/agents/apex-requirements.agent.md +69 -0
- package/assets/client-projections/github-copilot-cli/.github/agents/apex.agent.md +52 -0
- package/assets/client-projections/github-copilot-cli/.github/copilot-instructions.md +13 -0
- package/assets/client-projections/github-copilot-cli/.github/mcp.json +54 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-architecture/SKILL.md +36 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/SKILL.md +65 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/references/presentation-conventions.md +52 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/references/reference-only-outlines.md +78 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/architecture-assessment.md +35 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/cost-estimate.md +47 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/deployment-summary.md +35 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/governance-constraints.md +35 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/implementation-plan.md +43 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/operations-runbook.md +35 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/requirements.md +42 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-artifacts/templates/resource-inventory.md +29 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/SKILL.md +52 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/references/decision-examples.md +38 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/references/decision-guardrails.md +36 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/references/decision-quality.md +21 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-adr/references/decision-record-fields.md +57 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/SKILL.md +55 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/references/lambda-to-functions-assessment.md +29 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/references/migration-readiness.md +27 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/references/staged-validation-handoff.md +26 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cloud-migrate/references/workload-mapping.md +27 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compliance/SKILL.md +58 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compliance/references/compliance-finding-criteria.md +63 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compliance/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compute/SKILL.md +36 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compute/references/compute-selection.md +26 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compute/references/pricing-evidence.md +11 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-compute/references/recommendation-and-scale-rules.md +44 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cost-optimization/SKILL.md +61 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cost-optimization/references/cost-assessment-criteria.md +61 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-cost-optimization/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/SKILL.md +59 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/avm-binding-guidance.md +29 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/baseline-fallbacks.md +53 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/cost-monitoring.md +47 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/decision-boundaries.md +19 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/governance-effects.md +28 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/naming.md +47 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/network-planning.md +47 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/security-baseline.md +40 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/service-selection.md +51 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-defaults/references/tag-precedence.md +31 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-deploy/SKILL.md +50 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-deploy/references/operational-checklist.md +26 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-deploy/references/preview-recovery-verification.md +48 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-diagnostics/SKILL.md +60 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-diagnostics/references/diagnostic-interpretation.md +42 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-diagnostics/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-governance/SKILL.md +52 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-governance/references/evidence-interpretation.md +58 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-governance/references/operational-checklist.md +25 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-kusto/SKILL.md +58 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-kusto/references/kql-evidence-interpretation.md +41 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-kusto/references/operational-checklist.md +25 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-prepare/SKILL.md +52 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-prepare/references/functions-recipe-pack.md +27 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-prepare/references/preparation-lineage.md +36 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-quotas/SKILL.md +53 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-quotas/references/capacity-decision-rules.md +48 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-quotas/references/operational-checklist.md +23 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-rbac/SKILL.md +45 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-rbac/references/assignment-intent.md +39 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-rbac/references/least-privilege-selection.md +50 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-resources/SKILL.md +54 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-resources/references/inventory-query-patterns.md +49 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-resources/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-storage/SKILL.md +35 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-storage/references/security-and-governance.md +12 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-storage/references/service-auth-and-sdk-boundary.md +33 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-storage/references/storage-selection.md +12 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-validate/SKILL.md +49 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-validate/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-azure-validate/references/preflight-evidence.md +43 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/SKILL.md +41 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/avm-and-codegen-acceptance.md +11 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/codegen-acceptance-checklist.md +46 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/compiler-and-provider-gotchas.md +74 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/module-interfaces-and-parameters.md +56 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-bicep-patterns/references/network-and-observability.md +52 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-codegen/SKILL.md +32 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/SKILL.md +53 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/references/capability-receipts.md +21 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/references/design-and-diagnostics.md +36 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/references/oauth-registration-model.md +26 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-entra-app-registration/references/permissions-and-credentials.md +27 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-mermaid/SKILL.md +44 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-mermaid/references/styling.md +33 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-mermaid/references/syntax.md +99 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-microsoft-docs/SKILL.md +53 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-microsoft-docs/references/research-method.md +91 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-operations/SKILL.md +34 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-planning/SKILL.md +36 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-requirements/SKILL.md +43 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/SKILL.md +47 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/references/adoption-attestation.md +10 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/references/import-assessment.md +14 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/references/import-mapping.md +27 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-import/references/mapping-and-adoption-attestation.md +12 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/SKILL.md +49 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/module-composition-and-refactor.md +20 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/module-composition-and-state-boundaries.md +11 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/module-locks-and-codegen-acceptance.md +14 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/network-and-observability.md +12 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-patterns/references/plan-and-change-assessment.md +24 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/SKILL.md +45 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/references/evidence-acceptance.md +10 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/references/plan-mode-and-mock-design.md +12 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/references/plan-mode-test-design.md +23 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-terraform-test/references/test-design.md +13 -0
- package/assets/client-projections/github-copilot-cli/.github/skills/apex-workflow/SKILL.md +37 -0
- package/assets/client-projections/github-copilot-vscode/.github/agents/apex-architect.agent.md +87 -0
- package/assets/client-projections/github-copilot-vscode/.github/agents/apex-codegen.agent.md +54 -0
- package/assets/client-projections/github-copilot-vscode/.github/agents/apex-operator.agent.md +75 -0
- package/assets/client-projections/github-copilot-vscode/.github/agents/apex-planner.agent.md +89 -0
- package/assets/client-projections/github-copilot-vscode/.github/agents/apex-requirements.agent.md +78 -0
- package/assets/client-projections/github-copilot-vscode/.github/agents/apex-reviewer.agent.md +45 -0
- package/assets/client-projections/github-copilot-vscode/.github/agents/apex-validator.agent.md +50 -0
- package/assets/client-projections/github-copilot-vscode/.github/agents/apex.agent.md +71 -0
- package/assets/client-projections/github-copilot-vscode/.github/copilot-instructions.md +13 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-architecture/SKILL.md +36 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/SKILL.md +65 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/references/presentation-conventions.md +52 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/references/reference-only-outlines.md +78 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/architecture-assessment.md +35 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/cost-estimate.md +47 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/deployment-summary.md +35 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/governance-constraints.md +35 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/implementation-plan.md +43 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/operations-runbook.md +35 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/requirements.md +42 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-artifacts/templates/resource-inventory.md +29 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/SKILL.md +52 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/references/decision-examples.md +38 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/references/decision-guardrails.md +36 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/references/decision-quality.md +21 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-adr/references/decision-record-fields.md +57 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/SKILL.md +55 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/references/lambda-to-functions-assessment.md +29 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/references/migration-readiness.md +27 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/references/staged-validation-handoff.md +26 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cloud-migrate/references/workload-mapping.md +27 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compliance/SKILL.md +58 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compliance/references/compliance-finding-criteria.md +63 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compliance/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compute/SKILL.md +36 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compute/references/compute-selection.md +26 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compute/references/pricing-evidence.md +11 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-compute/references/recommendation-and-scale-rules.md +44 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cost-optimization/SKILL.md +61 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cost-optimization/references/cost-assessment-criteria.md +61 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-cost-optimization/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/SKILL.md +59 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/avm-binding-guidance.md +29 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/baseline-fallbacks.md +53 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/cost-monitoring.md +47 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/decision-boundaries.md +19 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/governance-effects.md +28 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/naming.md +47 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/network-planning.md +47 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/security-baseline.md +40 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/service-selection.md +51 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-defaults/references/tag-precedence.md +31 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-deploy/SKILL.md +50 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-deploy/references/operational-checklist.md +26 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-deploy/references/preview-recovery-verification.md +48 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-diagnostics/SKILL.md +60 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-diagnostics/references/diagnostic-interpretation.md +42 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-diagnostics/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-governance/SKILL.md +52 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-governance/references/evidence-interpretation.md +58 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-governance/references/operational-checklist.md +25 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-kusto/SKILL.md +58 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-kusto/references/kql-evidence-interpretation.md +41 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-kusto/references/operational-checklist.md +25 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-prepare/SKILL.md +52 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-prepare/references/functions-recipe-pack.md +27 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-prepare/references/preparation-lineage.md +36 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-quotas/SKILL.md +53 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-quotas/references/capacity-decision-rules.md +48 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-quotas/references/operational-checklist.md +23 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-rbac/SKILL.md +45 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-rbac/references/assignment-intent.md +39 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-rbac/references/least-privilege-selection.md +50 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-resources/SKILL.md +54 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-resources/references/inventory-query-patterns.md +49 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-resources/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-storage/SKILL.md +35 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-storage/references/security-and-governance.md +12 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-storage/references/service-auth-and-sdk-boundary.md +33 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-storage/references/storage-selection.md +12 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-validate/SKILL.md +49 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-validate/references/operational-checklist.md +24 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-azure-validate/references/preflight-evidence.md +43 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/SKILL.md +41 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/avm-and-codegen-acceptance.md +11 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/codegen-acceptance-checklist.md +46 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/compiler-and-provider-gotchas.md +74 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/module-interfaces-and-parameters.md +56 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-bicep-patterns/references/network-and-observability.md +52 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-codegen/SKILL.md +32 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/SKILL.md +53 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/references/capability-receipts.md +21 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/references/design-and-diagnostics.md +36 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/references/oauth-registration-model.md +26 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-entra-app-registration/references/permissions-and-credentials.md +27 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-mermaid/SKILL.md +44 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-mermaid/references/styling.md +33 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-mermaid/references/syntax.md +99 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-microsoft-docs/SKILL.md +53 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-microsoft-docs/references/research-method.md +91 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-operations/SKILL.md +34 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-planning/SKILL.md +36 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-requirements/SKILL.md +43 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/SKILL.md +47 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/references/adoption-attestation.md +10 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/references/import-assessment.md +14 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/references/import-mapping.md +27 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-import/references/mapping-and-adoption-attestation.md +12 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/SKILL.md +49 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/module-composition-and-refactor.md +20 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/module-composition-and-state-boundaries.md +11 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/module-locks-and-codegen-acceptance.md +14 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/network-and-observability.md +12 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-patterns/references/plan-and-change-assessment.md +24 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/SKILL.md +45 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/references/evidence-acceptance.md +10 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/references/plan-mode-and-mock-design.md +12 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/references/plan-mode-test-design.md +23 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-terraform-test/references/test-design.md +13 -0
- package/assets/client-projections/github-copilot-vscode/.github/skills/apex-workflow/SKILL.md +37 -0
- package/assets/client-projections/github-copilot-vscode/.vscode/mcp.json +21 -0
- package/assets/config/capability-packs.v1.json +43 -0
- package/assets/config/defaults.v1.json +98 -0
- package/assets/config/improvement-policy.v1.json +37 -0
- package/assets/config/quality-scorecard.v1.json +105 -0
- package/assets/config/recipe-packs.v1.json +29 -0
- package/assets/config/runtime-bundle.v1.json +84 -0
- package/assets/config/toolchain.v1.json +134 -0
- package/assets/config/workflow.v1.json +876 -0
- package/assets/customizations/.github/agents/apex-architect.agent.md +80 -0
- package/assets/customizations/.github/agents/apex-codegen.agent.md +51 -0
- package/assets/customizations/.github/agents/apex-operator.agent.md +68 -0
- package/assets/customizations/.github/agents/apex-planner.agent.md +82 -0
- package/assets/customizations/.github/agents/apex-requirements.agent.md +71 -0
- package/assets/customizations/.github/agents/apex-reviewer.agent.md +42 -0
- package/assets/customizations/.github/agents/apex-validator.agent.md +47 -0
- package/assets/customizations/.github/agents/apex.agent.md +64 -0
- package/assets/customizations/.github/copilot-instructions.md +13 -0
- package/assets/customizations/.github/mcp.json +54 -0
- package/assets/customizations/.github/skills/apex-architecture/SKILL.md +36 -0
- package/assets/customizations/.github/skills/apex-artifacts/SKILL.md +65 -0
- package/assets/customizations/.github/skills/apex-artifacts/references/presentation-conventions.md +52 -0
- package/assets/customizations/.github/skills/apex-artifacts/references/reference-only-outlines.md +78 -0
- package/assets/customizations/.github/skills/apex-artifacts/templates/architecture-assessment.md +35 -0
- package/assets/customizations/.github/skills/apex-artifacts/templates/cost-estimate.md +47 -0
- package/assets/customizations/.github/skills/apex-artifacts/templates/deployment-summary.md +35 -0
- package/assets/customizations/.github/skills/apex-artifacts/templates/governance-constraints.md +35 -0
- package/assets/customizations/.github/skills/apex-artifacts/templates/implementation-plan.md +43 -0
- package/assets/customizations/.github/skills/apex-artifacts/templates/operations-runbook.md +35 -0
- package/assets/customizations/.github/skills/apex-artifacts/templates/requirements.md +42 -0
- package/assets/customizations/.github/skills/apex-artifacts/templates/resource-inventory.md +29 -0
- package/assets/customizations/.github/skills/apex-azure-adr/SKILL.md +52 -0
- package/assets/customizations/.github/skills/apex-azure-adr/references/decision-examples.md +38 -0
- package/assets/customizations/.github/skills/apex-azure-adr/references/decision-guardrails.md +36 -0
- package/assets/customizations/.github/skills/apex-azure-adr/references/decision-quality.md +21 -0
- package/assets/customizations/.github/skills/apex-azure-adr/references/decision-record-fields.md +57 -0
- package/assets/customizations/.github/skills/apex-azure-cloud-migrate/SKILL.md +55 -0
- package/assets/customizations/.github/skills/apex-azure-cloud-migrate/references/lambda-to-functions-assessment.md +29 -0
- package/assets/customizations/.github/skills/apex-azure-cloud-migrate/references/migration-readiness.md +27 -0
- package/assets/customizations/.github/skills/apex-azure-cloud-migrate/references/staged-validation-handoff.md +26 -0
- package/assets/customizations/.github/skills/apex-azure-cloud-migrate/references/workload-mapping.md +27 -0
- package/assets/customizations/.github/skills/apex-azure-compliance/SKILL.md +58 -0
- package/assets/customizations/.github/skills/apex-azure-compliance/references/compliance-finding-criteria.md +63 -0
- package/assets/customizations/.github/skills/apex-azure-compliance/references/operational-checklist.md +24 -0
- package/assets/customizations/.github/skills/apex-azure-compute/SKILL.md +36 -0
- package/assets/customizations/.github/skills/apex-azure-compute/references/compute-selection.md +26 -0
- package/assets/customizations/.github/skills/apex-azure-compute/references/pricing-evidence.md +11 -0
- package/assets/customizations/.github/skills/apex-azure-compute/references/recommendation-and-scale-rules.md +44 -0
- package/assets/customizations/.github/skills/apex-azure-cost-optimization/SKILL.md +61 -0
- package/assets/customizations/.github/skills/apex-azure-cost-optimization/references/cost-assessment-criteria.md +61 -0
- package/assets/customizations/.github/skills/apex-azure-cost-optimization/references/operational-checklist.md +24 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/SKILL.md +59 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/avm-binding-guidance.md +29 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/baseline-fallbacks.md +53 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/cost-monitoring.md +47 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/decision-boundaries.md +19 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/governance-effects.md +28 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/naming.md +47 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/network-planning.md +47 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/security-baseline.md +40 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/service-selection.md +51 -0
- package/assets/customizations/.github/skills/apex-azure-defaults/references/tag-precedence.md +31 -0
- package/assets/customizations/.github/skills/apex-azure-deploy/SKILL.md +50 -0
- package/assets/customizations/.github/skills/apex-azure-deploy/references/operational-checklist.md +26 -0
- package/assets/customizations/.github/skills/apex-azure-deploy/references/preview-recovery-verification.md +48 -0
- package/assets/customizations/.github/skills/apex-azure-diagnostics/SKILL.md +60 -0
- package/assets/customizations/.github/skills/apex-azure-diagnostics/references/diagnostic-interpretation.md +42 -0
- package/assets/customizations/.github/skills/apex-azure-diagnostics/references/operational-checklist.md +24 -0
- package/assets/customizations/.github/skills/apex-azure-governance/SKILL.md +52 -0
- package/assets/customizations/.github/skills/apex-azure-governance/references/evidence-interpretation.md +58 -0
- package/assets/customizations/.github/skills/apex-azure-governance/references/operational-checklist.md +25 -0
- package/assets/customizations/.github/skills/apex-azure-kusto/SKILL.md +58 -0
- package/assets/customizations/.github/skills/apex-azure-kusto/references/kql-evidence-interpretation.md +41 -0
- package/assets/customizations/.github/skills/apex-azure-kusto/references/operational-checklist.md +25 -0
- package/assets/customizations/.github/skills/apex-azure-prepare/SKILL.md +52 -0
- package/assets/customizations/.github/skills/apex-azure-prepare/references/functions-recipe-pack.md +27 -0
- package/assets/customizations/.github/skills/apex-azure-prepare/references/preparation-lineage.md +36 -0
- package/assets/customizations/.github/skills/apex-azure-quotas/SKILL.md +53 -0
- package/assets/customizations/.github/skills/apex-azure-quotas/references/capacity-decision-rules.md +48 -0
- package/assets/customizations/.github/skills/apex-azure-quotas/references/operational-checklist.md +23 -0
- package/assets/customizations/.github/skills/apex-azure-rbac/SKILL.md +45 -0
- package/assets/customizations/.github/skills/apex-azure-rbac/references/assignment-intent.md +39 -0
- package/assets/customizations/.github/skills/apex-azure-rbac/references/least-privilege-selection.md +50 -0
- package/assets/customizations/.github/skills/apex-azure-resources/SKILL.md +54 -0
- package/assets/customizations/.github/skills/apex-azure-resources/references/inventory-query-patterns.md +49 -0
- package/assets/customizations/.github/skills/apex-azure-resources/references/operational-checklist.md +24 -0
- package/assets/customizations/.github/skills/apex-azure-storage/SKILL.md +35 -0
- package/assets/customizations/.github/skills/apex-azure-storage/references/security-and-governance.md +12 -0
- package/assets/customizations/.github/skills/apex-azure-storage/references/service-auth-and-sdk-boundary.md +33 -0
- package/assets/customizations/.github/skills/apex-azure-storage/references/storage-selection.md +12 -0
- package/assets/customizations/.github/skills/apex-azure-validate/SKILL.md +49 -0
- package/assets/customizations/.github/skills/apex-azure-validate/references/operational-checklist.md +24 -0
- package/assets/customizations/.github/skills/apex-azure-validate/references/preflight-evidence.md +43 -0
- package/assets/customizations/.github/skills/apex-bicep-patterns/SKILL.md +41 -0
- package/assets/customizations/.github/skills/apex-bicep-patterns/references/avm-and-codegen-acceptance.md +11 -0
- package/assets/customizations/.github/skills/apex-bicep-patterns/references/codegen-acceptance-checklist.md +46 -0
- package/assets/customizations/.github/skills/apex-bicep-patterns/references/compiler-and-provider-gotchas.md +74 -0
- package/assets/customizations/.github/skills/apex-bicep-patterns/references/module-interfaces-and-parameters.md +56 -0
- package/assets/customizations/.github/skills/apex-bicep-patterns/references/network-and-observability.md +52 -0
- package/assets/customizations/.github/skills/apex-codegen/SKILL.md +32 -0
- package/assets/customizations/.github/skills/apex-entra-app-registration/SKILL.md +53 -0
- package/assets/customizations/.github/skills/apex-entra-app-registration/references/capability-receipts.md +21 -0
- package/assets/customizations/.github/skills/apex-entra-app-registration/references/design-and-diagnostics.md +36 -0
- package/assets/customizations/.github/skills/apex-entra-app-registration/references/oauth-registration-model.md +26 -0
- package/assets/customizations/.github/skills/apex-entra-app-registration/references/permissions-and-credentials.md +27 -0
- package/assets/customizations/.github/skills/apex-mermaid/SKILL.md +44 -0
- package/assets/customizations/.github/skills/apex-mermaid/references/styling.md +33 -0
- package/assets/customizations/.github/skills/apex-mermaid/references/syntax.md +99 -0
- package/assets/customizations/.github/skills/apex-microsoft-docs/SKILL.md +53 -0
- package/assets/customizations/.github/skills/apex-microsoft-docs/references/research-method.md +91 -0
- package/assets/customizations/.github/skills/apex-operations/SKILL.md +34 -0
- package/assets/customizations/.github/skills/apex-planning/SKILL.md +36 -0
- package/assets/customizations/.github/skills/apex-requirements/SKILL.md +43 -0
- package/assets/customizations/.github/skills/apex-terraform-import/SKILL.md +47 -0
- package/assets/customizations/.github/skills/apex-terraform-import/references/adoption-attestation.md +10 -0
- package/assets/customizations/.github/skills/apex-terraform-import/references/import-assessment.md +14 -0
- package/assets/customizations/.github/skills/apex-terraform-import/references/import-mapping.md +27 -0
- package/assets/customizations/.github/skills/apex-terraform-import/references/mapping-and-adoption-attestation.md +12 -0
- package/assets/customizations/.github/skills/apex-terraform-patterns/SKILL.md +49 -0
- package/assets/customizations/.github/skills/apex-terraform-patterns/references/module-composition-and-refactor.md +20 -0
- package/assets/customizations/.github/skills/apex-terraform-patterns/references/module-composition-and-state-boundaries.md +11 -0
- package/assets/customizations/.github/skills/apex-terraform-patterns/references/module-locks-and-codegen-acceptance.md +14 -0
- package/assets/customizations/.github/skills/apex-terraform-patterns/references/network-and-observability.md +12 -0
- package/assets/customizations/.github/skills/apex-terraform-patterns/references/plan-and-change-assessment.md +24 -0
- package/assets/customizations/.github/skills/apex-terraform-test/SKILL.md +45 -0
- package/assets/customizations/.github/skills/apex-terraform-test/references/evidence-acceptance.md +10 -0
- package/assets/customizations/.github/skills/apex-terraform-test/references/plan-mode-and-mock-design.md +12 -0
- package/assets/customizations/.github/skills/apex-terraform-test/references/plan-mode-test-design.md +23 -0
- package/assets/customizations/.github/skills/apex-terraform-test/references/test-design.md +13 -0
- package/assets/customizations/.github/skills/apex-workflow/SKILL.md +37 -0
- package/assets/customizations/.vscode/mcp.json +21 -0
- package/assets/customizations/README.md +22 -0
- package/assets/customizations/manifest.json +251 -0
- package/assets/manifest.json +5027 -0
- package/dist/assets.d.ts +69 -0
- package/dist/assets.js +336 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +643 -0
- package/dist/dependency-revision.d.ts +5 -0
- package/dist/dependency-revision.js +21 -0
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +34 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/mcp.d.ts +5 -0
- package/dist/mcp.js +210 -0
- package/dist/provider-runtime.d.ts +27 -0
- package/dist/provider-runtime.js +229 -0
- package/dist/provider-transfer.d.ts +52 -0
- package/dist/provider-transfer.js +533 -0
- package/dist/service.d.ts +806 -0
- package/dist/service.js +3817 -0
- package/dist/state-transfer.d.ts +51 -0
- package/dist/state-transfer.js +559 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/dist/workflow-validators.d.ts +80 -0
- package/dist/workflow-validators.js +843 -0
- package/package.json +57 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import { chmod, lstat, mkdir, readFile } from "node:fs/promises";
|
|
2
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { BoundEnvelopeTransport } from "@apexops/capabilities";
|
|
4
|
+
import { atomicWriteBytes, canonicalJsonBytes, sha256Bytes, sha256Json } from "@apexops/kernel";
|
|
5
|
+
export const PROVIDER_TRANSFER_KIND = "apex-provider-authority";
|
|
6
|
+
export const PROVIDER_TRANSFER_MAX_BUNDLE_BYTES = 8 * 1024 * 1024;
|
|
7
|
+
export const PROVIDER_TRANSFER_MAX_FILE_BYTES = 4 * 1024 * 1024;
|
|
8
|
+
const HASH_PATTERN = /^[0-9a-f]{64}$/;
|
|
9
|
+
const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
10
|
+
const BINDING_PATH_PATTERN = /^bindings\/[0-9a-f]{64}\.json$/;
|
|
11
|
+
const ARTIFACT_PATH_PATTERN = /^artifacts\/[0-9a-f]{64}\.json$/;
|
|
12
|
+
const PLAN_KEY_PATH = "plan-transport.key";
|
|
13
|
+
function earliestExpiry(...values) {
|
|
14
|
+
return values.reduce((earliest, value) => (Date.parse(value) < Date.parse(earliest) ? value : earliest));
|
|
15
|
+
}
|
|
16
|
+
function requireRecord(value, label) {
|
|
17
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
18
|
+
throw new Error(`${label} is invalid`);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function requireNonempty(value, label) {
|
|
22
|
+
if (typeof value !== "string" || value.trim().length === 0)
|
|
23
|
+
throw new Error(`${label} is required`);
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
function requireHash(value, label) {
|
|
27
|
+
if (typeof value !== "string" || !HASH_PATTERN.test(value))
|
|
28
|
+
throw new Error(`${label} must be a SHA-256 hash`);
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
function requireBase64(value, bytes, label) {
|
|
32
|
+
if (typeof value !== "string" || !BASE64_PATTERN.test(value))
|
|
33
|
+
throw new Error(`${label} is invalid`);
|
|
34
|
+
const decoded = Buffer.from(value, "base64");
|
|
35
|
+
if (decoded.byteLength !== bytes || decoded.toString("base64") !== value)
|
|
36
|
+
throw new Error(`${label} is invalid`);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
function parseJson(bytes, label) {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(bytes.toString("utf8"));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
throw new Error(`${label} is not valid JSON`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function readRegular(path, label) {
|
|
48
|
+
const info = await lstat(path);
|
|
49
|
+
if (info.isSymbolicLink() || !info.isFile())
|
|
50
|
+
throw new Error(`${label} is not a regular file`);
|
|
51
|
+
if (info.size > PROVIDER_TRANSFER_MAX_FILE_BYTES)
|
|
52
|
+
throw new Error(`${label} exceeds the 4 MiB file limit`);
|
|
53
|
+
return await readFile(path);
|
|
54
|
+
}
|
|
55
|
+
function exactKeys(value, expected, label) {
|
|
56
|
+
if (Object.keys(value).sort().join("\0") !== [...expected].sort().join("\0")) {
|
|
57
|
+
throw new Error(`${label} shape is invalid`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function requireTimestamp(value, label) {
|
|
61
|
+
if (typeof value !== "string" || !Number.isFinite(Date.parse(value)))
|
|
62
|
+
throw new Error(`${label} is invalid`);
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
function validatePreview(preview) {
|
|
66
|
+
const expected = [
|
|
67
|
+
"blockers",
|
|
68
|
+
"changes",
|
|
69
|
+
"commit",
|
|
70
|
+
"createdAt",
|
|
71
|
+
"dependencyRevision",
|
|
72
|
+
"environment",
|
|
73
|
+
"expiresAt",
|
|
74
|
+
"iacHash",
|
|
75
|
+
"inputHash",
|
|
76
|
+
"operation",
|
|
77
|
+
"ownerEpoch",
|
|
78
|
+
"policyHash",
|
|
79
|
+
"previewHash",
|
|
80
|
+
"projectId",
|
|
81
|
+
"runId",
|
|
82
|
+
"schemaVersion",
|
|
83
|
+
"target",
|
|
84
|
+
"track",
|
|
85
|
+
];
|
|
86
|
+
for (const optional of ["artifactHash", "stateLineage", "stateSerial"]) {
|
|
87
|
+
if (preview[optional] !== undefined)
|
|
88
|
+
expected.push(optional);
|
|
89
|
+
}
|
|
90
|
+
exactKeys(preview, expected, "Provider binding preview");
|
|
91
|
+
if (preview.schemaVersion !== "1.0.0" || !Array.isArray(preview.changes) || !Array.isArray(preview.blockers)) {
|
|
92
|
+
throw new Error("Provider binding preview shape is invalid");
|
|
93
|
+
}
|
|
94
|
+
for (const changeValue of preview.changes) {
|
|
95
|
+
const change = requireRecord(changeValue, "Provider binding preview change");
|
|
96
|
+
const changeKeys = ["action", "material", "resourceId"];
|
|
97
|
+
if (change.details !== undefined)
|
|
98
|
+
changeKeys.push("details");
|
|
99
|
+
exactKeys(change, changeKeys, "Provider binding preview change");
|
|
100
|
+
if (!["create", "update", "delete", "replace", "no-op", "unknown"].includes(change.action) ||
|
|
101
|
+
typeof change.material !== "boolean") {
|
|
102
|
+
throw new Error("Provider binding preview change is invalid");
|
|
103
|
+
}
|
|
104
|
+
requireNonempty(change.resourceId, "Provider binding preview change resourceId");
|
|
105
|
+
if (change.details !== undefined)
|
|
106
|
+
requireNonempty(change.details, "Provider binding preview change details");
|
|
107
|
+
}
|
|
108
|
+
for (const blocker of preview.blockers)
|
|
109
|
+
requireNonempty(blocker, "Provider binding preview blocker");
|
|
110
|
+
for (const key of ["commit", "dependencyRevision", "iacHash", "inputHash", "policyHash"]) {
|
|
111
|
+
requireHash(preview[key], `Provider binding preview ${key}`);
|
|
112
|
+
}
|
|
113
|
+
if (preview.artifactHash !== undefined)
|
|
114
|
+
requireHash(preview.artifactHash, "Provider binding preview artifactHash");
|
|
115
|
+
requireTimestamp(preview.createdAt, "Provider binding preview createdAt");
|
|
116
|
+
requireTimestamp(preview.expiresAt, "Provider binding preview expiresAt");
|
|
117
|
+
requireNonempty(preview.environment, "Provider binding preview environment");
|
|
118
|
+
requireNonempty(preview.target, "Provider binding preview target");
|
|
119
|
+
if (preview.stateLineage !== undefined)
|
|
120
|
+
requireNonempty(preview.stateLineage, "Provider binding stateLineage");
|
|
121
|
+
if (preview.stateSerial !== undefined &&
|
|
122
|
+
(!Number.isInteger(preview.stateSerial) || preview.stateSerial < 0)) {
|
|
123
|
+
throw new Error("Provider binding stateSerial is invalid");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function parseBinding(value, previewHash, provider, recipient) {
|
|
127
|
+
const binding = requireRecord(value, "Provider binding");
|
|
128
|
+
if (binding.kind !== "bicep" && binding.kind !== "terraform")
|
|
129
|
+
throw new Error("Provider binding kind is invalid");
|
|
130
|
+
if (provider !== undefined && binding.kind !== provider)
|
|
131
|
+
throw new Error("Provider binding does not match requested provider");
|
|
132
|
+
exactKeys(binding, binding.kind === "bicep"
|
|
133
|
+
? ["kind", "parametersHash", "preview", "providerBindingHash", "stackStateHash", "templateHash"]
|
|
134
|
+
: ["attestation", "kind", "preview"], "Provider binding");
|
|
135
|
+
const preview = requireRecord(binding.preview, "Provider binding preview");
|
|
136
|
+
validatePreview(preview);
|
|
137
|
+
const previewExpiresAt = preview.expiresAt;
|
|
138
|
+
if (preview.previewHash !== previewHash)
|
|
139
|
+
throw new Error("Provider binding preview hash does not match its path");
|
|
140
|
+
const projectId = requireNonempty(preview.projectId, "Provider binding projectId");
|
|
141
|
+
const runId = requireNonempty(preview.runId, "Provider binding runId");
|
|
142
|
+
if (preview.operation !== "apply" && preview.operation !== "destroy") {
|
|
143
|
+
throw new Error("Provider binding operation is invalid");
|
|
144
|
+
}
|
|
145
|
+
if (!Number.isInteger(preview.ownerEpoch) || preview.ownerEpoch < 1) {
|
|
146
|
+
throw new Error("Provider binding ownerEpoch is invalid");
|
|
147
|
+
}
|
|
148
|
+
if (preview.track !== binding.kind)
|
|
149
|
+
throw new Error("Provider binding track is invalid");
|
|
150
|
+
if (binding.kind === "bicep") {
|
|
151
|
+
for (const key of ["parametersHash", "providerBindingHash", "stackStateHash", "templateHash"]) {
|
|
152
|
+
requireHash(binding[key], `Bicep ${key}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const common = {
|
|
156
|
+
provider: binding.kind,
|
|
157
|
+
operation: preview.operation,
|
|
158
|
+
projectId,
|
|
159
|
+
runId,
|
|
160
|
+
ownerEpoch: preview.ownerEpoch,
|
|
161
|
+
previewHash,
|
|
162
|
+
recipient: recipient ?? "",
|
|
163
|
+
authorityExpiresAt: previewExpiresAt,
|
|
164
|
+
};
|
|
165
|
+
if (binding.kind === "bicep")
|
|
166
|
+
return { binding, bindings: common };
|
|
167
|
+
const attestation = requireRecord(binding.attestation, "Terraform attestation");
|
|
168
|
+
const attestationKeys = [
|
|
169
|
+
"artifactRef",
|
|
170
|
+
"configHash",
|
|
171
|
+
"createdAt",
|
|
172
|
+
"expiresAt",
|
|
173
|
+
"iacHash",
|
|
174
|
+
"inputHash",
|
|
175
|
+
"lockfileHash",
|
|
176
|
+
"planDigest",
|
|
177
|
+
"policyHash",
|
|
178
|
+
"previewHash",
|
|
179
|
+
"projectId",
|
|
180
|
+
"recipient",
|
|
181
|
+
"runId",
|
|
182
|
+
"schemaVersion",
|
|
183
|
+
"track",
|
|
184
|
+
"transport",
|
|
185
|
+
];
|
|
186
|
+
for (const optional of ["stateLineage", "stateSerial"]) {
|
|
187
|
+
if (attestation[optional] !== undefined)
|
|
188
|
+
attestationKeys.push(optional);
|
|
189
|
+
}
|
|
190
|
+
exactKeys(attestation, attestationKeys, "Terraform attestation");
|
|
191
|
+
if (attestation.schemaVersion !== "1.0.0" || attestation.track !== "terraform") {
|
|
192
|
+
throw new Error("Terraform attestation shape is invalid");
|
|
193
|
+
}
|
|
194
|
+
for (const key of ["iacHash", "inputHash", "policyHash"]) {
|
|
195
|
+
requireHash(attestation[key], `Terraform attestation ${key}`);
|
|
196
|
+
}
|
|
197
|
+
requireTimestamp(attestation.createdAt, "Terraform attestation createdAt");
|
|
198
|
+
const attestationExpiresAt = requireTimestamp(attestation.expiresAt, "Terraform attestation expiresAt");
|
|
199
|
+
if (attestation.stateLineage !== undefined)
|
|
200
|
+
requireNonempty(attestation.stateLineage, "Terraform stateLineage");
|
|
201
|
+
if (attestation.stateSerial !== undefined &&
|
|
202
|
+
(!Number.isInteger(attestation.stateSerial) || attestation.stateSerial < 0)) {
|
|
203
|
+
throw new Error("Terraform stateSerial is invalid");
|
|
204
|
+
}
|
|
205
|
+
for (const [key, expected] of [
|
|
206
|
+
["projectId", projectId],
|
|
207
|
+
["runId", runId],
|
|
208
|
+
["previewHash", previewHash],
|
|
209
|
+
]) {
|
|
210
|
+
if (attestation[key] !== expected)
|
|
211
|
+
throw new Error(`Terraform attestation ${key} mismatch`);
|
|
212
|
+
}
|
|
213
|
+
const artifactRef = requireNonempty(attestation.artifactRef, "Terraform artifactRef");
|
|
214
|
+
const planDigest = requireHash(attestation.planDigest, "Terraform planDigest");
|
|
215
|
+
requireHash(attestation.configHash, "Terraform configHash");
|
|
216
|
+
requireHash(attestation.lockfileHash, "Terraform lockfileHash");
|
|
217
|
+
const attestationRecipient = requireNonempty(attestation.recipient, "Terraform recipient");
|
|
218
|
+
if (recipient !== undefined && attestationRecipient !== recipient)
|
|
219
|
+
throw new Error("Terraform recipient mismatch");
|
|
220
|
+
const transport = requireRecord(attestation.transport, "Terraform transport");
|
|
221
|
+
exactKeys(transport, ["algorithm", "authTag", "encrypted", "implementation", "iv", "mediaType", "recipient"], "Terraform transport");
|
|
222
|
+
if (transport.encrypted !== true ||
|
|
223
|
+
transport.implementation !== "local-reference" ||
|
|
224
|
+
transport.algorithm !== "aes-256-gcm" ||
|
|
225
|
+
transport.recipient !== attestationRecipient) {
|
|
226
|
+
throw new Error("Terraform transport is invalid");
|
|
227
|
+
}
|
|
228
|
+
requireBase64(transport.iv, 12, "Terraform attestation IV");
|
|
229
|
+
requireBase64(transport.authTag, 16, "Terraform attestation authTag");
|
|
230
|
+
return {
|
|
231
|
+
binding,
|
|
232
|
+
artifactRef,
|
|
233
|
+
bindings: {
|
|
234
|
+
...common,
|
|
235
|
+
recipient: attestationRecipient,
|
|
236
|
+
authorityExpiresAt: earliestExpiry(previewExpiresAt, attestationExpiresAt),
|
|
237
|
+
artifactRef,
|
|
238
|
+
planDigest,
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function parseStoredArtifact(value, authority) {
|
|
243
|
+
const stored = requireRecord(value, "Terraform artifact");
|
|
244
|
+
exactKeys(stored, ["artifact", "reference"], "Terraform artifact");
|
|
245
|
+
if (stored.reference !== authority.artifactRef)
|
|
246
|
+
throw new Error("Terraform artifact reference mismatch");
|
|
247
|
+
const artifact = requireRecord(stored.artifact, "Terraform encrypted artifact");
|
|
248
|
+
exactKeys(artifact, ["authTag", "ciphertext", "iv", "metadata"], "Terraform encrypted artifact");
|
|
249
|
+
const metadata = requireRecord(artifact.metadata, "Terraform artifact metadata");
|
|
250
|
+
exactKeys(metadata, ["algorithm", "createdAt", "digest", "expiresAt", "implementation", "recipient"], "Terraform artifact metadata");
|
|
251
|
+
if (metadata.digest !== authority.bindings.planDigest ||
|
|
252
|
+
metadata.recipient !== authority.bindings.recipient ||
|
|
253
|
+
metadata.implementation !== "local-reference" ||
|
|
254
|
+
metadata.algorithm !== "aes-256-gcm") {
|
|
255
|
+
throw new Error("Terraform artifact metadata mismatch");
|
|
256
|
+
}
|
|
257
|
+
const attestation = requireRecord(authority.binding.attestation, "Terraform attestation");
|
|
258
|
+
const transport = requireRecord(attestation.transport, "Terraform transport");
|
|
259
|
+
if (artifact.iv !== transport.iv || artifact.authTag !== transport.authTag) {
|
|
260
|
+
throw new Error("Terraform artifact IV/authTag mismatch");
|
|
261
|
+
}
|
|
262
|
+
requireBase64(artifact.iv, 12, "Terraform artifact IV");
|
|
263
|
+
requireBase64(artifact.authTag, 16, "Terraform artifact authTag");
|
|
264
|
+
requireTimestamp(metadata.createdAt, "Terraform artifact createdAt");
|
|
265
|
+
const expiresAt = requireTimestamp(metadata.expiresAt, "Terraform artifact expiresAt");
|
|
266
|
+
const ciphertext = requireNonempty(artifact.ciphertext, "Terraform artifact ciphertext");
|
|
267
|
+
if (!BASE64_PATTERN.test(ciphertext) || Buffer.from(ciphertext, "base64").toString("base64") !== ciphertext) {
|
|
268
|
+
throw new Error("Terraform artifact ciphertext is invalid");
|
|
269
|
+
}
|
|
270
|
+
return { reference: stored.reference, artifact, expiresAt };
|
|
271
|
+
}
|
|
272
|
+
function bundleFile(path, bytes) {
|
|
273
|
+
return { path, bytes: bytes.byteLength, sha256: sha256Bytes(bytes), content: bytes.toString("base64") };
|
|
274
|
+
}
|
|
275
|
+
export async function createProviderTransferBundle(root, options, now = new Date()) {
|
|
276
|
+
requireHash(options.previewHash, "Preview hash");
|
|
277
|
+
if (options.provider !== "bicep" && options.provider !== "terraform")
|
|
278
|
+
throw new Error("Provider is invalid");
|
|
279
|
+
requireNonempty(options.recipient, "Provider transfer recipient");
|
|
280
|
+
if (!Number.isFinite(options.ttlMs) || options.ttlMs <= 0)
|
|
281
|
+
throw new Error("Provider transfer TTL must be positive");
|
|
282
|
+
const runtimeRoot = resolve(root, ".apex", "local", "provider-runtime");
|
|
283
|
+
const bindingPath = `bindings/${options.previewHash}.json`;
|
|
284
|
+
const bindingBytes = await readRegular(join(runtimeRoot, ...bindingPath.split("/")), "Provider binding");
|
|
285
|
+
const authority = parseBinding(parseJson(bindingBytes, "Provider binding"), options.previewHash, options.provider, options.recipient);
|
|
286
|
+
let bindings = authority.bindings;
|
|
287
|
+
const selected = [{ path: bindingPath, bytes: bindingBytes }];
|
|
288
|
+
if (options.provider === "terraform") {
|
|
289
|
+
const artifactPath = `artifacts/${sha256Bytes(Buffer.from(authority.artifactRef, "utf8"))}.json`;
|
|
290
|
+
const artifactBytes = await readRegular(join(runtimeRoot, ...artifactPath.split("/")), "Terraform artifact");
|
|
291
|
+
const artifact = parseStoredArtifact(parseJson(artifactBytes, "Terraform artifact"), authority);
|
|
292
|
+
bindings = {
|
|
293
|
+
...bindings,
|
|
294
|
+
authorityExpiresAt: earliestExpiry(bindings.authorityExpiresAt, artifact.expiresAt),
|
|
295
|
+
};
|
|
296
|
+
selected.push({ path: artifactPath, bytes: artifactBytes });
|
|
297
|
+
selected.push({
|
|
298
|
+
path: PLAN_KEY_PATH,
|
|
299
|
+
bytes: await readRegular(join(runtimeRoot, PLAN_KEY_PATH), "Terraform plan key"),
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
if (Date.parse(bindings.authorityExpiresAt) <= now.getTime()) {
|
|
303
|
+
throw new Error("Provider transfer authority has expired");
|
|
304
|
+
}
|
|
305
|
+
if (now.getTime() + options.ttlMs > Date.parse(bindings.authorityExpiresAt)) {
|
|
306
|
+
throw new Error("Provider transfer envelope cannot outlive its preview authority");
|
|
307
|
+
}
|
|
308
|
+
const bundle = {
|
|
309
|
+
implementation: "apex-provider-transfer",
|
|
310
|
+
version: 1,
|
|
311
|
+
bindings,
|
|
312
|
+
files: selected
|
|
313
|
+
.sort((left, right) => left.path.localeCompare(right.path))
|
|
314
|
+
.map(({ path, bytes }) => bundleFile(path, bytes)),
|
|
315
|
+
};
|
|
316
|
+
if (canonicalJsonBytes(bundle).byteLength > PROVIDER_TRANSFER_MAX_BUNDLE_BYTES) {
|
|
317
|
+
throw new Error("Provider transfer plaintext bundle exceeds the 8 MiB limit");
|
|
318
|
+
}
|
|
319
|
+
return bundle;
|
|
320
|
+
}
|
|
321
|
+
export async function exportProviderTransfer(root, outputPath, options, dependencies = {}) {
|
|
322
|
+
if (!Number.isFinite(options.ttlMs) || options.ttlMs <= 0)
|
|
323
|
+
throw new Error("Provider transfer TTL must be positive");
|
|
324
|
+
const now = dependencies.now?.() ?? new Date();
|
|
325
|
+
const bundle = await createProviderTransferBundle(root, options, now);
|
|
326
|
+
const envelope = new BoundEnvelopeTransport(() => now).create(canonicalJsonBytes(bundle), {
|
|
327
|
+
kind: PROVIDER_TRANSFER_KIND,
|
|
328
|
+
recipient: options.recipient,
|
|
329
|
+
ttlMs: options.ttlMs,
|
|
330
|
+
bindings: bundle.bindings,
|
|
331
|
+
});
|
|
332
|
+
const bytes = canonicalJsonBytes(envelope);
|
|
333
|
+
await atomicWriteBytes(resolve(outputPath), bytes);
|
|
334
|
+
return {
|
|
335
|
+
path: resolve(outputPath),
|
|
336
|
+
sha256: sha256Bytes(bytes),
|
|
337
|
+
files: bundle.files.length,
|
|
338
|
+
expiresAt: envelope.metadata.expiresAt,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function requireBindings(value) {
|
|
342
|
+
const bindings = requireRecord(value, "Provider transfer bindings");
|
|
343
|
+
if (bindings.provider !== "bicep" && bindings.provider !== "terraform")
|
|
344
|
+
throw new Error("Provider transfer provider is invalid");
|
|
345
|
+
if (bindings.operation !== "apply" && bindings.operation !== "destroy")
|
|
346
|
+
throw new Error("Provider transfer operation is invalid");
|
|
347
|
+
requireNonempty(bindings.projectId, "Provider transfer projectId");
|
|
348
|
+
requireNonempty(bindings.runId, "Provider transfer runId");
|
|
349
|
+
requireNonempty(bindings.recipient, "Provider transfer recipient");
|
|
350
|
+
requireTimestamp(bindings.authorityExpiresAt, "Provider transfer authorityExpiresAt");
|
|
351
|
+
requireHash(bindings.previewHash, "Provider transfer previewHash");
|
|
352
|
+
if (!Number.isInteger(bindings.ownerEpoch) || (bindings.ownerEpoch ?? 0) < 1)
|
|
353
|
+
throw new Error("Provider transfer ownerEpoch is invalid");
|
|
354
|
+
const expected = [
|
|
355
|
+
"authorityExpiresAt",
|
|
356
|
+
"operation",
|
|
357
|
+
"ownerEpoch",
|
|
358
|
+
"previewHash",
|
|
359
|
+
"projectId",
|
|
360
|
+
"provider",
|
|
361
|
+
"recipient",
|
|
362
|
+
"runId",
|
|
363
|
+
];
|
|
364
|
+
if (bindings.provider === "terraform") {
|
|
365
|
+
requireNonempty(bindings.artifactRef, "Provider transfer artifactRef");
|
|
366
|
+
requireHash(bindings.planDigest, "Provider transfer planDigest");
|
|
367
|
+
expected.push("artifactRef", "planDigest");
|
|
368
|
+
}
|
|
369
|
+
exactKeys(bindings, expected, "Provider transfer bindings");
|
|
370
|
+
return bindings;
|
|
371
|
+
}
|
|
372
|
+
function decodeFile(entry) {
|
|
373
|
+
const file = requireRecord(entry, "Provider transfer file");
|
|
374
|
+
exactKeys(file, ["bytes", "content", "path", "sha256"], "Provider transfer file");
|
|
375
|
+
if (typeof file.path !== "string" ||
|
|
376
|
+
(!BINDING_PATH_PATTERN.test(file.path) && !ARTIFACT_PATH_PATTERN.test(file.path) && file.path !== PLAN_KEY_PATH)) {
|
|
377
|
+
throw new Error("Provider transfer file path is invalid");
|
|
378
|
+
}
|
|
379
|
+
if (!Number.isInteger(file.bytes) || file.bytes < 0 || file.bytes > PROVIDER_TRANSFER_MAX_FILE_BYTES) {
|
|
380
|
+
throw new Error(`Provider transfer file size is invalid: ${file.path}`);
|
|
381
|
+
}
|
|
382
|
+
requireHash(file.sha256, "Provider transfer file hash");
|
|
383
|
+
if (!BASE64_PATTERN.test(file.content))
|
|
384
|
+
throw new Error(`Provider transfer file encoding is invalid: ${file.path}`);
|
|
385
|
+
const bytes = Buffer.from(file.content, "base64");
|
|
386
|
+
if (bytes.toString("base64") !== file.content ||
|
|
387
|
+
bytes.byteLength !== file.bytes ||
|
|
388
|
+
sha256Bytes(bytes) !== file.sha256) {
|
|
389
|
+
throw new Error(`Provider transfer file integrity check failed: ${file.path}`);
|
|
390
|
+
}
|
|
391
|
+
return { path: file.path, bytes };
|
|
392
|
+
}
|
|
393
|
+
function validateBundle(value, envelopeBindings) {
|
|
394
|
+
const bundle = requireRecord(value, "Provider transfer bundle");
|
|
395
|
+
exactKeys(bundle, ["bindings", "files", "implementation", "version"], "Provider transfer bundle");
|
|
396
|
+
if (bundle.implementation !== "apex-provider-transfer" || bundle.version !== 1 || !Array.isArray(bundle.files)) {
|
|
397
|
+
throw new Error("Unsupported provider transfer bundle");
|
|
398
|
+
}
|
|
399
|
+
const bindings = requireBindings(bundle.bindings);
|
|
400
|
+
if (sha256Json(bindings) !== sha256Json(envelopeBindings)) {
|
|
401
|
+
throw new Error("Provider transfer envelope bindings do not match the bundle");
|
|
402
|
+
}
|
|
403
|
+
const entries = bundle.files.map(decodeFile);
|
|
404
|
+
const paths = entries.map(({ path }) => path);
|
|
405
|
+
if (new Set(paths).size !== paths.length || paths.join("\0") !== [...paths].sort().join("\0")) {
|
|
406
|
+
throw new Error("Provider transfer files are duplicate or not in deterministic order");
|
|
407
|
+
}
|
|
408
|
+
const bindingPath = `bindings/${bindings.previewHash}.json`;
|
|
409
|
+
const expected = [bindingPath];
|
|
410
|
+
const bindingBytes = entries.find(({ path }) => path === bindingPath)?.bytes;
|
|
411
|
+
if (bindingBytes === undefined)
|
|
412
|
+
throw new Error("Provider transfer exact binding is missing");
|
|
413
|
+
const authority = parseBinding(parseJson(bindingBytes, "Provider binding"), bindings.previewHash, bindings.provider, bindings.recipient);
|
|
414
|
+
let actualBindings = authority.bindings;
|
|
415
|
+
if (bindings.provider === "terraform") {
|
|
416
|
+
const artifactPath = `artifacts/${sha256Bytes(Buffer.from(bindings.artifactRef, "utf8"))}.json`;
|
|
417
|
+
expected.push(artifactPath);
|
|
418
|
+
expected.push(PLAN_KEY_PATH);
|
|
419
|
+
const artifactBytes = entries.find(({ path }) => path === artifactPath)?.bytes;
|
|
420
|
+
if (artifactBytes === undefined)
|
|
421
|
+
throw new Error("Provider transfer exact Terraform artifact is missing");
|
|
422
|
+
const artifact = parseStoredArtifact(parseJson(artifactBytes, "Terraform artifact"), authority);
|
|
423
|
+
const planKey = entries.find(({ path }) => path === PLAN_KEY_PATH)?.bytes;
|
|
424
|
+
if (planKey?.byteLength !== 32)
|
|
425
|
+
throw new Error("Provider transfer Terraform plan key is invalid");
|
|
426
|
+
actualBindings = {
|
|
427
|
+
...actualBindings,
|
|
428
|
+
authorityExpiresAt: earliestExpiry(actualBindings.authorityExpiresAt, artifact.expiresAt),
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
if (sha256Json(actualBindings) !== sha256Json(bindings)) {
|
|
432
|
+
throw new Error("Provider transfer binding does not match bundle authority");
|
|
433
|
+
}
|
|
434
|
+
if (paths.join("\0") !== expected.sort().join("\0"))
|
|
435
|
+
throw new Error("Provider transfer contains unrelated files");
|
|
436
|
+
return { bundle: bundle, entries };
|
|
437
|
+
}
|
|
438
|
+
async function assertSafeDirectory(path, label) {
|
|
439
|
+
try {
|
|
440
|
+
const info = await lstat(path);
|
|
441
|
+
if (info.isSymbolicLink() || !info.isDirectory())
|
|
442
|
+
throw new Error(`${label} is unsafe`);
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
if (error.code === "ENOENT")
|
|
447
|
+
return false;
|
|
448
|
+
throw error;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
async function ensureDirectory(path) {
|
|
452
|
+
if (!(await assertSafeDirectory(path, "Provider transfer destination directory")))
|
|
453
|
+
await mkdir(path, { mode: 0o700 });
|
|
454
|
+
await chmod(path, 0o700);
|
|
455
|
+
}
|
|
456
|
+
async function assertDestinationAncestors(root) {
|
|
457
|
+
const apexRoot = join(root, ".apex");
|
|
458
|
+
const localRoot = join(apexRoot, "local");
|
|
459
|
+
const runtimeRoot = join(localRoot, "provider-runtime");
|
|
460
|
+
await assertSafeDirectory(root, "Provider transfer workspace root");
|
|
461
|
+
if (await assertSafeDirectory(apexRoot, "Provider transfer .apex directory")) {
|
|
462
|
+
if (await assertSafeDirectory(localRoot, "Provider transfer local directory")) {
|
|
463
|
+
if (await assertSafeDirectory(runtimeRoot, "Provider transfer runtime directory")) {
|
|
464
|
+
await assertSafeDirectory(join(runtimeRoot, "bindings"), "Provider transfer bindings directory");
|
|
465
|
+
await assertSafeDirectory(join(runtimeRoot, "artifacts"), "Provider transfer artifacts directory");
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
export async function importProviderTransfer(root, envelopeValue, recipient, now = () => new Date()) {
|
|
471
|
+
requireNonempty(recipient, "Provider transfer recipient");
|
|
472
|
+
const envelopeRecord = requireRecord(envelopeValue, "Provider transfer envelope");
|
|
473
|
+
exactKeys(envelopeRecord, ["metadata", "payload"], "Provider transfer envelope");
|
|
474
|
+
const envelope = envelopeValue;
|
|
475
|
+
const metadata = requireRecord(envelope.metadata, "Provider transfer envelope metadata");
|
|
476
|
+
if (metadata.kind !== PROVIDER_TRANSFER_KIND)
|
|
477
|
+
throw new Error("Provider transfer envelope kind is invalid");
|
|
478
|
+
const maxEncodedBytes = Math.ceil(PROVIDER_TRANSFER_MAX_BUNDLE_BYTES / 3) * 4;
|
|
479
|
+
if (typeof envelope.payload !== "string" || envelope.payload.length > maxEncodedBytes) {
|
|
480
|
+
throw new Error("Provider transfer payload exceeds the 8 MiB limit");
|
|
481
|
+
}
|
|
482
|
+
const bindings = requireBindings(metadata.bindings);
|
|
483
|
+
if (bindings.recipient !== recipient || metadata.recipient !== recipient)
|
|
484
|
+
throw new Error("Provider transfer recipient mismatch");
|
|
485
|
+
const plaintext = new BoundEnvelopeTransport(now).open(envelope, recipient);
|
|
486
|
+
if (plaintext.byteLength > PROVIDER_TRANSFER_MAX_BUNDLE_BYTES)
|
|
487
|
+
throw new Error("Provider transfer plaintext exceeds 8 MiB");
|
|
488
|
+
const { bundle, entries } = validateBundle(parseJson(plaintext, "Provider transfer bundle"), bindings);
|
|
489
|
+
if (Date.parse(envelope.metadata.expiresAt) > Date.parse(bundle.bindings.authorityExpiresAt)) {
|
|
490
|
+
throw new Error("Provider transfer envelope expiry exceeds its preview authority");
|
|
491
|
+
}
|
|
492
|
+
const workspaceRoot = resolve(root);
|
|
493
|
+
await assertDestinationAncestors(workspaceRoot);
|
|
494
|
+
const runtimeRoot = join(workspaceRoot, ".apex", "local", "provider-runtime");
|
|
495
|
+
const preflight = [];
|
|
496
|
+
for (const entry of entries) {
|
|
497
|
+
const destination = resolve(runtimeRoot, ...entry.path.split("/"));
|
|
498
|
+
if (!destination.startsWith(`${runtimeRoot}${sep}`) || relative(runtimeRoot, destination).startsWith("..")) {
|
|
499
|
+
throw new Error("Provider transfer path escapes provider runtime");
|
|
500
|
+
}
|
|
501
|
+
try {
|
|
502
|
+
const info = await lstat(destination);
|
|
503
|
+
if (info.isSymbolicLink() || !info.isFile())
|
|
504
|
+
throw new Error(`Provider transfer destination is unsafe: ${entry.path}`);
|
|
505
|
+
const existing = await readFile(destination);
|
|
506
|
+
if (!existing.equals(entry.bytes))
|
|
507
|
+
throw new Error(`Provider transfer destination differs: ${entry.path}`);
|
|
508
|
+
preflight.push({ destination, bytes: entry.bytes, exists: true });
|
|
509
|
+
}
|
|
510
|
+
catch (error) {
|
|
511
|
+
if (error.code !== "ENOENT")
|
|
512
|
+
throw error;
|
|
513
|
+
preflight.push({ destination, bytes: entry.bytes, exists: false });
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
await ensureDirectory(join(workspaceRoot, ".apex"));
|
|
517
|
+
await ensureDirectory(join(workspaceRoot, ".apex", "local"));
|
|
518
|
+
await ensureDirectory(runtimeRoot);
|
|
519
|
+
await ensureDirectory(join(runtimeRoot, "bindings"));
|
|
520
|
+
await ensureDirectory(join(runtimeRoot, "artifacts"));
|
|
521
|
+
for (const entry of preflight) {
|
|
522
|
+
if (!entry.exists)
|
|
523
|
+
await atomicWriteBytes(entry.destination, entry.bytes, { refuseOverwrite: true });
|
|
524
|
+
await chmod(entry.destination, 0o600);
|
|
525
|
+
}
|
|
526
|
+
return {
|
|
527
|
+
provider: bundle.bindings.provider,
|
|
528
|
+
operation: bundle.bindings.operation,
|
|
529
|
+
previewHash: bundle.bindings.previewHash,
|
|
530
|
+
files: entries.length,
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
//# sourceMappingURL=provider-transfer.js.map
|