From 672fd2c9b26a5b7509f981c1ecd7295919c6df1e Mon Sep 17 00:00:00 2001 From: Callum Brown Date: Wed, 16 Feb 2022 17:26:18 +0000 Subject: [PATCH 1/2] Stabilise token authenticated registration support Token authenticated registration was added to the Matrix specification in v1.2: https://spec.matrix.org/v1.2/client-server-api/#token-authenticated-registration Signed-off-by: Callum Brown --- src/interactive-auth.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/interactive-auth.ts b/src/interactive-auth.ts index e55aa1d2ccb..b6d19f83fda 100644 --- a/src/interactive-auth.ts +++ b/src/interactive-auth.ts @@ -60,7 +60,7 @@ export enum AuthType { Sso = "m.login.sso", SsoUnstable = "org.matrix.login.sso", Dummy = "m.login.dummy", - RegistrationToken = "org.matrix.msc3231.login.registration_token", + RegistrationToken = "m.login.registration_token", } export interface IAuthDict { @@ -79,7 +79,8 @@ export interface IAuthDict { // eslint-disable-next-line camelcase threepid_creds?: any; threepidCreds?: any; - registrationToken?: string; + // For m.login.registration_token type + token?: string; } class NoAuthFlowFoundError extends Error { From 72bd2818f7b8b9abe014f7edd58e5ae76c591e30 Mon Sep 17 00:00:00 2001 From: Callum Brown Date: Fri, 18 Feb 2022 17:26:31 +0000 Subject: [PATCH 2/2] Backwards compatibility with unstable auth type Servers are not yet widely updated with support for the stable version of the registration token UIA type. Clients should check if the authentication type is either `RegistrationToken` or `UnstableRegistrationToken`. Signed-off-by: Callum Brown --- src/interactive-auth.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/interactive-auth.ts b/src/interactive-auth.ts index b6d19f83fda..f06369fe736 100644 --- a/src/interactive-auth.ts +++ b/src/interactive-auth.ts @@ -61,6 +61,10 @@ export enum AuthType { SsoUnstable = "org.matrix.login.sso", Dummy = "m.login.dummy", RegistrationToken = "m.login.registration_token", + // For backwards compatability with servers that have not yet updated to + // use the stable "m.login.registration_token" type. + // The authentication flow is the same in both cases. + UnstableRegistrationToken = "org.matrix.msc3231.login.registration_token", } export interface IAuthDict {