export type ChallengeRequest = {realm: string, username?: string | undefined, password?: string | undefined, ha1?: string | undefined, algorithm?: string | undefined, qop?: Array | undefined, max_expires?: number | undefined, app_id?: string | undefined}; export type CreateApiSipRegistrationsAttemptsIdChallengeArgs = {body: ChallengeRequest}; export type CreateApiSipRegistrationsAttemptsIdChallengeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Challenge a parked inbound REGISTER with a 401 digest auth request * * POST /sip/registrations/attempts/{id}/challenge */ export const createApiSipRegistrationsAttemptsIdChallenge = async (args: CreateApiSipRegistrationsAttemptsIdChallengeArgs, options?: CreateApiSipRegistrationsAttemptsIdChallengeOptions) => { const {baseUrl = "http://localhost:8080/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/sip/registrations/attempts/${encodeURIComponent(String(args.id))}/challenge${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 };