/** * Utility to extract OAuth error details from oauth4webapi errors. * * oauth4webapi's `parseOAuthResponseErrorBody()` only parses error bodies for * HTTP 4xx responses (producing `ResponseBodyError` with `.error` and * `.error_description`). For 5xx responses (e.g., when Auth0 Actions use * `api.access.deny()`), it throws `OperationProcessingError` with the raw * `Response` as `.cause`, losing the structured error information. * * This helper recovers those details by checking: * 1. If the error already has `.error` (ResponseBodyError from 4xx) → use directly * 2. If `.cause` is a `Response` (OperationProcessingError from 5xx) → parse JSON body * 3. Otherwise → return empty object * * See: https://github.com/auth0/nextjs-auth0/issues/2512 */ export interface OAuthErrorDetails { error?: string; error_description?: string; } /** * Extract `error` and `error_description` from an oauth4webapi error, * handling both 4xx `ResponseBodyError` and 5xx `OperationProcessingError`. * * Returns `{}` (empty `OAuthErrorDetails`) when the error structure is * unrecognized or the 5xx response body is not JSON / lacks error fields. * Callers should guard with `if (oauthErr.error)` before using the result. */ export declare function extractOAuthErrorDetails(err: unknown): Promise;