Class

TokenMaintainer

TokenMaintainer(args)

Represents a process for maintaining a Bearer token for a given accountId and login info

Constructor

# new TokenMaintainer(args)

Parameters:
Name Type Attributes Description
args Object
accountId string

the brand's accountId

authData Object

username and password to generate Bearer token

authSessionInfo Object <optional>

response object from TokenMaintainer#getAuthSessionInfo

View Source connection/token-maintainer.js, line 44

Methods

# async _generateToken()

Wraps the token generation function. Ensuring that only one token generation is happening at a time

View Source connection/token-maintainer.js, line 150

# async _generateTokenInner()

Generates an agent token for connecting to UMS

View Source connection/token-maintainer.js, line 213

# async _refreshToken()

Refreshes the token for a connection

View Source connection/token-maintainer.js, line 276

# async getAuthSessionInfo() → {Promise.<Object>}

Returns authSessionInfo from agentVep, awaiting any ongoing token regeneration process

View Source connection/token-maintainer.js, line 129

token maintainer not started

Error

authSessionInfo

Promise.<Object>

# async getToken() → {Promise.<string>}

Returns a valid token, awaiting any ongoing token regeneration process

View Source connection/token-maintainer.js, line 119

token maintainer not started

Error

Agent bearer token

Promise.<string>

# onTokenInvalid()

This function should be called when a 401 is received when using a bearer token. It will attempt to regen the token and resolve if it succeeds; if it fails it will throw an error

View Source connection/token-maintainer.js, line 323

# async start() → {Promise.<void>}

Starts the TokenMaintainer process

View Source connection/token-maintainer.js, line 72

Promise.<void>

# stop()

Stops the TokenMaintainer process

View Source connection/token-maintainer.js, line 101