Bluesky app fork with some witchin' additions 馃挮
witchsky.app
bluesky
fork
client
1import {type OAuthSession} from '@atproto/oauth-client-browser'
2
3import {type PersistedAccount} from '#/state/persisted'
4import {type Metrics} from '#/analytics/metrics'
5
6export type SessionAccount = PersistedAccount
7
8export type SessionStateContext = {
9 accounts: SessionAccount[]
10 currentAccount: SessionAccount | undefined
11 hasSession: boolean
12}
13
14export type SessionApiContext = {
15 createAccount: (
16 props: {
17 service: string
18 email: string
19 password: string
20 handle: string
21 birthDate: Date
22 inviteCode?: string
23 verificationPhone?: string
24 verificationCode?: string
25 },
26 metrics: Metrics['account:create:success'],
27 ) => Promise<void>
28 login: (
29 props: {
30 service: string
31 identifier: string
32 password: string
33 authFactorToken?: string | undefined
34 oauthSession?: OAuthSession
35 },
36 logContext: Metrics['account:loggedIn']['logContext'],
37 ) => Promise<void>
38 logoutCurrentAccount: (
39 logContext: Metrics['account:loggedOut']['logContext'],
40 ) => void
41 logoutEveryAccount: (
42 logContext: Metrics['account:loggedOut']['logContext'],
43 ) => void
44 resumeSession: (
45 account: SessionAccount,
46 isSwitchingAccounts?: boolean,
47 ) => Promise<void>
48 removeAccount: (account: SessionAccount) => void
49 /**
50 * Calls `getSession` and updates select fields on the current account and
51 * `BskyAgent`. This is an alternative to `resumeSession`, which updates
52 * current account/agent using the `persistSessionHandler`, but is more load
53 * bearing. This patches in updates without causing any side effects via
54 * `persistSessionHandler`.
55 */
56 partialRefreshSession: () => Promise<void>
57}