Track rotated auth tokens

This commit is contained in:
Paul Frazee
2022-11-21 16:17:40 -06:00
parent abd6ffdbf5
commit 652362b0c2
2 changed files with 16 additions and 1 deletions
+2
View File
@@ -34,6 +34,8 @@ export async function setupState() {
if (!api.sessionManager.session && rootStore.session.isAuthed) {
// reset session
rootStore.session.clear()
} else if (api.sessionManager.session) {
rootStore.session.updateAuthTokens(api.sessionManager.session)
}
})
+14 -1
View File
@@ -1,6 +1,9 @@
import {makeAutoObservable} from 'mobx'
import {sessionClient as AtpApi} from '../../third-party/api/index'
import type {SessionServiceClient} from '../../third-party/api/src/index'
import type {
SessionServiceClient,
Session,
} from '../../third-party/api/src/index'
import type * as GetAccountsConfig from '../../third-party/api/src/client/types/com/atproto/server/getAccountsConfig'
import {isObj, hasProp} from '../lib/type-guards'
import {RootStoreModel} from './root-store'
@@ -88,6 +91,16 @@ export class SessionModel {
this.data = data
}
updateAuthTokens(session: Session) {
if (this.data) {
this.setState({
...this.data,
accessJwt: session.accessJwt,
refreshJwt: session.refreshJwt,
})
}
}
private configureApi(): boolean {
if (!this.data) {
return false