@ckeditor/ckeditor5-cloud-services
Advanced tools
Comparing version 23.1.0 to 24.0.0
{ | ||
"name": "@ckeditor/ckeditor5-cloud-services", | ||
"version": "23.1.0", | ||
"version": "24.0.0", | ||
"description": "CKEditor 5's Cloud Services integration layer.", | ||
@@ -12,7 +12,8 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor-cloud-services-core": "^23.1.0", | ||
"@ckeditor/ckeditor5-core": "^23.1.0" | ||
"@ckeditor/ckeditor-cloud-services-core": "^24.0.0", | ||
"@ckeditor/ckeditor5-core": "^24.0.0", | ||
"@ckeditor/ckeditor5-utils": "^24.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-editor-classic": "^23.1.0" | ||
"@ckeditor/ckeditor5-editor-classic": "^24.0.0" | ||
}, | ||
@@ -19,0 +20,0 @@ "engines": { |
@@ -12,2 +12,3 @@ /** | ||
import Token from '@ckeditor/ckeditor-cloud-services-core/src/token/token'; | ||
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror'; | ||
@@ -43,2 +44,10 @@ /** | ||
/** | ||
* Map of `Token` object instances keyed by `tokenUrl`s. | ||
* | ||
* @private | ||
* @type {Map.<String, module:cloud-services-core/token~Token>} | ||
*/ | ||
this._tokens = new Map(); | ||
/** | ||
* The authentication token URL for CKEditor Cloud Services or a callback to the token value promise. See the | ||
@@ -63,3 +72,3 @@ * {@link module:cloud-services/cloudservices~CloudServicesConfig#tokenUrl} for more details. | ||
* @readonly | ||
* @member {Object|null} #token | ||
* @member {module:cloud-services-core/token~Token|null} #token | ||
*/ | ||
@@ -75,2 +84,4 @@ | ||
this._tokens.set( this.tokenUrl, this.token ); | ||
return this.token.init(); | ||
@@ -80,2 +91,43 @@ } | ||
/** | ||
* Registers an additional authentication token URL for CKEditor Cloud Services or a callback to the token value promise. See the | ||
* {@link module:cloud-services/cloudservices~CloudServicesConfig#tokenUrl} for more details. | ||
* | ||
* @param {String|Function} tokenUrl The authentication token URL for CKEditor Cloud Services or a callback to the token value promise. | ||
* @returns {Promise.<module:cloud-services-core/token~Token>} | ||
*/ | ||
registerTokenUrl( tokenUrl ) { | ||
// Reuse Token instance in case of multiple features using the same tokenUrl. | ||
if ( this._tokens.has( tokenUrl ) ) { | ||
return Promise.resolve( this.getTokenFor( tokenUrl ) ); | ||
} | ||
const token = new CloudServices.Token( tokenUrl ); | ||
this._tokens.set( tokenUrl, token ); | ||
return token.init(); | ||
} | ||
/** | ||
* Returns authentication token provider previously registered by {@link #registerTokenUrl}. | ||
* | ||
* @param {String|Function} tokenUrl The authentication token URL for CKEditor Cloud Services or a callback to the token value promise. | ||
* @returns {module:cloud-services-core/token~Token} | ||
*/ | ||
getTokenFor( tokenUrl ) { | ||
const token = this._tokens.get( tokenUrl ); | ||
if ( !token ) { | ||
/** | ||
* Provided `tokenUrl` was not registered by {@link module:cloud-services/cloudservices~CloudServices#registerTokenUrl}. | ||
* | ||
* @error cloudservices-token-not-registered | ||
*/ | ||
throw new CKEditorError( 'cloudservices-token-not-registered', this ); | ||
} | ||
return token; | ||
} | ||
/** | ||
* @inheritDoc | ||
@@ -86,4 +138,4 @@ */ | ||
if ( this.token ) { | ||
this.token.destroy(); | ||
for ( const token of this._tokens.values() ) { | ||
token.destroy(); | ||
} | ||
@@ -90,0 +142,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17342
227
3
+ Added@ckeditor/ckeditor-cloud-services-core@24.0.0(transitive)
+ Added@ckeditor/ckeditor5-core@24.0.0(transitive)
+ Added@ckeditor/ckeditor5-engine@24.0.0(transitive)
+ Added@ckeditor/ckeditor5-utils@24.0.0(transitive)
- Removed@ckeditor/ckeditor-cloud-services-core@23.1.0(transitive)
- Removed@ckeditor/ckeditor5-core@23.1.0(transitive)
- Removed@ckeditor/ckeditor5-engine@23.1.0(transitive)
- Removed@ckeditor/ckeditor5-utils@23.1.0(transitive)