diff --git a/src/SdkConfig.ts b/src/SdkConfig.ts index 7d7caa2d24..af2a706aaa 100644 --- a/src/SdkConfig.ts +++ b/src/SdkConfig.ts @@ -1,6 +1,6 @@ /* Copyright 2016 OpenMarket Ltd -Copyright 2019, 2020 The Matrix.org Foundation C.I.C. +Copyright 2019 - 2021 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. @@ -15,8 +15,17 @@ See the License for the specific language governing permissions and limitations under the License. */ +export interface ISsoRedirectOptions { + immediate?: boolean; + on_welcome_page?: boolean; // eslint-disable-line camelcase +} + export interface ConfigOptions { [key: string]: any; + + // sso_immediate_redirect is deprecated in favour of sso_redirect_options.immediate + sso_immediate_redirect?: boolean; // eslint-disable-line camelcase + sso_redirect_options?: ISsoRedirectOptions; // eslint-disable-line camelcase } export const DEFAULTS: ConfigOptions = { @@ -74,3 +83,14 @@ export default class SdkConfig { SdkConfig.put(newConfig); } } + +export function parseSsoRedirectOptions(config: ConfigOptions): ISsoRedirectOptions { + // Ignore deprecated options if the config is using new ones + if (config.sso_redirect_options) return config.sso_redirect_options; + + // We can cheat here because the default is false anyways + if (config.sso_immediate_redirect) return { immediate: true }; + + // Default: do nothing + return {}; +}