Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions wrangler.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// chittycommand β€” Cloudflare Workers configuration
{
"name": "chittycommand",
"account_id": "0bc21e3a5a9de1a4cc843be9c3e98121",
"main": "src/index.ts",
"compatibility_date": "2026-01-15",
"compatibility_flags": [
"nodejs_compat"
],
"routes": [
{
"pattern": "command.chitty.cc",
"custom_domain": true
},
{
"pattern": "disputes.chitty.cc",
"custom_domain": true
}
],
"vars": {
"ENVIRONMENT": "production",
"CHITTYAUTH_URL": "https://auth.chitty.cc",
"CHITTYLEDGER_URL": "https://ledger.chitty.cc",
"CHITTYFINANCE_URL": "https://finance.chitty.cc",
"CHITTYCHARGE_URL": "https://charge.chitty.cc",
"CHITTYCONNECT_URL": "https://connect.chitty.cc",
"PLAID_ENV": "sandbox",
"CHITTYBOOKS_URL": "https://chittybooks.chitty.cc",
"CHITTYASSETS_URL": "https://chittyassets.chitty.cc",
"CHITTYSCRAPE_URL": "https://scrape.chitty.cc",
"CHITTYROUTER_URL": "https://router.chitty.cc",
"CHITTYREGISTER_URL": "https://register.chitty.cc"
},
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "6f6cba43540b430eb77045f79384ca00"
}
],
"r2_buckets": [
{
"binding": "DOCUMENTS",
"bucket_name": "chittycommand-documents"
}
],
"kv_namespaces": [
{
"binding": "COMMAND_KV",
"id": "64eef343b99b46ac909dbbcc1c4b2dee"
}
],
"ai": {
"binding": "AI"
},
"tail_consumers": [
{
"service": "chittytrack"
}
],
Comment on lines +20 to +59

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="$(fd '^wrangler\.jsonc$' . | head -n1)"
python - <<'PY' "$file"
import json, re, sys
from pathlib import Path

path = Path(sys.argv[1])
text = path.read_text()

# Strip simple JSONC comments for this config shape.
text = re.sub(r'//.*', '', text)
cfg = json.loads(text)

top_keys = ["vars", "hyperdrive", "r2_buckets", "kv_namespaces", "ai", "tail_consumers"]
prod = cfg.get("env", {}).get("production", {})

print(f"file: {path}")
print("top-level non-inheritable-ish keys present:")
for k in top_keys:
    if k in cfg:
        print(f"  - {k}")

print("\nenv.production keys present:")
for k in top_keys:
    if k in prod:
        print(f"  - {k}")

missing = [k for k in top_keys if k in cfg and k not in prod]
print("\nmissing from env.production:")
for k in missing:
    print(f"  - {k}")

if missing:
    raise SystemExit(1)
PY

Repository: chittyos/chittycommand

Length of output: 689


🏁 Script executed:

fd '^wrangler\.jsonc$' . | head -n1

Repository: chittyos/chittycommand

Length of output: 82


🏁 Script executed:

cat -n ./wrangler.jsonc

Repository: chittyos/chittycommand

Length of output: 2295


🏁 Script executed:

cat -n ./src/middleware/auth.ts | head -50

Repository: chittyos/chittycommand

Length of output: 1825


🏁 Script executed:

rg -n 'mcpAuthMiddleware' ./src/middleware/auth.ts -A 20

Repository: chittyos/chittycommand

Length of output: 853


env.production missing ENVIRONMENT enables authentication bypass in production.

Wrangler environments are separate Workers, and vars plus bindings do not auto-inherit from top-level. Deploying with --env production will only apply PLAID_ENV: "production" from env.production (lines 70–72); the top-level ENVIRONMENT: "production" and all bindings (hyperdrive, r2_buckets, kv_namespaces, ai, tail_consumers) must be re-declared.

Critical: Without ENVIRONMENT in production, mcpAuthMiddleware (src/middleware/auth.ts:108) evaluates c.env.ENVIRONMENT !== 'production' as true when undefined, activating the dev bypass that skips MCP authentication.

Re-declare all top-level vars and bindings inside env.production, ensuring ENVIRONMENT: "production" is included.

πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@wrangler.jsonc` around lines 20 - 59, The production environment
`env.production` is missing the top-level `vars` and bindings (including
ENVIRONMENT) so deploying with --env production causes `mcpAuthMiddleware` to
treat ENVIRONMENT as undefined and enable the dev auth bypass; fix by
re-declaring the full set of top-level `vars` (at minimum add "ENVIRONMENT":
"production" plus the other keys like PLAID_ENV) and all bindings (`hyperdrive`,
`r2_buckets`, `kv_namespaces`, `ai`, `tail_consumers`) inside `env.production`
so the production worker receives the same environment and bindings as the
top-level configuration and `mcpAuthMiddleware` no longer inadvertently enables
the bypass.

"triggers": {
"crons": [
"0 12 * * *",
"0 13 * * *",
"0 14 * * 1",
"0 15 1 * *"
]
},
"env": {
"production": {
"vars": {
"PLAID_ENV": "production"
}
}
}
}
65 changes: 0 additions & 65 deletions wrangler.toml

This file was deleted.

Loading