Skip to content

Harden text and audio API for authenticated clients - #86

Merged
ashrafee-dev merged 1 commit into
mainfrom
feat/harden-text-audio-api
Sep 26, 2026
Merged

ashrafee-dev merged 1 commit into
mainfrom
feat/harden-text-audio-api

Conversation

@ashrafee-dev

Copy link
Copy Markdown
Owner

Summary

  • Add POST /text for messages, emails, and browser selections; retain /email as a deprecated compatibility alias.
  • Require server-side bearer tokens for analysis, reject unauthenticated uploads before parsing, and use atomic Redis 7+ quotas per token across HTTP and WebSockets.
  • Bound streamed HTTP bodies, file reads, audio duration, decoding time, inference concurrency, and upstream retries. Clean up temporary files and fail closed on dependency outages.
  • Separate untrusted text from system instructions, validate assessment output, sanitize upstream errors, and add readiness/startup validation.
  • Use CPU-only PyTorch on Linux; remove unused duplicate Whisper initialization and Python FFmpeg wrappers (the actual ffmpeg executable is required).
  • Make the check script stop when tests fail.

Migration

All analysis routes now require Authorization: Bearer . Configure SCAMSHIELD_API_KEYS with random tokens of at least 32 characters plus DEEPSEEK_API_KEY. Upgrade Redis to 7+. Clients sharing a token share its quota; browser extensions must use a user-authenticated backend rather than embed these tokens.

The deployment/docs PR will stack on this change and supply the production server settings required for transport-level WebSocket limits, Docker Compose, and rollout guidance.

Verification

  • 40 tests passed, including concurrent quota enforcement, chunked multipart cleanup, authentication, provider errors, and audio safeguards.
  • pylint app tests: 10.00/10.
  • Tests mock the model/provider; these results are not a live DeepSeek or Whisper accuracy benchmark.

@vercel

vercel Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scamshield-api Ready Ready Preview Sep 26, 2026 7:14pm UTC
scamshield-api-fhes Ready Ready Preview Sep 26, 2026 7:14pm UTC

@ashrafee-dev

Copy link
Copy Markdown
Owner Author

Deployment and integration documentation are in stacked PR #87. Merge this PR first, then retarget #87 to main. The combined changes passed local container startup, real Redis quota enforcement across HTTP/WebSocket, and real FFmpeg decoding smoke checks; live provider/model acceptance checks are documented separately.

@ashrafee-dev
ashrafee-dev merged commit 6891a4b into main Sep 26, 2026
4 checks passed

This branch was successfully deployed

2 active deployments
Preview – scamshield-api-fhes — f95a0c33 Deployed Sep 26, 2026 by vercel[bot]
Preview – scamshield-api — f95a0c33 Deployed Sep 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant