Skip to content

Commit

Permalink
Docs: Updated Token and tokenUrl API docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed Aug 13, 2024
1 parent 223443f commit c1bd2cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/ckeditor5-cloud-services/src/cloudservicesconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export interface CloudServicesConfig {
* } )
* ```
*
* If the request to the token endpoint fails, the editor will call the token request function every 5 seconds in attempt
* to refresh the token.
*
* You can find more information about token endpoints in the
* {@glink @cs guides/easy-image/quick-start#create-token-endpoint Cloud Services - Quick start}
* and {@glink @cs developer-resources/security/token-endpoint Cloud Services - Token endpoint} documentation.
Expand Down
18 changes: 13 additions & 5 deletions packages/ckeditor5-cloud-services/src/token/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ const DEFAULT_TOKEN_REFRESH_TIMEOUT_TIME = 3600000; // 1 hour
const TOKEN_FAILED_REFRESH_TIMEOUT_TIME = 5000; // 5 seconds

/**
* 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.
* The class representing the token used for communication with CKEditor Cloud Services.
* The value of the token is retrieved from the specified URL and refreshed every 1 hour by default.
* If the token retrieval fails, the token will automatically retry in 5 seconds intervals.
*/
export default class Token extends /* #__PURE__ */ ObservableMixin() {
/**
Expand Down Expand Up @@ -106,7 +107,13 @@ export default class Token extends /* #__PURE__ */ ObservableMixin() {
}

/**
* Refresh token method. Useful in a method form as it can be override in tests.
* Refresh token method. Useful in a method form as it can be overridden in tests.
*
* This method will be invoked periodically based on the token expiry date after first call to keep the token up-to-date
* (requires {@link module:cloud-services/token/token~TokenOptions auto refresh option} to be set).
*
* If the token refresh fails, the method will retry in 5 seconds intervals until success or until the token gets
* {@link #destroy destroyed}.
*/
public refreshToken(): Promise<InitializedToken> {
const autoRefresh = this._options.autoRefresh;
Expand All @@ -132,8 +139,9 @@ export default class Token extends /* #__PURE__ */ ObservableMixin() {
* endpoint is up and running. {@link module:cloud-services/cloudservicesconfig~CloudServicesConfig#tokenUrl Learn more}
* about token configuration.
*
* **Note:** If the {@link module:cloud-services/token/token~TokenOptions auto refresh} is enabled, attempts to refresh
* the token will be made until destroyed.
* **Note:** If the token's {@link module:cloud-services/token/token~TokenOptions auto refresh option} is enabled,
* attempts to refresh will be made until success or token's
* {@link module:cloud-services/token/token~Token#destroy destruction}.
*
* @error token-refresh-failed
* @param autoRefresh Whether the token will keep auto refreshing.
Expand Down

0 comments on commit c1bd2cf

Please sign in to comment.