export type GetApiWellKnownOpenidConfigurationOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, authenticatedEncryption?: string | undefined, ethereum?: string | undefined, collabLandOAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /.well-known/openid-configuration */ export const getApiWellKnownOpenidConfiguration = async (options?: GetApiWellKnownOpenidConfigurationOptions) => { const {baseUrl = "https://api.collab.land", fetch: fetchFn = fetch, apiKey, authenticatedEncryption, ethereum, collabLandOAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKey !== undefined) headers.set("x-api-key", apiKey) if (authenticatedEncryption !== undefined) headers.set("Authorization", authenticatedEncryption) if (ethereum !== undefined) headers.set("Authorization", ethereum) if (collabLandOAuth2 !== undefined) headers.set('authorization', `Bearer ${collabLandOAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/.well-known/openid-configuration${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 };