export type BackupCodeTwoFaAccountConfig = {useByDefault?: boolean | undefined, providerType: string, codes: Array, codesLeft?: number | undefined}; export type EmailTwoFaAccountConfig = {useByDefault?: boolean | undefined, providerType: string, email: string}; export type SmsTwoFaAccountConfig = {useByDefault?: boolean | undefined, providerType: string, phoneNumber: string}; export type TotpTwoFaAccountConfig = {useByDefault?: boolean | undefined, providerType: string, authUrl: string}; export type CreateApiApi2faAccountConfigSubmitArgs = {body: BackupCodeTwoFaAccountConfig | EmailTwoFaAccountConfig | SmsTwoFaAccountConfig | TotpTwoFaAccountConfig}; export type CreateApiApi2faAccountConfigSubmitOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Submit 2FA account config (submitTwoFaAccountConfig) * * POST /api/2fa/account/config/submit */ export const createApiApi2faAccountConfigSubmit = async (args: CreateApiApi2faAccountConfigSubmitArgs, options?: CreateApiApi2faAccountConfigSubmitOptions) => { const {baseUrl = "https://demo.thingsboard.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/2fa/account/config/submit${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 };