diff --git a/package.json b/package.json index ab2e118db3546d4d138c2375977c08207cc592aa..3a75bac5944682d07020942a1316ca12892dc128 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,6 @@ "vite": "^2.7.2" }, "dependencies": { - "hydrogen-view-sdk": "^0.0.10" + "hydrogen-view-sdk": "^0.0.11" } } diff --git a/src/main.ts b/src/main.ts index 91460d5322be5a05250758919749e3bfd6478202..9c3c83e1a26c778ca955733e81ba0c32ad4a9340 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,7 +36,7 @@ async function main() { } root.className = "hydrogen"; const config = await fetchConfig(); - const platform = new Platform(root, assetPaths, {}, { development: import.meta.env.DEV }); + const platform = new Platform({container: root, assetPaths, config: {}, options: { development: import.meta.env.DEV }}); const navigation = new Navigation(allowsChild); platform.setNavigation(navigation); const urlRouter = createRouter({ navigation, history: platform.history }); diff --git a/src/viewmodels/AccountSetupViewModel.ts b/src/viewmodels/AccountSetupViewModel.ts index 2444ef326266fdf33e6f7515d0b3c8fded006b55..9e46c51e921a14caf1e9f51f5f3c28865bd19989 100644 --- a/src/viewmodels/AccountSetupViewModel.ts +++ b/src/viewmodels/AccountSetupViewModel.ts @@ -25,7 +25,24 @@ export class AccountSetupViewModel extends ViewModel { for (let i = 0; i < maxAttempts; ++i) { try { const username = `${this._config.username_prefix}-${generateUsername(10)}`; - this._registration = await this._client.startRegistration(this._homeserver, username, this._password, "Chatterbox"); + const flowSelector = (flows) => { + const allowedStages = [ + "m.login.registration_token", + "org.matrix.msc3231.login.registration_token", + "m.login.terms", + "m.login.dummy" + ]; + for (const flow of flows) { + // Find the first flow that does not contain any unsupported stages but contains Token registration stage. + const containsUnsupportedStage = flow.stages.some(stage => !allowedStages.includes(stage)); + const containsTokenStage = flow.stages.includes("m.login.registration_token") || + flow.stages.includes("org.matrix.msc3231.login.registration_token"); + if (!containsUnsupportedStage && containsTokenStage) { + return flow; + } + } + } + this._registration = await this._client.startRegistration(this._homeserver, username, this._password, "Chatterbox", flowSelector); this._startStage = await this._registration.start(); let stage = this._startStage; while (stage && stage.type !== "m.login.terms") { diff --git a/yarn.lock b/yarn.lock index 77c7a0d3235a1bd272744a17175fabd9b1f64875..b441e1affc9cbe316ecaa980487377499b024824 100644 --- a/yarn.lock +++ b/yarn.lock @@ -163,10 +163,10 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -hydrogen-view-sdk@^0.0.10: - version "0.0.10" - resolved "https://registry.yarnpkg.com/hydrogen-view-sdk/-/hydrogen-view-sdk-0.0.10.tgz#be0c729db67e1d1511b7fa32aa101fd889ec9cdc" - integrity sha512-7Ni7ui0mQzKbz6noGDyS1ceIKjU5sjoyX6+2a5dk0nXwttrQYXJbrgblCWC3nIljQPbW+09o+t9BFE0OuBHDPw== +hydrogen-view-sdk@^0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/hydrogen-view-sdk/-/hydrogen-view-sdk-0.0.11.tgz#01c224b6bfd2f89d98d2f9e1816cd962411b9982" + integrity sha512-a7z9FEa078MNuSAtNhoJ82ircGTGVvHnRsl+BvDQaHvgVb01/ff2r81KdIqdqVwXzC9r2McqjTNPCwEKh2Xauw== dependencies: "@matrix-org/olm" "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.3.tgz" another-json "^0.2.0"