fix: critical bugs, serverless stability, and security hardening

Bug Fixes:
- Fix rate limiter API mismatch: check() -> checkAsync() in index.ts, worker.ts, api/relay.ts
- Fix WebSocket SSRF silent drop: return error Response instead of undefined
- Fix isDevMode() default: changed from true to false (production-safe)
- Fix process.env -> env bindings in worker.ts requireAuth for Cloudflare Workers
- Fix Bun.file() crash in Workers: add try/catch with fallback
- Fix Bun.CryptoHasher -> Web Crypto API in mimo-auth.ts for Workers compat

Architecture:
- Add public methods to ProxyPool (getEntryAtIndex, getProxyUrlAtIndex, getCurrentIndex, setCurrentIndex) to remove all 'as any' casts in SessionProxyPool
- Add addProxy() method for manual proxy management
- Add loadAsync(), tryLoadAsync(), loadFromString() to ProxyPool

Serverless Stability:
- Add optional DNS rebinding protection via SSRF_DNS_CHECK env flag
- CORS cache now auto-invalidates when CORS_ORIGIN env changes
- Rate limiter max-size eviction (10k keys) prevents unbounded memory growth

Tests:
- Fix type assertions in test files (body as Record<string, unknown>)
- All 153 tests pass, typecheck clean
This commit is contained in:
MythEclipse
2026-06-19 18:10:49 +07:00
parent 6d61dcba8f
commit cb6191902e
13 changed files with 865 additions and 121 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ describe("handleHealth", () => {
test("should include status, uptime, and version fields", async () => {
const response = handleHealth();
const body = await response.json();
const body = await response.json() as Record<string, unknown>;
expect(body.status).toBe("ok");
expect(typeof body.uptime).toBe("number");
expect(body.version).toBe("1.0.0");