From 20db27fa7ef1cbb9682780ecb4dbdf96cc4540ec Mon Sep 17 00:00:00 2001
From: Ajay Bura <32841439+ajbura@users.noreply.github.com>
Date: Sun, 21 Jan 2024 23:50:56 +1100
Subject: [PATCH] feat: URL navigation in auth (#1603)
* bump to react 18 and install react-router-dom
* Upgrade to react 18 root
* update vite
* add cs api's
* convert state/auth to ts
* add client config context
* add auto discovery context
* add spec version context
* add auth flow context
* add background dot pattern css
* add promise utils
* init url based routing
* update auth route server path as effect
* add auth server hook
* always use server from discovery info in context
* login - WIP
* upgrade jotai to v2
* add atom with localStorage util
* add multi account sessions atom
* add default IGNORE res to auto discovery
* add error type in async callback hook
* handle password login error
* fix async callback hook
* allow password login
* Show custom server not allowed error in mxId login
* add sso login component
* add token login
* fix hardcoded m.login.password in login func
* update server input on url change
* Improve sso login labels
* update folds
* fix async callback batching state update in safari
* wrap async callback set state in queueMicrotask
* wip
* wip - register
* arrange auth file structure
* add error codes
* extract filed error component form password login
* add register util function
* handle register flow - WIP
* update unsupported auth flow method reasons
* improve password input styles
* Improve UIA flow next stage calculation
complete stages can have any order so we will look for first stage which is not in completed
* process register UIA flow stages
* Extract register UIA stages component
* improve register error messages
* add focus trap & step count in UIA stages
* add reset password path and path utils
* add path with origin hook
* fix sso redirect url
* rename register token query param to token
* restyle auth screen header
* add reset password component - WIP
* add reset password form
* add netlify rewrites
* fix netlify file indentation
* test netlify redirect
* fix vite to include netlify toml
* add more netlify redirects
* add splat to public and assets path
* fix vite base name
* add option to use hash router in config and remove appVersion
* add splash screen component
* add client config loading and error screen
* fix server picker bug
* fix reset password email input type
* make auth page small screen responsive
* fix typo in reset password screen
---
_redirects | 3 -
build.config.ts | 3 +
config.json | 7 +-
index.html | 2 +-
netlify.toml | 34 +
package-lock.json | 1024 ++++++++++-------
package.json | 22 +-
src/app/components/AuthFlowsLoader.tsx | 64 ++
src/app/components/ClientConfigLoader.tsx | 38 +
src/app/components/ConfirmPasswordMatch.tsx | 35 +
src/app/components/SpecVersionsLoader.tsx | 32 +
.../components/SupportedUIAFlowsLoader.tsx | 17 +
src/app/components/UIAFlowOverlay.tsx | 72 ++
.../password-input/PasswordInput.tsx | 45 +
.../splash-screen/SplashScreen.css.ts | 12 +
.../components/splash-screen/SplashScreen.tsx | 29 +
src/app/components/splash-screen/index.ts | 1 +
src/app/components/uia-stages/DummyStage.tsx | 65 ++
src/app/components/uia-stages/EmailStage.tsx | 172 +++
.../components/uia-stages/ReCaptchaStage.tsx | 64 ++
.../uia-stages/RegistrationTokenStage.tsx | 117 ++
src/app/components/uia-stages/TermsStage.tsx | 69 ++
src/app/components/uia-stages/index.ts | 6 +
src/app/components/uia-stages/types.ts | 8 +
src/app/cs-api.ts | 115 ++
src/app/cs-errorcode.ts | 37 +
src/app/hooks/types.ts | 12 +
src/app/hooks/useAsyncCallback.ts | 48 +-
src/app/hooks/useAuthFlows.ts | 59 +
src/app/hooks/useAuthServer.ts | 14 +
src/app/hooks/useAutoDiscoveryInfo.ts | 15 +
src/app/hooks/useClientConfig.ts | 33 +
src/app/hooks/useCrossSigningStatus.js | 2 +-
src/app/hooks/useParsedLoginFlows.ts | 38 +
src/app/hooks/usePasswordEmail.ts | 32 +
src/app/hooks/usePathWithOrigin.ts | 26 +
src/app/hooks/useRegisterEmail.ts | 32 +
src/app/hooks/useSpecVersions.ts | 12 +
src/app/hooks/useUIAFlows.ts | 96 ++
.../molecules/room-aliases/RoomAliases.jsx | 4 +-
.../RoomHistoryVisibility.jsx | 4 +-
.../room-notification/RoomNotification.jsx | 4 +-
src/app/molecules/room-search/RoomSearch.jsx | 4 +-
.../room-visibility/RoomVisibility.jsx | 4 +-
.../emoji-verification/EmojiVerification.jsx | 2 +-
.../organisms/room/message/UrlPreviewCard.tsx | 5 +-
.../organisms/space-manage/SpaceManage.jsx | 4 +-
src/app/pages/App.jsx | 17 -
src/app/pages/App.tsx | 82 ++
src/app/pages/ConfigConfig.tsx | 53 +
src/app/pages/auth/AuthFooter.tsx | 28 +
src/app/pages/auth/AuthLayout.tsx | 215 ++++
src/app/pages/auth/FiledError.tsx | 13 +
src/app/pages/auth/OrDivider.tsx | 12 +
src/app/pages/auth/SSOLogin.tsx | 68 ++
src/app/pages/auth/ServerPicker.tsx | 140 +++
src/app/pages/auth/index.ts | 4 +
src/app/pages/auth/login/Login.tsx | 73 ++
.../pages/auth/login/PasswordLoginForm.tsx | 272 +++++
src/app/pages/auth/login/TokenLogin.tsx | 94 ++
src/app/pages/auth/login/index.ts | 1 +
src/app/pages/auth/login/loginUtil.ts | 118 ++
.../auth/register/PasswordRegisterForm.tsx | 420 +++++++
src/app/pages/auth/register/Register.tsx | 95 ++
src/app/pages/auth/register/index.ts | 1 +
src/app/pages/auth/register/registerUtil.ts | 125 ++
.../auth/reset-password/PasswordResetForm.tsx | 274 +++++
.../auth/reset-password/ResetPassword.tsx | 36 +
src/app/pages/auth/reset-password/index.ts | 1 +
.../auth/reset-password/resetPasswordUtil.ts | 23 +
src/app/pages/auth/styles.css.ts | 53 +
src/app/pages/pathUtils.ts | 28 +
src/app/pages/paths.ts | 17 +
src/app/state/hooks/inviteList.ts | 37 +-
src/app/state/hooks/roomList.ts | 34 +-
src/app/state/hooks/settings.ts | 20 +-
src/app/state/inviteList.ts | 4 +-
src/app/state/list.ts | 2 +-
src/app/state/mDirectList.ts | 9 +-
src/app/state/mutedRoomList.ts | 9 +-
src/app/state/roomList.ts | 9 +-
src/app/state/roomToParents.ts | 6 +-
src/app/state/roomToUnread.ts | 6 +-
src/app/state/sessions.ts | 129 +++
src/app/state/settings.ts | 2 +-
src/app/state/tabToRoom.ts | 2 +-
src/app/state/typingMembers.ts | 6 +-
src/app/state/upload.ts | 2 +-
src/app/state/utils.ts | 2 +-
src/app/state/utils/atomWithLocalStorage.ts | 51 +
src/app/styles/Patterns.css.ts | 9 +
src/app/utils/common.ts | 18 +
src/app/utils/matrix-uia.ts | 84 ++
src/app/utils/regex.ts | 3 +
src/client/action/auth.js | 2 +-
src/client/initMatrix.js | 3 +-
src/client/state/auth.js | 19 -
src/client/state/auth.ts | 12 +
src/ext.d.ts | 7 +
src/{index.jsx => index.tsx} | 17 +-
src/types/utils.ts | 3 +
tsconfig.json | 1 +
vite.config.js | 7 +-
103 files changed, 4775 insertions(+), 546 deletions(-)
delete mode 100644 _redirects
create mode 100644 build.config.ts
create mode 100644 netlify.toml
create mode 100644 src/app/components/AuthFlowsLoader.tsx
create mode 100644 src/app/components/ClientConfigLoader.tsx
create mode 100644 src/app/components/ConfirmPasswordMatch.tsx
create mode 100644 src/app/components/SpecVersionsLoader.tsx
create mode 100644 src/app/components/SupportedUIAFlowsLoader.tsx
create mode 100644 src/app/components/UIAFlowOverlay.tsx
create mode 100644 src/app/components/password-input/PasswordInput.tsx
create mode 100644 src/app/components/splash-screen/SplashScreen.css.ts
create mode 100644 src/app/components/splash-screen/SplashScreen.tsx
create mode 100644 src/app/components/splash-screen/index.ts
create mode 100644 src/app/components/uia-stages/DummyStage.tsx
create mode 100644 src/app/components/uia-stages/EmailStage.tsx
create mode 100644 src/app/components/uia-stages/ReCaptchaStage.tsx
create mode 100644 src/app/components/uia-stages/RegistrationTokenStage.tsx
create mode 100644 src/app/components/uia-stages/TermsStage.tsx
create mode 100644 src/app/components/uia-stages/index.ts
create mode 100644 src/app/components/uia-stages/types.ts
create mode 100644 src/app/cs-api.ts
create mode 100644 src/app/cs-errorcode.ts
create mode 100644 src/app/hooks/types.ts
create mode 100644 src/app/hooks/useAuthFlows.ts
create mode 100644 src/app/hooks/useAuthServer.ts
create mode 100644 src/app/hooks/useAutoDiscoveryInfo.ts
create mode 100644 src/app/hooks/useClientConfig.ts
create mode 100644 src/app/hooks/useParsedLoginFlows.ts
create mode 100644 src/app/hooks/usePasswordEmail.ts
create mode 100644 src/app/hooks/usePathWithOrigin.ts
create mode 100644 src/app/hooks/useRegisterEmail.ts
create mode 100644 src/app/hooks/useSpecVersions.ts
create mode 100644 src/app/hooks/useUIAFlows.ts
delete mode 100644 src/app/pages/App.jsx
create mode 100644 src/app/pages/App.tsx
create mode 100644 src/app/pages/ConfigConfig.tsx
create mode 100644 src/app/pages/auth/AuthFooter.tsx
create mode 100644 src/app/pages/auth/AuthLayout.tsx
create mode 100644 src/app/pages/auth/FiledError.tsx
create mode 100644 src/app/pages/auth/OrDivider.tsx
create mode 100644 src/app/pages/auth/SSOLogin.tsx
create mode 100644 src/app/pages/auth/ServerPicker.tsx
create mode 100644 src/app/pages/auth/index.ts
create mode 100644 src/app/pages/auth/login/Login.tsx
create mode 100644 src/app/pages/auth/login/PasswordLoginForm.tsx
create mode 100644 src/app/pages/auth/login/TokenLogin.tsx
create mode 100644 src/app/pages/auth/login/index.ts
create mode 100644 src/app/pages/auth/login/loginUtil.ts
create mode 100644 src/app/pages/auth/register/PasswordRegisterForm.tsx
create mode 100644 src/app/pages/auth/register/Register.tsx
create mode 100644 src/app/pages/auth/register/index.ts
create mode 100644 src/app/pages/auth/register/registerUtil.ts
create mode 100644 src/app/pages/auth/reset-password/PasswordResetForm.tsx
create mode 100644 src/app/pages/auth/reset-password/ResetPassword.tsx
create mode 100644 src/app/pages/auth/reset-password/index.ts
create mode 100644 src/app/pages/auth/reset-password/resetPasswordUtil.ts
create mode 100644 src/app/pages/auth/styles.css.ts
create mode 100644 src/app/pages/pathUtils.ts
create mode 100644 src/app/pages/paths.ts
create mode 100644 src/app/state/sessions.ts
create mode 100644 src/app/state/utils/atomWithLocalStorage.ts
create mode 100644 src/app/styles/Patterns.css.ts
create mode 100644 src/app/utils/matrix-uia.ts
delete mode 100644 src/client/state/auth.js
create mode 100644 src/client/state/auth.ts
rename src/{index.jsx => index.tsx} (57%)
create mode 100644 src/types/utils.ts
diff --git a/_redirects b/_redirects
deleted file mode 100644
index 270cd3386..000000000
--- a/_redirects
+++ /dev/null
@@ -1,3 +0,0 @@
-# Redirects from what the browser requests to what we serve
-/login /
-/register /
diff --git a/build.config.ts b/build.config.ts
new file mode 100644
index 000000000..ec8a41d08
--- /dev/null
+++ b/build.config.ts
@@ -0,0 +1,3 @@
+export default {
+ base: '/',
+};
diff --git a/config.json b/config.json
index 0ff493a17..484c7cd78 100644
--- a/config.json
+++ b/config.json
@@ -8,5 +8,10 @@
"mozilla.org",
"xmr.se"
],
- "allowCustomHomeservers": true
+ "allowCustomHomeservers": true,
+
+ "hashRouter": {
+ "enabled": false,
+ "basename": "/"
+ }
}
diff --git a/index.html b/index.html
index 6bc955c14..48f8e69eb 100644
--- a/index.html
+++ b/index.html
@@ -96,6 +96,6 @@
-
+