forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
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 reorderAccounts: (accounts: SessionAccount[]) => void
50 /**
51 * Calls `getSession` and updates select fields on the current account and
52 * `BskyAgent`. This is an alternative to `resumeSession`, which updates
53 * current account/agent using the `persistSessionHandler`, but is more load
54 * bearing. This patches in updates without causing any side effects via
55 * `persistSessionHandler`.
56 */
57 partialRefreshSession: () => Promise<void>
58 createEphemeralAgent: (
59 account: SessionAccount,
60 ) => Promise<import('@atproto/api').BskyAgent>
61}