/** * Reading Sentry API responses. Hosts map what these return to their own * errors: the MCP to `ApiError` subclasses, the CLI to its exit-coded ones. */ /** What a failed response's body says, read once. */ export type ErrorResponseBody = { /** The raw body, or undefined when it could not be read. */ text: string | undefined; /** The parsed body, when it is JSON. */ json?: unknown; /** Why the body is not JSON, when it is not. */ parseError?: string; /** The server's `detail` message, when the JSON body has a string one. */ detail?: string; /** True when the body is an HTML page, usually from a proxy or a wrong URL. */ isHtml: boolean; /** Server-requested wait before retrying, from the rate-limit headers. */ retryAfterMs?: number; /** * Scopes the endpoint accepts, from a 403's `insufficient_scope` challenge; * see {@link parseInsufficientScopeChallenge}. Unset for other responses. */ acceptedScopes?: string[]; }; /** * Read the scopes from an RFC 6750 `insufficient_scope` challenge. * * Sentry answers a token that lacks every scope an endpoint accepts with a * 403, DRF's generic `detail`, and * `WWW-Authenticate: Bearer error="insufficient_scope", scope="..."` * (getsentry/sentry#118612). The header lists each scope the endpoint * accepts, and any one of them is enough. Other 403s, such as a token for * another organization, come without it. * * @param header - The `WWW-Authenticate` response header * @returns The accepted scopes in the server's order. Empty when the header * is missing or is not an `insufficient_scope` challenge. */ export declare function parseInsufficientScopeChallenge(header: string | null | undefined): string[]; /** Read the body of a failed response, consuming it. */ export declare function readErrorResponse(response: Response): Promise; /** * Parse a successful response as JSON, checking its Content-Type first. * * @throws {Error} When the body is HTML, another content type, or malformed */ export declare function readJsonResponse(response: Response): Promise;