From 394e37f9ead40021779d4b351f63dd57fe0f0045 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sun, 4 Nov 2018 19:43:18 +0000 Subject: [PATCH 01/13] Set access_token and user_id after login in with username and password. --- src/base-apis.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/base-apis.js b/src/base-apis.js index 6dc9169dd..d00ab64dc 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -277,7 +277,21 @@ MatrixBaseApis.prototype.loginWithPassword = function(user, password, callback) return this.login("m.login.password", { user: user, password: password, - }, callback); + }, (error, response) => { + if (response && response.access_token) { + this._http.opts.accessToken = response.access_token; + } + + if (response && response.user_id) { + this.credentials = { + userId: response.user_id, + }; + } + + if(callback) { + callback(error, response); + } + }); }; /** From 3aabd63975fe760debbd8bb8727a7a7a98826222 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sun, 4 Nov 2018 21:49:17 +0000 Subject: [PATCH 02/13] Add function to get currently joined rooms. --- src/base-apis.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/base-apis.js b/src/base-apis.js index 6dc9169dd..a0a842140 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -927,6 +927,14 @@ MatrixBaseApis.prototype.setRoomReadMarkersHttpRequest = ); }; +/** + * @return {module:client.Promise} Resolves: A list of the user's current rooms + * @return {module:http-api.MatrixError} Rejects: with an error response. + */ +MatrixBaseApis.prototype.getJoinedRooms = function() { + const path = utils.encodeUri("/joined_rooms"); + return this._http.authedRequest(undefined, "GET", path); +}; // Room Directory operations // ========================= From a0d51803ed46bb3bec03c85ac6fbcede603c5de8 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 5 Nov 2018 00:08:04 +0000 Subject: [PATCH 03/13] Add function to get currently joined room members. --- src/base-apis.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/base-apis.js b/src/base-apis.js index a0a842140..38de1d693 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -936,6 +936,20 @@ MatrixBaseApis.prototype.getJoinedRooms = function() { return this._http.authedRequest(undefined, "GET", path); }; +/** + * Retrieve membership info. for a room. + * @param {string} roomId ID of the room to get membership for + * @return {module:client.Promise} Resolves: A list of currently joined users + * and their profile data. + * @return {module:http-api.MatrixError} Rejects: with an error response. + */ +MatrixBaseApis.prototype.getJoinedRoomMembers = function(roomId) { + const path = utils.encodeUri("/rooms/$roomId/joined_members", { + $roomId: roomId, + }); + return this._http.authedRequest(undefined, "GET", path); +}; + // Room Directory operations // ========================= From 094598196a6e8166e2dd05ef6aaa0b01b7d0d9c1 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 5 Nov 2018 16:02:30 +0000 Subject: [PATCH 04/13] Linting. --- src/base-apis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base-apis.js b/src/base-apis.js index d00ab64dc..8836c59d8 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -288,7 +288,7 @@ MatrixBaseApis.prototype.loginWithPassword = function(user, password, callback) }; } - if(callback) { + if (callback) { callback(error, response); } }); From b716e71784492b2c90555daae5f0648e5edf1922 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 5 Nov 2018 16:40:11 +0000 Subject: [PATCH 05/13] Refactor code to base 'login' method. --- src/base-apis.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/base-apis.js b/src/base-apis.js index 8836c59d8..ad0f84b45 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -262,7 +262,19 @@ MatrixBaseApis.prototype.login = function(loginType, data, callback) { utils.extend(login_data, data); return this._http.authedRequest( - callback, "POST", "/login", undefined, login_data, + (error, response) => { + if (loginType === "m.login.password" && response && + response.access_token && response.user_id) { + this._http.opts.accessToken = response.access_token; + this.credentials = { + userId: response.user_id, + }; + } + + if (callback) { + callback(error, response); + } + }, "POST", "/login", undefined, login_data, ); }; @@ -277,21 +289,7 @@ MatrixBaseApis.prototype.loginWithPassword = function(user, password, callback) return this.login("m.login.password", { user: user, password: password, - }, (error, response) => { - if (response && response.access_token) { - this._http.opts.accessToken = response.access_token; - } - - if (response && response.user_id) { - this.credentials = { - userId: response.user_id, - }; - } - - if (callback) { - callback(error, response); - } - }); + }, callback); }; /** From f4abd7d027a921a7c34a3357b1da38f5fe907cde Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 5 Nov 2018 17:06:39 +0000 Subject: [PATCH 06/13] Update CHANGELOG. --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4295d74fe..8c5b7ec7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +Changes in [0.13.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.13.0) (2018-11-15) +================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v0.12.1...v0.13.0) + +BREAKING CHANGE +---------------- + * `MatrixClient::login` now sets client `access_token` and `user_id` following successful login. + Changes in [0.12.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.12.1) (2018-10-29) ================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v0.12.1-rc.1...v0.12.1) From 23dfeb13dfd56bd0814da927cbe8fea63ec0fd7d Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 5 Nov 2018 17:17:22 +0000 Subject: [PATCH 07/13] Update CHANGELOG. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c5b7ec7d..666558997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Changes in [0.13.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0. BREAKING CHANGE ---------------- - * `MatrixClient::login` now sets client `access_token` and `user_id` following successful login. + * `MatrixClient::login` now sets client `access_token` and `user_id` following successful login with username and password. Changes in [0.12.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.12.1) (2018-10-29) ================================================================================================== From dbb6d8ac71524303a9a6f09bb24bbca0323b523b Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sun, 4 Nov 2018 19:43:18 +0000 Subject: [PATCH 08/13] Set access_token and user_id after login in with username and password. --- src/base-apis.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/base-apis.js b/src/base-apis.js index 6dc9169dd..d00ab64dc 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -277,7 +277,21 @@ MatrixBaseApis.prototype.loginWithPassword = function(user, password, callback) return this.login("m.login.password", { user: user, password: password, - }, callback); + }, (error, response) => { + if (response && response.access_token) { + this._http.opts.accessToken = response.access_token; + } + + if (response && response.user_id) { + this.credentials = { + userId: response.user_id, + }; + } + + if(callback) { + callback(error, response); + } + }); }; /** From b0d0782a729357aad63079a044c8c1ea48fa82fc Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 5 Nov 2018 16:02:30 +0000 Subject: [PATCH 09/13] Linting. --- src/base-apis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base-apis.js b/src/base-apis.js index d00ab64dc..8836c59d8 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -288,7 +288,7 @@ MatrixBaseApis.prototype.loginWithPassword = function(user, password, callback) }; } - if(callback) { + if (callback) { callback(error, response); } }); From 11be68ad4919d416891236308c8d8c072effc35c Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 5 Nov 2018 16:40:11 +0000 Subject: [PATCH 10/13] Refactor code to base 'login' method. --- src/base-apis.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/base-apis.js b/src/base-apis.js index 8836c59d8..ad0f84b45 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -262,7 +262,19 @@ MatrixBaseApis.prototype.login = function(loginType, data, callback) { utils.extend(login_data, data); return this._http.authedRequest( - callback, "POST", "/login", undefined, login_data, + (error, response) => { + if (loginType === "m.login.password" && response && + response.access_token && response.user_id) { + this._http.opts.accessToken = response.access_token; + this.credentials = { + userId: response.user_id, + }; + } + + if (callback) { + callback(error, response); + } + }, "POST", "/login", undefined, login_data, ); }; @@ -277,21 +289,7 @@ MatrixBaseApis.prototype.loginWithPassword = function(user, password, callback) return this.login("m.login.password", { user: user, password: password, - }, (error, response) => { - if (response && response.access_token) { - this._http.opts.accessToken = response.access_token; - } - - if (response && response.user_id) { - this.credentials = { - userId: response.user_id, - }; - } - - if (callback) { - callback(error, response); - } - }); + }, callback); }; /** From d40d7e18f5b4f1d54f67e8a9b0721420037a8db5 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 5 Nov 2018 17:06:39 +0000 Subject: [PATCH 11/13] Update CHANGELOG. --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4295d74fe..8c5b7ec7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +Changes in [0.13.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.13.0) (2018-11-15) +================================================================================================== +[Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v0.12.1...v0.13.0) + +BREAKING CHANGE +---------------- + * `MatrixClient::login` now sets client `access_token` and `user_id` following successful login. + Changes in [0.12.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.12.1) (2018-10-29) ================================================================================================== [Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v0.12.1-rc.1...v0.12.1) From 977d5331c0ca8779692fd14a1ceaef9cbe463370 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Mon, 5 Nov 2018 17:17:22 +0000 Subject: [PATCH 12/13] Update CHANGELOG. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c5b7ec7d..666558997 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Changes in [0.13.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0. BREAKING CHANGE ---------------- - * `MatrixClient::login` now sets client `access_token` and `user_id` following successful login. + * `MatrixClient::login` now sets client `access_token` and `user_id` following successful login with username and password. Changes in [0.12.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.12.1) (2018-10-29) ================================================================================================== From fbe174fb64e2c04b9dbd6654f9f95258b454db29 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 14 Nov 2018 10:53:42 +0100 Subject: [PATCH 13/13] v0.13.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8c9c9544f..0c872e9fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matrix-js-sdk", - "version": "0.12.1", + "version": "0.13.0", "description": "Matrix Client-Server SDK for Javascript", "main": "index.js", "scripts": {