From dd792e10a9237b0f63149d799af1a71698b038d3 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 24 Jul 2019 18:38:09 +0100 Subject: [PATCH 01/14] Convert 3PID lookup in address picker to async / await --- .../views/dialogs/AddressPickerDialog.js | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 5c004deebd..153f9c7792 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -443,7 +443,7 @@ module.exports = React.createClass({ }); if (this._cancelThreepidLookup) this._cancelThreepidLookup(); if (addrType === 'email') { - this._lookupThreepid(addrType, query).done(); + this._lookupThreepid(addrType, query); } } this.setState({ @@ -498,7 +498,7 @@ module.exports = React.createClass({ return hasError ? null : selectedList; }, - _lookupThreepid: function(medium, address) { + _lookupThreepid: async function(medium, address) { let cancelled = false; // Note that we can't safely remove this after we're done // because we don't know that it's the same one, so we just @@ -509,28 +509,29 @@ module.exports = React.createClass({ }; // wait a bit to let the user finish typing - return Promise.delay(500).then(() => { - if (cancelled) return null; - return MatrixClientPeg.get().lookupThreePid(medium, address); - }).then((res) => { - if (res === null || !res.mxid) return null; - if (cancelled) return null; + await Promise.delay(500); + if (cancelled) return null; + + try { + const lookup = await MatrixClientPeg.get().lookupThreePid(medium, address); + if (cancelled || lookup === null || !lookup.mxid) return null; + + const profile = await MatrixClientPeg.get().getProfileInfo(lookup.mxid); + if (cancelled || profile === null) return null; - return MatrixClientPeg.get().getProfileInfo(res.mxid); - }).then((res) => { - if (res === null) return null; - if (cancelled) return null; this.setState({ suggestedList: [{ // a UserAddressType addressType: medium, address: address, - displayName: res.displayname, - avatarMxc: res.avatar_url, + displayName: profile.displayname, + avatarMxc: profile.avatar_url, isKnown: true, }], }); - }); + } catch (e) { + console.error(e); + } }, _getFilteredSuggestions: function() { From 432e70e2ce817b2f52d7bdc8e613737d3da268b5 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 25 Jul 2019 11:06:46 +0100 Subject: [PATCH 02/14] Add IS auth to AddressPickerDialog --- src/components/views/dialogs/AddressPickerDialog.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 153f9c7792..53e630ff8f 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -513,7 +513,13 @@ module.exports = React.createClass({ if (cancelled) return null; try { - const lookup = await MatrixClientPeg.get().lookupThreePid(medium, address); + const hsAccountToken = await MatrixClientPeg.get().getOpenIdToken(); + if (cancelled) return null; + + const isAccountToken = await MatrixClientPeg.get().registerWithIdentityServer(hsAccountToken); + if (cancelled) return null; + + const lookup = await MatrixClientPeg.get().lookupThreePid(medium, address, undefined, isAccountToken); if (cancelled || lookup === null || !lookup.mxid) return null; const profile = await MatrixClientPeg.get().getProfileInfo(lookup.mxid); From 4d01d6a5b17c122cf6728afb398bcbe74653ed2d Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 29 Jul 2019 11:58:47 +0100 Subject: [PATCH 03/14] Move auth steps to IdentityAuthClient --- src/IdentityAuthClient.js | 60 +++++++++++++++++++ .../views/dialogs/AddressPickerDialog.js | 13 ++-- 2 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 src/IdentityAuthClient.js diff --git a/src/IdentityAuthClient.js b/src/IdentityAuthClient.js new file mode 100644 index 0000000000..94109ff265 --- /dev/null +++ b/src/IdentityAuthClient.js @@ -0,0 +1,60 @@ +/* +Copyright 2019 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import MatrixClientPeg from './MatrixClientPeg'; + +export default class IdentityAuthClient { + constructor() { + this.accessToken = null; + } + + hasCredentials() { + return this.accessToken != null; // undef or null + } + + // Returns a promise that resolves to the access_token string from the IS + async getAccessToken() { + let token = this.accessToken; + if (!token) { + token = window.localStorage.getItem("mx_is_access_token"); + } + + if (!token) { + return this.registerForToken(); + } + + try { + return await this._checkToken(token); + } catch (e) { + return await this.registerForToken(); + } + } + + _checkToken(token) { + // TODO: Test current API token via /account endpoint + return token; + } + + async registerForToken() { + const hsOpenIdToken = await MatrixClientPeg.get().getOpenIdToken(); + const { access_token: isAccessToken } = + await MatrixClientPeg.get().registerWithIdentityServer(hsOpenIdToken); + await this._checkToken(isAccessToken); + this.accessToken = isAccessToken; + window.localStorage.setItem("mx_is_access_token", isAccessToken); + return isAccessToken; + } +} diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 53e630ff8f..38b478d462 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -2,6 +2,7 @@ Copyright 2015, 2016 OpenMarket Ltd Copyright 2017, 2018, 2019 New Vector Ltd Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> +Copyright 2019 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,13 +19,15 @@ limitations under the License. import React from 'react'; import PropTypes from 'prop-types'; + import { _t, _td } from '../../../languageHandler'; import sdk from '../../../index'; import MatrixClientPeg from '../../../MatrixClientPeg'; import Promise from 'bluebird'; import { addressTypes, getAddressType } from '../../../UserAddress.js'; import GroupStore from '../../../stores/GroupStore'; -import * as Email from "../../../email"; +import * as Email from '../../../email'; +import IdentityAuthClient from '../../../IdentityAuthClient'; const TRUNCATE_QUERY_LIST = 40; const QUERY_USER_DIRECTORY_DEBOUNCE_MS = 200; @@ -513,13 +516,11 @@ module.exports = React.createClass({ if (cancelled) return null; try { - const hsAccountToken = await MatrixClientPeg.get().getOpenIdToken(); + const authClient = new IdentityAuthClient(); + const isAccessToken = await authClient.getAccessToken(); if (cancelled) return null; - const isAccountToken = await MatrixClientPeg.get().registerWithIdentityServer(hsAccountToken); - if (cancelled) return null; - - const lookup = await MatrixClientPeg.get().lookupThreePid(medium, address, undefined, isAccountToken); + const lookup = await MatrixClientPeg.get().lookupThreePid(medium, address, undefined, isAccessToken); if (cancelled || lookup === null || !lookup.mxid) return null; const profile = await MatrixClientPeg.get().getProfileInfo(lookup.mxid); From 18c4ece87ab6abb4b1b045d09e750fd59590acbe Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 29 Jul 2019 14:41:57 +0100 Subject: [PATCH 04/14] Improve error handling for IS auth --- src/IdentityAuthClient.js | 41 ++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/IdentityAuthClient.js b/src/IdentityAuthClient.js index 94109ff265..f3ec400148 100644 --- a/src/IdentityAuthClient.js +++ b/src/IdentityAuthClient.js @@ -19,6 +19,7 @@ import MatrixClientPeg from './MatrixClientPeg'; export default class IdentityAuthClient { constructor() { this.accessToken = null; + this.authEnabled = true; } hasCredentials() { @@ -27,34 +28,52 @@ export default class IdentityAuthClient { // Returns a promise that resolves to the access_token string from the IS async getAccessToken() { + if (!this.authEnabled) { + // The current IS doesn't support authentication + return null; + } + let token = this.accessToken; if (!token) { token = window.localStorage.getItem("mx_is_access_token"); } if (!token) { - return this.registerForToken(); + token = await this.registerForToken(); + this.accessToken = token; + window.localStorage.setItem("mx_is_access_token", token); } try { - return await this._checkToken(token); + await this._checkToken(token); } catch (e) { - return await this.registerForToken(); + // Retry in case token expired + token = await this.registerForToken(); + this.accessToken = token; + window.localStorage.setItem("mx_is_access_token", token); } + + return token; } _checkToken(token) { // TODO: Test current API token via /account endpoint - return token; } async registerForToken() { - const hsOpenIdToken = await MatrixClientPeg.get().getOpenIdToken(); - const { access_token: isAccessToken } = - await MatrixClientPeg.get().registerWithIdentityServer(hsOpenIdToken); - await this._checkToken(isAccessToken); - this.accessToken = isAccessToken; - window.localStorage.setItem("mx_is_access_token", isAccessToken); - return isAccessToken; + try { + const hsOpenIdToken = await MatrixClientPeg.get().getOpenIdToken(); + const { access_token: isAccessToken } = + await MatrixClientPeg.get().registerWithIdentityServer(hsOpenIdToken); + await this._checkToken(isAccessToken); + return isAccessToken; + } catch (err) { + if (err.cors === "rejected" || err.httpStatus === 404) { + // Assume IS only supports deprecated v1 API for now + // TODO: Remove this path once v2 is only supported version + console.warn("IS doesn't support v2 auth"); + this.authEnabled = false; + } + } } } From 244b613623660ecf5ac3ebda66fd140126d50cba Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 29 Jul 2019 15:04:18 +0100 Subject: [PATCH 05/14] Convert 3PID lookup in preview bar to async / await --- src/components/views/rooms/RoomPreviewBar.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index ed91c5aafc..db5d16c8cb 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -104,21 +104,21 @@ module.exports = React.createClass({ } }, - _checkInvitedEmail: function() { + _checkInvitedEmail: async function() { // If this is an invite and we've been told what email // address was invited, fetch the user's list of Threepids // so we can check them against the one that was invited if (this.props.inviterName && this.props.invitedEmail) { this.setState({busy: true}); - MatrixClientPeg.get().lookupThreePid( - 'email', this.props.invitedEmail, - ).finally(() => { - this.setState({busy: false}); - }).done((result) => { + try { + const result = await MatrixClientPeg.get().lookupThreePid( + 'email', this.props.invitedEmail, + ); this.setState({invitedEmailMxid: result.mxid}); - }, (err) => { + } catch (err) { this.setState({threePidFetchError: err}); - }); + } + this.setState({busy: false}); } }, From dacb5d42acd834b6657a4c14145365c7c9aa1d40 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 29 Jul 2019 15:08:54 +0100 Subject: [PATCH 06/14] Support IS v2 auth in preview bar --- src/components/views/dialogs/AddressPickerDialog.js | 7 ++++++- src/components/views/rooms/RoomPreviewBar.js | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 38b478d462..7ff9e8f233 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -520,7 +520,12 @@ module.exports = React.createClass({ const isAccessToken = await authClient.getAccessToken(); if (cancelled) return null; - const lookup = await MatrixClientPeg.get().lookupThreePid(medium, address, undefined, isAccessToken); + const lookup = await MatrixClientPeg.get().lookupThreePid( + medium, + address, + undefined /* callback */, + isAccessToken, + ); if (cancelled || lookup === null || !lookup.mxid) return null; const profile = await MatrixClientPeg.get().getProfileInfo(lookup.mxid); diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index db5d16c8cb..0fb8146943 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -25,6 +25,7 @@ import MatrixClientPeg from '../../../MatrixClientPeg'; import dis from '../../../dispatcher'; import classNames from 'classnames'; import { _t } from '../../../languageHandler'; +import IdentityAuthClient from '../../../IdentityAuthClient'; const MessageCase = Object.freeze({ NotLoggedIn: "NotLoggedIn", @@ -111,8 +112,13 @@ module.exports = React.createClass({ if (this.props.inviterName && this.props.invitedEmail) { this.setState({busy: true}); try { + const authClient = new IdentityAuthClient(); + const isAccessToken = await authClient.getAccessToken(); const result = await MatrixClientPeg.get().lookupThreePid( - 'email', this.props.invitedEmail, + 'email', + this.props.invitedEmail, + undefined /* callback */, + isAccessToken, ); this.setState({invitedEmailMxid: result.mxid}); } catch (err) { From 9fa8012315ac93db07e5a4510c06237e66ae8b44 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 29 Jul 2019 15:31:21 +0100 Subject: [PATCH 07/14] Convert haveMsisdnToken to async / await --- src/AddThreepid.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/AddThreepid.js b/src/AddThreepid.js index adeaf84a69..f47b26bea0 100644 --- a/src/AddThreepid.js +++ b/src/AddThreepid.js @@ -108,19 +108,19 @@ export default class AddThreepid { * with a "message" property which contains a human-readable message detailing why * the request failed. */ - haveMsisdnToken(token) { - return MatrixClientPeg.get().submitMsisdnToken( + async haveMsisdnToken(token) { + const result = await MatrixClientPeg.get().submitMsisdnToken( this.sessionId, this.clientSecret, token, - ).then((result) => { - if (result.errcode) { - throw result; - } - const identityServerDomain = MatrixClientPeg.get().idBaseUrl.split("://")[1]; - return MatrixClientPeg.get().addThreePid({ - sid: this.sessionId, - client_secret: this.clientSecret, - id_server: identityServerDomain, - }, this.bind); - }); + ); + if (result.errcode) { + throw result; + } + + const identityServerDomain = MatrixClientPeg.get().idBaseUrl.split("://")[1]; + return MatrixClientPeg.get().addThreePid({ + sid: this.sessionId, + client_secret: this.clientSecret, + id_server: identityServerDomain, + }, this.bind); } } From 654a8c2cb861f1044190eacae7e04a35ea26e366 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 29 Jul 2019 15:34:50 +0100 Subject: [PATCH 08/14] Support IS v2 auth in haveMsisdnToken --- src/AddThreepid.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/AddThreepid.js b/src/AddThreepid.js index f47b26bea0..a523e43643 100644 --- a/src/AddThreepid.js +++ b/src/AddThreepid.js @@ -17,6 +17,7 @@ limitations under the License. import MatrixClientPeg from './MatrixClientPeg'; import { _t } from './languageHandler'; +import IdentityAuthClient from './IdentityAuthClient'; /** * Allows a user to add a third party identifier to their homeserver and, @@ -103,14 +104,19 @@ export default class AddThreepid { /** * Takes a phone number verification code as entered by the user and validates * it with the ID server, then if successful, adds the phone number. - * @param {string} token phone number verification code as entered by the user + * @param {string} msisdnToken phone number verification code as entered by the user * @return {Promise} Resolves if the phone number was added. Rejects with an object * with a "message" property which contains a human-readable message detailing why * the request failed. */ - async haveMsisdnToken(token) { + async haveMsisdnToken(msisdnToken) { + const authClient = new IdentityAuthClient(); + const isAccessToken = await authClient.getAccessToken(); const result = await MatrixClientPeg.get().submitMsisdnToken( - this.sessionId, this.clientSecret, token, + this.sessionId, + this.clientSecret, + msisdnToken, + isAccessToken, ); if (result.errcode) { throw result; From 4ebafb93c329ada8417f8d9f061e1500eef1cbd9 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 30 Jul 2019 10:05:57 +0100 Subject: [PATCH 09/14] Rename isAccessToken to identityAccessToken --- src/AddThreepid.js | 4 ++-- src/IdentityAuthClient.js | 6 +++--- src/components/views/dialogs/AddressPickerDialog.js | 4 ++-- src/components/views/rooms/RoomPreviewBar.js | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/AddThreepid.js b/src/AddThreepid.js index a523e43643..8bd3099002 100644 --- a/src/AddThreepid.js +++ b/src/AddThreepid.js @@ -111,12 +111,12 @@ export default class AddThreepid { */ async haveMsisdnToken(msisdnToken) { const authClient = new IdentityAuthClient(); - const isAccessToken = await authClient.getAccessToken(); + const identityAccessToken = await authClient.getAccessToken(); const result = await MatrixClientPeg.get().submitMsisdnToken( this.sessionId, this.clientSecret, msisdnToken, - isAccessToken, + identityAccessToken, ); if (result.errcode) { throw result; diff --git a/src/IdentityAuthClient.js b/src/IdentityAuthClient.js index f3ec400148..dcc61c277b 100644 --- a/src/IdentityAuthClient.js +++ b/src/IdentityAuthClient.js @@ -63,10 +63,10 @@ export default class IdentityAuthClient { async registerForToken() { try { const hsOpenIdToken = await MatrixClientPeg.get().getOpenIdToken(); - const { access_token: isAccessToken } = + const { access_token: identityAccessToken } = await MatrixClientPeg.get().registerWithIdentityServer(hsOpenIdToken); - await this._checkToken(isAccessToken); - return isAccessToken; + await this._checkToken(identityAccessToken); + return identityAccessToken; } catch (err) { if (err.cors === "rejected" || err.httpStatus === 404) { // Assume IS only supports deprecated v1 API for now diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 7ff9e8f233..6d1d8c0b4e 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -517,14 +517,14 @@ module.exports = React.createClass({ try { const authClient = new IdentityAuthClient(); - const isAccessToken = await authClient.getAccessToken(); + const identityAccessToken = await authClient.getAccessToken(); if (cancelled) return null; const lookup = await MatrixClientPeg.get().lookupThreePid( medium, address, undefined /* callback */, - isAccessToken, + identityAccessToken, ); if (cancelled || lookup === null || !lookup.mxid) return null; diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index 0fb8146943..7715bd9339 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -113,12 +113,12 @@ module.exports = React.createClass({ this.setState({busy: true}); try { const authClient = new IdentityAuthClient(); - const isAccessToken = await authClient.getAccessToken(); + const identityAccessToken = await authClient.getAccessToken(); const result = await MatrixClientPeg.get().lookupThreePid( 'email', this.props.invitedEmail, undefined /* callback */, - isAccessToken, + identityAccessToken, ); this.setState({invitedEmailMxid: result.mxid}); } catch (err) { From 55780f3caf8c17cd5e55bda77ae86d0a031676b6 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 30 Jul 2019 10:09:38 +0100 Subject: [PATCH 10/14] Extend comment about checking tokens --- src/IdentityAuthClient.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/IdentityAuthClient.js b/src/IdentityAuthClient.js index dcc61c277b..a1a696e4c3 100644 --- a/src/IdentityAuthClient.js +++ b/src/IdentityAuthClient.js @@ -57,7 +57,13 @@ export default class IdentityAuthClient { } _checkToken(token) { - // TODO: Test current API token via /account endpoint + // TODO: Test current API token via `/account` endpoint + // At the moment, Sydent doesn't implement `/account`, so we can't use + // that yet. We could try a lookup for a null address perhaps...? + // In any case, we should ensure the token in `localStorage` is cleared + // appropriately. We already clear storage on sign out, but we'll need + // additional clearing when changing ISes in settings as part of future + // privacy work. } async registerForToken() { From 5bb68b4b3b0a22b36d0bd3149ef3d33d878244c5 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 30 Jul 2019 10:29:41 +0100 Subject: [PATCH 11/14] Display lookup errors in the UI --- .../views/dialogs/AddressPickerDialog.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index 6d1d8c0b4e..6cb5a278fd 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -74,12 +74,11 @@ module.exports = React.createClass({ getInitialState: function() { return { - error: false, - + // Whether to show an error message because of an invalid address + invalidAddressError: false, // List of UserAddressType objects representing // the list of addresses we're going to invite selectedList: [], - // Whether a search is ongoing busy: false, // An error message generated during the user directory search @@ -451,7 +450,7 @@ module.exports = React.createClass({ } this.setState({ suggestedList, - error: false, + invalidAddressError: false, }, () => { if (this.addressSelector) this.addressSelector.moveSelectionTop(); }); @@ -495,7 +494,7 @@ module.exports = React.createClass({ selectedList, suggestedList: [], query: "", - error: hasError ? true : this.state.error, + invalidAddressError: hasError ? true : this.state.invalidAddressError, }); if (this._cancelThreepidLookup) this._cancelThreepidLookup(); return hasError ? null : selectedList; @@ -543,6 +542,9 @@ module.exports = React.createClass({ }); } catch (e) { console.error(e); + this.setState({ + searchError: _t('Something went wrong!'), + }); } }, @@ -610,7 +612,7 @@ module.exports = React.createClass({ let error; let addressSelector; - if (this.state.error) { + if (this.state.invalidAddressError) { const validTypeDescriptions = this.props.validAddressTypes.map((t) => _t(addressTypeName[t])); error =
{ _t("You have entered an invalid address.") } From 15243ec2a557e1ea90345a9b264c328514a731c1 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 30 Jul 2019 10:39:07 +0100 Subject: [PATCH 12/14] Note cleanup issue --- src/IdentityAuthClient.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/IdentityAuthClient.js b/src/IdentityAuthClient.js index a1a696e4c3..d7f810951b 100644 --- a/src/IdentityAuthClient.js +++ b/src/IdentityAuthClient.js @@ -77,6 +77,7 @@ export default class IdentityAuthClient { if (err.cors === "rejected" || err.httpStatus === 404) { // Assume IS only supports deprecated v1 API for now // TODO: Remove this path once v2 is only supported version + // See https://github.com/vector-im/riot-web/issues/10443 console.warn("IS doesn't support v2 auth"); this.authEnabled = false; } From edcdac464c007024b0dafb89a6d272a545e4685e Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 30 Jul 2019 16:56:19 +0100 Subject: [PATCH 13/14] Add note to test tokens --- src/IdentityAuthClient.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/IdentityAuthClient.js b/src/IdentityAuthClient.js index d7f810951b..185354012d 100644 --- a/src/IdentityAuthClient.js +++ b/src/IdentityAuthClient.js @@ -58,8 +58,13 @@ export default class IdentityAuthClient { _checkToken(token) { // TODO: Test current API token via `/account` endpoint + // At the moment, Sydent doesn't implement `/account`, so we can't use // that yet. We could try a lookup for a null address perhaps...? + // Sydent doesn't currently expire tokens, but we should still be testing + // them in any case. + // See also https://github.com/vector-im/riot-web/issues/10452. + // In any case, we should ensure the token in `localStorage` is cleared // appropriately. We already clear storage on sign out, but we'll need // additional clearing when changing ISes in settings as part of future From 92dbb583847f6a947291e1dcb8635447a8801d36 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 30 Jul 2019 17:19:59 +0100 Subject: [PATCH 14/14] Add note to log out from IS --- src/IdentityAuthClient.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/IdentityAuthClient.js b/src/IdentityAuthClient.js index 185354012d..133cca774b 100644 --- a/src/IdentityAuthClient.js +++ b/src/IdentityAuthClient.js @@ -69,6 +69,7 @@ export default class IdentityAuthClient { // appropriately. We already clear storage on sign out, but we'll need // additional clearing when changing ISes in settings as part of future // privacy work. + // See also https://github.com/vector-im/riot-web/issues/10455. } async registerForToken() {