feat(card): add CardOnboardingStore and CardTokenStore#27092
Conversation
|
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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
The committed fixture schema is out of date. To update, comment: |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Key observations:
While these changes are in the critical path (app/core/Engine/controllers/), they represent isolated utility modules that don't affect any current user flows. The SmokeCard tag is selected as a precautionary measure since these modules are part of the Card feature infrastructure, even though the E2E tests won't directly exercise this new code until it's integrated into the CardController. Performance Test Selection: |
|


Description
Adds two SecureKeychain-backed stores for the Card feature. These stores will be used by the
CardController(merged in #27020) to manage auth tokens and onboarding session data.Why: Card auth tokens already live in SecureKeychain via
cardTokenVault.ts, but the API is tightly coupled to a single provider. Onboarding session data (onboardingId,contactVerificationId,consentSetId).What changed:
CardTokenStore.ts(~90 lines): SecureKeychain wrapper for auth tokens keyed by provider ID. For the legacy provider, reads from the same keychain scope ascardTokenVault.ts(com.metamask.CARD_BAANX_TOKENS) — zero migration, both old and new code can coexist. New providers get their own scoped keychain entry. Methods:get(providerId),set(providerId, tokenSet),remove(providerId). All errors caught and logged with structured Sentry context.CardOnboardingStore.ts(~100 lines): SecureKeychain wrapper for onboarding session data keyed by provider ID. StoresonboardingId,contactVerificationId,consentSetId, andselectedCountry. Theset()method merges partial data with existing data (read-modify-write). Scope:com.metamask.CARD_ONBOARDING_{providerId}. Intentionally not populated in this PR — it will only be written to when the new controller code path is active (Phase 1d).CardTokenStore.test.ts(151 lines): 8 tests covering retrieval (null, valid, legacy scope, provider-specific scope, invalid data, keychain error), storage (success, failure, error), and removal.CardOnboardingStore.test.ts(162 lines): 8 tests covering retrieval (null, merged with defaults, correct scope, error), storage (merge with existing, create from empty, error), and removal.Important design decision: Neither store is populated during a Redux migration. Onboarding data stays in Redux until the code path switch (Phase 1d), avoiding stale data issues where old code clears Redux via
dispatch(resetOnboardingState())but has no knowledge of the keychain store. Auth tokens already exist in keychain —CardTokenStorereads the same data, no write needed.Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
No UI changes — this is an infrastructure-only PR.
Before
Auth tokens managed by
cardTokenVault.ts. Onboarding data in plaintext Redux.After
CardTokenStoreandCardOnboardingStoreexist alongside existing code. Neither is actively used yet — they are wired in during Phase 1d (code path switch). Existing behavior is unchanged.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Additive, self-contained storage wrappers with unit tests; no existing call sites are changed, so runtime impact is limited unless/until these stores are wired into the card flow.
Overview
Adds two new SecureKeychain-backed persistence helpers for the Card feature:
CardTokenStorefor provider-scoped auth token sets (including legacy Baanx key/scope compatibility) andCardOnboardingStorefor provider-scoped onboarding session fields with read-modify-write merging.Both stores include structured error logging and defensive parsing/validation, plus comprehensive Jest coverage for success paths, scoping, invalid data, and keychain failures.
Written by Cursor Bugbot for commit 4721714. This will update automatically on new commits. Configure here.