From 4287f2229b26b53e4c03378475dba5cd3ad8fdd1 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 28 Jan 2020 13:21:01 +0000 Subject: [PATCH] Add a bunch of null guards to feature checks --- src/client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 8a3059431..b5dccc96c 100644 --- a/src/client.js +++ b/src/client.js @@ -4675,6 +4675,7 @@ MatrixClient.prototype.isVersionSupported = async function(version) { */ MatrixClient.prototype.doesServerSupportLazyLoading = async function() { const response = await this.getVersions(); + if (!response) return false; const versions = response["versions"]; const unstableFeatures = response["unstable_features"]; @@ -4690,6 +4691,7 @@ MatrixClient.prototype.doesServerSupportLazyLoading = async function() { */ MatrixClient.prototype.doesServerRequireIdServerParam = async function() { const response = await this.getVersions(); + if (!response) return true; const versions = response["versions"]; @@ -4699,6 +4701,7 @@ MatrixClient.prototype.doesServerRequireIdServerParam = async function() { } const unstableFeatures = response["unstable_features"]; + if (!unstableFeatures) return true; if (unstableFeatures["m.require_identity_server"] === undefined) { return true; } else { @@ -4714,10 +4717,10 @@ MatrixClient.prototype.doesServerRequireIdServerParam = async function() { */ MatrixClient.prototype.doesServerAcceptIdentityAccessToken = async function() { const response = await this.getVersions(); + if (!response) return false; const versions = response["versions"]; const unstableFeatures = response["unstable_features"]; - return (versions && versions.includes("r0.6.0")) || (unstableFeatures && unstableFeatures["m.id_access_token"]); }; @@ -4730,6 +4733,7 @@ MatrixClient.prototype.doesServerAcceptIdentityAccessToken = async function() { */ MatrixClient.prototype.doesServerSupportSeparateAddAndBind = async function() { const response = await this.getVersions(); + if (!response) return false; const versions = response["versions"]; const unstableFeatures = response["unstable_features"];