AuthToken

auth. AuthToken

Utilities for dealing with JSON web tokens

Constructor

new AuthToken()

Source:

Members

(static) secret :String

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

Methods

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

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

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

Source:
Retrieves an existing token
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}

Source:
Generates a new token
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}

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

(static) isSuper(scopes) → {Promise}

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

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

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