@@ -57,8 +57,13 @@ export default class IdentityAuthClient {
57
57
}
58
58
}
59
59
60
+ // This client must not be used for general operations as it may not have a baseUrl or be running (tempClient).
61
+ private get identityClient ( ) : MatrixClient {
62
+ return this . tempClient ?? this . matrixClient ;
63
+ }
64
+
60
65
private get matrixClient ( ) : MatrixClient {
61
- return this . tempClient ? this . tempClient : MatrixClientPeg . safeGet ( ) ;
66
+ return MatrixClientPeg . safeGet ( ) ;
62
67
}
63
68
64
69
private writeToken ( ) : void {
@@ -117,10 +122,10 @@ export default class IdentityAuthClient {
117
122
}
118
123
119
124
private async checkToken ( token : string ) : Promise < void > {
120
- const identityServerUrl = this . matrixClient . getIdentityServerUrl ( ) ! ;
125
+ const identityServerUrl = this . identityClient . getIdentityServerUrl ( ) ! ;
121
126
122
127
try {
123
- await this . matrixClient . getIdentityAccount ( token ) ;
128
+ await this . identityClient . getIdentityAccount ( token ) ;
124
129
} catch ( e ) {
125
130
if ( e instanceof MatrixError && e . errcode === "M_TERMS_NOT_SIGNED" ) {
126
131
logger . log ( "Identity server requires new terms to be agreed to" ) ;
@@ -171,7 +176,8 @@ export default class IdentityAuthClient {
171
176
public async registerForToken ( check = true ) : Promise < string > {
172
177
const hsOpenIdToken = await MatrixClientPeg . safeGet ( ) . getOpenIdToken ( ) ;
173
178
// XXX: The spec is `token`, but we used `access_token` for a Sydent release.
174
- const { access_token : accessToken , token } = await this . matrixClient . registerWithIdentityServer ( hsOpenIdToken ) ;
179
+ const { access_token : accessToken , token } =
180
+ await this . identityClient . registerWithIdentityServer ( hsOpenIdToken ) ;
175
181
const identityAccessToken = token ? token : accessToken ;
176
182
if ( check ) await this . checkToken ( identityAccessToken ) ;
177
183
return identityAccessToken ;
0 commit comments