@uppy/companion-client
Advanced tools
Comparing version 1.8.3 to 1.9.0
'use strict'; | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } | ||
@@ -9,3 +9,3 @@ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
@@ -12,0 +12,0 @@ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } |
@@ -5,6 +5,10 @@ 'use strict'; | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var qsStringify = require('qs-stringify'); | ||
var URL = require('url-parse'); | ||
var RequestClient = require('./RequestClient'); | ||
@@ -155,3 +159,3 @@ | ||
} else { | ||
plugin.opts.companionAllowedHosts = opts.companionUrl; | ||
plugin.opts.companionAllowedHosts = new URL(opts.companionUrl).origin; | ||
} | ||
@@ -158,0 +162,0 @@ } |
@@ -210,2 +210,2 @@ 'use strict'; | ||
return RequestClient; | ||
}(), _class.VERSION = "1.8.3", _temp); | ||
}(), _class.VERSION = "1.9.0", _temp); |
'use strict'; | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var RequestClient = require('./RequestClient'); | ||
@@ -6,0 +8,0 @@ |
{ | ||
"name": "@uppy/companion-client", | ||
"description": "Client library for communication with Companion. Intended for use in Uppy plugins.", | ||
"version": "1.8.3", | ||
"version": "1.9.0", | ||
"license": "MIT", | ||
@@ -24,7 +24,8 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@uppy/utils": "^3.4.2", | ||
"@uppy/utils": "^3.5.0", | ||
"namespace-emitter": "^2.0.1", | ||
"qs-stringify": "^1.1.0" | ||
"qs-stringify": "^1.1.0", | ||
"url-parse": "^1.4.7" | ||
}, | ||
"gitHead": "4bf107236340dc98f8584f15a06e13ffa9fc31f4" | ||
"gitHead": "1751241362692202ed626f752fc740d4db0f2a9a" | ||
} |
@@ -16,3 +16,3 @@ 'use strict' | ||
SearchProvider, | ||
Socket | ||
Socket, | ||
} |
'use strict' | ||
const qsStringify = require('qs-stringify') | ||
const URL = require('url-parse') | ||
const RequestClient = require('./RequestClient') | ||
@@ -36,3 +37,3 @@ const tokenStorage = require('./tokenStorage') | ||
} | ||
return Object.assign({}, headers, authHeaders) | ||
return { ...headers, ...authHeaders } | ||
}) | ||
@@ -94,3 +95,3 @@ } | ||
response, | ||
this.uppy.getPlugin(this.pluginId).storage.removeItem(this.tokenKey) | ||
this.uppy.getPlugin(this.pluginId).storage.removeItem(this.tokenKey), | ||
])).then(([response]) => response) | ||
@@ -103,3 +104,3 @@ } | ||
if (defaultOpts) { | ||
plugin.opts = Object.assign({}, defaultOpts, opts) | ||
plugin.opts = { ...defaultOpts, ...opts } | ||
} | ||
@@ -123,3 +124,3 @@ | ||
} else { | ||
plugin.opts.companionAllowedHosts = opts.companionUrl | ||
plugin.opts.companionAllowedHosts = new URL(opts.companionUrl).origin | ||
} | ||
@@ -126,0 +127,0 @@ } |
@@ -32,3 +32,3 @@ 'use strict' | ||
'Content-Type': 'application/json', | ||
'Uppy-Versions': `@uppy/companion-client=${RequestClient.VERSION}` | ||
'Uppy-Versions': `@uppy/companion-client=${RequestClient.VERSION}`, | ||
} | ||
@@ -41,3 +41,3 @@ } | ||
...this.defaultHeaders, | ||
...userHeaders | ||
...userHeaders, | ||
}) | ||
@@ -64,5 +64,3 @@ } | ||
this.uppy.setState({ | ||
companion: Object.assign({}, companion, { | ||
[host]: headers.get('i-am') | ||
}) | ||
companion: { ...companion, [host]: headers.get('i-am') }, | ||
}) | ||
@@ -103,3 +101,3 @@ } | ||
return fetch(this._getUrl(path), { | ||
method: 'OPTIONS' | ||
method: 'OPTIONS', | ||
}) | ||
@@ -141,4 +139,4 @@ .then((response) => { | ||
method: 'get', | ||
headers: headers, | ||
credentials: this.opts.companionCookiesRule || 'same-origin' | ||
headers, | ||
credentials: this.opts.companionCookiesRule || 'same-origin', | ||
})) | ||
@@ -158,5 +156,5 @@ .then(this._getPostResponseFunc(skipPostResponse)) | ||
method: 'post', | ||
headers: headers, | ||
headers, | ||
credentials: this.opts.companionCookiesRule || 'same-origin', | ||
body: JSON.stringify(data) | ||
body: JSON.stringify(data), | ||
})) | ||
@@ -176,5 +174,5 @@ .then(this._getPostResponseFunc(skipPostResponse)) | ||
method: 'delete', | ||
headers: headers, | ||
headers, | ||
credentials: this.opts.companionCookiesRule || 'same-origin', | ||
body: data ? JSON.stringify(data) : null | ||
body: data ? JSON.stringify(data) : null, | ||
})) | ||
@@ -181,0 +179,0 @@ .then(this._getPostResponseFunc(skipPostResponse)) |
@@ -59,3 +59,3 @@ const ee = require('namespace-emitter') | ||
action, | ||
payload | ||
payload, | ||
})) | ||
@@ -62,0 +62,0 @@ } |
@@ -43,3 +43,3 @@ const UppySocket = require('./Socket') | ||
new UppySocket({ | ||
target: 'foo' | ||
target: 'foo', | ||
}) instanceof UppySocket | ||
@@ -62,3 +62,3 @@ ) | ||
expect(webSocketSendSpy.mock.calls[0]).toEqual([ | ||
JSON.stringify({ action: 'bar', payload: 'boo' }) | ||
JSON.stringify({ action: 'bar', payload: 'boo' }), | ||
]) | ||
@@ -83,3 +83,3 @@ }) | ||
{ action: 'bar', payload: 'boo' }, | ||
{ action: 'moo', payload: 'baa' } | ||
{ action: 'moo', payload: 'baa' }, | ||
]) | ||
@@ -93,6 +93,6 @@ expect(webSocketSendSpy.mock.calls.length).toEqual(0) | ||
expect(webSocketSendSpy.mock.calls[0]).toEqual([ | ||
JSON.stringify({ action: 'bar', payload: 'boo' }) | ||
JSON.stringify({ action: 'bar', payload: 'boo' }), | ||
]) | ||
expect(webSocketSendSpy.mock.calls[1]).toEqual([ | ||
JSON.stringify({ action: 'moo', payload: 'baa' }) | ||
JSON.stringify({ action: 'moo', payload: 'baa' }), | ||
]) | ||
@@ -131,6 +131,6 @@ }) | ||
webSocketInstance.onmessage({ | ||
data: JSON.stringify({ action: 'hi', payload: 'ho' }) | ||
data: JSON.stringify({ action: 'hi', payload: 'ho' }), | ||
}) | ||
expect(emitterListenerMock.mock.calls).toEqual([ | ||
['ho', undefined, undefined, undefined, undefined, undefined] | ||
['ho', undefined, undefined, undefined, undefined, undefined], | ||
]) | ||
@@ -158,4 +158,4 @@ }) | ||
undefined, | ||
undefined | ||
] | ||
undefined, | ||
], | ||
]) | ||
@@ -176,5 +176,5 @@ }) | ||
expect(emitterListenerMock.mock.calls).toEqual([ | ||
['ho', undefined, undefined, undefined, undefined, undefined] | ||
['ho', undefined, undefined, undefined, undefined, undefined], | ||
]) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
76165
1064
4
+ Addedurl-parse@^1.4.7
+ Addedquerystringify@2.2.0(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedurl-parse@1.5.10(transitive)
Updated@uppy/utils@^3.5.0