From 99407164001be3ef9f49e88e6b7d78865d5be7c0 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 21 Dec 2022 13:53:08 -0700 Subject: [PATCH 1/2] Remove usage of v1 Identity Server API It's been deprecated for over a year at this point - everyone should be able to support v2. --- spec/unit/autodiscovery.spec.ts | 12 ++++++------ src/autodiscovery.ts | 2 +- src/http-api/prefix.ts | 5 ----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/spec/unit/autodiscovery.spec.ts b/spec/unit/autodiscovery.spec.ts index 0b6f8036d61..f6db5327c7b 100644 --- a/spec/unit/autodiscovery.spec.ts +++ b/spec/unit/autodiscovery.spec.ts @@ -544,7 +544,7 @@ describe("AutoDiscovery", function () { .respond(200, { versions: ["r0.0.1"], }); - httpBackend.when("GET", "/_matrix/identity/api/v1").respond(404, {}); + httpBackend.when("GET", "/_matrix/identity/v2").respond(404, {}); httpBackend.when("GET", "/.well-known/matrix/client").respond(200, { "m.homeserver": { // Note: we also expect this test to trim the trailing slash @@ -591,7 +591,7 @@ describe("AutoDiscovery", function () { .respond(200, { versions: ["r0.0.1"], }); - httpBackend.when("GET", "/_matrix/identity/api/v1").respond(500, {}); + httpBackend.when("GET", "/_matrix/identity/v2").respond(500, {}); httpBackend.when("GET", "/.well-known/matrix/client").respond(200, { "m.homeserver": { // Note: we also expect this test to trim the trailing slash @@ -636,9 +636,9 @@ describe("AutoDiscovery", function () { versions: ["r0.0.1"], }); httpBackend - .when("GET", "/_matrix/identity/api/v1") + .when("GET", "/_matrix/identity/v2") .check((req) => { - expect(req.path).toEqual("https://identity.example.org/_matrix/identity/api/v1"); + expect(req.path).toEqual("https://identity.example.org/_matrix/identity/v2"); }) .respond(200, {}); httpBackend.when("GET", "/.well-known/matrix/client").respond(200, { @@ -682,9 +682,9 @@ describe("AutoDiscovery", function () { versions: ["r0.0.1"], }); httpBackend - .when("GET", "/_matrix/identity/api/v1") + .when("GET", "/_matrix/identity/v2") .check((req) => { - expect(req.path).toEqual("https://identity.example.org/_matrix/identity/api/v1"); + expect(req.path).toEqual("https://identity.example.org/_matrix/identity/v2"); }) .respond(200, {}); httpBackend.when("GET", "/.well-known/matrix/client").respond(200, { diff --git a/src/autodiscovery.ts b/src/autodiscovery.ts index aa839550f9e..c87ba198d52 100644 --- a/src/autodiscovery.ts +++ b/src/autodiscovery.ts @@ -214,7 +214,7 @@ export class AutoDiscovery { // Step 5b: Verify there is an identity server listening on the provided // URL. - const isResponse = await this.fetchWellKnownObject(`${isUrl}/_matrix/identity/api/v1`); + const isResponse = await this.fetchWellKnownObject(`${isUrl}/_matrix/identity/v2`); if (!isResponse?.raw || isResponse.action !== AutoDiscoveryAction.SUCCESS) { logger.error("Invalid /api/v1 response"); failingClientConfig["m.identity_server"].error = AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER; diff --git a/src/http-api/prefix.ts b/src/http-api/prefix.ts index c350b1dee17..f15b1ac1e77 100644 --- a/src/http-api/prefix.ts +++ b/src/http-api/prefix.ts @@ -34,11 +34,6 @@ export enum ClientPrefix { } export enum IdentityPrefix { - /** - * URI path for v1 of the identity API - * @deprecated Use v2. - */ - V1 = "/_matrix/identity/api/v1", /** * URI path for the v2 identity API */ From 83dcf01c48986fce199159efcbfa53e6961f2317 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 21 Dec 2022 14:11:03 -0700 Subject: [PATCH 2/2] Missed one. --- src/autodiscovery.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autodiscovery.ts b/src/autodiscovery.ts index c87ba198d52..0457175f389 100644 --- a/src/autodiscovery.ts +++ b/src/autodiscovery.ts @@ -216,7 +216,7 @@ export class AutoDiscovery { // URL. const isResponse = await this.fetchWellKnownObject(`${isUrl}/_matrix/identity/v2`); if (!isResponse?.raw || isResponse.action !== AutoDiscoveryAction.SUCCESS) { - logger.error("Invalid /api/v1 response"); + logger.error("Invalid /v2 response"); failingClientConfig["m.identity_server"].error = AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER; // Supply the base_url to the caller because they may be ignoring