import { APIClient } from "./ApiClient"; export interface ServerConfig { auth_disabled: boolean; oidc_provider_name: string; accounts_types: AccountType[]; constraints: ServerConstraints; } export interface AccountType { label: string; code: string; icon: string; } export interface ServerConstraints { token_name: LenConstraint; token_ip_net: LenConstraint; token_max_inactivity: LenConstraint; } export interface LenConstraint { min: number; max: number; } let config: ServerConfig | null = null; export class ServerApi { /** * Get server configuration */ static async LoadConfig(): Promise { config = ( await APIClient.exec({ uri: "/server/config", method: "GET", }) ).data; } /** * Get cached configuration */ static get Config(): ServerConfig { if (config === null) throw new Error("Missing configuration!"); return config; } }