Type Parameters

Hierarchy (view full)

Constructors

Properties

abortController: AbortController = ...
opts: O

Methods

  • Perform an authorised request to the homeserver.

    Type Parameters

    • T

    Parameters

    • method: Method

      The HTTP method e.g. "GET".

    • path: string

      The HTTP path after the supplied prefix e.g. "/createRoom".

    • Optional queryParams: QueryDict

      A dict of query params (these will NOT be urlencoded). If unspecified, there will be no query params.

    • Optional body: Body

      The HTTP JSON body.

    • paramOpts: IRequestOpts & {
          doNotAttemptTokenRefresh?: boolean;
      } = {}

      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 Promise<ResponseType<T, O>>

    Promise which resolves to

    {
    data: {Object},
    headers: {Object},
    code: {Number},
    }

    If onlyData is set, this will resolve to the data object only.

  • Form and return a homeserver request URL based on the given path params and prefix.

    Parameters

    • path: string

      The HTTP path after the supplied prefix e.g. "/createRoom".

    • Optional queryParams: QueryDict

      A dict of query params (these will NOT be urlencoded).

    • Optional prefix: string

      The full prefix to use e.g. "/_matrix/client/v2_alpha", defaulting to this.opts.prefix.

    • Optional baseUrl: string

      The baseUrl to use e.g. "https://matrix.org", defaulting to this.opts.baseUrl.

    Returns URL

    URL

  • Perform a request to the homeserver without any credentials.

    Type Parameters

    • T

    Parameters

    • method: Method

      The HTTP method e.g. "GET".

    • path: string

      The HTTP path after the supplied prefix e.g. "/createRoom".

    • Optional queryParams: QueryDict

      A dict of query params (these will NOT be urlencoded). If unspecified, there will be no query params.

    • Optional body: Body

      The HTTP JSON body.

    • Optional opts: IRequestOpts

      additional options

    Returns Promise<ResponseType<T, O>>

    Promise which resolves to

    {
    data: {Object},
    headers: {Object},
    code: {Number},
    }

    If onlyData</code> is set, this will resolve to the <code>data object only.

  • Perform a request to an arbitrary URL.

    Type Parameters

    • T

    Parameters

    • method: Method

      The HTTP method e.g. "GET".

    • url: string | URL

      The HTTP URL object.

    • Optional body: Body

      The HTTP JSON body.

    • opts: Pick<IRequestOpts, "priority" | "json" | "headers" | "keepAlive" | "abortSignal" | "localTimeoutMs"> = {}

      additional options

    Returns Promise<ResponseType<T, O>>

    Promise which resolves to data unless onlyData is specified as false, where the resolved value will be a fetch Response object.

  • Sets the base URL for the identity server

    Parameters

    • Optional url: string

      The new base url

    Returns void

  • Attempt to refresh access tokens. On success, sets new access and refresh tokens in opts.

    Returns Promise<boolean>

    Promise that resolves to a boolean - true when token was refreshed successfully

Generated using TypeDoc