export type HeadApiApiV3UserOptions = {baseUrl: string, cookieAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Poll session status * * HEAD /api/v3/user */ export const headApiApiV3User = async (options: HeadApiApiV3UserOptions) => { const {baseUrl, fetch: fetchFn = fetch, cookieAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (cookieAuth !== undefined) cookies.push("JSESSIONID=" + encodeURIComponent(cookieAuth)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/user${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "HEAD", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };