export type NeonAuthSupportedAuthProvider = 'mock' | 'stack' | 'better_auth'; export type NeonAuthAddDomainToRedirectURIWhitelistRequest = {domain: string, auth_provider: NeonAuthSupportedAuthProvider}; export type CreateApiProjectsProjectIdBranchesBranchIdAuthDomainsArgs = {body: NeonAuthAddDomainToRedirectURIWhitelistRequest}; export type CreateApiProjectsProjectIdBranchesBranchIdAuthDomainsOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add domain to redirect_uri whitelist * * POST /projects/{project_id}/branches/{branch_id}/auth/domains * * Also accepts auth: CookieAuth, TokenCookieAuth */ export const createApiProjectsProjectIdBranchesBranchIdAuthDomains = async (args: CreateApiProjectsProjectIdBranchesBranchIdAuthDomainsArgs, options?: CreateApiProjectsProjectIdBranchesBranchIdAuthDomainsOptions) => { const {baseUrl = "https://console.neon.tech/api/v2", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/projects/${encodeURIComponent(String(args.project_id))}/branches/${encodeURIComponent(String(args.branch_id))}/auth/domains${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };