import { type TypedEventEmitter } from "../models/typed-event-emitter.ts"; import { Method } from "./method.ts"; import { type BaseRequestOpts, HttpApiEvent, type HttpApiEventHandlerMap, type IHttpOpts, type IRequestOpts, type Body } from "./interface.ts"; import { type QueryDict } from "../utils.ts"; export declare class FetchHttpApi { private eventEmitter; readonly opts: O; private abortController; private readonly tokenManager; constructor(eventEmitter: TypedEventEmitter, opts: O); abort(): void; /** * Attempt to revoke the current access and refresh tokens with the OAuth2 authorization server, e.g. as * part of logging out an OAuth2-native session. Does nothing if `opts.oauth2ClientConfig` was not supplied. * @throws when discovery of the auth server metadata, or revocation of either token, fails */ revokeOAuthTokens(): Promise; fetch(resource: URL | string, options?: RequestInit): ReturnType; /** * Sets the base URL for the identity server * @param url - The new base url */ setIdBaseUrl(url?: string): void; idServerRequest>(method: Method, path: string, params: Record | undefined, prefix: string, accessToken?: string): Promise; /** * Perform an authorised request to the homeserver. * @param method - The HTTP method e.g. "GET". * @param path - The HTTP path after the supplied prefix e.g. * "/createRoom". * * @param queryParams - A dict of query params (these will NOT be * urlencoded). If unspecified, there will be no query params. * * @param body - The HTTP JSON body. * * @param paramOpts - additional options. * When `paramOpts.doNotAttemptTokenRefresh` is true, token refresh will not be attempted * when an expired token is encountered. Used to only attempt token refresh once. * * @returns The parsed response. * @throws Error if a problem occurred. This includes network problems and Matrix-specific error JSON. */ authedRequest(method: Method, path: string, queryParams?: QueryDict, body?: Body, paramOpts?: IRequestOpts): Promise; /** * Perform an authenticated request, ensuring that the access token is fresh before it is made, and * refreshing the token and retrying the request if it fails with `M_UNKNOWN_TOKEN`. * * Emits {@link HttpApiEvent.SessionLoggedOut} and {@link HttpApiEvent.NoConsent} as appropriate. * * @param request - performs the request using the given access token, and rejects with a * {@link MatrixError} if the homeserver returns an error. May be called more than once. * @param inhibitLogoutEmit - if true, {@link HttpApiEvent.SessionLoggedOut} will not be emitted. * @param attempt - the number of attempts made so far, including this one. Used to back off between * token refresh attempts. * @returns the result of `request`. */ protected withTokenRefresh(request: (accessToken: string | undefined) => Promise, inhibitLogoutEmit?: boolean, attempt?: number): Promise; /** * Perform a request to the homeserver without any credentials. * @param method - The HTTP method e.g. "GET". * @param path - The HTTP path after the supplied prefix e.g. * "/createRoom". * * @param queryParams - A dict of query params (these will NOT be * urlencoded). If unspecified, there will be no query params. * * @param body - The HTTP JSON body. * * @param opts - additional options * * @returns The parsed response. * @throws Error if a problem occurred. This includes network problems and Matrix-specific error JSON. */ request(method: Method, path: string, queryParams?: QueryDict, body?: Body, opts?: IRequestOpts): Promise; /** * Perform a request to an arbitrary URL. * @param method - The HTTP method e.g. "GET". * @param url - The HTTP URL object. * * @param body - The HTTP JSON body. * * @param opts - additional options * * @returns The parsed response. * @throws Error if a problem occurred. This includes network problems and Matrix-specific error JSON. */ requestOtherUrl(method: Method, url: URL | string, body?: Body, opts?: BaseRequestOpts): Promise; /** * Form and return a homeserver request URL based on the given path params and prefix. * @param path - The HTTP path after the supplied prefix e.g. "/createRoom". * @param queryParams - A dict of query params (these will NOT be urlencoded). * @param prefix - The full prefix to use e.g. "/_matrix/client/v2_alpha", defaulting to this.opts.prefix. * @param baseUrl - The baseUrl to use e.g. "https://matrix.org", defaulting to this.opts.baseUrl. * @returns URL */ getUrl(path: string, queryParams?: QueryDict, prefix?: string, baseUrl?: string): URL; } //# sourceMappingURL=fetch.d.ts.map