feat: persist wallet and session state securely#52
Open
shadrach68 wants to merge 1 commit into
Open
Conversation
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.
Summary This PR implements secure persistence for wallet and session states, ensuring users remain connected across app restarts without compromising sensitive data. It introduces a hybrid storage approach using AsyncStorage for non-sensitive preferences and Expo SecureStore for session tokens.
Key Changes
Hybrid Storage Architecture : Created a new storage utility that wraps AsyncStorage and SecureStore with standardized error handling.
State Persistence : Integrated Zustand persist middleware into wallet.store.ts and session.store.ts .
Smooth Rehydration : Updated the entry screen to handle the hydration lifecycle, preventing flashes of unauthenticated states during startup.
Secure Data Clearing : Enhanced the reset flow to purge all persisted data when a user logs out or resets the app.
Testing : Added a new storage test suite and global mocks to ensure reliable rehydration and storage error handling.
Acceptance Criteria Verified
Wallet address is restored after app restart.
Startup flow waits for hydration before redirecting.
Session tokens are stored exclusively in Secure Storage.
Resetting app state clears all persisted data.
Storage errors are handled gracefully without crashing.