wire up secure session storage
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+12
-3
@@ -44,6 +44,8 @@ import {
|
|||||||
useSession,
|
useSession,
|
||||||
useSessionApi,
|
useSessionApi,
|
||||||
} from '#/state/session'
|
} from '#/state/session'
|
||||||
|
import {initSessionStorage} from '#/state/session/storage'
|
||||||
|
import {SecureSessionStorageGateSync} from '#/state/session/storage/gate-sync'
|
||||||
import {readLastActiveAccount} from '#/state/session/util'
|
import {readLastActiveAccount} from '#/state/session/util'
|
||||||
import {Provider as ShellStateProvider} from '#/state/shell'
|
import {Provider as ShellStateProvider} from '#/state/shell'
|
||||||
import {Provider as ComposerProvider} from '#/state/shell/composer'
|
import {Provider as ComposerProvider} from '#/state/shell/composer'
|
||||||
@@ -152,6 +154,7 @@ function InnerApp() {
|
|||||||
// Resets the entire tree below when it changes:
|
// Resets the entire tree below when it changes:
|
||||||
key={currentAccount?.did}>
|
key={currentAccount?.did}>
|
||||||
<AnalyticsFeaturesContext>
|
<AnalyticsFeaturesContext>
|
||||||
|
<SecureSessionStorageGateSync />
|
||||||
<QueryProvider currentDid={currentAccount?.did}>
|
<QueryProvider currentDid={currentAccount?.did}>
|
||||||
<BetaUserStorageSync />
|
<BetaUserStorageSync />
|
||||||
<PolicyUpdateOverlayProvider>
|
<PolicyUpdateOverlayProvider>
|
||||||
@@ -218,9 +221,15 @@ function App() {
|
|||||||
const [isReady, setIsReady] = useState(false)
|
const [isReady, setIsReady] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void Promise.all([initPersistedState(), Geo.resolve(), setupDeviceId]).then(
|
void Promise.all([
|
||||||
() => setIsReady(true),
|
/*
|
||||||
)
|
* `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) {
|
if (!isReady) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {useDeleteActorDeclaration} from '#/state/queries/messages/actor-declarat
|
|||||||
import {useProfileQuery, useProfilesQuery} from '#/state/queries/profile'
|
import {useProfileQuery, useProfilesQuery} from '#/state/queries/profile'
|
||||||
import {usePdsClient} from '#/state/session'
|
import {usePdsClient} from '#/state/session'
|
||||||
import {type SessionAccount, useSession, useSessionApi} from '#/state/session'
|
import {type SessionAccount, useSession, useSessionApi} from '#/state/session'
|
||||||
|
import {clearSessionStorage} from '#/state/session/storage'
|
||||||
import {useOnboardingDispatch} from '#/state/shell'
|
import {useOnboardingDispatch} from '#/state/shell'
|
||||||
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
||||||
import {useCloseAllActiveElements} from '#/state/util'
|
import {useCloseAllActiveElements} from '#/state/util'
|
||||||
@@ -410,6 +411,7 @@ function DevOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const clearAllStorage = async () => {
|
const clearAllStorage = async () => {
|
||||||
|
clearSessionStorage()
|
||||||
await clearStorage()
|
await clearStorage()
|
||||||
Toast.show(l`Storage cleared, you need to restart the app now.`)
|
Toast.show(l`Storage cleared, you need to restart the app now.`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {type Client} from '@atproto/lex'
|
|||||||
import {type SessionData} from '@atproto/lex-password-session'
|
import {type SessionData} from '@atproto/lex-password-session'
|
||||||
|
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
|
import {mirrorSessionSnapshot} from '#/state/session/storage'
|
||||||
import {useCloseAllActiveElements} from '#/state/util'
|
import {useCloseAllActiveElements} from '#/state/util'
|
||||||
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
|
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
|
||||||
import {AnalyticsContext, useAnalyticsBase, utils} from '#/analytics'
|
import {AnalyticsContext, useAnalyticsBase, utils} from '#/analytics'
|
||||||
@@ -119,6 +120,7 @@ class SessionStore {
|
|||||||
data: redactPersistedSession(persistedData),
|
data: redactPersistedSession(persistedData),
|
||||||
})
|
})
|
||||||
void persisted.write('session', persistedData)
|
void persisted.write('session', persistedData)
|
||||||
|
mirrorSessionSnapshot(persistedData)
|
||||||
}
|
}
|
||||||
this.listeners.forEach(listener => listener())
|
this.listeners.forEach(listener => listener())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user