AuthToken

auth. AuthToken

Utilities for dealing with JSON web tokens

Constructor

new AuthToken()

Source:

Members

(static) secret :String

Description:
  • Retrieves the secret used during token generation
Source:
Retrieves the secret used during token generation
Type:
  • String

Methods

(async, static) decode(token) → {Promise}

Description:
  • Decodes a token
Source:
Parameters:
Name Type Description
token String The token to decode
Returns:
Decoded token data
Type
Promise

(async, static) find(query, options) → {Promise}

Description:
  • Retrieves an existing token
Source:
Parameters:
Name Type Description
query Object
options Object
Properties
Name Type Description
sanitise Object Whether the token data should be sanitised for returning via an API
Returns:
Resolves with the value from MongoDBModule#find
Type
Promise

(async, static) generate(authType, userData, options) → {Promise}

Description:
  • Generates a new token
Source:
Parameters:
Name Type Description
authType String Authentication type used
userData Object The user to be encoded
options Object
Properties
Name Type Description
lifespan string Lifespan of the token
Returns:
Resolves with the token value
Type
Promise

(async, static) initRequestData(req) → {Promise}

Description:
  • Decodes and stores any token data on the Express ClientRequest object
Source:
Parameters:
Name Type Description
req external:ExpressRequest
Returns:
Type
Promise

(static) isSuper(scopes) → {Promise}

Description:
  • Utility function to check if a user has super privileges
Source:
Parameters:
Name Type Description
scopes Array The user's permission scopes
Returns:
Type
Promise

(async, static) revoke(query) → {Promise}

Description:
  • Invalidates an existing token
Source:
Parameters:
Name Type Description
query Object Database query to identify tokens to be deleted
Returns:
Resolves with the value from MongoDBModule#delete
Type
Promise