Skip to content

AbstractGrantType

Kind: global class
Classdesc#:

new AbstractGrantType(options)

Throws:

  • InvalidArgumentError if {options.accessTokenLifeTime} is missing
  • InvalidArgumentError if {options.model} is missing
ParamTypeDefaultDescription
optionsobject
options.accessTokenLifetimenumberaccess token lifetime in seconds
options.modelModelthe model
options.refreshTokenLifetimenumber
[options.alwaysIssueNewRefreshToken]booleantrueAlways revoke the used refresh token and issue a new one for the refresh_token grant.

abstractGrantType.generateAccessToken(client, user, scope) ⇒ Promise.<string>

Generate access token. If the model implements generateAccessToken then this implementation will be used. Otherwise, falls back to an internal implementation from TokenUtil.generateRandomToken.

Kind: instance method of AbstractGrantType

Param
client
user
scope

abstractGrantType.generateRefreshToken()

Generate refresh token.

Kind: instance method of AbstractGrantType

abstractGrantType.getAccessTokenExpiresAt()

Get access token expiration date.

Kind: instance method of AbstractGrantType

abstractGrantType.getRefreshTokenExpiresAt() ⇒ Date

Get refresh token expiration date (now + refresh token lifetime)

Kind: instance method of AbstractGrantType

abstractGrantType.getScope(request) ⇒ string | undefined

Get scope from the request body.

Kind: instance method of AbstractGrantType

ParamType
requestRequest

abstractGrantType.validateScope(user, client, scope) ⇒ string

Validate requested scope. Delegates validation to the Model's validateScope method, if the model implements this method. Otherwise, treats given scope as valid.

Kind: instance method of AbstractGrantType
Returns: string - the validated scope
Throws:

  • InvalidScopeError if the {Model#validateScope} method returned a falsy value
ParamType
userobject
clientClientData
scopestring