feat(card): migrate authentication to CardController#28414
Conversation
…card-feature-flag-refactor
…card-feature-flag-refactor
…migrate-unauthenticated-state-card
…migrate-unauthenticated-state-card
…migrate-unauthenticated-state-card
…/metamask-mobile into feat/card-feature-flag-refactor
…card-feature-flag-refactor
…migrate-unauthenticated-state-card
…migrate-unauthenticated-state-card
…-migrate-authentication-to-controller
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
…card-migrate-authentication-to-controller
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
This is a medium-risk refactor of the Card authentication flow. The core logic is preserved but the implementation is significantly changed, warranting E2E validation of the Card feature. Per SmokeCard tag description: "When selecting SmokeCard, also select SmokeTrade and SmokeConfirmations (Add Funds uses swaps which require transaction confirmations)." No other feature areas (accounts, network, identity, etc.) are affected by these changes. Performance Test Selection: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5f48937. Configure here.
|
|
✅ E2E Fixture Validation — Schema is up to date |




Description
Card: authentication and session state →
CardControllerThis PR migrates Card authentication to
CardControllerso session state is no longer owned by the Reduxcardslice and coordinated through Card SDK helpers (logout,resetAuthenticatedData, globalCardVerification, etc.). Call sites useEngine.context.CardControllerandselectIsCardAuthenticated(and related selectors inapp/selectors/cardController.ts) as the source of truth.Why: One place for sign-in state, logout, token/session refresh, and cardholder checks avoids duplicated logic between Redux and the SDK and removes the old side-effect verification flow.
What changed (Card-focused):
CardAuthentication+useCardAuthuseCardProviderAuthentication(hook deleted; large test file removed). The screen usesuseCardAuthfor the login / OTP flow, withresetToLoginonuseCardAuthto reset mutations and step state.CardAuthentication.test.tsxexpanded; snapshot updated.CardControllerisAuthenticated, session/cardholder fields, andlogout()/validateAndRefreshSession(); expandedCardController.test.ts, messenger, and types.app/selectors/cardController.ts)selectIsCardAuthenticated,selectCardholderAccounts,selectIsCardholder,selectCardUserLocation, etc., instead of Redux auth fields.cardslicehasViewedCardButton).sdk/index.tsx)CardController.logout()instead of providersdk.logout()+resetAuthenticatedData.CardVerificationand the hooks it mounted.fetchUserDataupdates controller location only whencountryOfResidenceis set (avoids bad auth/region sync when the API returns null); related fixes for nullable location /effectiveLocationto avoid unnecessary SDK reloads.useCardholderCheck,getCardholder,handleLocalAuthentication,useCardAuthenticationVerification(and tests).OnboardingNavigator.tsx)ACCOUNTvscontactVerificationId, keep-going modal waits foruser).default-fixture.json; AddToWalletButton mock path fix.Changelog
CHANGELOG entry: Card authentication and session/cardholder state are sourced from
CardControllerandselectIsCardAuthenticated(and related selectors) instead of the Redux Card slice and Card SDK auth helpers; the globalCardVerificationflow and legacy auth utilities are removed.Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Include Card home after login/logout and any onboarding resume path you exercised while validating auth.
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Changes the card sign-in/OTP flow to rely on
useCardAuth/CardControllermutations and resets, affecting login, OTP auto-send/resend, and onboarding redirects. Risk is moderate due to altered authentication control flow and error/loading handling, though covered by expanded tests.Overview
Refactors
CardAuthenticationto use the newuseCardAuthhook (initiate/submit/stepAction) instead of the removeduseCardProviderAuthentication, deriving loading/error/OTP state from React Query mutations and usingresetToLoginto return from OTP to email/password.Updates the login + OTP UX behavior to: initiate auth using the stored location, auto-trigger OTP send when the step becomes
otp, auto-submit on 6 digits, support resend with a cooldown timer, and route to either Card Home or onboarding based onsubmitresults.Reworks and expands
CardAuthentication.test.tsxto mockuseCardAuth, add OTP-step coverage (auto-send, resend cooldown, auto-submit, back-to-login, onboarding redirect), and updates the snapshot; addsresetToLoginsupport + test coverage inuseCardAuthand deletesuseCardProviderAuthenticationand its tests.Reviewed by Cursor Bugbot for commit 5f48937. Bugbot is set up for automated code reviews on this repo. Configure here.