AbstractGrantType
Kind: global class
Classdesc#:
- AbstractGrantType
- new AbstractGrantType(options)
- .generateAccessToken(client, user, scope) ⇒
Promise.<string> - .generateRefreshToken()
- .getAccessTokenExpiresAt()
- .getRefreshTokenExpiresAt() ⇒
Date - .getScope(request) ⇒
string|undefined - .validateScope(user, client, scope) ⇒
string
new AbstractGrantType(options)
Throws:
InvalidArgumentErrorif {options.accessTokenLifeTime} is missingInvalidArgumentErrorif {options.model} is missing
| Param | Type | Default | Description |
|---|---|---|---|
| options | object | ||
| options.accessTokenLifetime | number | access token lifetime in seconds | |
| options.model | Model | the model | |
| options.refreshTokenLifetime | number | ||
| [options.alwaysIssueNewRefreshToken] | boolean | true | Always 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
| Param | Type |
|---|---|
| request | Request |
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:
InvalidScopeErrorif the {Model#validateScope} method returned a falsy value
| Param | Type |
|---|---|
| user | object |
| client | ClientData |
| scope | string |