Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HubSession

Represents a communication session with a particular Hub instance.

Hierarchy

  • HubSession

Index

Constructors

constructor

Properties

Private authentication

authentication: Authentication

Private clientDid

clientDid: string

Private currentAccessToken

currentAccessToken: string | undefined

Private hubDid

hubDid: string

Private hubEndpoint

hubEndpoint: string

Private targetDid

targetDid: string

Methods

Private callFetch

  • callFetch(url: string | Request, init?: RequestInit): Promise<Response>
  • Fetch API wrapper, to allow unit testing.

    Parameters

    • url: string | Request

      The URL to make a request to.

    • Optional init: RequestInit

      Request initialization details.

    Returns Promise<Response>

Private getAccessToken

  • getAccessToken(): Promise<string>
  • Returns the current access token for the Hub, requesting one if necessary.

    Returns Promise<string>

Private makeRequest

  • makeRequest(message: string, accessToken?: undefined | string): Promise<string>
  • Sends a raw (string) request body to the Hub and receives a response.

    Parameters

    • message: string

      The raw request body to send.

    • Optional accessToken: undefined | string

      The access token to include in the request, if any.

    Returns Promise<string>

Private refreshAccessToken

  • refreshAccessToken(): Promise<string>
  • Requests an updated access token from the Hub.

    Returns Promise<string>

send

Static Private mapResponseToObject

  • mapResponseToObject(response: IHubResponse<string>): any
  • Transforms a JSON blob returned by the Hub into a subclass of HubResponse, based on the @type field of the response.

    Parameters

    • response: IHubResponse<string>

      The Hub response to be transformed.

    Returns any

Object literals

Static Private responseTypes

responseTypes: object

Mapping of known response types.

CommitQueryResponse

CommitQueryResponse: HubCommitQueryResponse = HubCommitQueryResponse

ObjectQueryResponse

ObjectQueryResponse: HubObjectQueryResponse = HubObjectQueryResponse

WriteResponse

WriteResponse: HubWriteResponse = HubWriteResponse

Generated using TypeDoc