feat(webapp): live in-app QR scanner with photo-upload fallback#26
Merged
Conversation
Replace the single-photo file-upload Scan flow with a live in-browser camera scanner that decodes continuously and fires the fight the instant a QR is in frame. Three tiers, best-effort down: native BarcodeDetector (Chrome/Android) -> vendored jsQR (iOS Safari and others without BarcodeDetector) -> the existing photo upload to /scan/ (cv2) when there's no camera / permission is denied / on desktop. The scanner is an in-page <video> overlay, so the happy path never leaves the app (no OS camera sheet, no file picker) and decoding runs on the phone -- the server does no QR image processing unless the photo fallback is used. A shared resolveFightUrl() guard only follows a decoded value that resolves to a same-origin /fight/ URL, hardening both the live and photo paths over the old unguarded `location = text`. - jsQR vendored as a static asset (no runtime CDN dependency); guarded by a small presence/sanity test. - getUserMedia requires a secure context, which prod (HTTPS) already serves. - Verified cross-phone: Android Chrome (BarcodeDetector), macOS Safari and iPhone Safari (jsQR, rear camera + inline playback), plus the deny-permission and "Use photo instead" fallbacks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
🔴 One must-fix: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replaces the single-photo file-upload Scan flow with a live in-browser camera scanner that decodes continuously and fires the fight the instant a QR is in frame. Keeps photo-upload as a fallback.
Three tiers, best-effort down:
BarcodeDetector— Chrome / Android (fast, on-device)/scan/(cv2) — no camera / permission denied / desktopWhy
One-shot photos were unreliable (blur, framing, round-trip). The new scanner is an in-page
<video>overlay, so:location =is a same-origin/fight/nav, so it stays inside the installed PWA window.Notes
resolveFightUrl()is a shared guard that only follows a decoded value resolving to a same-origin/fight/URL — hardens both the live and photo paths over the old unguardedlocation = text.tests/test_static_assets.pyguards its presence/sanity.getUserMedianeeds a secure context, which prod (HTTPS behind the Cloudflare tunnel) already serves. No API/route/requirementschanges.Verification
/test— full suite green (69 passed), incl. the new asset guard;test_qr_decode.pystill covers thecv2fallback.🤖 Generated with Claude Code