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.
ci: add Lighthouse CI visual regression check to gate merges (Closes #941) #1035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
ci: add Lighthouse CI visual regression check to gate merges (Closes #941) #1035
Changes from all commits
8cfd128abcbd70e304aac0e7e893ead3b187c8f6decd03d5f4262eec0c05948faf9d04fc25ba6064fe723fc4f52516d6b0ab28fccFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
Authentication Flows
Audience: Frontend contributors
Last reviewed: 2026-07-26
Credence does not use username/password authentication. A user's Stellar wallet (Freighter browser extension) is their identity. This document describes the three session-lifecycle flows: login (connect), logout (disconnect), and session refresh (re-authentication).
All three flows live in two layers:
src/lib/freighterClient.ts@stellar/freighter-apisrc/hooks/useWallet.ts+src/context/WalletContext.tsxconnect,disconnect,reauth, andisReauthRequiredto the component treeLogin (Connect Wallet)
A login is a wallet connection. No credentials leave the browser ÔÇö Freighter holds the private key and only returns a public address after the user approves.
sequenceDiagram actor User participant UI as ConnectWalletModal participant Hook as useWallet participant Free as Freighter Extension User->>UI: Click "Connect Wallet" UI->>Hook: connect() Hook->>Free: checkFreighterInstalled() Free-->>Hook: { isConnected: true } Hook->>Free: requestFreighterAccess() Note right of Free: Freighter popup<br/>asks for approval User->>Free: Approve Free-->>Hook: { address: "G..." } Hook->>Hook: setAddress("G...") Hook->>Free: fetchFreighterNetwork() Free-->>Hook: "public" alt Network matches settings Hook->>Hook: startWatcher() Hook-->>UI: { isConnected: true, address: "G..." } UI->>UI: Auto-close modal else Network mismatch Hook->>Hook: setError("network_mismatch") Hook-->>UI: { error: { code: "network_mismatch" } } UI-->>User: Show error message endKey code paths:
src/hooks/useWallet.ts:76ÔÇöconnect()entry pointsrc/lib/freighterClient.ts:66ÔÇörequestFreighterAccess()prompts the usersrc/components/ConnectWalletModal.tsx:43ÔÇö auto-closes on successSilent session restore
On every page load,
useWallettries to restore a prior session without prompting the user:sequenceDiagram participant App as App Mount participant Hook as useWallet participant Free as Freighter Extension App->>Hook: useEffect (mount) Hook->>Free: checkFreighterInstalled() Free-->>Hook: true Hook->>Free: fetchFreighterAddress() Note right of Free: Reads already-authorised<br/>address ÔÇö no popup alt Previously authorised Free-->>Hook: "G..." Hook->>Hook: setAddress("G...") Hook->>Hook: startWatcher() else Not authorised Free-->>Hook: null Hook-->>App: Stay disconnected endKey code path:
src/hooks/useWallet.ts:132Logout (Disconnect)
A logout clears all local wallet state and stops the address watcher. It can be triggered manually by the user or automatically after inactivity.
sequenceDiagram actor User participant UI as App UI participant WC as WalletContext participant Hook as useWallet participant Nav as React Router alt Manual logout User->>UI: Click "Disconnect" UI->>WC: disconnect() else Auto-logout (inactivity) Note over WC: 15 min idle +<br/>60s warning expired WC->>WC: handleLogout() end WC->>Hook: disconnect() Hook->>Hook: stopWatcher() Hook->>Hook: setAddress("") Hook->>Hook: setNetwork(null) Hook->>Hook: setError(null) WC->>WC: setLastReauthTime(null) WC->>Nav: navigate("/signin") WC->>WC: addToast("warning", "Logged out due to inactivity.")Key code paths:
src/hooks/useWallet.ts:124ÔÇödisconnect()clears local statesrc/context/WalletContext.tsx:69ÔÇöhandleLogout()orchestrates the full logout including navigation and toastSession Refresh (Re-authentication)
The app enforces a configurable re-authentication threshold. When a sensitive action (e.g. viewing a USDC balance) is attempted and the threshold has elapsed since the last re-auth, the user is prompted to reconnect their wallet before proceeding.
Threshold check
sequenceDiagram participant Comp as Component (e.g. useUsdcBalance) participant WC as WalletContext participant Set as SettingsContext Comp->>WC: isReauthRequired() WC->>Set: reauthThresholdMinutes (default: from settings) alt Not connected or no reauth time WC-->>Comp: true else Elapsed  threshold WC-->>Comp: true else Elapsed < threshold WC-->>Comp: false endKey code path:
src/context/WalletContext.tsx:87Re-authentication prompt
When
isReauthRequired()returnstrue, aReauthPromptdialog is displayed. The user must click "Reconnect Wallet" to trigger the Freighter access prompt again.sequenceDiagram actor User participant Prompt as ReauthPrompt participant WC as WalletContext participant Free as Freighter Extension Prompt->>WC: reauth() WC->>Free: wallet.connect() Free->>User: Freighter popup ÔÇö approve access User->>Free: Approve Free-->>WC: { address: "G..." } WC->>WC: setLastReauthTime(Date.now()) WC-->>Prompt: Resolved Prompt->>Prompt: Close dialogKey code paths:
src/context/WalletContext.tsx:81ÔÇöreauth()reconnects and resets timersrc/components/ReauthPrompt.tsx:51ÔÇö dialog confirm handlerWhere re-auth is enforced
src/hooks/useUsdcBalance.ts:80) ÔÇö throwsSessionReauthRequiredErrorwhen threshold elapsedsrc/components/CreateBondFlow.tsx:81) ÔÇö showsReauthPromptbefore proceedingSession Timeout (Inactivity Logout)
Independently of the re-auth threshold, the app enforces a hard idle timeout. After 15 minutes of no user activity (mouse, keyboard, touch, scroll), a 60-second warning is shown. If the user does not interact with the warning within that window, they are logged out.
sequenceDiagram participant User participant Idle as useIdleTimeout participant WC as WalletContext participant Modal as SessionTimeoutModal participant Nav as React Router Note over Idle: 14 min of inactivity Idle->>WC: onIdle (first timer) WC->>WC: setShowWarning(true) WC->>Modal: open={true}, timeLeft=60 alt User interacts (mousemove, keypress, etc.) User->>Idle: Activity event Idle->>WC: onActivity WC->>WC: setShowWarning(false) WC->>Modal: open={false} Note over Idle: Timer resets else No interaction Note over Modal: 60s countdown expires Idle->>WC: onIdle (second timer) WC->>WC: handleLogout() WC->>Nav: navigate("/signin") WC->>WC: addToast("warning", "Logged out due to inactivity.") endKey code paths:
src/context/WalletContext.tsx:96ÔÇö first idle timer (14 min)src/context/WalletContext.tsx:111ÔÇö second idle timer (60s warning window)src/components/SessionTimeoutModal.tsxÔÇö countdown UIRelated documents
useWallethook API, connection state machine, UX contractUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.