You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-23 17:02:25 +03:00
Broaden spec version support (#4014)
This commit does two things: * It puts the "minimum supported matrix version" from v1.5 back down to v1.1. In other words, it is a partial revert of https://github.com/matrix-org/matrix-js-sdk/pull/3970. (Partial, because we don't need to update the tests.) We're doing this largely because https://github.com/matrix-org/matrix-js-sdk/pull/3970 was introduced without a suitable announcement and deprecation policy. We haven't yet decided if the js-sdk's spec support policy needs to change, or if we will re-introduce this change in future in a more graceful manner. * It increases the "maximum supported matrix version" from v1.5 up to v1.9. Previously, the two concepts were tied together, but as discussed at length in https://github.com/matrix-org/matrix-js-sdk/issues/3915#issuecomment-1865221366, this is incorrect. Unfortunately, we have no real way of testing whether it is true that the js-sdk actually works with a server which supports *only* v1.9, but as per the comment above, we can't do much about that. Fixes https://github.com/matrix-org/matrix-js-sdk/issues/3915.
This commit is contained in:
committed by
GitHub
parent
81b58388ee
commit
c885542628
@@ -11,7 +11,7 @@
|
|||||||
This is the [Matrix](https://matrix.org) Client-Server SDK for JavaScript and TypeScript. This SDK can be run in a
|
This is the [Matrix](https://matrix.org) Client-Server SDK for JavaScript and TypeScript. This SDK can be run in a
|
||||||
browser or in Node.js.
|
browser or in Node.js.
|
||||||
|
|
||||||
#### Minimum Matrix server version: v1.5
|
#### Minimum Matrix server version: v1.1
|
||||||
|
|
||||||
The Matrix specification is constantly evolving - while this SDK aims for maximum backwards compatibility, it only
|
The Matrix specification is constantly evolving - while this SDK aims for maximum backwards compatibility, it only
|
||||||
guarantees that a feature will be supported for at least 4 spec releases. For example, if a feature the js-sdk supports
|
guarantees that a feature will be supported for at least 4 spec releases. For example, if a feature the js-sdk supports
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
validateWellKnownAuthentication,
|
validateWellKnownAuthentication,
|
||||||
} from "./oidc/validate";
|
} from "./oidc/validate";
|
||||||
import { OidcError } from "./oidc/error";
|
import { OidcError } from "./oidc/error";
|
||||||
import { MINIMUM_MATRIX_VERSION } from "./version-support";
|
import { SUPPORTED_MATRIX_VERSIONS } from "./version-support";
|
||||||
|
|
||||||
// Dev note: Auto discovery is part of the spec.
|
// Dev note: Auto discovery is part of the spec.
|
||||||
// See: https://matrix.org/docs/spec/client_server/r0.4.0.html#server-discovery
|
// See: https://matrix.org/docs/spec/client_server/r0.4.0.html#server-discovery
|
||||||
@@ -51,7 +51,10 @@ export enum AutoDiscoveryError {
|
|||||||
InvalidIs = "Invalid identity server discovery response",
|
InvalidIs = "Invalid identity server discovery response",
|
||||||
MissingWellknown = "No .well-known JSON file found",
|
MissingWellknown = "No .well-known JSON file found",
|
||||||
InvalidJson = "Invalid JSON",
|
InvalidJson = "Invalid JSON",
|
||||||
HomeserverTooOld = "The homeserver does not meet the minimum version requirements",
|
UnsupportedHomeserverSpecVersion = "The homeserver does not meet the version requirements",
|
||||||
|
|
||||||
|
/** @deprecated Replaced by `UnsupportedHomeserverSpecVersion` */
|
||||||
|
HomeserverTooOld = UnsupportedHomeserverSpecVersion,
|
||||||
// TODO: Implement when Sydent supports the `/versions` endpoint - https://github.com/matrix-org/sydent/issues/424
|
// TODO: Implement when Sydent supports the `/versions` endpoint - https://github.com/matrix-org/sydent/issues/424
|
||||||
//IdentityServerTooOld = "The identity server does not meet the minimum version requirements",
|
//IdentityServerTooOld = "The identity server does not meet the minimum version requirements",
|
||||||
}
|
}
|
||||||
@@ -112,7 +115,11 @@ export class AutoDiscovery {
|
|||||||
|
|
||||||
public static readonly ERROR_INVALID_JSON = AutoDiscoveryError.InvalidJson;
|
public static readonly ERROR_INVALID_JSON = AutoDiscoveryError.InvalidJson;
|
||||||
|
|
||||||
public static readonly ERROR_HOMESERVER_TOO_OLD = AutoDiscoveryError.HomeserverTooOld;
|
public static readonly ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION =
|
||||||
|
AutoDiscoveryError.UnsupportedHomeserverSpecVersion;
|
||||||
|
|
||||||
|
/** @deprecated Replaced by ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION */
|
||||||
|
public static readonly ERROR_HOMESERVER_TOO_OLD = AutoDiscovery.ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION;
|
||||||
|
|
||||||
public static readonly ALL_ERRORS = Object.keys(AutoDiscoveryError) as AutoDiscoveryError[];
|
public static readonly ALL_ERRORS = Object.keys(AutoDiscoveryError) as AutoDiscoveryError[];
|
||||||
|
|
||||||
@@ -216,10 +223,19 @@ export class AutoDiscovery {
|
|||||||
return Promise.resolve(clientConfig);
|
return Promise.resolve(clientConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3.1: Non-spec check to ensure the server will actually work for us
|
// Step 3.1: Non-spec check to ensure the server will actually work for us. We need to check if
|
||||||
if (!hsVersions.raw!["versions"].includes(MINIMUM_MATRIX_VERSION)) {
|
// any of the versions in `SUPPORTED_MATRIX_VERSIONS` are listed in the /versions response.
|
||||||
logger.error("Homeserver does not meet minimum version requirements");
|
const hsVersionSet = new Set(hsVersions.raw!["versions"]);
|
||||||
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_HOMESERVER_TOO_OLD;
|
let supportedVersionFound = false;
|
||||||
|
for (const version of SUPPORTED_MATRIX_VERSIONS) {
|
||||||
|
if (hsVersionSet.has(version)) {
|
||||||
|
supportedVersionFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!supportedVersionFound) {
|
||||||
|
logger.error("Homeserver does not meet version requirements");
|
||||||
|
clientConfig["m.homeserver"].error = AutoDiscovery.ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION;
|
||||||
|
|
||||||
// Supply the base_url to the caller because they may be ignoring liveliness
|
// Supply the base_url to the caller because they may be ignoring liveliness
|
||||||
// errors, like this one.
|
// errors, like this one.
|
||||||
|
|||||||
@@ -15,9 +15,22 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum Matrix specification version the js-sdk supports.
|
* A list of the spec versions which the js-sdk is compatible with.
|
||||||
*
|
*
|
||||||
* (This means that we require any servers we connect to to declare support for this spec version, so it is important
|
* In practice, this means: when we connect to a server, it must declare support for one of the versions in this list.
|
||||||
* for it not to be too old, as well as not too new.)
|
*
|
||||||
|
* Note that it does not *necessarily* mean that the js-sdk has good support for all the features in the listed spec
|
||||||
|
* versions; only that we should be able to provide a base level of functionality with a server that offers support for
|
||||||
|
* any of the listed versions.
|
||||||
*/
|
*/
|
||||||
export const MINIMUM_MATRIX_VERSION = "v1.5";
|
export const SUPPORTED_MATRIX_VERSIONS = ["v1.1", "v1.2", "v1.3", "v1.4", "v1.5", "v1.6", "v1.7", "v1.8", "v1.9"];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The oldest Matrix specification version the js-sdk supports.
|
||||||
|
*/
|
||||||
|
export const MINIMUM_MATRIX_VERSION = SUPPORTED_MATRIX_VERSIONS[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The most recent Matrix specification version the js-sdk supports.
|
||||||
|
*/
|
||||||
|
export const MAXIMUM_MATRIX_VERSION = SUPPORTED_MATRIX_VERSIONS[SUPPORTED_MATRIX_VERSIONS.length - 1];
|
||||||
|
|||||||
Reference in New Issue
Block a user