export type MfaPreferenceRequest = {mfaOptions: Array<'EMAIL' | 'SOFTWARE_TOKEN'>, preferredMfa?: string | undefined}; export type UpdateApiUsersUsernameMfaArgs = {username: string, body: MfaPreferenceRequest}; export type UpdateApiUsersUsernameMfaOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Change role of an existing user * * PUT /users/{username}/mfa */ export const updateApiUsersUsernameMfa = async (args: UpdateApiUsersUsernameMfaArgs, options?: UpdateApiUsersUsernameMfaOptions) => { const {baseUrl = "https://api.quivo.co", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/users/${encodeURIComponent(String(args.username))}/mfa${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };