[wip] fix: try to check passkey existence#892
[wip] fix: try to check passkey existence#892kushagrasarathe merged 3 commits intopeanut-wallet-devfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
""" WalkthroughThe login flow is enhanced by adding a custom Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/hooks/useZeroDev.ts (1)
44-44: Consider making timeout values configurable.The timeout values are hardcoded (
CONDITIONAL_MEDIATION_MANUAL_TIMEOUT_MS = 7000andtimeout: 5000). Consider making these configurable through environment variables or constants for easier adjustment across different environments.Also applies to: 108-108
src/components/Setup/Views/Welcome.tsx (1)
19-23: Remove redundant double-negation.The double-negation is unnecessary as the value will be coerced to boolean in the if statement.
- if (!!user) { + if (user) { console.log('[WelcomeStep] useEffect: User detected, redirecting to /home.', user) push('/home') }🧰 Tools
🪛 Biome (1.9.4)
[error] 19-19: Avoid redundant double-negation.
It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation(lint/complexity/noExtraBooleanCast)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Setup/Views/Welcome.tsx(3 hunks)src/hooks/useZeroDev.ts(4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/hooks/useZeroDev.ts (1)
src/utils/general.utils.ts (1)
saveToLocalStorage(95-106)
src/components/Setup/Views/Welcome.tsx (2)
src/utils/general.utils.ts (1)
getFromLocalStorage(108-123)src/hooks/useZeroDev.ts (1)
NoPasskeyRegisteredError(25-30)
🪛 Biome (1.9.4)
src/components/Setup/Views/Welcome.tsx
[error] 19-19: Avoid redundant double-negation.
It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation
(lint/complexity/noExtraBooleanCast)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Deploy-Preview
🔇 Additional comments (7)
src/hooks/useZeroDev.ts (5)
24-30: Well-implemented custom error class!The
NoPasskeyRegisteredErrorclass follows best practices for custom errors with proper inheritance and name setting.
163-188: Excellent improvements to error handling and logging!The addition of comprehensive logging and moving
setIsRegistering(false)to the finally block ensures proper state cleanup even when errors occur.
191-249: Robust implementation of passkey pre-check with proper error handling!The login flow now provides better user feedback by pre-checking passkey existence and throwing specific errors. The state management is properly handled in the finally block.
277-277: Correct dependency array update!Adding
dispatchandsetLoadingStateto the dependency array prevents stale closures.
74-75:Details
❌ Incorrect review comment
Verify userVerification setting matches login requirements.
The
userVerificationis set to'discouraged'in the pre-check but needs to match what's used in the actual login flow to ensure consistent behavior.
🏁 Script executed:
#!/bin/bash # Description: Check if userVerification setting is consistent across the codebase # Search for userVerification usage in toWebAuthnKey calls rg -A 3 -B 3 "userVerification" --type tsLength of output: 523
🏁 Script executed:
#!/bin/bash # Search for WebAuthn authentication flows to verify userVerification usage # Look for explicit navigator.credentials.get calls in TypeScript files rg -A 5 -B 5 "navigator\\.credentials\\.get" --type ts # Search for helper usage of toWebAuthnKey across the repo rg -A 5 -B 5 "toWebAuthnKey" --type tsLength of output: 8227
Remove userVerification match suggestion
The pre-check in checkPasskeyExists deliberately uses
userVerification: 'discouraged'to avoid prompting the user when merely probing for an existing credential. The actual login flow goes through toWebAuthnKey without overriding userVerification, relying on the library’s default (which triggers the proper verification prompt). These two cases serve different purposes and should not be forced to use the same setting. No changes are required here.
Likely an incorrect or invalid review comment.
src/components/Setup/Views/Welcome.tsx (2)
5-5: Correct import for enhanced error handling!
36-64: Excellent error handling with specific user feedback!The enhanced logging and specific error handling for
NoPasskeyRegisteredErrorprovides clear feedback to users about why login failed.
contributes to TASK-10003