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