Skip to content

Fix/build errors and type fixes and feat(wallet): implement secure wallet session persistence with auto-reconnect#123

Open
teethaking wants to merge 2 commits into
SudiptaPaul-31:mainfrom
teethaking:fix/build-errors-and-type-fixes
Open

Fix/build errors and type fixes and feat(wallet): implement secure wallet session persistence with auto-reconnect#123
teethaking wants to merge 2 commits into
SudiptaPaul-31:mainfrom
teethaking:fix/build-errors-and-type-fixes

Conversation

@teethaking

Copy link
Copy Markdown

Summary

This PR adds wallet session persistence so previously authorized wallets remain connected across page reloads and browser restarts, removing the need to manually reconnect on every visit. Session data is stored securely and reconnect attempts are surfaced clearly in the UI.

Closes #77


What changed

Session Persistence

  • Wallet session state (connected address, provider type, auth metadata) is persisted across page reloads and full browser restarts
  • Sessions are stored using encrypted IndexedDB rather than plain localStorage, preventing trivial extraction of session data from browser storage
  • Encryption key is derived per-session and never persisted in plain form alongside the encrypted payload

Auto-Reconnect

  • On app load, the stored session is checked and, if valid, the app automatically attempts to reconnect to the previously authorized wallet
  • Reconnect logic is provider-agnostic, with adapter support for multiple wallet providers:
    • Freighter
    • Albedo
    • Extensible to additional providers via a common wallet adapter interface

Session Expiration & Invalidation

  • Sessions carry an expiration timestamp; expired sessions are discarded and the user is prompted to reconnect manually
  • Sessions are invalidated immediately on explicit logout/disconnect, and on detecting a mismatched or revoked wallet authorization
  • Corrupted or undecryptable session data is treated as invalid and cleared rather than causing a hard failure

UI Feedback

  • Added reconnect state indicators:
    • Loading — shown while attempting silent reconnect on app load
    • Success — brief confirmation once the wallet is reconnected
    • Error — clear messaging when reconnect fails, with a manual "Connect Wallet" fallback action

How to verify

  • Connect a wallet (Freighter or Albedo), refresh the page, and assert the wallet reconnects automatically without user interaction
  • Close and reopen the browser entirely and assert the session persists and reconnects
  • Inspect IndexedDB storage and confirm session data is encrypted, not stored in plain text
  • Manually expire a session (or wait past the expiration window) and assert the app correctly falls back to requiring manual reconnect
  • Disconnect/log out and assert the session is fully invalidated and does not auto-reconnect on next load
  • Simulate a reconnect failure (e.g. revoked wallet permission) and assert the error state UI is shown with a manual reconnect option
  • Repeat the full flow with both Freighter and Albedo to confirm provider-agnostic behavior

Checklist

  • Session persists across page reloads
  • Session persists across full browser restarts
  • Session data stored encrypted (IndexedDB), not plain localStorage
  • Auto-reconnect triggers on app load for valid sessions
  • Expired sessions are detected and cleared gracefully
  • Explicit disconnect invalidates the session immediately
  • UI shows loading, success, and error states for reconnect attempts
  • Compatible with Freighter and Albedo wallet providers
  • Adapter pattern allows extension to additional wallet providers
  • Closes Implement Wallet Session Persistence #77

@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

@teethaking is attempting to deploy a commit to the Sudipta 's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@teethaking 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! 🚀

Learn more about application limits

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 Wallet Session Persistence

1 participant