feat(mobile): Zustand auth store for authentication state management (#115)#146
Merged
Oluwaseyi89 merged 4 commits intoNFTopia-Foundation:mainfrom Mar 29, 2026
Conversation
Install zustand for state management and @react-native-async-storage/async-storage for persistent storage middleware required by the auth store. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implement useAuthStore with persist middleware (AsyncStorage) covering: - user, wallet, isAuthenticated, isLoading, error state fields - loginWithWallet: saves to SecureStorage and marks session authenticated - loginWithEmail / registerWithEmail: stubbed for future auth service integration - logout: clears both AsyncStorage token and SecureStorage wallet - checkAuth: restores session from stored token or wallet on app launch - Sensitive wallet data is excluded from AsyncStorage persistence (partialize) Closes NFTopia-Foundation#115 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cover all store actions with mocked expo-secure-store and AsyncStorage: - initial state shape - all simple setters (setUser, setWallet, setAuthenticated, setLoading, setError, clearError) - loginWithWallet: success, secure storage write, storage error, loading guard - loginWithEmail / registerWithEmail: not-implemented error, loading guard - logout: state reset, SecureStorage deletion, AsyncStorage removal, error resilience - checkAuth: no session, token present, wallet-only session, storage error Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@KevinMB0220 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
@Oluwaseyi89 done can you review please? |
Contributor
|
@KevinMB0220 please, resolve the merge conflict. Contact me once done. |
Contributor
Author
Done can you review @Oluwaseyi89 |
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.
Closes #115
Summary
Implements a Zustand store for managing authentication state across the mobile app, including user data, wallet info, and authentication status.
src/stores/types.ts—Userinterface andAuthStatetype contractsrc/stores/authStore.ts—useAuthStorewithpersistmiddleware (AsyncStorage)src/stores/__tests__/authStore.test.ts— 25 integration tests covering all actionsStore design
userandisAuthenticatedare persisted to AsyncStorage viapartialize. Wallet keys stay exclusively inSecureStorage— storing key material in plain AsyncStorage would be a security risk.loginWithWalletSecureStorage, setsisAuthenticated: truecheckAuthSecureStoragewallet — both auth paths are restored on app relaunchlogoutloginWithEmail/registerWithEmailTODOcomments for when the API auth service is availableisLoadingat entry to prevent duplicate in-flight requestsTest plan
npx jest --no-coverage)loginWithWallet— success, SecureStorage write, storage error, loading guardloginWithEmail/registerWithEmail— not-implemented error, loading guardlogout— state reset, SecureStorage deletion, AsyncStorage removal, error resiliencecheckAuth— no session, token present, wallet-only session, storage errorAtomic commits
chore(mobile)feat(mobile)types.ts+authStore.ts)test(mobile)