export type GetApiV1UafRequestsIdQrcodeArgs = {id: string, qrData?: Record | undefined, width?: number | undefined, height?: number | undefined, fg?: string | undefined, bg?: string | undefined}; export type GetApiV1UafRequestsIdQrcodeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the QR code for a given Hanko Authenticator request * * GET /v1/uaf/requests/{id}/qrcode */ export const getApiV1UafRequestsIdQrcode = async (args: GetApiV1UafRequestsIdQrcodeArgs, options?: GetApiV1UafRequestsIdQrcodeOptions) => { const {baseUrl = "https://.hanko.io/admin", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.qrData != null) query.append("qrData", JSON.stringify(args.qrData)) if (args.width != null) query.append("width", String(args.width)) if (args.height != null) query.append("height", String(args.height)) if (args.fg != null) query.append("fg", String(args.fg)) if (args.bg != null) query.append("bg", String(args.bg)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/uaf/requests/${encodeURIComponent(String(args.id))}/qrcode${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };