2021-01-02 17:58:24 +07:00
|
|
|
import { Configuration } from "../models/Configuration";
|
2020-06-21 20:40:37 +07:00
|
|
|
import { ConfigurationPath } from "./Api";
|
2021-01-02 17:58:24 +07:00
|
|
|
import { Get } from "./Client";
|
2019-12-07 23:40:42 +07:00
|
|
|
import { toEnum, Method2FA } from "./UserPreferences";
|
2019-11-19 06:37:36 +07:00
|
|
|
|
2020-06-21 20:40:37 +07:00
|
|
|
interface ConfigurationPayload {
|
2019-12-07 23:40:42 +07:00
|
|
|
available_methods: Method2FA[];
|
2020-03-06 07:31:09 +07:00
|
|
|
second_factor_enabled: boolean;
|
2020-03-25 08:48:20 +07:00
|
|
|
totp_period: number;
|
2019-12-07 23:40:42 +07:00
|
|
|
}
|
|
|
|
|
2020-06-21 20:40:37 +07:00
|
|
|
export async function getConfiguration(): Promise<Configuration> {
|
|
|
|
const config = await Get<ConfigurationPayload>(ConfigurationPath);
|
2019-12-07 23:40:42 +07:00
|
|
|
return { ...config, available_methods: new Set(config.available_methods.map(toEnum)) };
|
2021-01-02 17:58:24 +07:00
|
|
|
}
|