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 : String
module:cloud-services/token~Token#value
readonly observable
Value of the token. The value of the token is null if
initValue
is not provided orinit
method was not called.create
method creates token with initialized value from url. -
_options : Object
module:cloud-services/token~Token#_options
private
-
_refresh : String | function
module:cloud-services/token~Token#_refresh
private
Base refreshing function.
Methods
-
constructor( tokenUrlOrRefreshToken, options = { [options.initValue], [options.autoRefresh] } )
module:cloud-services/token~Token#constructor
Creates
Token
instance. Methodinit
should be called after using the constructor or usecreate
method instead.Parameters
tokenUrlOrRefreshToken : String | function
Endpoint address to download the token or a callback that provides the token. If the value is a function it has to match the
refreshToken
interface.options : Object
-
Properties
[ options.initValue ] : String
Initial value of the token.
[ options.autoRefresh ] : Boolean
Specifies whether to start the refresh automatically.
Defaults to
true
-
destroy()
module:cloud-services/token~Token#destroy
Destroys token instance. Stops refreshing.
-
Initializes the token.
Returns
Promise.<Token>
-
refreshToken() → Promise.<String>
module:cloud-services/token~Token#refreshToken
Refresh token method. Useful in a method form as it can be override in tests.
Returns
Promise.<String>
-
_getTokenRefreshTimeoutTime() → Number
module:cloud-services/token~Token#_getTokenRefreshTimeoutTime
protected
Returns 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
-
_registerRefreshTokenTimeout()
module:cloud-services/token~Token#_registerRefreshTokenTimeout
protected
Registers a refresh token timeout for the time taken from token.
-
_validateTokenValue( tokenValue )
module:cloud-services/token~Token#_validateTokenValue
protected
Checks whether the provided token follows the JSON Web Tokens (JWT) format.
Parameters
tokenValue : String
The token to validate.
Static methods
-
create( tokenUrlOrRefreshToken, options = { [options.initValue], [options.autoRefresh] } ) → Promise.<Token>
module:cloud-services/token~Token.create
static
Creates a initialized
Token
instance.Parameters
tokenUrlOrRefreshToken : String | function
Endpoint address to download the token or a callback that provides the token. If the value is a function it has to match the
refreshToken
interface.options : Object
-
Properties
[ options.initValue ] : String
Initial value of the token.
[ options.autoRefresh ] : Boolean
Specifies 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:value
Fired when the
value
property changed value.Parameters
eventInfo : EventInfo
An object containing information about the fired event.
name : String
Name of the changed property (
value
).value : String
New value of the
value
property with given key ornull
, if operation should remove property.oldValue : String
Old value of the
value
property with given key ornull
, if property was not set before.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.