Skip to content

feat: Implement initial authentication and wallet management using Re…#14

Open
rahimatonize wants to merge 2 commits intoHubDApp:mainfrom
rahimatonize:feat/issue-5-implement-wallet-management
Open

feat: Implement initial authentication and wallet management using Re…#14
rahimatonize wants to merge 2 commits intoHubDApp:mainfrom
rahimatonize:feat/issue-5-implement-wallet-management

Conversation

@rahimatonize
Copy link

Implements a client-side session system that treats the connected Stellar wallet public key as the authenticated user. Sessions persist across page reloads via localStorage and are structured for easy future backend auth integration.

New Files

services/auth/session.service.ts
— Session CRUD:

createSession(publicKey)
,

getSession()
,

clearSession()
,

isAuthenticated()
. Stores a { publicKey, connectedAt } object in localStorage under the dongle_session key.

context/auth.context.tsx

AuthProvider
+

useAuth()
hook exposing publicKey,

isAuthenticated
, isLoading, login(), logout(). Restores session on mount and cross-checks wallet connectivity to clear stale sessions.
Modified Files

context/wallet.context.tsx
— Calls sessionService.createSession() on successful wallet connect and sessionService.clearSession() on disconnect to keep localStorage in sync.

app/providers.tsx
— Wraps

AuthProvider
inside

WalletProvider
so the auth layer can verify wallet connectivity during session restore.
ARCHITECTURE
WalletProvider ← outermost, initialises Freighter state
└─ AuthProvider ← restores session from localStorage on mount
└─ App
Connect flow: WalletProvider.connect() → Freighter approval → sessionService.createSession(address) → localStorage updated
Refresh flow:

AuthProvider
mount → sessionService.getSession() → verify wallet still connected → restore auth state
Logout flow: WalletProvider.disconnect() → sessionService.clearSession() → localStorage cleared
closes #5

@Iwueseiter
Copy link
Contributor

@rahimatonize Please resolve the conflicts

@rahimatonize
Copy link
Author

conflict resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Frontend Wallet Session Management

2 participants