export type IdentityOidcIntrospectRequest = {client_id?: string | undefined, token?: string | undefined}; export type CreateApiIdentityOidcIntrospectArgs = {body: IdentityOidcIntrospectRequest}; export type CreateApiIdentityOidcIntrospectOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Verify the authenticity of an OIDC token * * POST /identity/oidc/introspect */ export const createApiIdentityOidcIntrospect = async (args: CreateApiIdentityOidcIntrospectArgs, options: CreateApiIdentityOidcIntrospectOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/identity/oidc/introspect${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 };