Commit graph

9 commits

Author SHA1 Message Date
Claude
d1873dbe09
feat: migrate all API routes to ApiRoutesRegistering
All 6 Mod modules now register API routes via ApiRoutesRegistering
instead of WebRoutesRegistering with CSRF hacks. The api middleware
group (ThrottleRequests + SubstituteBindings, no CSRF/session)
handles everything natively. Website/Api module simplified to just
metrics and homepage. fireApiRoutes() added to Web Boot.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 12:51:53 +01:00
Claude
d83c9094cd
refactor: move /v1/* API routes exclusively to Website/Api module
Production stack has honeypot that null-routes API payloads sent to
the web domain. API routes now only register via Website/Api module
(api.lthn.io). Mod modules stripped to web-only routes. Frontend JS
fetch calls use configurable API_URL for cross-origin API access.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 09:36:59 +01:00
Claude
6b2032c687
fix: exclude API routes from CSRF validation
POST endpoints on /v1/* were returning 419 CSRF mismatch because
$event->routes() wraps routes in the web middleware group which
includes ValidateCsrfToken. External clients (Blesta, curl) can't
send CSRF tokens. withoutMiddleware() on /v1/* prefixes fixes this.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 09:26:54 +01:00
Claude
646fb0602f
refactor: adopt CorePHP lifecycle event patterns in all Mod modules
All 6 Mod modules now use $event->routes() and $event->views() instead
of raw Route:: and app('view')-> calls. Service singletons moved to
FrameworkBooted where appropriate. Website/Api module added for
api.lthn.io domain with proper DomainResolving.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 09:13:34 +01:00
Claude
0220be23a4
fix: medium code review findings
- NodeSelector: array_values inside cache closure (fix key gaps)
- GatewayRegistry: prune expired entries from live_list on access
- Removed orphaned lethean::names view (replaced by names::index)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 08:10:58 +01:00
Claude
a5f28d5f6f
security: fix critical + high code review findings
CRITICAL:
- DaemonRpc: only cache successful responses as stale fallback (not errors)
- Records endpoint: replaced file_get_contents with Http::timeout(3)

HIGH:
- WalletRpc: removed exception message from API response (IP leak)
- Ticket/session IDs: replaced MD5(predictable) with random_bytes (CSPRNG)
- Race condition lock: Cache::add() atomic instead of has()+put()

MEDIUM:
- Block caching: getBlockByHeight cached 1hr (blocks are immutable)
- Sunrise meta description: fixed Blade variable syntax

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 08:08:18 +01:00
Claude
94f0b454b2
feat(proxy): billing endpoint for Blesta metered invoicing
- GET /v1/proxy/billing/{apiKey} — usage + charges per tier
- Mobile: $5/GB, Residential: $2.50/GB, SEO: $1/1K requests
- Period, usage bytes/GB/requests, per-tier cost breakdown
- Blesta cron queries this to generate overage invoices

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 05:25:40 +01:00
Claude
7c38f1a836
feat(proxy): prefer live paired gateways over chain discovery
- connect endpoint checks GatewayRegistry first for paired nodes
- Returns real WireGuard/proxy endpoints, region, load from live data
- Falls back to chain alias discovery when no paired gateways available
- Response includes source: 'paired' or 'chain' for transparency

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 04:56:46 +01:00
Claude
a7fa7ca087
feat(proxy): api.lthn.io proxy gateway module
- POST /v1/proxy/connect — get gateway node for service type (mobile/residential/seo)
- GET /v1/proxy/usage — usage tracking per API key (bytes, GB, requests)
- GET /v1/proxy/nodes — list available nodes by capability
- GET /v1/proxy/status — network availability + service pricing
- NodeSelector: round-robin selection from chain aliases by capability
- UsageMeter: per-key tracking of bytes and requests
- Three billing models: mobile ($5/GB), residential ($2.50/GB), SEO (per-request)
- Auth required for connect/usage, public for status/nodes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 04:33:13 +01:00