diff --git a/src/IConfigOptions.ts b/src/IConfigOptions.ts index 09b179bc84..395a97d3d4 100644 --- a/src/IConfigOptions.ts +++ b/src/IConfigOptions.ts @@ -17,7 +17,7 @@ limitations under the License. import { IClientWellKnown } from "matrix-js-sdk/src/matrix"; -import { ValidatedServerConfig } from "./utils/AutoDiscoveryUtils"; +import { ValidatedServerConfig } from "./utils/ValidatedServerConfig"; // Convention decision: All config options are lower_snake_case // We use an isolated file for the interface so we can mess around with the eslint options. diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index ea2852df3d..eb979c5798 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -61,7 +61,7 @@ import ThemeController from "../../settings/controllers/ThemeController"; import { startAnyRegistrationFlow } from "../../Registration"; import { messageForSyncError } from '../../utils/ErrorUtils'; import ResizeNotifier from "../../utils/ResizeNotifier"; -import AutoDiscoveryUtils, { ValidatedServerConfig } from "../../utils/AutoDiscoveryUtils"; +import AutoDiscoveryUtils from "../../utils/AutoDiscoveryUtils"; import DMRoomMap from '../../utils/DMRoomMap'; import ThemeWatcher from "../../settings/watchers/ThemeWatcher"; import { FontWatcher } from '../../settings/watchers/FontWatcher'; @@ -131,6 +131,7 @@ import { leaveRoomBehaviour } from "../../utils/leave-behaviour"; import VideoChannelStore from "../../stores/VideoChannelStore"; import { IRoomStateEventsActionPayload } from "../../actions/MatrixActionCreators"; import { UseCaseSelection } from '../views/elements/UseCaseSelection'; +import { ValidatedServerConfig } from '../../utils/ValidatedServerConfig'; // legacy export export { default as Views } from "../../Views"; diff --git a/src/components/structures/auth/ForgotPassword.tsx b/src/components/structures/auth/ForgotPassword.tsx index b1f8154792..0766dcd09c 100644 --- a/src/components/structures/auth/ForgotPassword.tsx +++ b/src/components/structures/auth/ForgotPassword.tsx @@ -24,7 +24,7 @@ import { createClient } from "matrix-js-sdk/src/matrix"; import { _t, _td } from '../../../languageHandler'; import Modal from "../../../Modal"; import PasswordReset from "../../../PasswordReset"; -import AutoDiscoveryUtils, { ValidatedServerConfig } from "../../../utils/AutoDiscoveryUtils"; +import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils"; import AuthPage from "../../views/auth/AuthPage"; import ServerPicker from "../../views/elements/ServerPicker"; import EmailField from "../../views/auth/EmailField"; @@ -39,6 +39,7 @@ import AuthBody from "../../views/auth/AuthBody"; import PassphraseConfirmField from "../../views/auth/PassphraseConfirmField"; import AccessibleButton from '../../views/elements/AccessibleButton'; import StyledCheckbox from '../../views/elements/StyledCheckbox'; +import { ValidatedServerConfig } from '../../../utils/ValidatedServerConfig'; enum Phase { // Show the forgot password inputs diff --git a/src/components/structures/auth/Login.tsx b/src/components/structures/auth/Login.tsx index e38fdb4180..1a102e97b4 100644 --- a/src/components/structures/auth/Login.tsx +++ b/src/components/structures/auth/Login.tsx @@ -23,7 +23,7 @@ import { _t, _td } from '../../../languageHandler'; import Login, { ISSOFlow, LoginFlow } from '../../../Login'; import SdkConfig from '../../../SdkConfig'; import { messageForResourceLimitError } from '../../../utils/ErrorUtils'; -import AutoDiscoveryUtils, { ValidatedServerConfig } from "../../../utils/AutoDiscoveryUtils"; +import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils"; import AuthPage from "../../views/auth/AuthPage"; import PlatformPeg from '../../../PlatformPeg'; import SettingsStore from "../../../settings/SettingsStore"; @@ -37,6 +37,7 @@ import ServerPicker from "../../views/elements/ServerPicker"; import AuthBody from "../../views/auth/AuthBody"; import AuthHeader from "../../views/auth/AuthHeader"; import AccessibleButton from '../../views/elements/AccessibleButton'; +import { ValidatedServerConfig } from '../../../utils/ValidatedServerConfig'; // These are used in several places, and come from the js-sdk's autodiscovery // stuff. We define them here so that they'll be picked up by i18n. diff --git a/src/components/structures/auth/Registration.tsx b/src/components/structures/auth/Registration.tsx index 92d72c8ac5..976f359961 100644 --- a/src/components/structures/auth/Registration.tsx +++ b/src/components/structures/auth/Registration.tsx @@ -22,7 +22,7 @@ import { logger } from "matrix-js-sdk/src/logger"; import { _t, _td } from '../../../languageHandler'; import { messageForResourceLimitError } from '../../../utils/ErrorUtils'; -import AutoDiscoveryUtils, { ValidatedServerConfig } from "../../../utils/AutoDiscoveryUtils"; +import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils"; import * as Lifecycle from '../../../Lifecycle'; import { IMatrixClientCreds, MatrixClientPeg } from "../../../MatrixClientPeg"; import AuthPage from "../../views/auth/AuthPage"; @@ -39,6 +39,7 @@ import Spinner from "../../views/elements/Spinner"; import { AuthHeaderDisplay } from './header/AuthHeaderDisplay'; import { AuthHeaderProvider } from './header/AuthHeaderProvider'; import SettingsStore from '../../../settings/SettingsStore'; +import { ValidatedServerConfig } from '../../../utils/ValidatedServerConfig'; const debuglog = (...args: any[]) => { if (SettingsStore.getValue("debug_registration")) { diff --git a/src/components/views/auth/PasswordLogin.tsx b/src/components/views/auth/PasswordLogin.tsx index db22393112..3f63f2a86c 100644 --- a/src/components/views/auth/PasswordLogin.tsx +++ b/src/components/views/auth/PasswordLogin.tsx @@ -19,7 +19,7 @@ import classNames from 'classnames'; import { _t } from '../../../languageHandler'; import SdkConfig from '../../../SdkConfig'; -import { ValidatedServerConfig } from "../../../utils/AutoDiscoveryUtils"; +import { ValidatedServerConfig } from '../../../utils/ValidatedServerConfig'; import AccessibleButton from "../elements/AccessibleButton"; import withValidation, { IValidationResult } from "../elements/Validation"; import Field from "../elements/Field"; diff --git a/src/components/views/auth/RegistrationForm.tsx b/src/components/views/auth/RegistrationForm.tsx index 113c09aaba..690acd5c31 100644 --- a/src/components/views/auth/RegistrationForm.tsx +++ b/src/components/views/auth/RegistrationForm.tsx @@ -26,7 +26,7 @@ import { _t, _td } from '../../../languageHandler'; import SdkConfig from '../../../SdkConfig'; import { SAFE_LOCALPART_REGEX } from '../../../Registration'; import withValidation, { IValidationResult } from '../elements/Validation'; -import { ValidatedServerConfig } from "../../../utils/AutoDiscoveryUtils"; +import { ValidatedServerConfig } from '../../../utils/ValidatedServerConfig'; import EmailField from "./EmailField"; import PassphraseField from "./PassphraseField"; import Field from '../elements/Field'; diff --git a/src/components/views/dialogs/ServerPickerDialog.tsx b/src/components/views/dialogs/ServerPickerDialog.tsx index 0761bb6b9d..1d4cc4ae81 100644 --- a/src/components/views/dialogs/ServerPickerDialog.tsx +++ b/src/components/views/dialogs/ServerPickerDialog.tsx @@ -18,7 +18,7 @@ import React, { createRef } from "react"; import { AutoDiscovery } from "matrix-js-sdk/src/autodiscovery"; import { logger } from "matrix-js-sdk/src/logger"; -import AutoDiscoveryUtils, { ValidatedServerConfig } from "../../../utils/AutoDiscoveryUtils"; +import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils"; import BaseDialog from './BaseDialog'; import { _t } from '../../../languageHandler'; import AccessibleButton from "../elements/AccessibleButton"; @@ -27,6 +27,7 @@ import Field from "../elements/Field"; import StyledRadioButton from "../elements/StyledRadioButton"; import TextWithTooltip from "../elements/TextWithTooltip"; import withValidation, { IFieldState } from "../elements/Validation"; +import { ValidatedServerConfig } from "../../../utils/ValidatedServerConfig"; interface IProps { title?: string; diff --git a/src/components/views/elements/ServerPicker.tsx b/src/components/views/elements/ServerPicker.tsx index 7276bd20c7..4cc60ebf02 100644 --- a/src/components/views/elements/ServerPicker.tsx +++ b/src/components/views/elements/ServerPicker.tsx @@ -17,7 +17,7 @@ limitations under the License. import React from 'react'; import AccessibleButton from "./AccessibleButton"; -import { ValidatedServerConfig } from "../../../utils/AutoDiscoveryUtils"; +import { ValidatedServerConfig } from '../../../utils/ValidatedServerConfig'; import { _t } from "../../../languageHandler"; import TextWithTooltip from "./TextWithTooltip"; import SdkConfig from "../../../SdkConfig"; diff --git a/src/utils/AutoDiscoveryUtils.tsx b/src/utils/AutoDiscoveryUtils.tsx index 101648569a..f995f93304 100644 --- a/src/utils/AutoDiscoveryUtils.tsx +++ b/src/utils/AutoDiscoveryUtils.tsx @@ -21,26 +21,13 @@ import { logger } from "matrix-js-sdk/src/logger"; import { _t, _td, newTranslatableError } from "../languageHandler"; import { makeType } from "./TypeUtils"; import SdkConfig from '../SdkConfig'; +import { ValidatedServerConfig } from './ValidatedServerConfig'; const LIVELINESS_DISCOVERY_ERRORS: string[] = [ AutoDiscovery.ERROR_INVALID_HOMESERVER, AutoDiscovery.ERROR_INVALID_IDENTITY_SERVER, ]; -export class ValidatedServerConfig { - hsUrl: string; - hsName: string; - hsNameIsDifferent: string; - - isUrl: string; - - isDefault: boolean; - // when the server config is based on static URLs the hsName is not resolvable and things may wish to use hsUrl - isNameResolvable: boolean; - - warning: string; -} - export interface IAuthComponentState { serverIsAlive: boolean; serverErrorIsFatal: boolean; diff --git a/src/utils/ValidatedServerConfig.ts b/src/utils/ValidatedServerConfig.ts new file mode 100644 index 0000000000..51cdde0840 --- /dev/null +++ b/src/utils/ValidatedServerConfig.ts @@ -0,0 +1,29 @@ +/* +Copyright 2022 The Matrix.org Foundation C.I.C. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +export class ValidatedServerConfig { + hsUrl: string; + hsName: string; + hsNameIsDifferent: string; + + isUrl: string; + + isDefault: boolean; + // when the server config is based on static URLs the hsName is not resolvable and things may wish to use hsUrl + isNameResolvable: boolean; + + warning: string; +} diff --git a/test/test-utils/test-utils.ts b/test/test-utils/test-utils.ts index 7a27a1165e..62ef22f92f 100644 --- a/test/test-utils/test-utils.ts +++ b/test/test-utils/test-utils.ts @@ -35,7 +35,7 @@ import { import { MatrixClientPeg as peg } from '../../src/MatrixClientPeg'; import dis from '../../src/dispatcher/dispatcher'; import { makeType } from "../../src/utils/TypeUtils"; -import { ValidatedServerConfig } from "../../src/utils/AutoDiscoveryUtils"; +import { ValidatedServerConfig } from "../../src/utils/ValidatedServerConfig"; import { EnhancedMap } from "../../src/utils/maps"; import { AsyncStoreWithClient } from "../../src/stores/AsyncStoreWithClient"; import MatrixClientBackedSettingsHandler from "../../src/settings/handlers/MatrixClientBackedSettingsHandler";