export type CreateApiProductsIdentityAccountIdConsentArgs = {account_id: string, body: {auth_request: string, svid: string, decision: 'approve' | 'deny'}}; export type CreateApiProductsIdentityAccountIdConsentOptions = {baseUrl?: string | undefined, IdentityHubSessionCookie?: string | undefined, fetch?: typeof fetch | undefined}; /** * Approve or deny a resource grant on the hosted sign-in page * * POST /products/identity/{account_id}/consent */ export const createApiProductsIdentityAccountIdConsent = async (args: CreateApiProductsIdentityAccountIdConsentArgs, options?: CreateApiProductsIdentityAccountIdConsentOptions) => { const {baseUrl = "https://api.sparkvault.com/v1", fetch: fetchFn = fetch, IdentityHubSessionCookie} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") if (IdentityHubSessionCookie !== undefined) cookies.push("__Host-authsv_sso=" + encodeURIComponent(IdentityHubSessionCookie)) const url = `${baseUrl.replace(/\/+$/, '')}/products/identity/${encodeURIComponent(String(args.account_id))}/consent${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };