@uppy/companion-client
Advanced tools
Comparing version 0.27.1 to 0.27.2
'use-strict'; | ||
/** | ||
* Manages communications with Uppy Server | ||
* Manages communications with Companion | ||
*/ | ||
@@ -5,0 +5,0 @@ |
@@ -33,3 +33,3 @@ 'use strict'; | ||
_this.name = _this.opts.name || _getName(_this.id); | ||
_this.tokenKey = 'uppy-server-' + _this.id + '-auth-token'; | ||
_this.tokenKey = 'companion-' + _this.id + '-auth-token'; | ||
return _this; | ||
@@ -36,0 +36,0 @@ } |
@@ -26,11 +26,11 @@ 'use strict'; | ||
var state = this.uppy.getState(); | ||
var uppyServer = state.uppyServer || {}; | ||
var companion = state.companion || {}; | ||
var host = this.opts.serverUrl; | ||
var headers = response.headers; | ||
// Store the self-identified domain name for the uppy-server we just hit. | ||
if (headers.has('i-am') && headers.get('i-am') !== uppyServer[host]) { | ||
// Store the self-identified domain name for the Companion instance we just hit. | ||
if (headers.has('i-am') && headers.get('i-am') !== companion[host]) { | ||
var _extends2; | ||
this.uppy.setState({ | ||
uppyServer: _extends({}, uppyServer, (_extends2 = {}, _extends2[host] = headers.get('i-am'), _extends2)) | ||
companion: _extends({}, companion, (_extends2 = {}, _extends2[host] = headers.get('i-am'), _extends2)) | ||
}); | ||
@@ -103,6 +103,6 @@ } | ||
var _uppy$getState = this.uppy.getState(), | ||
uppyServer = _uppy$getState.uppyServer; | ||
companion = _uppy$getState.companion; | ||
var host = this.opts.serverUrl; | ||
return stripSlash(uppyServer && uppyServer[host] ? uppyServer[host] : host); | ||
return stripSlash(companion && companion[host] ? companion[host] : host); | ||
} | ||
@@ -109,0 +109,0 @@ }, { |
{ | ||
"name": "@uppy/companion-client", | ||
"description": "Client library for communication with Uppy Server. Intended for use in Uppy plugins.", | ||
"version": "0.27.1", | ||
"description": "Client library for communication with Companion. Intended for use in Uppy plugins.", | ||
"version": "0.27.2", | ||
"license": "MIT", | ||
@@ -13,3 +13,3 @@ "main": "lib/index.js", | ||
"uppy-plugin", | ||
"uppy-server", | ||
"companion", | ||
"provider" | ||
@@ -27,4 +27,3 @@ ], | ||
"namespace-emitter": "^2.0.1" | ||
}, | ||
"gitHead": "6b82d12d42a0dfdd9e0677a18efcaf44c251c58c" | ||
} | ||
} |
@@ -8,3 +8,3 @@ # @uppy/companion-client | ||
Client library for communication with Uppy Server. Intended for use in Uppy plugins. | ||
Client library for communication with Companion. Intended for use in Uppy plugins. | ||
@@ -11,0 +11,0 @@ Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service. |
'use-strict' | ||
/** | ||
* Manages communications with Uppy Server | ||
* Manages communications with Companion | ||
*/ | ||
@@ -5,0 +5,0 @@ |
@@ -16,3 +16,3 @@ 'use strict' | ||
this.name = this.opts.name || _getName(this.id) | ||
this.tokenKey = `uppy-server-${this.id}-auth-token` | ||
this.tokenKey = `companion-${this.id}-auth-token` | ||
} | ||
@@ -19,0 +19,0 @@ |
@@ -16,5 +16,5 @@ 'use strict' | ||
get hostname () { | ||
const { uppyServer } = this.uppy.getState() | ||
const { companion } = this.uppy.getState() | ||
const host = this.opts.serverUrl | ||
return stripSlash(uppyServer && uppyServer[host] ? uppyServer[host] : host) | ||
return stripSlash(companion && companion[host] ? companion[host] : host) | ||
} | ||
@@ -35,9 +35,9 @@ | ||
const state = this.uppy.getState() | ||
const uppyServer = state.uppyServer || {} | ||
const companion = state.companion || {} | ||
const host = this.opts.serverUrl | ||
const headers = response.headers | ||
// Store the self-identified domain name for the uppy-server we just hit. | ||
if (headers.has('i-am') && headers.get('i-am') !== uppyServer[host]) { | ||
// Store the self-identified domain name for the Companion instance we just hit. | ||
if (headers.has('i-am') && headers.get('i-am') !== companion[host]) { | ||
this.uppy.setState({ | ||
uppyServer: Object.assign({}, uppyServer, { | ||
companion: Object.assign({}, companion, { | ||
[host]: headers.get('i-am') | ||
@@ -44,0 +44,0 @@ }) |
@@ -6,8 +6,8 @@ const RequestClient = require('./RequestClient') | ||
const mockCore = { getState: () => ({}) } | ||
const a = new RequestClient(mockCore, { serverUrl: 'http://server.uppy.io' }) | ||
const b = new RequestClient(mockCore, { serverUrl: 'http://server.uppy.io/' }) | ||
const a = new RequestClient(mockCore, { serverUrl: 'http://companion.uppy.io' }) | ||
const b = new RequestClient(mockCore, { serverUrl: 'http://companion.uppy.io/' }) | ||
expect(a.hostname).toBe('http://server.uppy.io') | ||
expect(b.hostname).toBe('http://server.uppy.io') | ||
expect(a.hostname).toBe('http://companion.uppy.io') | ||
expect(b.hostname).toBe('http://companion.uppy.io') | ||
}) | ||
}) |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6
28352