Token (cloud-services)
@ckeditor/ckeditor5-cloud-services/src/token
Class representing the token used for communication with CKEditor Cloud Services. Value of the token is retrieving from the specified URL and is refreshed every 1 hour by default.
Filtering
Properties
-
Value of the token. The value of the token is null if
initValueis not provided orinitmethod was not called.createmethod creates token with initialized value from url. -
Base refreshing function.
Methods
-
constructor( tokenUrlOrRefreshToken, options = { [options.initValue], [options.autoRefresh] } )module:cloud-services/token~Token#constructorCreates
Tokeninstance. Methodinitshould be called after using the constructor or usecreatemethod instead.Parameters
tokenUrlOrRefreshToken : String | functionEndpoint address to download the token or a callback that provides the token. If the value is a function it has to match the
refreshTokeninterface.options : Object-
Properties
[ options.initValue ] : StringInitial value of the token.
[ options.autoRefresh ] : BooleanSpecifies whether to start the refresh automatically.
Defaults to
true
-
destroy()module:cloud-services/token~Token#destroyDestroys token instance. Stops refreshing.
-
-
refreshToken() → Promise.<String>module:cloud-services/token~Token#refreshTokenRefresh token method. Useful in a method form as it can be override in tests.
Returns
Promise.<String>
-
protected
_getTokenRefreshTimeoutTime() → Numbermodule:cloud-services/token~Token#_getTokenRefreshTimeoutTimeReturns token refresh timeout time calculated from expire time in the token payload.
If the token parse fails or the token payload doesn't contain, the default DEFAULT_TOKEN_REFRESH_TIMEOUT_TIME is returned.
Returns
Number
-
protected
_registerRefreshTokenTimeout()module:cloud-services/token~Token#_registerRefreshTokenTimeoutRegisters a refresh token timeout for the time taken from token.
-
Checks whether the provided token follows the JSON Web Tokens (JWT) format.
Parameters
tokenValue : StringThe token to validate.
Static methods
-
static
create( tokenUrlOrRefreshToken, options = { [options.initValue], [options.autoRefresh] } ) → Promise.<Token>module:cloud-services/token~Token.createCreates a initialized
Tokeninstance.Parameters
tokenUrlOrRefreshToken : String | functionEndpoint address to download the token or a callback that provides the token. If the value is a function it has to match the
refreshTokeninterface.options : Object-
Properties
[ options.initValue ] : StringInitial value of the token.
[ options.autoRefresh ] : BooleanSpecifies whether to start the refresh automatically.
Defaults to
true
Returns
Promise.<Token>
Events
-
change:value( eventInfo, name, value, oldValue )module:cloud-services/token~Token#event:change:valueFired when the
valueproperty changed value.Parameters
eventInfo : EventInfoAn object containing information about the fired event.
name : StringName of the changed property (
value).value : StringNew value of the
valueproperty with given key ornull, if operation should remove property.oldValue : StringOld value of the
valueproperty with given key ornull, if property was not set before.
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.