[Session] Restore emailAuthFactor and emailConfirmed from last session (#3939)

zio/stable
dan 2024-05-10 00:05:44 +01:00 committed by GitHub
parent 55fdbc7399
commit 6e172b6ce3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,4 @@
import {BskyAgent} from '@atproto/api'
import {AtpSessionEvent} from '@atproto-labs/api'
import {AtpSessionData, AtpSessionEvent, BskyAgent} from '@atproto/api'
import {networkRetry} from '#/lib/async/retry'
import {PUBLIC_BSKY_SERVICE} from '#/lib/constants'
@ -32,11 +31,15 @@ export async function createAgentAndResume(
}
const gates = tryFetchGates(storedAccount.did, 'prefer-low-latency')
const moderation = configureModerationForAccount(agent, storedAccount)
const prevSession = {
const prevSession: AtpSessionData = {
// Sorted in the same property order as when returned by BskyAgent (alphabetical).
accessJwt: storedAccount.accessJwt ?? '',
refreshJwt: storedAccount.refreshJwt ?? '',
did: storedAccount.did,
email: storedAccount.email,
emailAuthFactor: storedAccount.emailAuthFactor,
emailConfirmed: storedAccount.emailConfirmed,
handle: storedAccount.handle,
refreshJwt: storedAccount.refreshJwt ?? '',
}
if (isSessionExpired(storedAccount)) {
await networkRetry(1, () => agent.resumeSession(prevSession))