import { HTTPError } from "../http-api/errors.ts"; /** * Errors expected to be encountered during OAuth2 discovery, client registration, and authentication. * Not intended to be displayed directly to the user. */ export declare enum OAuth2Error { General = "Something went wrong with OAuth2 discovery", OpSupport = "Configured OAuth2 OP does not support required functions", DynamicRegistrationNotSupported = "Dynamic registration not supported", DynamicRegistrationFailed = "Dynamic registration failed", DynamicRegistrationInvalid = "Dynamic registration invalid response", CodeExchangeFailed = "Failed to exchange code for token", InvalidBearerTokenResponse = "Invalid bearer token response", InvalidDeviceAuthorizationResponse = "Invalid device authorization response", MissingOrInvalidStoredState = "State required to finish logging in is not found in storage.", RefreshTokenFailed = "Failed to refresh token", RevokeTokenFailed = "Failed to revoke token", DeviceAuthorizationGrantFailed = "Failed to perform device authorization grant" } /** * An error response from an OAuth 2.0 endpoint, * as specified in https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 */ export interface OAuth2ErrorResponse { /** A single ASCII error code, e.g. `invalid_grant`. */ error: string; /** Human-readable ASCII text providing additional information about the error. */ error_description?: string; /** A URI identifying a human-readable web page with information about the error. */ error_uri?: string; } /** * Check whether the given (JSON-parsed) response body is an OAuth 2.0 error response * as specified in https://datatracker.ietf.org/doc/html/rfc6749#section-5.2 * @param response - the parsed response body to check * @returns whether the response is a valid {@link OAuth2ErrorResponse} */ export declare function isOAuth2ErrorResponse(response: unknown): response is OAuth2ErrorResponse; /** * An error thrown when a request to an OAuth 2.0 endpoint fails with a body matching the error * response format specified in [RFC 6749 section 5.2](https://datatracker.ietf.org/doc/html/rfc6749#section-5.2). */ export declare class OAuth2HTTPError extends HTTPError implements OAuth2ErrorResponse { /** * RFC 6749 section 5.2 error code, e.g. `invalid_grant` * * IANA matains a registry of valid values at * https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#extensions-error */ error: string; /** * RFC 6749 section 5.2 human-readable ASCII text providing additional information about the error. * This field is optional and may be omitted by the endpoint. */ error_description?: string; /** * RFC 6749 section 5.2 URI identifying a human-readable web page with information about the error. * This field is optional and may be omitted by the endpoint. */ error_uri?: string; constructor(msg: string, httpStatus: number | undefined, httpHeaders: Headers | undefined, { error, error_description, error_uri }: OAuth2ErrorResponse); } //# sourceMappingURL=error.d.ts.map