export type GetApiSamlMetadataArgs = {domain: string, cert_only?: boolean | undefined}; export type GetApiSamlMetadataOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get SAML Metadata * * GET /saml/metadata */ export const getApiSamlMetadata = async (args: GetApiSamlMetadataArgs, options?: GetApiSamlMetadataOptions) => { const {baseUrl = "https://.hanko.io/admin", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.domain != null) query.append("domain", String(args.domain)) if (args.cert_only != null) query.append("cert_only", String(args.cert_only)) const url = `${baseUrl.replace(/\/+$/, '')}/saml/metadata${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() };