export type IdentityMfaMethodTotpRequest = {algorithm?: string | undefined, digits?: number | undefined, issuer?: string | undefined, key_size?: number | undefined, max_validation_attempts?: number | undefined, method_id?: string | undefined, period?: number | undefined, qr_size?: number | undefined, skew?: number | undefined}; export type CreateApiIdentityMfaMethodTotpMethodIdArgs = {body: IdentityMfaMethodTotpRequest}; export type CreateApiIdentityMfaMethodTotpMethodIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Update or create a configuration for the given MFA method * * POST /identity/mfa/method/totp/{method_id} */ export const createApiIdentityMfaMethodTotpMethodId = async (args: CreateApiIdentityMfaMethodTotpMethodIdArgs, options: CreateApiIdentityMfaMethodTotpMethodIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/identity/mfa/method/totp/${encodeURIComponent(String(args.method_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };