2019-11-19 06:37:36 +07:00
|
|
|
import { Get } from "./Client";
|
2019-12-07 23:40:42 +07:00
|
|
|
import { ExtendedConfigurationPath, ConfigurationPath } from "./Api";
|
|
|
|
import { toEnum, Method2FA } from "./UserPreferences";
|
|
|
|
import { Configuration, ExtendedConfiguration } from "../models/Configuration";
|
2019-11-19 06:37:36 +07:00
|
|
|
|
2019-12-07 23:40:42 +07:00
|
|
|
export async function getConfiguration(): Promise<Configuration> {
|
|
|
|
return Get<Configuration>(ConfigurationPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ExtendedConfigurationPayload {
|
|
|
|
available_methods: Method2FA[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function getExtendedConfiguration(): Promise<ExtendedConfiguration> {
|
|
|
|
const config = await Get<ExtendedConfigurationPayload>(ExtendedConfigurationPath);
|
|
|
|
return { ...config, available_methods: new Set(config.available_methods.map(toEnum)) };
|
2019-11-19 06:37:36 +07:00
|
|
|
}
|