rework session layer on PasswordSession + three-client pattern

- PasswordSession (@atproto/lex-password-session) is now the single auth
  core; SessionAgent bridges it to the base Agent from @atproto/api so
  the ~148 useAgent() consumer files keep working unchanged
- SessionBundle carries {session, agent, accountClient, appviewClient};
  useLexClient() now returns the authed appview client, new
  useAppviewClient()/usePdsClient() hooks
- reducer: OpaqueSessionBundle, new replaced-current-bundle action for
  network-free cross-tab same-did sync (PasswordSession is immutable, so
  the bundle is rebuilt instead of mutated in place)
- moderation: AtpAgent.configure -> Client.configure + Agent.configure,
  per-account labelers on both the bridge and the appview client
- push-token unregistration uses temporary PasswordSessions
- hard-tail migrations: SignupQueued refresh via resumeSession shim,
  useBeginAgeAssurance scoped-token raw Client, useAccountEmailState
  reads currentAccount
- PDS routing preserved on the no-network resume fast path by
  synthesizing a minimal didDoc from the persisted pdsUrl

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-07-16 14:40:01 +03:00
parent 105e68c12c
commit bf8b6bc0c7
58 changed files with 2826 additions and 996 deletions
+3 -3
View File
@@ -1,20 +1,20 @@
import {
AppBskyFeedDefs,
type AppBskyFeedGetAuthorFeed as GetAuthorFeed,
type AtpAgent,
} from '@atproto/api'
import {type SessionAgent} from '#/state/session'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class AuthorFeedAPI implements FeedAPI {
agent: AtpAgent
agent: SessionAgent
_params: GetAuthorFeed.QueryParams
constructor({
agent,
feedParams,
}: {
agent: AtpAgent
agent: SessionAgent
feedParams: GetAuthorFeed.QueryParams
}) {
this.agent = agent
+3 -2
View File
@@ -9,11 +9,12 @@ import {
getAppLanguageAsContentLanguage,
getContentLanguages,
} from '#/state/preferences/languages'
import {type SessionAgent} from '#/state/session'
import {type FeedAPI, type FeedAPIResponse} from './types'
import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils'
export class CustomFeedAPI implements FeedAPI {
agent: AtpAgent
agent: SessionAgent
params: GetCustomFeed.QueryParams
userInterests?: string
@@ -22,7 +23,7 @@ export class CustomFeedAPI implements FeedAPI {
feedParams,
userInterests,
}: {
agent: AtpAgent
agent: SessionAgent
feedParams: GetCustomFeed.QueryParams
userInterests?: string
}) {
+4 -3
View File
@@ -1,12 +1,13 @@
import {type AppBskyFeedDefs, type AtpAgent} from '@atproto/api'
import {type AppBskyFeedDefs} from '@atproto/api'
import {DEMO_FEED} from '#/lib/demo'
import {type SessionAgent} from '#/state/session'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class DemoFeedAPI implements FeedAPI {
agent: AtpAgent
agent: SessionAgent
constructor({agent}: {agent: AtpAgent}) {
constructor({agent}: {agent: SessionAgent}) {
this.agent = agent
}
+4 -3
View File
@@ -1,11 +1,12 @@
import {type AppBskyFeedDefs, type AtpAgent} from '@atproto/api'
import {type AppBskyFeedDefs} from '@atproto/api'
import {type SessionAgent} from '#/state/session'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class FollowingFeedAPI implements FeedAPI {
agent: AtpAgent
agent: SessionAgent
constructor({agent}: {agent: AtpAgent}) {
constructor({agent}: {agent: SessionAgent}) {
this.agent = agent
}
+4 -3
View File
@@ -1,6 +1,7 @@
import {type AppBskyFeedDefs, type AtpAgent} from '@atproto/api'
import {type AppBskyFeedDefs} from '@atproto/api'
import {PROD_DEFAULT_FEED} from '#/lib/constants'
import {type SessionAgent} from '#/state/session'
import {CustomFeedAPI} from './custom'
import {FollowingFeedAPI} from './following'
import {type FeedAPI, type FeedAPIResponse} from './types'
@@ -27,7 +28,7 @@ export const FALLBACK_MARKER_POST: AppBskyFeedDefs.FeedViewPost = {
}
export class HomeFeedAPI implements FeedAPI {
agent: AtpAgent
agent: SessionAgent
following: FollowingFeedAPI
discover: CustomFeedAPI
usingDiscover = false
@@ -39,7 +40,7 @@ export class HomeFeedAPI implements FeedAPI {
agent,
}: {
userInterests?: string
agent: AtpAgent
agent: SessionAgent
}) {
this.agent = agent
this.following = new FollowingFeedAPI({agent})
+3 -3
View File
@@ -1,20 +1,20 @@
import {
type AppBskyFeedDefs,
type AppBskyFeedGetActorLikes as GetActorLikes,
type AtpAgent,
} from '@atproto/api'
import {type SessionAgent} from '#/state/session'
import {type FeedAPI, type FeedAPIResponse} from './types'
export class LikesFeedAPI implements FeedAPI {
agent: AtpAgent
agent: SessionAgent
params: GetActorLikes.QueryParams
constructor({
agent,
feedParams,
}: {
agent: AtpAgent
agent: SessionAgent
feedParams: GetActorLikes.QueryParams
}) {
this.agent = agent
+8 -11
View File
@@ -1,8 +1,4 @@
import {
type AppBskyFeedDefs,
type AppBskyFeedGetTimeline,
type AtpAgent,
} from '@atproto/api'
import {type AppBskyFeedDefs, type AppBskyFeedGetTimeline} from '@atproto/api'
import shuffle from 'lodash.shuffle'
import {bundleAsync} from '#/lib/async/bundle'
@@ -10,6 +6,7 @@ import {timeout} from '#/lib/async/timeout'
import {feedUriToHref} from '#/lib/strings/url-helpers'
import {getContentLanguages} from '#/state/preferences/languages'
import {type FeedParams} from '#/state/queries/post-feed'
import {type SessionAgent} from '#/state/session'
import {FeedTuner} from '../feed-manip'
import {type FeedTunerFn} from '../feed-manip'
import {
@@ -24,7 +21,7 @@ const POST_AGE_CUTOFF = 60e3 * 60 * 24 // 24hours
export class MergeFeedAPI implements FeedAPI {
userInterests?: string
agent: AtpAgent
agent: SessionAgent
params: FeedParams
feedTuners: FeedTunerFn[]
following: MergeFeedSource_Following
@@ -39,7 +36,7 @@ export class MergeFeedAPI implements FeedAPI {
feedTuners,
userInterests,
}: {
agent: AtpAgent
agent: SessionAgent
feedParams: FeedParams
feedTuners: FeedTunerFn[]
userInterests?: string
@@ -175,7 +172,7 @@ export class MergeFeedAPI implements FeedAPI {
}
class MergeFeedSource {
agent: AtpAgent
agent: SessionAgent
feedTuners: FeedTunerFn[]
sourceInfo: ReasonFeedSource | undefined
cursor: string | undefined = undefined
@@ -186,7 +183,7 @@ class MergeFeedSource {
agent,
feedTuners,
}: {
agent: AtpAgent
agent: SessionAgent
feedTuners: FeedTunerFn[]
}) {
this.agent = agent
@@ -253,7 +250,7 @@ class MergeFeedSource_Following extends MergeFeedSource {
}
class MergeFeedSource_Custom extends MergeFeedSource {
agent: AtpAgent
agent: SessionAgent
minDate: Date
feedUri: string
userInterests?: string
@@ -264,7 +261,7 @@ class MergeFeedSource_Custom extends MergeFeedSource {
feedTuners,
userInterests,
}: {
agent: AtpAgent
agent: SessionAgent
feedUri: string
feedTuners: FeedTunerFn[]
userInterests?: string