wire up secure session storage

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-08-15 19:39:39 +03:00
parent 24d3c506ad
commit 30607c26a4
3 changed files with 16 additions and 3 deletions
+12 -3
View File
@@ -44,6 +44,8 @@ import {
useSession,
useSessionApi,
} from '#/state/session'
import {initSessionStorage} from '#/state/session/storage'
import {SecureSessionStorageGateSync} from '#/state/session/storage/gate-sync'
import {readLastActiveAccount} from '#/state/session/util'
import {Provider as ShellStateProvider} from '#/state/shell'
import {Provider as ComposerProvider} from '#/state/shell/composer'
@@ -152,6 +154,7 @@ function InnerApp() {
// Resets the entire tree below when it changes:
key={currentAccount?.did}>
<AnalyticsFeaturesContext>
<SecureSessionStorageGateSync />
<QueryProvider currentDid={currentAccount?.did}>
<BetaUserStorageSync />
<PolicyUpdateOverlayProvider>
@@ -218,9 +221,15 @@ function App() {
const [isReady, setIsReady] = useState(false)
useEffect(() => {
void Promise.all([initPersistedState(), Geo.resolve(), setupDeviceId]).then(
() => setIsReady(true),
)
void Promise.all([
/*
* `initSessionStorage` reads the persisted session blob, so it has to
* follow `initPersistedState`. The rest stay parallel.
*/
initPersistedState().then(() => initSessionStorage()),
Geo.resolve(),
setupDeviceId,
]).then(() => setIsReady(true))
}, [])
if (!isReady) {
+2
View File
@@ -24,6 +24,7 @@ import {useDeleteActorDeclaration} from '#/state/queries/messages/actor-declarat
import {useProfileQuery, useProfilesQuery} from '#/state/queries/profile'
import {usePdsClient} from '#/state/session'
import {type SessionAccount, useSession, useSessionApi} from '#/state/session'
import {clearSessionStorage} from '#/state/session/storage'
import {useOnboardingDispatch} from '#/state/shell'
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
import {useCloseAllActiveElements} from '#/state/util'
@@ -410,6 +411,7 @@ function DevOptions() {
}
const clearAllStorage = async () => {
clearSessionStorage()
await clearStorage()
Toast.show(l`Storage cleared, you need to restart the app now.`)
}
+2
View File
@@ -13,6 +13,7 @@ import {type Client} from '@atproto/lex'
import {type SessionData} from '@atproto/lex-password-session'
import * as persisted from '#/state/persisted'
import {mirrorSessionSnapshot} from '#/state/session/storage'
import {useCloseAllActiveElements} from '#/state/util'
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
import {AnalyticsContext, useAnalyticsBase, utils} from '#/analytics'
@@ -119,6 +120,7 @@ class SessionStore {
data: redactPersistedSession(persistedData),
})
void persisted.write('session', persistedData)
mirrorSessionSnapshot(persistedData)
}
this.listeners.forEach(listener => listener())
}