export type CreateApiLoginSend2faArgs = {email: string, password: string}; export type CreateApiLoginSend2faOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send 2FA code * * POST /login/send/2fa */ export const createApiLoginSend2fa = async (args: CreateApiLoginSend2faArgs, options?: CreateApiLoginSend2faOptions) => { const {baseUrl = "https://api.sinao.app/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.email != null) query.append("email", String(args.email)) if (args.password != null) query.append("password", String(args.password)) const url = `${baseUrl.replace(/\/+$/, '')}/login/send/2fa${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };