Skip to content

Commit 7bc9d41

Browse files
committed
Fix up merge
1 parent c444a2f commit 7bc9d41

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

src/domain/RootViewModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class RootViewModel extends ViewModel {
9393
if (oidcCallback.error) {
9494
this._setSection(() => this._error = new Error(`OIDC error: ${oidcCallback.error}`));
9595
} else {
96-
this.urlCreator.normalizeUrl();
96+
this.urlRouter.normalizeUrl();
9797
if (this.activeSection !== "login") {
9898
this._showLogin({
9999
oidc: oidcCallback,

src/domain/login/StartOIDCLoginViewModel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class StartOIDCLoginViewModel extends ViewModel {
2929
request: this.platform.request,
3030
encoding: this.platform.encoding,
3131
crypto: this.platform.crypto,
32-
urlCreator: this.urlCreator,
32+
urlRouter: this.urlRouter,
3333
});
3434
}
3535

@@ -60,7 +60,7 @@ export class StartOIDCLoginViewModel extends ViewModel {
6060
const deviceScope = this._api.generateDeviceScope();
6161
const p = this._api.generateParams({
6262
scope: `openid urn:matrix:org.matrix.msc2967.client:api:* ${deviceScope}`,
63-
redirectUri: this.urlCreator.createOIDCRedirectURL(),
63+
redirectUri: this.urlRouter.createOIDCRedirectURL(),
6464
});
6565
const clientId = await this._api.clientId();
6666
await Promise.all([

src/matrix/Client.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,14 @@ export class Client {
203203
}
204204

205205
if (loginData.expires_in) {
206-
sessionInfo.accessTokenExpiresAt = clock.now() + loginData.expires_in * 1000;
206+
sessionInfo.expiresIn = loginData.expires_in;
207207
}
208208

209209
if (loginData.oidc_issuer) {
210210
sessionInfo.oidcIssuer = loginData.oidc_issuer;
211211
sessionInfo.oidcClientId = loginData.oidc_client_id;
212212
sessionInfo.accountManagementUrl = loginData.oidc_account_management_url;
213213
}
214-
215-
log.set("id", sessionId);
216214
} catch (err) {
217215
this._error = err;
218216
if (err.name === "HomeServerError") {
@@ -235,7 +233,7 @@ export class Client {
235233
});
236234
}
237235

238-
async _createSessionAfterAuth({deviceId, userId, accessToken, homeserver}, inspectAccountSetup, log) {
236+
async _createSessionAfterAuth({deviceId, userId, accessToken, refreshToken, homeserver, expiresIn, oidcIssuer, oidcClientId, accountManagementUrl}, inspectAccountSetup, log) {
239237
const id = this.createNewSessionId();
240238
const lastUsed = this._platform.clock.now();
241239
const sessionInfo = {
@@ -246,14 +244,22 @@ export class Client {
246244
homeserver,
247245
accessToken,
248246
lastUsed,
247+
refreshToken,
248+
oidcIssuer,
249+
oidcClientId,
250+
accountManagementUrl,
249251
};
252+
if (expiresIn) {
253+
sessionInfo.accessTokenExpiresAt = lastUsed + expiresIn * 1000;
254+
}
250255
let dehydratedDevice;
251256
if (inspectAccountSetup) {
252257
dehydratedDevice = await this._inspectAccountAfterLogin(sessionInfo, log);
253258
if (dehydratedDevice) {
254259
sessionInfo.deviceId = dehydratedDevice.deviceId;
255260
}
256261
}
262+
log.set("id", id);
257263
await this._platform.sessionInfoStorage.add(sessionInfo);
258264
// loading the session can only lead to
259265
// LoadStatus.Error in case of an error,

src/matrix/net/OidcApi.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ export class OidcApi<N extends object = SegmentType> {
7878
_requestFn: RequestFunction;
7979
_encoding: any;
8080
_crypto: any;
81-
_urlCreator: IURLRouter<N>;
81+
_urlRouter: IURLRouter<N>;
8282
_metadataPromise: Promise<any>;
8383
_registrationPromise: Promise<any>;
8484

85-
constructor({ issuer, request, encoding, crypto, urlCreator, clientId }) {
85+
constructor({ issuer, request, encoding, crypto, urlRouter, clientId }) {
8686
this._issuer = issuer;
8787
this._requestFn = request;
8888
this._encoding = encoding;
8989
this._crypto = crypto;
90-
this._urlCreator = urlCreator;
90+
this._urlRouter = urlRouter;
9191

9292
if (clientId) {
9393
this._registrationPromise = Promise.resolve({ client_id: clientId });
@@ -97,13 +97,13 @@ export class OidcApi<N extends object = SegmentType> {
9797
get clientMetadata() {
9898
return {
9999
client_name: "Hydrogen Web",
100-
logo_uri: this._urlCreator.absoluteUrlForAsset("icon.png"),
101-
client_uri: this._urlCreator.absoluteAppUrl(),
100+
logo_uri: this._urlRouter.absoluteUrlForAsset("icon.png"),
101+
client_uri: this._urlRouter.absoluteAppUrl(),
102102
tos_uri: "https://element.io/terms-of-service",
103103
policy_uri: "https://element.io/privacy",
104104
response_types: ["code"],
105105
grant_types: ["authorization_code", "refresh_token"],
106-
redirect_uris: [this._urlCreator.createOIDCRedirectURL()],
106+
redirect_uris: [this._urlRouter.createOIDCRedirectURL()],
107107
id_token_signed_response_alg: "RS256",
108108
token_endpoint_auth_method: "none",
109109
};

0 commit comments

Comments
 (0)