@mesh-tech/mesh-cli 0.1.0 → 0.12.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/intent/agents-fence.md +10 -0
- package/assets/intent/intent-claude-gate.mjs +255 -0
- package/assets/log-shipper.mjs +94 -0
- package/bin/mesh.mjs +80 -0
- package/dist/bin/mesh.d.ts +7 -9
- package/dist/bin/mesh.d.ts.map +1 -1
- package/dist/bin/mesh.js +20826 -37
- package/dist/bin/mesh.js.map +7 -1
- package/dist/build-info.json +4 -0
- package/dist/src/commands/agent-api-client.d.ts +79 -0
- package/dist/src/commands/agent-api-client.d.ts.map +1 -0
- package/dist/src/commands/agent-api-client.js +170 -0
- package/dist/src/commands/agent-api-client.js.map +1 -0
- package/dist/src/commands/artifacts.d.ts +13 -0
- package/dist/src/commands/artifacts.d.ts.map +1 -0
- package/dist/src/commands/artifacts.js +140 -0
- package/dist/src/commands/artifacts.js.map +1 -0
- package/dist/src/commands/cluster.d.ts +45 -0
- package/dist/src/commands/cluster.d.ts.map +1 -0
- package/dist/src/commands/cluster.js +259 -0
- package/dist/src/commands/cluster.js.map +1 -0
- package/dist/src/commands/conversations.d.ts +61 -0
- package/dist/src/commands/conversations.d.ts.map +1 -0
- package/dist/src/commands/conversations.js +239 -0
- package/dist/src/commands/conversations.js.map +1 -0
- package/dist/src/commands/create-app.d.ts +26 -3
- package/dist/src/commands/create-app.d.ts.map +1 -1
- package/dist/src/commands/create-app.js +465 -107
- package/dist/src/commands/create-app.js.map +1 -1
- package/dist/src/commands/deploy.d.ts +19 -0
- package/dist/src/commands/deploy.d.ts.map +1 -1
- package/dist/src/commands/deploy.js +83 -142
- package/dist/src/commands/deploy.js.map +1 -1
- package/dist/src/commands/dev-doctor.d.ts +137 -0
- package/dist/src/commands/dev-doctor.d.ts.map +1 -0
- package/dist/src/commands/dev-doctor.js +671 -0
- package/dist/src/commands/dev-doctor.js.map +1 -0
- package/dist/src/commands/dev-launch.d.ts +59 -0
- package/dist/src/commands/dev-launch.d.ts.map +1 -0
- package/dist/src/commands/dev-launch.js +118 -0
- package/dist/src/commands/dev-launch.js.map +1 -0
- package/dist/src/commands/dev-token-server.d.ts +32 -0
- package/dist/src/commands/dev-token-server.d.ts.map +1 -0
- package/dist/src/commands/dev-token-server.js +68 -0
- package/dist/src/commands/dev-token-server.js.map +1 -0
- package/dist/src/commands/dev.d.ts +289 -2
- package/dist/src/commands/dev.d.ts.map +1 -1
- package/dist/src/commands/dev.js +2501 -574
- package/dist/src/commands/dev.js.map +1 -1
- package/dist/src/commands/docs.d.ts +3 -0
- package/dist/src/commands/docs.d.ts.map +1 -0
- package/dist/src/commands/docs.js +262 -0
- package/dist/src/commands/docs.js.map +1 -0
- package/dist/src/commands/hub/index.d.ts +99 -0
- package/dist/src/commands/hub/index.d.ts.map +1 -0
- package/dist/src/commands/hub/index.js +452 -0
- package/dist/src/commands/hub/index.js.map +1 -0
- package/dist/src/commands/init.d.ts +65 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +370 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/install-shim.d.ts +21 -0
- package/dist/src/commands/install-shim.d.ts.map +1 -0
- package/dist/src/commands/install-shim.js +132 -0
- package/dist/src/commands/install-shim.js.map +1 -0
- package/dist/src/commands/local/auth-provision.d.ts +71 -0
- package/dist/src/commands/local/auth-provision.d.ts.map +1 -0
- package/dist/src/commands/local/auth-provision.js +286 -0
- package/dist/src/commands/local/auth-provision.js.map +1 -0
- package/dist/src/commands/local/dev-local.d.ts +97 -0
- package/dist/src/commands/local/dev-local.d.ts.map +1 -0
- package/dist/src/commands/local/dev-local.js +306 -0
- package/dist/src/commands/local/dev-local.js.map +1 -0
- package/dist/src/commands/local/docker-runner.d.ts +37 -0
- package/dist/src/commands/local/docker-runner.d.ts.map +1 -0
- package/dist/src/commands/local/docker-runner.js +104 -0
- package/dist/src/commands/local/docker-runner.js.map +1 -0
- package/dist/src/commands/local/helpers.d.ts +22 -0
- package/dist/src/commands/local/helpers.d.ts.map +1 -0
- package/dist/src/commands/local/helpers.js +46 -0
- package/dist/src/commands/local/helpers.js.map +1 -0
- package/dist/src/commands/local/hub-local.d.ts +51 -0
- package/dist/src/commands/local/hub-local.d.ts.map +1 -0
- package/dist/src/commands/local/hub-local.js +197 -0
- package/dist/src/commands/local/hub-local.js.map +1 -0
- package/dist/src/commands/local/index.d.ts +23 -0
- package/dist/src/commands/local/index.d.ts.map +1 -0
- package/dist/src/commands/local/index.js +386 -0
- package/dist/src/commands/local/index.js.map +1 -0
- package/dist/src/commands/local/mocks.d.ts +361 -0
- package/dist/src/commands/local/mocks.d.ts.map +1 -0
- package/dist/src/commands/local/mocks.js +756 -0
- package/dist/src/commands/local/mocks.js.map +1 -0
- package/dist/src/commands/local/seed-zitadel.d.ts +151 -0
- package/dist/src/commands/local/seed-zitadel.d.ts.map +1 -0
- package/dist/src/commands/local/seed-zitadel.js +408 -0
- package/dist/src/commands/local/seed-zitadel.js.map +1 -0
- package/dist/src/commands/local/seed.d.ts +106 -0
- package/dist/src/commands/local/seed.d.ts.map +1 -0
- package/dist/src/commands/local/seed.js +252 -0
- package/dist/src/commands/local/seed.js.map +1 -0
- package/dist/src/commands/local/stack.d.ts +173 -0
- package/dist/src/commands/local/stack.d.ts.map +1 -0
- package/dist/src/commands/local/stack.js +499 -0
- package/dist/src/commands/local/stack.js.map +1 -0
- package/dist/src/commands/login.d.ts +256 -12
- package/dist/src/commands/login.d.ts.map +1 -1
- package/dist/src/commands/login.js +978 -50
- package/dist/src/commands/login.js.map +1 -1
- package/dist/src/commands/peer-addressing.d.ts +51 -0
- package/dist/src/commands/peer-addressing.d.ts.map +1 -0
- package/dist/src/commands/peer-addressing.js +64 -0
- package/dist/src/commands/peer-addressing.js.map +1 -0
- package/dist/src/commands/port-ownership.d.ts +69 -0
- package/dist/src/commands/port-ownership.d.ts.map +1 -0
- package/dist/src/commands/port-ownership.js +161 -0
- package/dist/src/commands/port-ownership.js.map +1 -0
- package/dist/src/commands/registry-publish.d.ts +3 -0
- package/dist/src/commands/registry-publish.d.ts.map +1 -0
- package/dist/src/commands/registry-publish.js +161 -0
- package/dist/src/commands/registry-publish.js.map +1 -0
- package/dist/src/commands/registry.d.ts +146 -2
- package/dist/src/commands/registry.d.ts.map +1 -1
- package/dist/src/commands/registry.js +541 -85
- package/dist/src/commands/registry.js.map +1 -1
- package/dist/src/commands/secrets/index.d.ts.map +1 -1
- package/dist/src/commands/secrets/index.js +15 -1
- package/dist/src/commands/secrets/index.js.map +1 -1
- package/dist/src/commands/secrets/migrate-config.d.ts +24 -0
- package/dist/src/commands/secrets/migrate-config.d.ts.map +1 -0
- package/dist/src/commands/secrets/migrate-config.js +277 -0
- package/dist/src/commands/secrets/migrate-config.js.map +1 -0
- package/dist/src/commands/secrets/set.d.ts +4 -0
- package/dist/src/commands/secrets/set.d.ts.map +1 -1
- package/dist/src/commands/secrets/set.js +243 -64
- package/dist/src/commands/secrets/set.js.map +1 -1
- package/dist/src/commands/skills.d.ts +34 -0
- package/dist/src/commands/skills.d.ts.map +1 -0
- package/dist/src/commands/skills.js +207 -0
- package/dist/src/commands/skills.js.map +1 -0
- package/dist/src/commands/stack.d.ts.map +1 -1
- package/dist/src/commands/stack.js +361 -23
- package/dist/src/commands/stack.js.map +1 -1
- package/dist/src/commands/temporal.d.ts +15 -0
- package/dist/src/commands/temporal.d.ts.map +1 -0
- package/dist/src/commands/temporal.js +781 -0
- package/dist/src/commands/temporal.js.map +1 -0
- package/dist/src/commands/tenant.d.ts +56 -0
- package/dist/src/commands/tenant.d.ts.map +1 -0
- package/dist/src/commands/tenant.js +233 -0
- package/dist/src/commands/tenant.js.map +1 -0
- package/dist/src/commands/tunnel/index.d.ts +49 -3
- package/dist/src/commands/tunnel/index.d.ts.map +1 -1
- package/dist/src/commands/tunnel/index.js +331 -8
- package/dist/src/commands/tunnel/index.js.map +1 -1
- package/dist/src/commands/vcs/clone.d.ts +3 -0
- package/dist/src/commands/vcs/clone.d.ts.map +1 -0
- package/dist/src/commands/vcs/clone.js +20 -0
- package/dist/src/commands/vcs/clone.js.map +1 -0
- package/dist/src/commands/vcs/common.d.ts +21 -0
- package/dist/src/commands/vcs/common.d.ts.map +1 -0
- package/dist/src/commands/vcs/common.js +62 -0
- package/dist/src/commands/vcs/common.js.map +1 -0
- package/dist/src/commands/vcs/drafts.d.ts +13 -0
- package/dist/src/commands/vcs/drafts.d.ts.map +1 -0
- package/dist/src/commands/vcs/drafts.js +45 -0
- package/dist/src/commands/vcs/drafts.js.map +1 -0
- package/dist/src/commands/vcs/get.d.ts +8 -0
- package/dist/src/commands/vcs/get.d.ts.map +1 -0
- package/dist/src/commands/vcs/get.js +61 -0
- package/dist/src/commands/vcs/get.js.map +1 -0
- package/dist/src/commands/vcs/index.d.ts +3 -0
- package/dist/src/commands/vcs/index.d.ts.map +1 -0
- package/dist/src/commands/vcs/index.js +58 -0
- package/dist/src/commands/vcs/index.js.map +1 -0
- package/dist/src/commands/vcs/propose.d.ts +23 -0
- package/dist/src/commands/vcs/propose.d.ts.map +1 -0
- package/dist/src/commands/vcs/propose.js +94 -0
- package/dist/src/commands/vcs/propose.js.map +1 -0
- package/dist/src/commands/vcs/review.d.ts +15 -0
- package/dist/src/commands/vcs/review.d.ts.map +1 -0
- package/dist/src/commands/vcs/review.js +35 -0
- package/dist/src/commands/vcs/review.js.map +1 -0
- package/dist/src/commands/vcs-enrich.d.ts +15 -0
- package/dist/src/commands/vcs-enrich.d.ts.map +1 -0
- package/dist/src/commands/vcs-enrich.js +28 -0
- package/dist/src/commands/vcs-enrich.js.map +1 -0
- package/dist/src/commands/vpn/index.d.ts +24 -0
- package/dist/src/commands/vpn/index.d.ts.map +1 -0
- package/dist/src/commands/vpn/index.js +543 -0
- package/dist/src/commands/vpn/index.js.map +1 -0
- package/dist/src/commands/vpn/tunnel.d.ts +11 -0
- package/dist/src/commands/vpn/tunnel.d.ts.map +1 -0
- package/dist/src/commands/vpn/tunnel.js +188 -0
- package/dist/src/commands/vpn/tunnel.js.map +1 -0
- package/dist/src/commands/workflow.d.ts +24 -0
- package/dist/src/commands/workflow.d.ts.map +1 -0
- package/dist/src/commands/workflow.js +577 -0
- package/dist/src/commands/workflow.js.map +1 -0
- package/dist/src/docs/assemble.d.ts +217 -0
- package/dist/src/docs/assemble.d.ts.map +1 -0
- package/dist/src/docs/assemble.js +739 -0
- package/dist/src/docs/assemble.js.map +1 -0
- package/dist/src/docs/cli-reference.d.ts +93 -0
- package/dist/src/docs/cli-reference.d.ts.map +1 -0
- package/dist/src/docs/cli-reference.js +256 -0
- package/dist/src/docs/cli-reference.js.map +1 -0
- package/dist/src/docs/discover.d.ts +60 -0
- package/dist/src/docs/discover.d.ts.map +1 -0
- package/dist/src/docs/discover.js +233 -0
- package/dist/src/docs/discover.js.map +1 -0
- package/dist/src/docs/portal.d.ts +79 -0
- package/dist/src/docs/portal.d.ts.map +1 -0
- package/dist/src/docs/portal.js +242 -0
- package/dist/src/docs/portal.js.map +1 -0
- package/dist/src/docs/registry-docs.d.ts +43 -0
- package/dist/src/docs/registry-docs.d.ts.map +1 -0
- package/dist/src/docs/registry-docs.js +138 -0
- package/dist/src/docs/registry-docs.js.map +1 -0
- package/dist/src/docs/schema.d.ts +48 -0
- package/dist/src/docs/schema.d.ts.map +1 -0
- package/dist/src/docs/schema.js +96 -0
- package/dist/src/docs/schema.js.map +1 -0
- package/dist/src/docs/serve.d.ts +27 -0
- package/dist/src/docs/serve.d.ts.map +1 -0
- package/dist/src/docs/serve.js +102 -0
- package/dist/src/docs/serve.js.map +1 -0
- package/dist/src/docs/start.d.ts +80 -0
- package/dist/src/docs/start.d.ts.map +1 -0
- package/dist/src/docs/start.js +313 -0
- package/dist/src/docs/start.js.map +1 -0
- package/dist/src/eval/agent-eval.d.mts +14 -0
- package/dist/src/eval/agent-eval.d.mts.map +1 -0
- package/dist/src/eval/agent-eval.mjs +273 -0
- package/dist/src/eval/agent-eval.mjs.map +1 -0
- package/dist/src/index.js +624 -7
- package/dist/src/index.js.map +7 -1
- package/dist/src/program.d.ts +26 -0
- package/dist/src/program.d.ts.map +1 -0
- package/dist/src/program.js +76 -0
- package/dist/src/program.js.map +1 -0
- package/dist/src/utils/auth-preflight.d.ts +159 -0
- package/dist/src/utils/auth-preflight.d.ts.map +1 -0
- package/dist/src/utils/auth-preflight.js +298 -0
- package/dist/src/utils/auth-preflight.js.map +1 -0
- package/dist/src/utils/aws-auth.d.ts +181 -0
- package/dist/src/utils/aws-auth.d.ts.map +1 -0
- package/dist/src/utils/aws-auth.js +527 -0
- package/dist/src/utils/aws-auth.js.map +1 -0
- package/dist/src/utils/bastion.d.ts +1 -1
- package/dist/src/utils/bastion.d.ts.map +1 -1
- package/dist/src/utils/bastion.js +29 -8
- package/dist/src/utils/bastion.js.map +1 -1
- package/dist/src/utils/build-info.d.ts +33 -0
- package/dist/src/utils/build-info.d.ts.map +1 -0
- package/dist/src/utils/build-info.js +102 -0
- package/dist/src/utils/build-info.js.map +1 -0
- package/dist/src/utils/capture-history.d.ts +62 -0
- package/dist/src/utils/capture-history.d.ts.map +1 -0
- package/dist/src/utils/capture-history.js +94 -0
- package/dist/src/utils/capture-history.js.map +1 -0
- package/dist/src/utils/deploy-preflight.d.ts +52 -0
- package/dist/src/utils/deploy-preflight.d.ts.map +1 -0
- package/dist/src/utils/deploy-preflight.js +183 -0
- package/dist/src/utils/deploy-preflight.js.map +1 -0
- package/dist/src/utils/errors.d.ts +75 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/errors.js +106 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/first-party-contexts.d.ts +40 -0
- package/dist/src/utils/first-party-contexts.d.ts.map +1 -0
- package/dist/src/utils/first-party-contexts.js +53 -0
- package/dist/src/utils/first-party-contexts.js.map +1 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +2 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/kubeconfig.d.ts +62 -0
- package/dist/src/utils/kubeconfig.d.ts.map +1 -0
- package/dist/src/utils/kubeconfig.js +118 -0
- package/dist/src/utils/kubeconfig.js.map +1 -0
- package/dist/src/utils/log.d.ts +27 -1
- package/dist/src/utils/log.d.ts.map +1 -1
- package/dist/src/utils/log.js +59 -5
- package/dist/src/utils/log.js.map +1 -1
- package/dist/src/utils/pid.d.ts +47 -0
- package/dist/src/utils/pid.d.ts.map +1 -0
- package/dist/src/utils/pid.js +83 -0
- package/dist/src/utils/pid.js.map +1 -0
- package/dist/src/utils/pulumi-run.d.ts +23 -0
- package/dist/src/utils/pulumi-run.d.ts.map +1 -0
- package/dist/src/utils/pulumi-run.js +112 -0
- package/dist/src/utils/pulumi-run.js.map +1 -0
- package/dist/src/utils/pulumi.d.ts +15 -0
- package/dist/src/utils/pulumi.d.ts.map +1 -1
- package/dist/src/utils/pulumi.js +35 -0
- package/dist/src/utils/pulumi.js.map +1 -1
- package/dist/src/utils/reachability.d.ts +29 -0
- package/dist/src/utils/reachability.d.ts.map +1 -0
- package/dist/src/utils/reachability.js +81 -0
- package/dist/src/utils/reachability.js.map +1 -0
- package/dist/src/utils/recover-conversation.d.ts +154 -0
- package/dist/src/utils/recover-conversation.d.ts.map +1 -0
- package/dist/src/utils/recover-conversation.js +314 -0
- package/dist/src/utils/recover-conversation.js.map +1 -0
- package/dist/src/utils/registry-broker.d.ts +148 -0
- package/dist/src/utils/registry-broker.d.ts.map +1 -0
- package/dist/src/utils/registry-broker.js +180 -0
- package/dist/src/utils/registry-broker.js.map +1 -0
- package/dist/src/utils/socks-forward.d.ts +40 -0
- package/dist/src/utils/socks-forward.d.ts.map +1 -0
- package/dist/src/utils/socks-forward.js +97 -0
- package/dist/src/utils/socks-forward.js.map +1 -0
- package/dist/src/utils/stack-flag.d.ts +23 -0
- package/dist/src/utils/stack-flag.d.ts.map +1 -0
- package/dist/src/utils/stack-flag.js +41 -0
- package/dist/src/utils/stack-flag.js.map +1 -0
- package/dist/src/utils/tailscale-targets.d.ts +52 -0
- package/dist/src/utils/tailscale-targets.d.ts.map +1 -0
- package/dist/src/utils/tailscale-targets.js +93 -0
- package/dist/src/utils/tailscale-targets.js.map +1 -0
- package/dist/src/utils/tailscale.d.ts +277 -0
- package/dist/src/utils/tailscale.d.ts.map +1 -0
- package/dist/src/utils/tailscale.js +1007 -0
- package/dist/src/utils/tailscale.js.map +1 -0
- package/dist/src/utils/temporal-auth.d.ts +43 -0
- package/dist/src/utils/temporal-auth.d.ts.map +1 -0
- package/dist/src/utils/temporal-auth.js +176 -0
- package/dist/src/utils/temporal-auth.js.map +1 -0
- package/dist/src/utils/temporal-codec.d.ts +101 -0
- package/dist/src/utils/temporal-codec.d.ts.map +1 -0
- package/dist/src/utils/temporal-codec.js +319 -0
- package/dist/src/utils/temporal-codec.js.map +1 -0
- package/dist/src/utils/tunnel-ownership.d.ts +130 -0
- package/dist/src/utils/tunnel-ownership.d.ts.map +1 -0
- package/dist/src/utils/tunnel-ownership.js +274 -0
- package/dist/src/utils/tunnel-ownership.js.map +1 -0
- package/dist/src/utils/vpn-join.d.ts +32 -0
- package/dist/src/utils/vpn-join.d.ts.map +1 -0
- package/dist/src/utils/vpn-join.js +62 -0
- package/dist/src/utils/vpn-join.js.map +1 -0
- package/dist/src/utils/vpn.d.ts +62 -0
- package/dist/src/utils/vpn.d.ts.map +1 -0
- package/dist/src/utils/vpn.js +183 -0
- package/dist/src/utils/vpn.js.map +1 -0
- package/dist/src/utils/workflow-fingerprint.d.ts +49 -0
- package/dist/src/utils/workflow-fingerprint.d.ts.map +1 -0
- package/dist/src/utils/workflow-fingerprint.js +135 -0
- package/dist/src/utils/workflow-fingerprint.js.map +1 -0
- package/dist/src/utils/worktree-identity.d.ts +86 -0
- package/dist/src/utils/worktree-identity.d.ts.map +1 -0
- package/dist/src/utils/worktree-identity.js +164 -0
- package/dist/src/utils/worktree-identity.js.map +1 -0
- package/fragments/agents/AGENTS.md.hbs +92 -0
- package/fragments/agents/CLAUDE.md.hbs +8 -0
- package/fragments/base/Pulumi.dev.yaml.hbs +10 -0
- package/fragments/base/Pulumi.yaml.hbs +9 -0
- package/fragments/base/index.ts.hbs +107 -0
- package/fragments/base/package.json.hbs +22 -0
- package/{templates/api-web-db/api → fragments/base}/tsconfig.json +3 -4
- package/fragments/bucket/api/src/storage.ts.hbs +81 -0
- package/fragments/database/api/src/db.ts.hbs +23 -0
- package/fragments/database/prisma/schema.prisma.hbs +18 -0
- package/{templates/api-web-db → fragments/service}/api/.dockerignore +2 -0
- package/fragments/service/api/package.json.hbs +40 -0
- package/fragments/service/api/src/index.ts.hbs +58 -0
- package/{templates/api-web-db → fragments/service/api}/tsconfig.json +5 -3
- package/fragments/temporal/worker/.dockerignore +4 -0
- package/fragments/temporal/worker/Dockerfile +15 -0
- package/{templates/temporal-api-worker → fragments/temporal}/worker/package.json.hbs +3 -2
- package/fragments/temporal/worker/src/activities.ts.hbs +14 -0
- package/fragments/temporal/worker/src/worker.ts.hbs +27 -0
- package/fragments/temporal/worker/src/workflows.ts.hbs +24 -0
- package/fragments/temporal/worker/tsconfig.json +13 -0
- package/package.json +35 -21
- package/skills/core/SKILL.md +365 -0
- package/skills/pull-remote-agent-context/SKILL.md +194 -0
- package/stack/docker-compose.hub.yml +134 -0
- package/stack/docker-compose.yml +447 -0
- package/stack/hub/Dockerfile.api +18 -0
- package/stack/hub/Dockerfile.auth +10 -0
- package/stack/hub/Dockerfile.ui +10 -0
- package/stack/init/01-databases.sql +12 -0
- package/stack/observability/blackbox.yml +20 -0
- package/stack/observability/otel-collector.yaml +73 -0
- package/stack/observability/prometheus.yml +36 -0
- package/stack/observability/tempo.yaml +25 -0
- package/stack/temporal/local.yaml +44 -0
- package/templates/api-auth/AGENTS.md.hbs +16 -0
- package/templates/api-auth/Pulumi.dev.yaml.hbs +8 -0
- package/templates/api-auth/Pulumi.yaml.hbs +8 -0
- package/templates/api-auth/README.md.hbs +67 -0
- package/templates/api-auth/api/package.json.hbs +28 -0
- package/templates/api-auth/api/src/index.ts.hbs +96 -0
- package/templates/api-auth/api/src/schema.ts.hbs +35 -0
- package/templates/api-auth/api/src/seed-authz.ts.hbs +48 -0
- package/templates/api-auth/api/src/spicedb-http-provider.ts.hbs +89 -0
- package/templates/api-auth/index.ts.hbs +65 -0
- package/templates/api-auth/package.json.hbs +20 -0
- package/templates/api-auth/skills/develop/SKILL.md.hbs +32 -0
- package/templates/api-role-gating/AGENTS.md.hbs +20 -0
- package/templates/api-role-gating/Pulumi.dev.yaml.hbs +8 -0
- package/templates/api-role-gating/Pulumi.yaml.hbs +8 -0
- package/templates/api-role-gating/README.md.hbs +64 -0
- package/templates/api-role-gating/api/Dockerfile +17 -0
- package/templates/api-role-gating/api/package.json.hbs +28 -0
- package/templates/api-role-gating/api/src/authn.ts.hbs +29 -0
- package/templates/api-role-gating/api/src/authz.ts.hbs +12 -0
- package/templates/api-role-gating/api/src/main.ts.hbs +58 -0
- package/templates/api-role-gating/api/src/schema.ts.hbs +22 -0
- package/templates/api-role-gating/api/tsconfig.json +13 -0
- package/templates/api-role-gating/index.ts.hbs +107 -0
- package/templates/api-role-gating/package.json.hbs +21 -0
- package/templates/api-role-gating/skills/develop/SKILL.md.hbs +60 -0
- package/templates/api-role-gating/tsconfig.json +10 -0
- package/templates/apps-repo/README.md.hbs +24 -0
- package/templates/apps-repo/gitignore +41 -0
- package/templates/apps-repo/npmrc.hbs +7 -0
- package/templates/apps-repo/package.json.hbs +15 -0
- package/templates/apps-repo/pnpm-workspace.yaml +3 -0
- package/templates/apps-repo/tsconfig.json +18 -0
- package/templates/external-service/AGENTS.md.hbs +20 -0
- package/templates/external-service/Pulumi.dev.yaml.hbs +8 -0
- package/templates/external-service/Pulumi.yaml.hbs +8 -0
- package/templates/external-service/README.md.hbs +56 -0
- package/templates/external-service/api/Dockerfile +15 -0
- package/templates/external-service/api/package.json.hbs +25 -0
- package/templates/external-service/api/src/index.ts.hbs +81 -0
- package/templates/external-service/index.ts.hbs +82 -0
- package/templates/external-service/mocks/vendorpay/package.json.hbs +9 -0
- package/templates/external-service/mocks/vendorpay/server.mjs.hbs +61 -0
- package/templates/external-service/package.json.hbs +34 -0
- package/templates/external-service/skills/develop/SKILL.md.hbs +55 -0
- package/templates/external-service/tsconfig.json +10 -0
- package/templates/platform-repo/AGENTS.md.hbs +18 -0
- package/templates/platform-repo/README.md.hbs +38 -0
- package/templates/platform-repo/core/Pulumi.yaml.hbs +12 -0
- package/templates/platform-repo/core/Pulumi.{{tenant}}-{{env}}.yaml.hbs +57 -0
- package/templates/platform-repo/core/index.ts +62 -0
- package/templates/platform-repo/core/package.json.hbs +22 -0
- package/templates/platform-repo/core/tsconfig.json +8 -0
- package/templates/platform-repo/package.json.hbs +15 -0
- package/templates/platform-repo/platform/Pulumi.yaml.hbs +12 -0
- package/templates/platform-repo/platform/Pulumi.{{tenant}}-{{env}}.yaml.hbs +59 -0
- package/templates/platform-repo/platform/index.ts +95 -0
- package/templates/platform-repo/platform/package.json.hbs +26 -0
- package/templates/platform-repo/platform/tsconfig.json +8 -0
- package/templates/platform-repo/pnpm-workspace.yaml +3 -0
- package/templates/workflow/AGENTS.md.hbs +15 -0
- package/templates/workflow/Pulumi.dev.yaml.hbs +8 -0
- package/templates/workflow/Pulumi.yaml.hbs +8 -0
- package/templates/workflow/README.md.hbs +45 -0
- package/templates/workflow/api/.dockerignore +4 -0
- package/templates/workflow/api/Dockerfile +15 -0
- package/templates/{temporal-api-worker → workflow}/api/package.json.hbs +8 -6
- package/templates/workflow/api/src/index.ts.hbs +130 -0
- package/templates/workflow/api/tsconfig.json +14 -0
- package/templates/workflow/index.ts.hbs +67 -0
- package/templates/workflow/package.json.hbs +20 -0
- package/templates/workflow/skills/develop/SKILL.md.hbs +32 -0
- package/templates/workflow/tsconfig.json +10 -0
- package/templates/workflow/worker/.dockerignore +4 -0
- package/templates/workflow/worker/Dockerfile +13 -0
- package/templates/workflow/worker/package.json.hbs +25 -0
- package/templates/workflow/worker/src/worker.ts.hbs +24 -0
- package/templates/workflow/worker/tsconfig.json +14 -0
- package/dist/src/commands/devbox.d.ts +0 -22
- package/dist/src/commands/devbox.d.ts.map +0 -1
- package/dist/src/commands/devbox.js +0 -463
- package/dist/src/commands/devbox.js.map +0 -1
- package/templates/api-web-db/api/Dockerfile +0 -16
- package/templates/api-web-db/api/package.json.hbs +0 -21
- package/templates/api-web-db/api/src/index.ts.hbs +0 -123
- package/templates/api-web-db/package.json.hbs +0 -27
- package/templates/api-web-db/sst.config.ts.hbs +0 -151
- package/templates/api-web-db/web/.dockerignore +0 -3
- package/templates/api-web-db/web/Dockerfile +0 -17
- package/templates/api-web-db/web/app/lib/db.server.ts +0 -36
- package/templates/api-web-db/web/app/root.tsx +0 -29
- package/templates/api-web-db/web/app/routes/home.tsx.hbs +0 -114
- package/templates/api-web-db/web/app/routes.ts +0 -3
- package/templates/api-web-db/web/package.json.hbs +0 -30
- package/templates/api-web-db/web/prisma/schema.prisma +0 -25
- package/templates/api-web-db/web/prisma.config.ts +0 -18
- package/templates/api-web-db/web/react-router.config.ts +0 -5
- package/templates/api-web-db/web/tsconfig.json +0 -19
- package/templates/api-web-db/web/vite.config.ts +0 -9
- package/templates/temporal-api-worker/README.md.hbs +0 -133
- package/templates/temporal-api-worker/api/src/index.ts.hbs +0 -145
- package/templates/temporal-api-worker/package.json.hbs +0 -29
- package/templates/temporal-api-worker/sst.config.ts.hbs +0 -161
- package/templates/temporal-api-worker/worker/Dockerfile +0 -11
- package/templates/temporal-api-worker/worker/src/bundle-workflows.ts +0 -38
- package/templates/temporal-api-worker/worker/src/worker.ts.hbs +0 -93
- /package/templates/{temporal-api-worker → api-auth}/api/.dockerignore +0 -0
- /package/templates/{temporal-api-worker → api-auth}/api/Dockerfile +0 -0
- /package/templates/{temporal-api-worker → api-auth}/api/tsconfig.json +0 -0
- /package/templates/{temporal-api-worker → api-auth}/tsconfig.json +0 -0
- /package/templates/{temporal-api-worker/worker → api-role-gating/api}/.dockerignore +0 -0
- /package/templates/{temporal-api-worker/worker → external-service/api}/tsconfig.json +0 -0
- /package/templates/{temporal-api-worker → workflow}/api/src/encryption-codec.ts +0 -0
- /package/templates/{temporal-api-worker → workflow}/worker/src/activities.ts.hbs +0 -0
- /package/templates/{temporal-api-worker → workflow}/worker/src/encryption-codec.ts +0 -0
- /package/templates/{temporal-api-worker → workflow}/worker/src/workflows.ts.hbs +0 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-run auth preflight helpers (MESH-2479).
|
|
3
|
+
*
|
|
4
|
+
* `mesh start`/`mesh dev` do long work (registry tarball fetches, docker
|
|
5
|
+
* builds, pnpm installs) that fails minutes in — with npm's generic advice —
|
|
6
|
+
* when the CodeArtifact token or AWS SSO session is stale. These helpers
|
|
7
|
+
* verify auth BEFORE the long work and name the exact fixing command.
|
|
8
|
+
*
|
|
9
|
+
* Pure parsers/classifiers are exported separately from the impure probes so
|
|
10
|
+
* the branch logic is unit-testable without network or a home directory.
|
|
11
|
+
*/
|
|
12
|
+
import * as fs from "fs";
|
|
13
|
+
import * as os from "os";
|
|
14
|
+
import * as path from "path";
|
|
15
|
+
/**
|
|
16
|
+
* The context that owns the `@mesh-tech` registry. There is exactly one — the
|
|
17
|
+
* `mesh-platform` CodeArtifact domain every tenant pulls from — so this is the
|
|
18
|
+
* context whose broker can mint a read token for anybody, and it is what a
|
|
19
|
+
* printed remediation should name.
|
|
20
|
+
*
|
|
21
|
+
* Safe to hardcode for the same reason `--profile mesh-dev` already was: it
|
|
22
|
+
* identifies the registry, not the reader's own platform. It also resolves on a
|
|
23
|
+
* machine with no AWS at all, via the pinned first-party alias.
|
|
24
|
+
*/
|
|
25
|
+
export const REGISTRY_CONTEXT = "mesh.dev";
|
|
26
|
+
/**
|
|
27
|
+
* The command that fixes a stale/missing CodeArtifact token — **broker-first**,
|
|
28
|
+
* so it works for someone with no AWS account at all.
|
|
29
|
+
*
|
|
30
|
+
* Prefer `registryLoginFix(context)` at any call site that knows a better
|
|
31
|
+
* context than the registry's own.
|
|
32
|
+
*/
|
|
33
|
+
export const REGISTRY_LOGIN_FIX = `mesh registry login ${REGISTRY_CONTEXT}`;
|
|
34
|
+
/**
|
|
35
|
+
* The AWS-profile form. Only correct for people who **deploy**, or when the
|
|
36
|
+
* platform publishes no registry broker.
|
|
37
|
+
*
|
|
38
|
+
* Kept as a separate named constant rather than the default: `--profile`
|
|
39
|
+
* deliberately skips the broker, so printing it as the generic fix sends a
|
|
40
|
+
* developer with no AWS account to a command that cannot work for them.
|
|
41
|
+
*/
|
|
42
|
+
export const REGISTRY_LOGIN_FIX_AWS = "mesh registry login --profile mesh-dev";
|
|
43
|
+
/**
|
|
44
|
+
* Render the registry fix for a known context, falling back to the registry's
|
|
45
|
+
* own context when the caller has none. Always returns a command that can be
|
|
46
|
+
* run as printed — a remediation the reader has to edit first is half a
|
|
47
|
+
* remediation.
|
|
48
|
+
*/
|
|
49
|
+
export function registryLoginFix(context) {
|
|
50
|
+
return `mesh registry login ${context ?? REGISTRY_CONTEXT}`;
|
|
51
|
+
}
|
|
52
|
+
/** The documented AWS SSO login form (root package.json `sso` script). */
|
|
53
|
+
export const SSO_LOGIN_FIX = "aws sso login --sso-session=mesh # or: pnpm sso";
|
|
54
|
+
/**
|
|
55
|
+
* The `aws configure sso-session` snippet `pnpm sso` depends on. Printed
|
|
56
|
+
* verbatim when ~/.aws/config has no [sso-session mesh] section — kept here
|
|
57
|
+
* so the CLI and scripts/sso-login.sh describe the same setup.
|
|
58
|
+
*/
|
|
59
|
+
export const SSO_SESSION_SNIPPET = `[sso-session mesh]
|
|
60
|
+
sso_start_url = https://trabian.awsapps.com/start
|
|
61
|
+
sso_region = us-east-1
|
|
62
|
+
sso_registration_scopes = sso:account:access`;
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// ~/.npmrc parsing (pure)
|
|
65
|
+
// ============================================================================
|
|
66
|
+
/**
|
|
67
|
+
* The user-level npmrc `aws codeartifact login` writes into — the token line
|
|
68
|
+
* and, when the namespace flag is omitted, the unscoped `registry=` line.
|
|
69
|
+
*
|
|
70
|
+
* One definition for the whole CLI: the doctor, the probe, and the repair have
|
|
71
|
+
* to be looking at the same file or they disagree about the same machine.
|
|
72
|
+
* `os.homedir()` reads `$HOME` on POSIX, so a scratch-`HOME` test still works.
|
|
73
|
+
*/
|
|
74
|
+
export function homeNpmrcPath() {
|
|
75
|
+
return path.join(os.homedir(), ".npmrc");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Extract the CodeArtifact registry endpoint + auth token from npmrc content.
|
|
79
|
+
* `aws codeartifact login` writes a line shaped like:
|
|
80
|
+
* //mesh-platform-…d.codeartifact.<region>.amazonaws.com/npm/<repo>/:_authToken=<tok>
|
|
81
|
+
* Returns null when no CodeArtifact token line is present.
|
|
82
|
+
*/
|
|
83
|
+
export function parseNpmrcRegistryAuth(content) {
|
|
84
|
+
for (const line of content.split("\n")) {
|
|
85
|
+
const match = line.trim().match(/^\/\/([^:]*\.codeartifact\.[^:]*):_authToken=(.+)$/);
|
|
86
|
+
if (match && match[1] && match[2]) {
|
|
87
|
+
const endpoint = `https://${match[1]}${match[1].endsWith("/") ? "" : "/"}`;
|
|
88
|
+
return { endpoint, token: match[2].trim() };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Find an **unscoped** `registry=` line in npmrc content that points at
|
|
95
|
+
* CodeArtifact — the line `aws codeartifact login` writes when it is run
|
|
96
|
+
* WITHOUT `--namespace @mesh-tech`.
|
|
97
|
+
*
|
|
98
|
+
* That line makes CodeArtifact the *default* registry, so every public package
|
|
99
|
+
* (lodash, react, …) is fetched through it with the CodeArtifact token. When
|
|
100
|
+
* the token expires 12 hours later, `npm install` of anything at all fails
|
|
101
|
+
* with E401 — the private-scope breakage everyone expects, plus a total public
|
|
102
|
+
* npm outage nobody does.
|
|
103
|
+
*
|
|
104
|
+
* Deliberately narrow — it must only match a line that is BOTH unscoped AND a
|
|
105
|
+
* CodeArtifact host, so it never touches:
|
|
106
|
+
* - `@mesh-tech:registry=…` (scoped: the line we WANT)
|
|
107
|
+
* - `//…:_authToken=…` (auth, unaffected by the default registry)
|
|
108
|
+
* - `registry=https://npm.acme.internal/` (a team's legitimate private mirror)
|
|
109
|
+
*
|
|
110
|
+
* Returns the offending line verbatim (as it appears in the file), or null.
|
|
111
|
+
*/
|
|
112
|
+
export function findUnscopedCodeArtifactRegistry(content) {
|
|
113
|
+
for (const line of content.split("\n")) {
|
|
114
|
+
const trimmed = line.trim();
|
|
115
|
+
// npmrc comments start with ; or #
|
|
116
|
+
if (!trimmed || trimmed.startsWith(";") || trimmed.startsWith("#"))
|
|
117
|
+
continue;
|
|
118
|
+
// Anchored at `registry` — a scoped line starts with `@scope:`, so it can't match.
|
|
119
|
+
const match = trimmed.match(/^registry\s*=\s*(\S+)$/);
|
|
120
|
+
if (!match || !match[1])
|
|
121
|
+
continue;
|
|
122
|
+
if (isCodeArtifactRegistryUrl(match[1]))
|
|
123
|
+
return line;
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
/** True when a registry URL's *host* is a CodeArtifact endpoint. */
|
|
128
|
+
function isCodeArtifactRegistryUrl(value) {
|
|
129
|
+
try {
|
|
130
|
+
return new URL(value).hostname.includes(".codeartifact.");
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// Not a parseable URL (env-var interpolation, protocol-relative, …) —
|
|
134
|
+
// fall back to a substring test so we don't miss an obvious hijack.
|
|
135
|
+
return value.includes(".codeartifact.");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Remove every unscoped CodeArtifact `registry=` line from npmrc content.
|
|
140
|
+
* Pure: returns the rewritten content plus the first line removed (null when
|
|
141
|
+
* the content was already clean, in which case `content` is returned
|
|
142
|
+
* unchanged and callers should skip the write entirely).
|
|
143
|
+
*/
|
|
144
|
+
export function stripUnscopedCodeArtifactRegistry(content) {
|
|
145
|
+
const offender = findUnscopedCodeArtifactRegistry(content);
|
|
146
|
+
if (offender === null)
|
|
147
|
+
return { content, removed: null };
|
|
148
|
+
const kept = content
|
|
149
|
+
.split("\n")
|
|
150
|
+
.filter((line) => findUnscopedCodeArtifactRegistry(line) === null);
|
|
151
|
+
// split/join round-trips the file's trailing-newline state exactly.
|
|
152
|
+
return { content: kept.join("\n"), removed: offender };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The `//host/path/:_authToken=` key `aws codeartifact login` writes for a
|
|
156
|
+
* registry endpoint — the endpoint with its scheme stripped and a leading `//`.
|
|
157
|
+
*
|
|
158
|
+
* Pure and shared so the broker path writes byte-identical lines to the AWS CLI
|
|
159
|
+
* path. Two spellings of the same key would leave a stale token line behind
|
|
160
|
+
* that npm might prefer, and the symptom (E401 hours later) points nowhere
|
|
161
|
+
* near the cause.
|
|
162
|
+
*/
|
|
163
|
+
export function npmrcAuthKeyForEndpoint(endpoint) {
|
|
164
|
+
const withoutScheme = endpoint.replace(/^https?:\/\//, "");
|
|
165
|
+
return `//${withoutScheme.endsWith("/") ? withoutScheme : `${withoutScheme}/`}`;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Upsert `key=value` lines into npmrc content: replace the existing line for a
|
|
169
|
+
* key when present, append it otherwise, and leave every other line untouched.
|
|
170
|
+
*
|
|
171
|
+
* Pure. Always emits a trailing newline, and never reorders lines a
|
|
172
|
+
* user put there themselves — an npmrc is a config file people hand-edit, and
|
|
173
|
+
* a token refresh that rewrites the whole thing is how unrelated settings
|
|
174
|
+
* silently disappear.
|
|
175
|
+
*/
|
|
176
|
+
export function upsertNpmrcLines(content, entries) {
|
|
177
|
+
let lines = content.length ? content.split("\n") : [];
|
|
178
|
+
const trailingNewline = content.endsWith("\n");
|
|
179
|
+
if (trailingNewline)
|
|
180
|
+
lines = lines.slice(0, -1);
|
|
181
|
+
for (const { key, value } of entries) {
|
|
182
|
+
const line = `${key}=${value}`;
|
|
183
|
+
const idx = lines.findIndex((l) => {
|
|
184
|
+
const trimmed = l.trim();
|
|
185
|
+
if (!trimmed || trimmed.startsWith(";") || trimmed.startsWith("#"))
|
|
186
|
+
return false;
|
|
187
|
+
const eq = trimmed.indexOf("=");
|
|
188
|
+
return eq > 0 && trimmed.slice(0, eq).trim() === key;
|
|
189
|
+
});
|
|
190
|
+
if (idx >= 0)
|
|
191
|
+
lines[idx] = line;
|
|
192
|
+
else
|
|
193
|
+
lines.push(line);
|
|
194
|
+
}
|
|
195
|
+
return lines.join("\n") + "\n";
|
|
196
|
+
}
|
|
197
|
+
/** Map an HTTP status from an authenticated registry request to a token state. */
|
|
198
|
+
export function classifyRegistryStatus(status) {
|
|
199
|
+
// 401/403 mean the token itself was rejected. Anything else (200, 404, …)
|
|
200
|
+
// means auth was accepted — the token is usable.
|
|
201
|
+
return status === 401 || status === 403 ? "expired" : "fresh";
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Verify the CodeArtifact token in ~/.npmrc actually works, with one small
|
|
205
|
+
* authenticated metadata request (bounded by `timeoutMs`). Never throws.
|
|
206
|
+
*/
|
|
207
|
+
export async function probeRegistryToken(opts) {
|
|
208
|
+
const npmrcPath = opts?.npmrcPath ?? homeNpmrcPath();
|
|
209
|
+
const timeoutMs = opts?.timeoutMs ?? 8_000;
|
|
210
|
+
const fetchFn = opts?.fetchFn ?? fetch;
|
|
211
|
+
let auth = null;
|
|
212
|
+
try {
|
|
213
|
+
auth = parseNpmrcRegistryAuth(fs.readFileSync(npmrcPath, "utf-8"));
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
// unreadable/missing ~/.npmrc — same as no auth configured
|
|
217
|
+
}
|
|
218
|
+
if (!auth)
|
|
219
|
+
return { state: "missing" };
|
|
220
|
+
try {
|
|
221
|
+
const res = await fetchFn(`${auth.endpoint}${encodeURIComponent("@mesh-tech/hub")}`, {
|
|
222
|
+
method: "GET",
|
|
223
|
+
headers: { authorization: `Bearer ${auth.token}` },
|
|
224
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
225
|
+
});
|
|
226
|
+
const state = classifyRegistryStatus(res.status);
|
|
227
|
+
return state === "expired"
|
|
228
|
+
? { state, detail: `registry answered HTTP ${res.status} for an authenticated request` }
|
|
229
|
+
: { state };
|
|
230
|
+
}
|
|
231
|
+
catch (err) {
|
|
232
|
+
return {
|
|
233
|
+
state: "unreachable",
|
|
234
|
+
detail: err instanceof Error ? err.message : String(err),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// ============================================================================
|
|
239
|
+
// npm / AWS error classification (pure)
|
|
240
|
+
// ============================================================================
|
|
241
|
+
/** True when npm output/an error message is an auth failure (E401/E403). */
|
|
242
|
+
export function isNpmAuthErrorText(text) {
|
|
243
|
+
return /\bE?40[13]\b|unauthenticated|unable to authenticate|authentication (required|failed)/i.test(text);
|
|
244
|
+
}
|
|
245
|
+
/** True when an npm exec error (with stderr/message) is an auth failure. */
|
|
246
|
+
export function isNpmAuthError(err) {
|
|
247
|
+
const e = err;
|
|
248
|
+
const text = [e?.stderr, e?.message]
|
|
249
|
+
.map((v) => (v === null || v === undefined ? "" : String(v)))
|
|
250
|
+
.join("\n");
|
|
251
|
+
return isNpmAuthErrorText(text);
|
|
252
|
+
}
|
|
253
|
+
/** True when an AWS SDK/CLI error message means the ambient session expired. */
|
|
254
|
+
export function isExpiredAwsTokenMessage(message) {
|
|
255
|
+
return /expired|invalid.*(security )?token|token.*(is )?invalid|no credential|could not load credentials|could not be found|sso session/i.test(message);
|
|
256
|
+
}
|
|
257
|
+
// ============================================================================
|
|
258
|
+
// ~/.aws/config parsing (pure) — `pnpm sso` / --profile prerequisites
|
|
259
|
+
// ============================================================================
|
|
260
|
+
/** Names of `[sso-session <name>]` sections in an AWS config file. */
|
|
261
|
+
export function parseSsoSessionNames(content) {
|
|
262
|
+
const names = [];
|
|
263
|
+
for (const line of content.split("\n")) {
|
|
264
|
+
const match = line.trim().match(/^\[sso-session\s+([^\]]+)\]$/);
|
|
265
|
+
if (match && match[1])
|
|
266
|
+
names.push(match[1].trim());
|
|
267
|
+
}
|
|
268
|
+
return names;
|
|
269
|
+
}
|
|
270
|
+
/** True when the AWS config file declares the named profile. */
|
|
271
|
+
export function awsConfigHasProfile(content, profile) {
|
|
272
|
+
const pattern = new RegExp(`^\\[(?:profile\\s+)?${profile.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\]$`);
|
|
273
|
+
return content.split("\n").some((line) => pattern.test(line.trim()));
|
|
274
|
+
}
|
|
275
|
+
/** Read ~/.aws/config (honoring AWS_CONFIG_FILE); "" when unreadable. */
|
|
276
|
+
export function readAwsConfig() {
|
|
277
|
+
const file = process.env.AWS_CONFIG_FILE ?? path.join(os.homedir(), ".aws", "config");
|
|
278
|
+
try {
|
|
279
|
+
return fs.readFileSync(file, "utf-8");
|
|
280
|
+
}
|
|
281
|
+
catch {
|
|
282
|
+
return "";
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
// ============================================================================
|
|
286
|
+
// App dependency scan (for the dev doctor's registry check)
|
|
287
|
+
// ============================================================================
|
|
288
|
+
/** True when the app's package.json depends on any @mesh-tech/* package. */
|
|
289
|
+
export function appUsesMeshPackages(appRoot) {
|
|
290
|
+
try {
|
|
291
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(appRoot, "package.json"), "utf-8"));
|
|
292
|
+
return [pkg.dependencies, pkg.devDependencies, pkg.optionalDependencies].some((deps) => deps && Object.keys(deps).some((name) => name.startsWith("@mesh-tech/")));
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
//# sourceMappingURL=auth-preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-preflight.js","sourceRoot":"","sources":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,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,aAAa;IAC3B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtF,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,4DAA4D;AAC5D,+EAA+E;AAE/E,4EAA4E;AAC5E,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAIlF,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,eAAe,EAAE,GAAG,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAC3E,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CACnF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared AWS credential resolution for mesh CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* Three-tier resolution:
|
|
5
|
+
* 1. Existing AWS credentials in environment (CI/CD) → use directly
|
|
6
|
+
* 2. Zitadel JWT via `mesh login` → AssumeRoleWithWebIdentity
|
|
7
|
+
* 3. Fallback → AssumeRole via current AWS session (SSO)
|
|
8
|
+
*
|
|
9
|
+
* Uses @aws-sdk/client-sts directly — does NOT shell out to the `aws` CLI
|
|
10
|
+
* binary, so the binary is not a runtime requirement.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Derive the platform context key (e.g., "mesh.dev") from a Pulumi stack config.
|
|
14
|
+
*
|
|
15
|
+
* Reads `mesh:platform` from Pulumi.<stack>.yaml. Supports both formats:
|
|
16
|
+
* mesh:platform: '{"env":"dev","name":"mesh"}' → "mesh.dev"
|
|
17
|
+
* mesh:platform:
|
|
18
|
+
* name: mesh
|
|
19
|
+
* env: dev → "mesh.dev"
|
|
20
|
+
*/
|
|
21
|
+
export declare function derivePlatformContext(appRoot: string, stack: string): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve a STABLE absolute path to the running `mesh` entrypoint for
|
|
24
|
+
* embedding in a `credential_process` line — or fall back to plain `mesh`
|
|
25
|
+
* (PATH lookup) when `argv1` is missing, doesn't exist on disk, or lives in
|
|
26
|
+
* a transient location (`npx` cache / OS temp dir): a profile pointing at a
|
|
27
|
+
* path that evaporates breaks every later AWS call with a cryptic
|
|
28
|
+
* credential_process error. The fallback is announced via `logWarn` so the
|
|
29
|
+
* user knows to install mesh-cli globally.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveStableMeshBin(argv1: string | undefined, deps?: {
|
|
32
|
+
exists?: (p: string) => boolean;
|
|
33
|
+
warn?: (msg: string) => void;
|
|
34
|
+
}): string;
|
|
35
|
+
/**
|
|
36
|
+
* Render an AWS config-file `[profile …]` block whose `credential_process`
|
|
37
|
+
* re-invokes `mesh login … --credential-process`, so the AWS SDK's default
|
|
38
|
+
* provider chain auto-refreshes the underlying STS triple (the `mesh login`
|
|
39
|
+
* process re-issues the Zitadel token as needed).
|
|
40
|
+
*
|
|
41
|
+
* Shared by `mesh dev` (child services) and `mesh login --export` so both
|
|
42
|
+
* produce byte-identical profiles. Pure — no I/O. The `region` line is
|
|
43
|
+
* emitted only when `region` is a non-empty string. Includes a trailing
|
|
44
|
+
* newline. The binary path and role ARN are double-quoted when they contain
|
|
45
|
+
* whitespace (AWS config command-splitting rules).
|
|
46
|
+
*/
|
|
47
|
+
export declare function renderCredentialProcessProfile(args: {
|
|
48
|
+
profileName: string;
|
|
49
|
+
context: string;
|
|
50
|
+
roleArn: string;
|
|
51
|
+
region?: string;
|
|
52
|
+
meshBin: string;
|
|
53
|
+
}): string;
|
|
54
|
+
/**
|
|
55
|
+
* Insert or replace the mesh-managed `[profile …]` section for `context` in
|
|
56
|
+
* the user's AWS config content, preserving ALL other content byte-for-byte
|
|
57
|
+
* (this is the user's real ~/.aws/config — clobbering it breaks their other
|
|
58
|
+
* profiles). Pure — no I/O; exported for unit testing.
|
|
59
|
+
*
|
|
60
|
+
* - Existing managed section for this context → replaced in place.
|
|
61
|
+
* - Orphaned START (matching END lost) → only the contiguous profile block
|
|
62
|
+
* that is provably ours is reclaimed; other contexts' sections and user
|
|
63
|
+
* content below are preserved (see `orphanedSectionTail`).
|
|
64
|
+
* - No section → appended, separated by a single blank line (and a trailing
|
|
65
|
+
* newline is added to the existing content if it lacks one).
|
|
66
|
+
*/
|
|
67
|
+
export declare function upsertManagedAwsConfigSection(existing: string, context: string, profileBlock: string): string;
|
|
68
|
+
/** Assume an IAM role via current AWS session and return credentials as env vars. */
|
|
69
|
+
export declare function assumeRole(roleArn: string, sessionName?: string, durationSeconds?: number): Promise<Record<string, string> | null>;
|
|
70
|
+
/** STS credentials for a Zitadel-JWT-assumed role, including expiry. */
|
|
71
|
+
export interface StsCreds {
|
|
72
|
+
AccessKeyId: string;
|
|
73
|
+
SecretAccessKey: string;
|
|
74
|
+
SessionToken: string;
|
|
75
|
+
/** ISO-8601 expiration timestamp. */
|
|
76
|
+
Expiration: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Assume role using a Zitadel JWT via AssumeRoleWithWebIdentity, returning
|
|
80
|
+
* the full STS credential struct (including `Expiration`) rather than the
|
|
81
|
+
* env-var shape. Used by callers that need to track/refresh expiry (e.g.
|
|
82
|
+
* `credential_process`).
|
|
83
|
+
*/
|
|
84
|
+
export declare function assumeRoleCredentials(roleArn: string, idToken: string, sessionName: string, durationSeconds?: number): Promise<StsCreds | null>;
|
|
85
|
+
/** Assume role using a Zitadel JWT via AssumeRoleWithWebIdentity. */
|
|
86
|
+
export declare function assumeRoleWithWebIdentity(roleArn: string, idToken: string, sessionName: string, durationSeconds?: number): Promise<Record<string, string> | null>;
|
|
87
|
+
/**
|
|
88
|
+
* Extract the `iss` claim from a JWT without ever throwing — malformed or
|
|
89
|
+
* corrupt tokens (e.g. a damaged `~/.config/mesh/credentials.json`) yield
|
|
90
|
+
* `undefined`. The failure-diagnostic paths use this; a decode that throws
|
|
91
|
+
* there would crash before the diagnostic prints, which is exactly the
|
|
92
|
+
* failure class MESH-2515 removes.
|
|
93
|
+
*/
|
|
94
|
+
export declare function tokenIssuer(token: string): string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Explain an AssumeRoleWithWebIdentity failure in platform terms: which login
|
|
97
|
+
* session (context + token issuer) tried to assume which role, in which AWS
|
|
98
|
+
* account. STS's "web identity token could not be validated" reads like an
|
|
99
|
+
* IAM/expiry problem, but the usual cause is a context whose issuer the role's
|
|
100
|
+
* account simply doesn't trust — e.g. a `mesh.dev` session against a role in a
|
|
101
|
+
* `trabian`-platform account (MESH-2515). stderr only — callers in
|
|
102
|
+
* `--credential-process` mode must keep stdout JSON-clean.
|
|
103
|
+
*
|
|
104
|
+
* `format: "inline"` renders the same facts as one line, for detail fields
|
|
105
|
+
* that get interpolated mid-sentence (the doctor/preflight cred probe). Both
|
|
106
|
+
* forms keep the `AssumeRoleWithWebIdentity failed` prefix the doctor plan
|
|
107
|
+
* documents as the detail capture.
|
|
108
|
+
*/
|
|
109
|
+
export declare function describeAssumeFailure(opts: {
|
|
110
|
+
roleArn: string;
|
|
111
|
+
context?: string;
|
|
112
|
+
issuer?: string;
|
|
113
|
+
}, format?: "block" | "inline"): string;
|
|
114
|
+
/** Format STS credentials as AWS `credential_process` JSON (Version 1). */
|
|
115
|
+
export declare function toCredentialProcessJson(creds: StsCreds): string;
|
|
116
|
+
export interface ResolvedAwsCreds {
|
|
117
|
+
/** AWS credential env vars (ACCESS_KEY_ID, SECRET_ACCESS_KEY, SESSION_TOKEN) */
|
|
118
|
+
env: Record<string, string>;
|
|
119
|
+
/** How the credentials were obtained */
|
|
120
|
+
method: "environment" | "zitadel" | "sso";
|
|
121
|
+
}
|
|
122
|
+
export interface AwsIdentity {
|
|
123
|
+
/** Full caller ARN, e.g. arn:aws:iam::159923586610:user/CI-CD_User */
|
|
124
|
+
arn: string;
|
|
125
|
+
accountId: string;
|
|
126
|
+
/** Where the SDK's default chain found the credentials, for the human reading it. */
|
|
127
|
+
source: "environment" | "profile";
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Ask "is there a working AWS connection right now?" — nothing more.
|
|
131
|
+
*
|
|
132
|
+
* Deliberately NOT `resolveAwsCredentials`: that one answers "get me credentials
|
|
133
|
+
* for role X" and has an opinion about how they were obtained. This one runs
|
|
134
|
+
* GetCallerIdentity through the SDK's default provider chain and reports whatever
|
|
135
|
+
* it finds, so a static key/secret pair in `~/.aws/credentials` counts exactly as
|
|
136
|
+
* much as an SSO session or a Zitadel-minted role. Returns null when the chain
|
|
137
|
+
* yields nothing usable.
|
|
138
|
+
*/
|
|
139
|
+
export declare function probeAwsIdentity(): Promise<AwsIdentity | null>;
|
|
140
|
+
/**
|
|
141
|
+
* Pick the AWS role ARN to assume based on Zitadel claims.
|
|
142
|
+
*
|
|
143
|
+
* Zitadel emits project roles under
|
|
144
|
+
* `urn:zitadel:iam:org:project:<projectId>:roles` as a nested object
|
|
145
|
+
* keyed by role name. We treat the presence of `mesh.platform:admin`
|
|
146
|
+
* (or any role listed in `meshcli.adminRoles` in config) as the
|
|
147
|
+
* signal to assume the broader admin role when the caller has
|
|
148
|
+
* configured one.
|
|
149
|
+
*
|
|
150
|
+
* Returns `defaultRole` when no admin role is configured, no admin
|
|
151
|
+
* claim is present, or the JWT can't be parsed. This keeps existing
|
|
152
|
+
* deployments working without a config change.
|
|
153
|
+
*
|
|
154
|
+
* The admin AWS role's IAM trust policy is expected to gate
|
|
155
|
+
* assumption on the same Zitadel claim in production (so the CLI
|
|
156
|
+
* preference can't be spoofed). That setup is its own change — see
|
|
157
|
+
* TODO(mesh-zitadel-aws-role-mapping).
|
|
158
|
+
*/
|
|
159
|
+
export declare function selectRoleForCaller(idToken: string | null, options: {
|
|
160
|
+
defaultRole: string;
|
|
161
|
+
adminRole?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Zitadel role names that should map to `adminRole`. Defaults to
|
|
164
|
+
* a single `mesh.platform:admin` role; callers can override via
|
|
165
|
+
* config to introduce role tiers later.
|
|
166
|
+
*/
|
|
167
|
+
adminClaimRoles?: string[];
|
|
168
|
+
}): string;
|
|
169
|
+
/**
|
|
170
|
+
* Resolve AWS credentials using the three-tier strategy.
|
|
171
|
+
*
|
|
172
|
+
* @param roleArn The IAM role to assume (from mesh:deployerRole)
|
|
173
|
+
* @param appRoot Pulumi app root directory
|
|
174
|
+
* @param stack Pulumi stack name
|
|
175
|
+
* @returns Resolved credentials, or null if all methods fail
|
|
176
|
+
*
|
|
177
|
+
* To inherit a broader role based on Zitadel claims, call
|
|
178
|
+
* `selectRoleForCaller` first and pass the result as `roleArn`.
|
|
179
|
+
*/
|
|
180
|
+
export declare function resolveAwsCredentials(roleArn: string, appRoot: string, stack: string): Promise<ResolvedAwsCreds | null>;
|
|
181
|
+
//# sourceMappingURL=aws-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws-auth.d.ts","sourceRoot":"","sources":["../../../src/utils/aws-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAiBH;;;;;;;;GAQG;AACH,wBAAgB,qBA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