Socket
Socket
Sign inDemoInstall

@uppy/companion-client

Package Overview
Dependencies
Maintainers
5
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/companion-client - npm Package Compare versions

Comparing version 0.28.4 to 0.28.5

20

lib/Provider.js

@@ -100,15 +100,19 @@ 'use strict';

if (opts.serverPattern) {
var pattern = opts.serverPattern;
// validate serverPattern param
if (opts.serverUrl || opts.serverPattern) {
throw new Error('`serverUrl` and `serverPattern` have been renamed to `companionUrl` and `companionAllowedHosts` respectively in 0.30.5 release. Please consult the docs (for example, https://uppy.io/docs/instagram/ for Instagram plugin) and use the updated options.`');
}
if (opts.companionAllowedHosts) {
var pattern = opts.companionAllowedHosts;
// validate companionAllowedHosts param
if (typeof pattern !== 'string' && !Array.isArray(pattern) && !(pattern instanceof RegExp)) {
throw new TypeError(plugin.id + ': the option "serverPattern" must be one of string, Array, RegExp');
throw new TypeError(plugin.id + ': the option "companionAllowedHosts" must be one of string, Array, RegExp');
}
plugin.opts.serverPattern = pattern;
plugin.opts.companionAllowedHosts = pattern;
} else {
// does not start with https://
if (/^(?!https?:\/\/).*$/i.test(opts.serverUrl)) {
plugin.opts.serverPattern = 'https://' + opts.serverUrl.replace(/^\/\//, '');
if (/^(?!https?:\/\/).*$/i.test(opts.companionUrl)) {
plugin.opts.companionAllowedHosts = 'https://' + opts.companionUrl.replace(/^\/\//, '');
} else {
plugin.opts.serverPattern = opts.serverUrl;
plugin.opts.companionAllowedHosts = opts.companionUrl;
}

@@ -115,0 +119,0 @@ }

4

lib/RequestClient.js

@@ -44,3 +44,3 @@ 'use strict';

var companion = state.companion || {};
var host = this.opts.serverUrl;
var host = this.opts.companionUrl;
var headers = response.headers;

@@ -141,3 +141,3 @@ // Store the self-identified domain name for the Companion instance we just hit.

var host = this.opts.serverUrl;
var host = this.opts.companionUrl;
return stripSlash(companion && companion[host] ? companion[host] : host);

@@ -144,0 +144,0 @@ }

{
"name": "@uppy/companion-client",
"description": "Client library for communication with Companion. Intended for use in Uppy plugins.",
"version": "0.28.4",
"version": "0.28.5",
"license": "MIT",

@@ -26,3 +26,3 @@ "main": "lib/index.js",

},
"gitHead": "7ae8af44abdd42eef71c46b831b2e3dadb00237f"
"gitHead": "0f95529cc56175c017e149dd3a122a3bcf9325b7"
}

@@ -20,7 +20,7 @@ # @uppy/companion-client

const client = new RequestClient(uppy, { serverUrl: 'https://uppy.mywebsite.com/' })
const client = new RequestClient(uppy, { companionUrl: 'https://uppy.mywebsite.com/' })
client.get('/drive/list').then(() => {})
const provider = new Provider(uppy, {
serverUrl: 'https://uppy.mywebsite.com/',
companionUrl: 'https://uppy.mywebsite.com/',
provider: providerPluginInstance

@@ -27,0 +27,0 @@ })

@@ -77,15 +77,19 @@ 'use strict'

if (opts.serverPattern) {
const pattern = opts.serverPattern
// validate serverPattern param
if (opts.serverUrl || opts.serverPattern) {
throw new Error('`serverUrl` and `serverPattern` have been renamed to `companionUrl` and `companionAllowedHosts` respectively in 0.30.5 release. Please consult the docs (for example, https://uppy.io/docs/instagram/ for Instagram plugin) and use the updated options.`')
}
if (opts.companionAllowedHosts) {
const pattern = opts.companionAllowedHosts
// validate companionAllowedHosts param
if (typeof pattern !== 'string' && !Array.isArray(pattern) && !(pattern instanceof RegExp)) {
throw new TypeError(`${plugin.id}: the option "serverPattern" must be one of string, Array, RegExp`)
throw new TypeError(`${plugin.id}: the option "companionAllowedHosts" must be one of string, Array, RegExp`)
}
plugin.opts.serverPattern = pattern
plugin.opts.companionAllowedHosts = pattern
} else {
// does not start with https://
if (/^(?!https?:\/\/).*$/i.test(opts.serverUrl)) {
plugin.opts.serverPattern = `https://${opts.serverUrl.replace(/^\/\//, '')}`
if (/^(?!https?:\/\/).*$/i.test(opts.companionUrl)) {
plugin.opts.companionAllowedHosts = `https://${opts.companionUrl.replace(/^\/\//, '')}`
} else {
plugin.opts.serverPattern = opts.serverUrl
plugin.opts.companionAllowedHosts = opts.companionUrl
}

@@ -92,0 +96,0 @@ }

@@ -19,3 +19,3 @@ 'use strict'

const { companion } = this.uppy.getState()
const host = this.opts.serverUrl
const host = this.opts.companionUrl
return stripSlash(companion && companion[host] ? companion[host] : host)

@@ -48,3 +48,3 @@ }

const companion = state.companion || {}
const host = this.opts.serverUrl
const host = this.opts.companionUrl
const headers = response.headers

@@ -51,0 +51,0 @@ // Store the self-identified domain name for the Companion instance we just hit.

@@ -6,4 +6,4 @@ const RequestClient = require('./RequestClient')

const mockCore = { getState: () => ({}) }
const a = new RequestClient(mockCore, { serverUrl: 'http://companion.uppy.io' })
const b = new RequestClient(mockCore, { serverUrl: 'http://companion.uppy.io/' })
const a = new RequestClient(mockCore, { companionUrl: 'http://companion.uppy.io' })
const b = new RequestClient(mockCore, { companionUrl: 'http://companion.uppy.io/' })

@@ -10,0 +10,0 @@ expect(a.hostname).toBe('http://companion.uppy.io')

import Uppy = require('@uppy/core');
export interface RequestClientOptions {
serverUrl: string;
companionUrl: string;
serverHeaders?: object;

@@ -6,0 +6,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc