Options
All
  • Public
  • Public/Protected
  • All
Menu
label

COMMON

description

This class extends baseGateway and is responsible for handling authentication requests, running challenge validation and finally allowing the frontend to call the /auth/token endpoint.

This class defines multiple communication flows:

  • server to server using the event emitter (OnEvent)
  • client to server using websocket channel messages (SubscribeMessage)
since

v0.6.0

Hierarchy

Index

Constructors

  • new AuthGateway(validateChallengeScheduler: ValidateChallengeScheduler, emitter: EventEmitter2): AuthGateway

Properties

This property implements list of currently connected clients by storing their challenges. Challenge gets removed from list once client disconnects.

access

protected

var

{WebsocketConsumerMap}

emitter: EventEmitter2
logger: LogService

This property permits to log information to the console or in files depending on the configuration. This logger instance can be accessed by extending listeners to use a common log process.

access

protected

var

{LogService}

options: { debug: boolean } = ...

Type declaration

  • debug: boolean
server: Server<typeof IncomingMessage, typeof ServerResponse>

This property implements gateway server which is broadcasts different messages to single or multiple clients.

access

protected

var

{Server}

websocketUrl: string

Contains the full websocket connection URL (including path).

access

protected

var

{string}

Methods

  • afterInit(server: Server<typeof IncomingMessage, typeof ServerResponse>): void
  • This method handles gateway initialize hook.

    access

    public

    Parameters

    • server: Server<typeof IncomingMessage, typeof ServerResponse>

      Websocket connection param, holds server and client info.

    Returns void

    Removes client challenge from list

  • handleConnection(ws: any, req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>): Promise<void>
  • This method handles connection via websocket with the client.

    Additionally, this method will emit the event auth.open given the presence of an authentication challenge in the signed request cookies.

    access

    public

    emits

    OnAuthOpened Given the presence of a challenge in signed cookies of the request.

    throws

    {HttpException} Given a missing or invalid challenge in the signer cookies of the request.

    Parameters

    • ws: any

      UDP datagrap socket used to connect.

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

      HTTP Request forwarded to enable reading signed client cookies.

    Returns Promise<void>

  • handleDisconnect(ws: any): void
  • This method handles closing connection with the client. After client was disconnected - remove his challenge from list.

    In case of a successful validation attempts, i.e. when the challenge parameter has been found in a recent transfer transaction's message, a document will be insert in the collection authChallenges.

    access

    public

    Parameters

    • ws: any

      Websocket connection param, holds server and client info.

    Returns void

    Removes client challenge from list

  • This method handles auth.close event, which is getting triggered by validateChallengeScheduler when challenge on chain. Sends auth.complete message to the client.

    Parameters

    Returns Promise<void>

    Emits "auth.complete" event which informs client that token may be queried.

  • This method handles starting of challenge validation. Gets trigged by "auth.open" emit from handleConnection(). Calls .startCronJob from validateChallengeScheduler.

    Parameters

    Returns Promise<void>

    Emits "auth.open" event which triggers validating of the received challenge

Generated using TypeDoc