export type DeleteApiUserOptions = {baseUrl?: string | undefined, CookieAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Deletes the current user * * DELETE /user * * Also accepts auth: BearerTokenAuth */ export const deleteApiUser = async (options?: DeleteApiUserOptions) => { const {baseUrl = "https://.hanko.io/admin", fetch: fetchFn = fetch, CookieAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (CookieAuth !== undefined) cookies.push("hanko=" + encodeURIComponent(CookieAuth)) const url = `${baseUrl.replace(/\/+$/, '')}/user${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };