From 378802a5ab1a50ea9c71a9fc9e956bd52773c1d0 Mon Sep 17 00:00:00 2001 From: Callum Brown Date: Sat, 9 Apr 2022 05:53:57 +0100 Subject: [PATCH] Stabilise token authenticated registration support (#2181) * 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 * 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/interactive-auth.ts b/src/interactive-auth.ts index e55aa1d2ccb..f06369fe736 100644 --- a/src/interactive-auth.ts +++ b/src/interactive-auth.ts @@ -60,7 +60,11 @@ 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", + // 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 { @@ -79,7 +83,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 {