@ckeditor/ckeditor-cloudservices-core
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "@ckeditor/ckeditor-cloudservices-core", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "CKEditor Cloud Services Core API", | ||
@@ -5,0 +5,0 @@ "license": "(GPL-2.0 OR LGPL-2.1 OR MPL-1.1)", |
@@ -23,3 +23,3 @@ /** | ||
* @param {Blob|String} fileOrData A blob object or a data string encoded with Base64. | ||
* @param {String} token Token used for authentication. | ||
* @param {Token} token Token used for authentication. | ||
* @param {String} apiAddress API address. | ||
@@ -50,3 +50,3 @@ */ | ||
* | ||
* @type {String} | ||
* @type {Token} | ||
* @private | ||
@@ -120,3 +120,3 @@ */ | ||
xhr.open( 'POST', this._apiAddress ); | ||
xhr.setRequestHeader( 'Authorization', this._token ); | ||
xhr.setRequestHeader( 'Authorization', this._token.value ); | ||
xhr.responseType = 'json'; | ||
@@ -123,0 +123,0 @@ |
@@ -17,3 +17,3 @@ /** | ||
* | ||
* @param {String} token Token used for authentication. | ||
* @param {Token} token Token used for authentication. | ||
* @param {String} apiAddress API address. | ||
@@ -33,3 +33,3 @@ */ | ||
* | ||
* @type {String} | ||
* @type {Token} | ||
* @private | ||
@@ -53,3 +53,4 @@ */ | ||
* | ||
* new UploadGateway( 'JSON_WEB_TOKEN_FROM_SERVER', 'https://example.org' ) | ||
* const token = await Token.create( 'https://token-endpoint' ); | ||
* new UploadGateway( token, 'https://example.org' ) | ||
* .upload( 'FILE' ) | ||
@@ -62,3 +63,4 @@ * .onProgress( ( data ) => console.log( data ) ) | ||
* | ||
* new UploadGateway( 'JSON_WEB_TOKEN_FROM_SERVER', 'https://example.org' ) | ||
* const token = await Token.create( 'https://token-endpoint' ); | ||
* new UploadGateway( token, 'https://example.org' ) | ||
* .upload( 'FILE' ) | ||
@@ -65,0 +67,0 @@ * .onProgress( ( data ) => console.log( data ) ) |
@@ -11,5 +11,5 @@ /** | ||
import FileUploader from '../../src/uploadgateway/fileuploader'; | ||
import Token from '../../src/token/token'; | ||
const API_ADDRESS = 'https://example.dev'; | ||
const TOKEN = 'token'; | ||
const BASE_64_FILE = 'data:image/gif;base64,R0lGODlhCQAJAPIAAGFhYZXK/1FRUf///' + | ||
@@ -19,6 +19,8 @@ '9ra2gD/AAAAAAAAACH5BAEAAAUALAAAAAAJAAkAAAMYWFqwru2xERcYJLSNNWNBVimC5wjfaTkJADs='; | ||
describe( 'FileUploader', () => { | ||
const token = new Token( 'url', { initValue: 'token', autoRefresh: false } ); | ||
let fileUploader; | ||
beforeEach( () => { | ||
fileUploader = new FileUploader( BASE_64_FILE, TOKEN, API_ADDRESS ); | ||
fileUploader = new FileUploader( BASE_64_FILE, token, API_ADDRESS ); | ||
} ); | ||
@@ -36,7 +38,7 @@ | ||
it( 'should throw error when no api address provided', () => { | ||
expect( () => new FileUploader( 'file', TOKEN ) ).to.throw( 'Api address must be provided' ); | ||
expect( () => new FileUploader( 'file', token ) ).to.throw( 'Api address must be provided' ); | ||
} ); | ||
it( 'should throw error when wrong Base64 file is provided', () => { | ||
expect( () => new FileUploader( 'data:image/gif;base64,R', TOKEN, API_ADDRESS ) ) | ||
expect( () => new FileUploader( 'data:image/gif;base64,R', token, API_ADDRESS ) ) | ||
.to.throw( 'Problem with decoding Base64 image data.' ); | ||
@@ -59,3 +61,3 @@ } ); | ||
const fileUploader = new FileUploader( file, TOKEN, API_ADDRESS ); | ||
const fileUploader = new FileUploader( file, token, API_ADDRESS ); | ||
@@ -62,0 +64,0 @@ expect( fileUploader.file.name ).to.be.equal( 'test.jpg' ); |
@@ -10,4 +10,7 @@ /** | ||
import UploadGateway from '../../src/uploadgateway/uploadgateway'; | ||
import Token from '../../src/token/token'; | ||
describe( 'UploadGateway', () => { | ||
const token = new Token( 'url', { initValue: 'token', autoRefresh: false } ); | ||
describe( 'constructor()', () => { | ||
@@ -19,3 +22,3 @@ it( 'should throw error when no token provided', () => { | ||
it( 'should throw error when no apiAddress provided', () => { | ||
expect( () => new UploadGateway( 'token' ) ).to.throw( 'Api address must be provided' ); | ||
expect( () => new UploadGateway( token ) ).to.throw( 'Api address must be provided' ); | ||
} ); | ||
@@ -26,3 +29,3 @@ } ); | ||
it( 'should return `FileUploader` instance', () => { | ||
const uploader = new UploadGateway( 'token', 'test' ); | ||
const uploader = new UploadGateway( token, 'test' ); | ||
@@ -29,0 +32,0 @@ expect( uploader.upload( 'file' ) ).to.be.instanceOf( FileUploader ); |
Sorry, the diff of this file is not supported yet
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
29335
13
847
1