Skip to content

DigitalWorldHttpApi

Defined in: src/http-api/index.ts:32

  • FetchHttpApi<O>

O extends IHttpOpts

new DigitalWorldHttpApi<O>(eventEmitter, opts): DigitalWorldHttpApi<O>

Defined in: src/http-api/fetch.ts:41

TypedEventEmitter<HttpApiEvent, HttpApiEventHandlerMap>

O

DigitalWorldHttpApi<O>

FetchHttpApi<O>.constructor

readonly opts: O

Defined in: src/http-api/fetch.ts:43

FetchHttpApi.opts

abort(): void

Defined in: src/http-api/fetch.ts:54

void

FetchHttpApi.abort


authedRequest<T>(method, path, queryParams?, body?, paramOpts?): Promise<T>

Defined in: src/http-api/fetch.ts:124

Perform an authorised request to the hub.

T

Method

The HTTP method e.g. “GET”.

string

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

QueryDict = {}

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

Body

The HTTP JSON body.

IRequestOpts = {}

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.

Promise<T>

The parsed response.

Error if a problem occurred. This includes network problems and protocol-specific error JSON.

FetchHttpApi.authedRequest


cancelUpload(promise): boolean

Defined in: src/http-api/index.ts:160

Promise<UploadResponse>

boolean


fetch(resource, options?): Promise<Response>

Defined in: src/http-api/fetch.ts:59

string | URL

RequestInit

Promise<Response>

FetchHttpApi.fetch


getCurrentUploads(): Upload[]

Defined in: src/http-api/index.ts:169

Upload[]


getUrl(path, queryParams?, prefix?, baseUrl?): URL

Defined in: src/http-api/fetch.ts:363

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

string

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

QueryDict

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

string

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

string

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

URL

URL

FetchHttpApi.getUrl


idServerRequest<T>(method, path, params, prefix, accessToken?): Promise<T>

Defined in: src/http-api/fetch.ts:74

T extends object = Record<string, unknown>

Method

string

Record<string, string | string[]> | undefined

string

string

Promise<T>

FetchHttpApi.idServerRequest


request<T>(method, path, queryParams?, body?, opts?): Promise<T>

Defined in: src/http-api/fetch.ts:211

Perform a request to the hub without any credentials.

T = unknown

Method

The HTTP method e.g. “GET”.

string

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

QueryDict

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

Body

The HTTP JSON body.

IRequestOpts

additional options

Promise<T>

The parsed response.

Error if a problem occurred. This includes network problems and protocol-specific error JSON.

FetchHttpApi.request


requestOtherUrl<T>(method, url, body?, opts?): Promise<T>

Defined in: src/http-api/fetch.ts:234

Perform a request to an arbitrary URL.

T

Method

The HTTP method e.g. “GET”.

string | URL

The HTTP URL object.

Body

The HTTP JSON body.

BaseRequestOpts = {}

additional options

Promise<T>

The parsed response.

Error if a problem occurred. This includes network problems and protocol-specific error JSON.

FetchHttpApi.requestOtherUrl


setIdBaseUrl(url?): void

Defined in: src/http-api/fetch.ts:70

Sets the base URL for the identity server

string

The new base url

void

FetchHttpApi.setIdBaseUrl


uploadContent(file, opts?): Promise<UploadResponse>

Defined in: src/http-api/index.ts:48

Upload content to the hub

XMLHttpRequestBodyInit

The object to upload. On a browser, something that can be sent to XMLHttpRequest.send (typically a File). Under node.js, a Buffer, String or ReadStream.

UploadOpts = {}

options object

Promise<UploadResponse>

Promise which resolves to response object, or rejects with an error (usually a DigitalWorldError).

May throw a DigitalWorldSafetyError if content is deemed unsafe.

DigitalWorldSafetyError