Options
All
  • Public
  • Public/Protected
  • All
Menu
description

This class handles managing of authentication related actions.

Currently includes 2 methods which are responsible for getting QR code authCode and accessToken

example

Using the Auth class

  const auth = new Auth();
console.log(auth.getAuthChallenge());
todo

Should randomly select one of the multiple authentication registries

todo

Should include the selected registry in the /auth/challenge request

since

v0.2.0

Hierarchy

Index

Constructors

Properties

baseUrl: string = ...

This property is used to define the base URL which is queried with each HTTP request executed using this backend service.

example:

"http://localhost:7903"

access

protected

var

{string}

Accessors

  • This property sets the request handler used for the implemented requests. This handler forwards the execution of the request to axios.

    access

    protected

    Returns HttpRequestHandler

Methods

  • getChallenge(): Promise<string>
  • This method executes a backend API request to the endpoint /auth/challenge to generate an authentication challenge that is then attached to a QR Code to perform authentication on-chain.

    access

    public

    async

    Returns Promise<string>

  • getDateFormatForPeriod(periodFormat: string): string
  • getProfile(): Promise<User>
  • This method executes a backend API request to the endpoint /me and returns the authenticated user's profile information.

    Returns Promise<User>

  • getUrl(endpoint: string): string
  • login(challenge: string, registry: string, refCode?: undefined | string): Promise<AccessTokenDTO>
  • This method executes a backend API request to the endpoint /auth/token to retrieve a user's access/refresh token [pair].

    Note that this method will only be successful after an authentication challenge was included correctly inside a transaction on dHealth Network.

    access

    public

    async

    Parameters

    • challenge: string

      The authentication challenge that was used to perform sign-in (on-chain).

    • registry: string
    • refCode: undefined | string = undefined

    Returns Promise<AccessTokenDTO>

  • logout(): Promise<boolean>
  • This method executes a backend API request to the endpoint /auth/logout to revoke the user's access token (sign-out / log-out).

    Returns Promise<boolean>

Generated using TypeDoc