fix(dashproof-lab): clear error when crypto.subtle is unavailable#78
Conversation
Hashing requires a Secure Context, so plain http:// origins (e.g. bare-IP hosting, non-HTTPS IPFS gateways) crashed with "Cannot read properties of undefined (reading 'digest')". Detect the missing crypto.subtle up front and throw a message pointing to HTTPS or localhost. Applied to both the React app and the dashproof-lite single-file companion. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Asserts the exact error message so an accidental rewording would fail the test instead of silently degrading the user-facing diagnostic. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds an early precondition check to ChangesSecure Context Check for Hash Operations
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
http://(e.g. bare-IP hosting, non-HTTPS IPFS gateways) crashed withCannot read properties of undefined (reading 'digest')becausecrypto.subtleis only exposed in Secure Contexts.hashFilenow checks forcrypto.subtleup front and throws a clear message pointing the user to HTTPS orhttp://localhost. Applied to both the React app (src/lib/hash.ts) and the zero-build companion (public/dashproof-lite.html).AnchorFormandVerifyPanelalready pipe thrown errors througherrorMessage(err)into the status UI, so the new message surfaces inline instead of crashing.crypto.subtle = undefinedand asserts the exact error string, so any future reword fails the test rather than silently degrading the diagnostic.Test plan
npm run test— 138/138 pass (20 files)npm run format— cleannpm run build— typecheck + bundle cleanhttp://and confirm the inline error replaces the cryptic crashhttps:///http://localhostand confirm hashing still works🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
http://localhostinstead of encountering cryptic failures during file operations.Tests