From 7685852b0e6ba0a323b8ee303c7f1e17c4711fbc Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 17 Oct 2022 18:50:50 +0530 Subject: [PATCH 1/3] Upgrade SDK --- package.json | 4 ++-- yarn.lock | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index bbb604a..093614f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "author": "matrix.org", "license": "Apache-2.0", "scripts": { - "start": "vite", + "start": "vite --port 5400", "build": "tsc && vite build && vite build --config parent-vite.config.js && scripts/after-build.sh", "preview": "vite preview" }, @@ -19,6 +19,6 @@ "dependencies": { "@sentry/browser": "^7.5.0", "@sentry/tracing": "^7.5.0", - "hydrogen-view-sdk": "^0.1.0" + "hydrogen-view-sdk": "^0.1.1" } } diff --git a/yarn.lock b/yarn.lock index edfa91e..53dcffb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -133,7 +133,7 @@ aggregate-error@^3.0.0: another-json@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/another-json/-/another-json-0.2.0.tgz#b5f4019c973b6dd5c6506a2d93469cb6d32aeedc" - integrity sha1-tfQBnJc7bdXGUGotk0acttMq7tw= + integrity sha512-/Ndrl68UQLhnCdsAzEXLMFuOR546o2qbYRqCglaNHbjXrwG1ayTcdwr3zkSGOGtGXDyR5X9nCFfnyG2AFJIsqg== ansi-colors@^4.1.1: version "4.1.3" @@ -356,9 +356,9 @@ concat-map@0.0.1: integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== core-js@^3.6.5: - version "3.22.2" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.22.2.tgz#3ea0a245b0895fa39d1faa15fe75d91ade504a01" - integrity sha512-Z5I2vzDnEIqO2YhELVMFcL1An2CIsFe9Q7byZhs8c/QxummxZlAHw33TUHbIte987LkisOgL0LwQ1P9D6VISnA== + version "3.25.5" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.25.5.tgz#e86f651a2ca8a0237a5f064c2fe56cef89646e27" + integrity sha512-nbm6eZSjm+ZuBQxCUPQKQCoUEfFOXjUZ8dTTyikyKaWrTYmAVbykQfwsKE5dBK88u3QCkCrzsx/PPlKfhsvgpw== core-util-is@1.0.2: version "1.0.2" @@ -459,9 +459,9 @@ delayed-stream@~1.0.0: integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== dompurify@^2.3.0: - version "2.3.6" - resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.3.6.tgz#2e019d7d7617aacac07cbbe3d88ae3ad354cf875" - integrity sha512-OFP2u/3T1R5CEgWCEONuJ1a5+MFKnOYpkywpUSxv/dj1LeBT1erK+JwM7zK0ROy2BRhqVCf0LRw/kHqKuMkVGg== + version "2.4.0" + resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.4.0.tgz#c9c88390f024c2823332615c9e20a453cf3825dd" + integrity sha512-Be9tbQMZds4a3C6xTmz68NlMfeONA//4dOavl/1rNw50E+/QO0KVpbcU0PcaW0nsQxurXls9ZocqFxk8R2mWEA== ecc-jsbn@~0.1.1: version "0.1.2" @@ -798,10 +798,10 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== -hydrogen-view-sdk@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/hydrogen-view-sdk/-/hydrogen-view-sdk-0.1.0.tgz#564af3a14030a988d4870e036044824b1fcb33b7" - integrity sha512-BkQ7PdWxK/vZRsxsChjaByTUEp7FoB96Dya6fpldUv9OAVZE8kyW/z2Xh4chR1mMMf9SrjYLThXZQs+sHvWWFg== +hydrogen-view-sdk@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/hydrogen-view-sdk/-/hydrogen-view-sdk-0.1.1.tgz#9b221bc63c48c1aec631ed6d5296643f6840c720" + integrity sha512-xSWLu1Y0JqP0RaFWoWJYa5VWPlz8TeBif6qk0U9RVFACzF/asYYq7Ti0J3JwhR6AZSpFONKCIuC6TuTUGRoN7g== dependencies: "@matrix-org/olm" "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz" another-json "^0.2.0" From c700405a4ec9dc1279a90928857f1c3c62f928ff Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 17 Oct 2022 18:53:23 +0530 Subject: [PATCH 2/3] Pass dev flag and theme manifests to Platform --- src/main.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index f0af0d1..81f27c0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -79,7 +79,12 @@ async function main() { } } - const platform = new Platform({container: root, assetPaths, config: {}, options: { development: import.meta.env.DEV }}); + const platform = new Platform({ + container: root, + assetPaths, + config: { themeManifests: [] }, + options: { development: import.meta.env.DEV }, + }); attachLogExportToWindow(platform); const navigation = new Navigation(allowsChild); platform.setNavigation(navigation); From d0029bce6c67fe8a222477bdf2b8b8754c8ce413 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 17 Oct 2022 18:56:22 +0530 Subject: [PATCH 3/3] Don't login after registration --- src/viewmodels/AccountSetupViewModel.ts | 15 ++++++--------- src/viewmodels/RootViewModel.ts | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/viewmodels/AccountSetupViewModel.ts b/src/viewmodels/AccountSetupViewModel.ts index 454fea2..b7eff5a 100644 --- a/src/viewmodels/AccountSetupViewModel.ts +++ b/src/viewmodels/AccountSetupViewModel.ts @@ -24,7 +24,6 @@ export class AccountSetupViewModel extends ViewModel { private _config: IChatterboxConfig; private _client: typeof Client; private _startStage?: any; - private _password: string; private _registration: any; private _privacyPolicyLink: string; private _showButtonSpinner: boolean = false; @@ -37,7 +36,7 @@ export class AccountSetupViewModel extends ViewModel { } private async _startRegistration(): Promise { - this._password = generatePassword(10); + const password = generatePassword(10); const maxAttempts = 10; for (let i = 0; i < maxAttempts; ++i) { try { @@ -59,7 +58,7 @@ export class AccountSetupViewModel extends ViewModel { } } } - this._registration = await this._client.startRegistration(this._homeserver, username, this._password, "Chatterbox", flowSelector); + this._registration = await this._client.startRegistration(this._homeserver, username, password, "Chatterbox", flowSelector); this._startStage = await this._registration.start(); let stage = this._startStage; while (stage && stage.type !== "m.login.terms") { @@ -95,14 +94,12 @@ export class AccountSetupViewModel extends ViewModel { } stage = await this._registration.submitStage(stage); } - const loginPromise = this.login(this._password); - this.navigation.push("timeline", loginPromise); + const promise = this.setupSession(); + this.navigation.push("timeline", promise); } - async login(password: string): Promise { - const loginOptions = await this._client.queryLogin(this._homeserver).result; - const username = this._registration.sessionInfo.user_id; - this._client.startWithLogin(loginOptions.password(username, password)); + async setupSession(): Promise { + this._client.startWithAuthData(this._registration.authData); await this._client.loadStatus.waitFor((status: string) => { return status === LoadStatus.Ready || status === LoadStatus.Error || diff --git a/src/viewmodels/RootViewModel.ts b/src/viewmodels/RootViewModel.ts index cd80268..17928ac 100644 --- a/src/viewmodels/RootViewModel.ts +++ b/src/viewmodels/RootViewModel.ts @@ -49,7 +49,7 @@ export class RootViewModel extends ViewModel { private _setupNavigation() { this.navigation.observe("account-setup").subscribe(() => this._showAccountSetup()); - this.navigation.observe("timeline").subscribe((loginPromise) => this._showTimeline(loginPromise)); + this.navigation.observe("timeline").subscribe((setupSessionPromise) => this._showTimeline(setupSessionPromise)); this.navigation.observe("minimize").subscribe(() => this.minimizeChatterbox()); }