Commit Graph

10 Commits

Author SHA1 Message Date
kappa
91f50ddc12 fix: critical security improvements
- Apply optimistic locking to deposit-matcher.ts (race condition fix)
- Add timing-safe comparison for API key validation
- Move admin IDs from wrangler.toml vars to secrets
- Add .env.example for secure credential management

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:18:21 +09:00
kappa
45e0677ab0 refactor: code quality improvements (P3)
## Type Safety
- Add zod runtime validation for external API responses
  * Namecheap API responses (domain-register.ts)
  * n8n webhook responses (n8n-service.ts)
  * User request bodies (routes/api.ts)
  * Replaced unsafe type assertions with safeParse()
  * Proper error handling and logging

## Dead Code Removal
- Remove unused callDepositAgent function (127 lines)
  * Legacy Assistants API code no longer needed
  * Now using direct code execution
  * File reduced from 469 → 345 lines (26.4% reduction)

## Configuration Management
- Extract hardcoded URLs to environment variables
  * Added 7 new vars in wrangler.toml:
    OPENAI_API_BASE, NAMECHEAP_API_URL, WHOIS_API_URL,
    CONTEXT7_API_BASE, BRAVE_API_BASE, WTTR_IN_URL, HOSTING_SITE_URL
  * Updated Env interface in types.ts
  * All URLs have fallback to current production values
  * Enables environment-specific configuration (dev/staging/prod)

## Dependencies
- Add zod 4.3.5 for runtime type validation

## Files Modified
- Configuration: wrangler.toml, types.ts, package.json
- Services: 11 TypeScript files with URL/validation updates
- Total: 15 files, +196/-189 lines

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 22:06:01 +09:00
kappa
4eb5bbd3d3 feat(security): API 키 보호, CORS 강화, Rate Limiting KV 전환
보안 개선:
- API 키 하드코딩 제거 (NAMECHEAP_API_KEY_INTERNAL)
- CORS 정책: * → hosting.anvil.it.com 제한
- /health 엔드포인트 DB 정보 노출 방지
- Rate Limiting 인메모리 Map → Cloudflare KV 전환
  - 분산 환경 일관성 보장
  - 재시작 후에도 유지
  - 자동 만료 (TTL)

문서:
- CLAUDE.md Security 섹션 추가
- KV Namespace 설정 가이드 추가
- 배포/마이그레이션 가이드 추가

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 15:20:14 +09:00
kappa
db859efc56 feat: 도메인 인라인 버튼 등록 + cheapest TLD + Cron 자동취소
- 도메인 등록 인라인 버튼 확인 플로우 (domain-register.ts)
- manage_domain에 cheapest action 추가 (가장 저렴한 TLD TOP 15)
- 24시간 경과 입금 대기 자동 취소 Cron (UTC 15:00)
- 거래 내역 한글 라벨 + description 표시
- CLAUDE.md 문서 업데이트

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 15:24:03 +09:00
kappa
89f8ea19f1 fix: Email Routing MIME 파싱 개선 + 레거시 코드 정리
- Email Routing에서 수신한 이메일 파싱 수정
  - Quoted-Printable UTF-8 디코딩 함수 추가
  - HTML <br/> 태그를 줄바꿈으로 변환
  - SMS 키워드 위치 기반 본문 추출

- 레거시 코드 삭제
  - /api/bank-notification 엔드포인트 제거 (Email Routing으로 대체)
  - BANK_API_SECRET 관련 코드 및 문서 제거
  - DEPOSIT_AGENT_ID 제거 (Assistants API → 코드 직접 처리)

- CLI 테스트 클라이언트 개선
  - .env 파일 자동 로드 지원
  - WEBHOOK_SECRET 환경변수 불필요

- 문서 업데이트
  - NAMECHEAP_API_KEY 설명 명확화 (래퍼 인증 키)
  - CLI 테스트 섹션 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 13:12:26 +09:00
kappa
42ab702d1c feat: 도메인 시스템 개선 + 검색 한글→영문 번역
주요 변경:
- Domain Agent 제거, 코드 직접 처리로 전환
- suggest_domains: 등록 가능 도메인만 표시, 10개 미만 시 재시도
- search_web: 한글 검색어 자동 영문 번역 (GPT-4o-mini)
- WHOIS: raw 데이터 파싱으로 상세 정보 추출
- 가격 조회: API 필드명 수정 (register_krw → krw)
- 동적 도구 로딩 시스템 추가
- 문서 정리 및 업데이트

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 11:15:49 +09:00
kappa
9822b28028 feat: Gmail → Apps Script → Worker 입금 알림 연동
- POST /api/bank-notification 엔드포인트 추가
- 하나은행 Web발신 SMS 패턴 파싱 지원
- Gmail message_id 기반 중복 방지
- BANK_API_SECRET 인증 추가
- deposit_transactions 자동 매칭 구현
- 문서 업데이트 (CLAUDE.md, README.md)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 00:09:16 +09:00
kappa
e98bfd3a68 feat: 예치금 시스템 추가 (은행 SMS 자동 매칭)
- manage_deposit Function Calling 추가 (잔액조회, 입금신고, 거래내역, 취소)
- Email Worker로 은행 SMS 파싱 (하나/KB/신한 지원)
- 양방향 자동 매칭: 사용자 신고 ↔ 은행 알림
- D1 테이블: user_deposits, deposit_transactions, bank_notifications
- 관리자 전용: 대기목록 조회, 입금 확인/거절

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 12:29:57 +09:00
kappa
8b2ccf05b5 feat: 도메인 관리 기능 추가 (Domain Agent 연동)
- manage_domain Function Calling 도구 추가
- OpenAI Assistants API 기반 Domain Agent 연동
- Namecheap API 호출 (도메인 목록, 네임서버 관리 등)
- user_domains 테이블로 사용자별 도메인 권한 관리
- 타임스탬프 검증 비활성화 (WEBHOOK_SECRET으로 충분)
- CLAUDE.md 프로젝트 문서 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 08:50:16 +09:00
kappa
1e71e035e7 Initial commit: Telegram bot with Cloudflare Workers
- OpenAI GPT-4o-mini with Function Calling
- Cloudflare D1 for user profiles and message buffer
- Sliding window (3 summaries max) for infinite context
- Tools: weather, search, time, calculator
- Workers AI fallback support
- Webhook security with rate limiting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 13:00:44 +09:00