export type GetApiAuthLinkProviderArgs = {provider: 'github' | 'microsoft' | 'azure-ad' | 'google'}; export type GetApiAuthLinkProviderOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Link OAuth provider to account * * GET /auth/link/{provider} */ export const getApiAuthLinkProvider = async (args: GetApiAuthLinkProviderArgs, options: GetApiAuthLinkProviderOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/auth/link/${encodeURIComponent(String(args.provider))}${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 undefined };