Bläddra i källkod

Merge pull request #1446 from transloadit/serverUrl-to-companionUrl

rename serverUrl to companionUrl
Artur Paikin 6 år sedan
förälder
incheckning
bc2baf740f
55 ändrade filer med 129 tillägg och 129 borttagningar
  1. 2 2
      README.md
  2. 2 2
      examples/aws-companion/main.js
  3. 3 3
      examples/bundled/index.js
  4. 1 1
      examples/custom-provider/client/MyCustomProvider.js
  5. 2 2
      examples/custom-provider/client/main.js
  6. 4 4
      examples/dev/main.js
  7. 1 1
      examples/digitalocean-spaces/main.js
  8. 1 1
      examples/react-example/App.js
  9. 2 2
      examples/uppy-with-companion/client/index.html
  10. 1 1
      packages/@uppy/aws-s3-multipart/README.md
  11. 3 3
      packages/@uppy/aws-s3-multipart/src/index.js
  12. 1 1
      packages/@uppy/aws-s3-multipart/types/index.d.ts
  13. 1 1
      packages/@uppy/aws-s3/README.md
  14. 2 2
      packages/@uppy/aws-s3/src/index.js
  15. 1 1
      packages/@uppy/aws-s3/types/index.d.ts
  16. 2 2
      packages/@uppy/companion-client/README.md
  17. 8 8
      packages/@uppy/companion-client/src/Provider.js
  18. 2 2
      packages/@uppy/companion-client/src/RequestClient.js
  19. 2 2
      packages/@uppy/companion-client/src/RequestClient.test.js
  20. 1 1
      packages/@uppy/companion-client/types/index.d.ts
  21. 2 2
      packages/@uppy/dashboard/src/index.test.js
  22. 1 1
      packages/@uppy/dropbox/src/index.js
  23. 2 2
      packages/@uppy/dropbox/types/index.d.ts
  24. 1 1
      packages/@uppy/google-drive/src/index.js
  25. 2 2
      packages/@uppy/google-drive/types/index.d.ts
  26. 1 1
      packages/@uppy/instagram/src/index.js
  27. 2 2
      packages/@uppy/instagram/types/index.d.ts
  28. 3 3
      packages/@uppy/provider-views/src/index.js
  29. 4 4
      packages/@uppy/robodog/src/addProviders.js
  30. 5 5
      packages/@uppy/transloadit/src/index.js
  31. 1 1
      packages/@uppy/tus/src/index.js
  32. 3 3
      packages/@uppy/url/src/index.js
  33. 1 1
      packages/@uppy/url/types/index.d.ts
  34. 1 1
      packages/@uppy/xhr-upload/src/index.js
  35. 2 2
      packages/uppy/types/uppy-tests.ts
  36. 1 1
      test/endtoend/create-react-app/src/App.js
  37. 3 3
      test/endtoend/providers/main.js
  38. 4 4
      test/endtoend/typescript/main.ts
  39. 1 1
      test/endtoend/url-plugin/main.js
  40. 2 2
      website/src/docs/aws-s3-multipart.md
  41. 3 3
      website/src/docs/aws-s3.md
  42. 3 3
      website/src/docs/dropbox.md
  43. 3 3
      website/src/docs/google-drive.md
  44. 3 3
      website/src/docs/instagram.md
  45. 5 5
      website/src/docs/providers.md
  46. 2 2
      website/src/docs/robodog-picker.md
  47. 9 9
      website/src/docs/transloadit.md
  48. 2 2
      website/src/docs/url.md
  49. 4 4
      website/src/examples/dashboard/app.es6
  50. 3 3
      website/src/examples/dashboard/index.ejs
  51. 2 2
      website/src/examples/transloadit/app.es6
  52. 1 1
      website/src/examples/transloadit/index.ejs
  53. 1 1
      website/src/frontpage-code-sample.ejs
  54. 3 3
      website/themes/uppy/layout/index.ejs
  55. 1 1
      website/themes/uppy/layout/partials/frontpage-code-sample.html

+ 2 - 2
README.md

@@ -33,8 +33,8 @@ const Tus = require('@uppy/tus')
 
 const uppy = Uppy({ autoProceed: false })
   .use(Dashboard, { trigger: '#select-files' })
-  .use(GoogleDrive, { target: Dashboard, serverUrl: 'https://companion.uppy.io' })
-  .use(Instagram, { target: Dashboard, serverUrl: 'https://companion.uppy.io' })
+  .use(GoogleDrive, { target: Dashboard, companionUrl: 'https://companion.uppy.io' })
+  .use(Instagram, { target: Dashboard, companionUrl: 'https://companion.uppy.io' })
   .use(Webcam, { target: Dashboard })
   .use(Tus, { endpoint: 'https://master.tus.io/files/' })
   .on('complete', (result) => {

+ 2 - 2
examples/aws-companion/main.js

@@ -10,7 +10,7 @@ const uppy = Uppy({
 })
 
 uppy.use(GoogleDrive, {
-  serverUrl: 'http://localhost:3020'
+  companionUrl: 'http://localhost:3020'
 })
 uppy.use(Webcam)
 uppy.use(Dashboard, {
@@ -19,5 +19,5 @@ uppy.use(Dashboard, {
   plugins: ['GoogleDrive', 'Webcam']
 })
 uppy.use(AwsS3, {
-  serverUrl: 'http://localhost:3020'
+  companionUrl: 'http://localhost:3020'
 })

+ 3 - 3
examples/bundled/index.js

@@ -33,9 +33,9 @@ const uppy = Uppy({
     proudlyDisplayPoweredByUppy: true,
     note: '2 files, images and video only'
   })
-  .use(GoogleDrive, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Instagram, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Url, { target: Dashboard, serverUrl: 'http://localhost:3020' })
+  .use(GoogleDrive, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Instagram, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Url, { target: Dashboard, companionUrl: 'http://localhost:3020' })
   .use(Webcam, { target: Dashboard })
   .use(Tus, { endpoint: TUS_ENDPOINT })
 

+ 1 - 1
examples/custom-provider/client/MyCustomProvider.js

@@ -18,7 +18,7 @@ module.exports = class MyCustomProvider extends Plugin {
     // writing out the key explicitly for readability the key used to store
     // the provider instance must be equal to this.id.
     this[this.id] = new Provider(uppy, {
-      serverUrl: this.opts.serverUrl,
+      companionUrl: this.opts.companionUrl,
       provider: 'mycustomprovider'
     })
 

+ 2 - 2
examples/custom-provider/client/main.js

@@ -9,11 +9,11 @@ const uppy = Uppy({
 })
 
 uppy.use(GoogleDrive, {
-  serverUrl: 'http://localhost:3020'
+  companionUrl: 'http://localhost:3020'
 })
 
 uppy.use(MyCustomProvider, {
-  serverUrl: 'http://localhost:3020'
+  companionUrl: 'http://localhost:3020'
 })
 
 uppy.use(Dashboard, {

+ 4 - 4
examples/dev/main.js

@@ -31,10 +31,10 @@ const uppy = Uppy({
     proudlyDisplayPoweredByUppy: true,
     note: '2 files, images and video only'
   })
-  .use(GoogleDrive, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Instagram, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Dropbox, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Url, { target: Dashboard, serverUrl: 'http://localhost:3020' })
+  .use(GoogleDrive, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Instagram, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Dropbox, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Url, { target: Dashboard, companionUrl: 'http://localhost:3020' })
   .use(Webcam, { target: Dashboard })
   .use(Tus, { endpoint: TUS_ENDPOINT })
   // .use(XHRUpload, { endpoint: XHR_ENDPOINT })

+ 1 - 1
examples/digitalocean-spaces/main.js

@@ -12,4 +12,4 @@ uppy.use(Dashboard, {
 })
 
 // No client side changes needed!
-uppy.use(AwsS3, { serverUrl: '/companion' })
+uppy.use(AwsS3, { companionUrl: '/companion' })

+ 1 - 1
examples/react-example/App.js

@@ -16,7 +16,7 @@ module.exports = class App extends React.Component {
 
     this.uppy = new Uppy({ id: 'uppy1', autoProceed: true, debug: true })
       .use(Tus, { endpoint: 'https://master.tus.io/files/' })
-      .use(GoogleDrive, { serverUrl: 'https://companion.uppy.io' })
+      .use(GoogleDrive, { companionUrl: 'https://companion.uppy.io' })
 
     this.uppy2 = new Uppy({ id: 'uppy2', autoProceed: false, debug: true })
       .use(Tus, { endpoint: 'https://master.tus.io/files/' })

+ 2 - 2
examples/uppy-with-companion/client/index.html

@@ -12,8 +12,8 @@
     <script>
       const uppy = Uppy.Core({debug: true, autoProceed: false})
         .use(Uppy.Dashboard, { trigger: '#uppyModalOpener' })
-        .use(Uppy.Instagram, { target: Uppy.Dashboard, serverUrl: 'http://localhost:3020' })
-        .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, serverUrl: 'http://localhost:3020' })
+        .use(Uppy.Instagram, { target: Uppy.Dashboard, companionUrl: 'http://localhost:3020' })
+        .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, companionUrl: 'http://localhost:3020' })
         .use(Uppy.Tus, { endpoint: 'https://master.tus.io/files/' })
 
       uppy.on('success', (fileCount) => {

+ 1 - 1
packages/@uppy/aws-s3-multipart/README.md

@@ -18,7 +18,7 @@ const AwsS3Multipart = require('@uppy/aws-s3-multipart')
 const uppy = Uppy()
 uppy.use(AwsS3Multipart, {
   limit: 2,
-  serverUrl: 'https://companion.myapp.com/'
+  companionUrl: 'https://companion.myapp.com/'
 })
 ```
 

+ 3 - 3
packages/@uppy/aws-s3-multipart/src/index.js

@@ -86,8 +86,8 @@ module.exports = class AwsS3Multipart extends Plugin {
   }
 
   assertHost () {
-    if (!this.opts.serverUrl) {
-      throw new Error('Expected a `serverUrl` option containing a Companion address.')
+    if (!this.opts.companionUrl) {
+      throw new Error('Expected a `companionUrl` option containing a Companion address.')
     }
   }
 
@@ -278,7 +278,7 @@ module.exports = class AwsS3Multipart extends Plugin {
   connectToServerSocket (file) {
     return new Promise((resolve, reject) => {
       const token = file.serverToken
-      const host = getSocketHost(file.remote.serverUrl)
+      const host = getSocketHost(file.remote.companionUrl)
       const socket = new Socket({ target: `${host}/api/${token}` })
       this.uploaderSockets[socket] = socket
       this.uploaderEvents[file.id] = createEventTracker(this.uppy)

+ 1 - 1
packages/@uppy/aws-s3-multipart/types/index.d.ts

@@ -8,7 +8,7 @@ declare module AwsS3Multipart {
   }
 
   interface AwsS3MultipartOptions extends Uppy.PluginOptions {
-    serverUrl: string;
+    companionUrl: string;
     createMultipartUpload(file: Uppy.UppyFile): Promise<{ uploadId: string, key: string }>;
     listParts(file: Uppy.UppyFile, opts: { uploadId: string, key: string }): Promise<AwsS3Part[]>;
     prepareUploadPart(file: Uppy.UppyFile, partData: { uploadId: string, key: string, body: Blob, number: number }): Promise<{ url: string }>;

+ 1 - 1
packages/@uppy/aws-s3/README.md

@@ -19,7 +19,7 @@ const uppy = Uppy()
 uppy.use(AwsS3, {
   limit: 2,
   timeout: ms('1 minute'),
-  serverUrl: 'https://companion.myapp.com/'
+  companionUrl: 'https://companion.myapp.com/'
 })
 ```
 

+ 2 - 2
packages/@uppy/aws-s3/src/index.js

@@ -66,8 +66,8 @@ module.exports = class AwsS3 extends Plugin {
   }
 
   getUploadParameters (file) {
-    if (!this.opts.serverUrl) {
-      throw new Error('Expected a `serverUrl` option containing a Companion address.')
+    if (!this.opts.companionUrl) {
+      throw new Error('Expected a `companionUrl` option containing a Companion address.')
     }
 
     const filename = encodeURIComponent(file.meta.name)

+ 1 - 1
packages/@uppy/aws-s3/types/index.d.ts

@@ -9,7 +9,7 @@ declare module AwsS3 {
   }
 
   interface AwsS3Options extends Uppy.PluginOptions {
-    serverUrl: string;
+    companionUrl: string;
     getUploadParameters(file: Uppy.UppyFile): Promise<AwsS3UploadParameters>;
     timeout: number;
     limit: number;

+ 2 - 2
packages/@uppy/companion-client/README.md

@@ -17,11 +17,11 @@ const { Provider, RequestClient, Socket } = require('@uppy/companion-client')
 
 const uppy = Uppy()
 
-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
 })
 provider.checkAuth().then(() => {})

+ 8 - 8
packages/@uppy/companion-client/src/Provider.js

@@ -74,19 +74,19 @@ module.exports = class Provider extends RequestClient {
       plugin.opts = Object.assign({}, defaultOpts, opts)
     }
 
-    if (opts.serverPattern) {
-      const pattern = opts.serverPattern
-      // validate serverPattern param
+    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
       }
     }
 

+ 2 - 2
packages/@uppy/companion-client/src/RequestClient.js

@@ -16,7 +16,7 @@ module.exports = class RequestClient {
 
   get hostname () {
     const { companion } = this.uppy.getState()
-    const host = this.opts.serverUrl
+    const host = this.opts.companionUrl
     return stripSlash(companion && companion[host] ? companion[host] : host)
   }
 
@@ -44,7 +44,7 @@ module.exports = class RequestClient {
   onReceiveResponse (response) {
     const state = this.uppy.getState()
     const companion = state.companion || {}
-    const host = this.opts.serverUrl
+    const host = this.opts.companionUrl
     const headers = response.headers
     // Store the self-identified domain name for the Companion instance we just hit.
     if (headers.has('i-am') && headers.get('i-am') !== companion[host]) {

+ 2 - 2
packages/@uppy/companion-client/src/RequestClient.test.js

@@ -3,8 +3,8 @@ const RequestClient = require('./RequestClient')
 describe('RequestClient', () => {
   it('has a hostname without trailing slash', () => {
     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/' })
 
     expect(a.hostname).toBe('http://companion.uppy.io')
     expect(b.hostname).toBe('http://companion.uppy.io')

+ 1 - 1
packages/@uppy/companion-client/types/index.d.ts

@@ -1,7 +1,7 @@
 import Uppy = require('@uppy/core');
 
 export interface RequestClientOptions {
-  serverUrl: string;
+  companionUrl: string;
   serverHeaders?: object;
 }
 

+ 2 - 2
packages/@uppy/dashboard/src/index.test.js

@@ -35,7 +35,7 @@ describe('Dashboard', () => {
         inline: true,
         target: 'body'
       })
-      core.use(GoogleDrivePlugin, { target: DashboardPlugin, serverUrl: 'https://fake.uppy.io/' })
+      core.use(GoogleDrivePlugin, { target: DashboardPlugin, companionUrl: 'https://fake.uppy.io/' })
     }).not.toThrow()
 
     core.close()
@@ -43,7 +43,7 @@ describe('Dashboard', () => {
 
   it('works when passing plugins in `plugins` array', () => {
     const core = new Core()
-    core.use(GoogleDrivePlugin, { serverUrl: 'https://fake.uppy.io/' })
+    core.use(GoogleDrivePlugin, { companionUrl: 'https://fake.uppy.io/' })
 
     expect(() => {
       core.use(DashboardPlugin, {

+ 1 - 1
packages/@uppy/dropbox/src/index.js

@@ -16,7 +16,7 @@ module.exports = class Dropbox extends Plugin {
     )
 
     this.provider = new Provider(uppy, {
-      serverUrl: this.opts.serverUrl,
+      companionUrl: this.opts.companionUrl,
       serverHeaders: this.opts.serverHeaders,
       storage: this.opts.storage,
       provider: 'dropbox',

+ 2 - 2
packages/@uppy/dropbox/types/index.d.ts

@@ -3,8 +3,8 @@ import CompanionClient = require('@uppy/companion-client');
 
 declare module Dropbox {
   interface DropboxOptions extends Uppy.PluginOptions, CompanionClient.ProviderOptions {
-    serverUrl: string;
-    serverPattern: string | RegExp | Array<string | RegExp>;
+    companionUrl: string;
+    companionAllowedHosts: string | RegExp | Array<string | RegExp>;
   }
 }
 

+ 1 - 1
packages/@uppy/google-drive/src/index.js

@@ -21,7 +21,7 @@ module.exports = class GoogleDrive extends Plugin {
     )
 
     this.provider = new Provider(uppy, {
-      serverUrl: this.opts.serverUrl,
+      companionUrl: this.opts.companionUrl,
       serverHeaders: this.opts.serverHeaders,
       storage: this.opts.storage,
       provider: 'drive',

+ 2 - 2
packages/@uppy/google-drive/types/index.d.ts

@@ -3,8 +3,8 @@ import CompanionClient = require('@uppy/companion-client');
 
 declare module GoogleDrive {
   interface GoogleDriveOptions extends Uppy.PluginOptions, CompanionClient.ProviderOptions {
-    serverUrl: string;
-    serverPattern: string | RegExp | Array<string | RegExp>;
+    companionUrl: string;
+    companionAllowedHosts: string | RegExp | Array<string | RegExp>;
   }
 }
 

+ 1 - 1
packages/@uppy/instagram/src/index.js

@@ -18,7 +18,7 @@ module.exports = class Instagram extends Plugin {
     )
 
     this.provider = new Provider(uppy, {
-      serverUrl: this.opts.serverUrl,
+      companionUrl: this.opts.companionUrl,
       serverHeaders: this.opts.serverHeaders,
       storage: this.opts.storage,
       provider: 'instagram',

+ 2 - 2
packages/@uppy/instagram/types/index.d.ts

@@ -3,8 +3,8 @@ import CompanionClient = require('@uppy/companion-client');
 
 declare module Instagram {
   interface InstagramOptions extends Uppy.PluginOptions, CompanionClient.ProviderOptions {
-    serverUrl: string;
-    serverPattern: string | RegExp | Array<string | RegExp>;
+    companionUrl: string;
+    companionAllowedHosts: string | RegExp | Array<string | RegExp>;
   }
 }
 

+ 3 - 3
packages/@uppy/provider-views/src/index.js

@@ -153,7 +153,7 @@ module.exports = class ProviderView {
         fileId: file.id
       },
       remote: {
-        serverUrl: this.plugin.opts.serverUrl,
+        companionUrl: this.plugin.opts.companionUrl,
         url: `${this.provider.fileUrl(file.requestPath)}`,
         body: {
           fileId: file.id
@@ -423,8 +423,8 @@ module.exports = class ProviderView {
 
     const authWindow = window.open(link, '_blank')
     const handleToken = (e) => {
-      if (!this._isOriginAllowed(e.origin, this.plugin.opts.serverPattern) || e.source !== authWindow) {
-        this.plugin.uppy.log(`rejecting event from ${e.origin} vs allowed pattern ${this.plugin.opts.serverPattern}`)
+      if (!this._isOriginAllowed(e.origin, this.plugin.opts.companionAllowedHosts) || e.source !== authWindow) {
+        this.plugin.uppy.log(`rejecting event from ${e.origin} vs allowed pattern ${this.plugin.opts.companionAllowedHosts}`)
         return
       }
       authWindow.close()

+ 4 - 4
packages/@uppy/robodog/src/addProviders.js

@@ -12,8 +12,8 @@ const localProviders = {
 }
 
 const remoteProviderOptionNames = [
-  'serverUrl',
-  'serverPattern',
+  'companionUrl',
+  'companionAllowedHosts',
   'serverHeaders',
   'target'
 ]
@@ -27,8 +27,8 @@ function addRemoteProvider (uppy, name, opts) {
   const Provider = remoteProviders[name]
   const providerOptions = {
     // Default to the :tl: Companion servers.
-    serverUrl: Transloadit.COMPANION,
-    serverPattern: Transloadit.COMPANION_PATTERN
+    companionUrl: Transloadit.COMPANION,
+    companionAllowedHosts: Transloadit.COMPANION_PATTERN
   }
 
   remoteProviderOptionNames.forEach((name) => {

+ 5 - 5
packages/@uppy/transloadit/src/index.js

@@ -113,10 +113,10 @@ module.exports = class Transloadit extends Plugin {
     // We only replace the hostname for Transloadit's companions, so that
     // people can also self-host them while still using Transloadit for encoding.
     let remote = file.remote
-    if (file.remote && TL_UPPY_SERVER.test(file.remote.serverUrl)) {
+    if (file.remote && TL_UPPY_SERVER.test(file.remote.companionUrl)) {
       const err = new Error(
         'The https://api2.transloadit.com/uppy-server endpoint was renamed to ' +
-        'https://api2.transloadit.com/companion, please update your `serverUrl` ' +
+        'https://api2.transloadit.com/companion, please update your `companionUrl` ' +
         'options accordingly.')
       // Explicitly log this error here because it is caught by the `createAssembly`
       // Promise further along.
@@ -126,16 +126,16 @@ module.exports = class Transloadit extends Plugin {
       throw err
     }
 
-    if (file.remote && TL_COMPANION.test(file.remote.serverUrl)) {
+    if (file.remote && TL_COMPANION.test(file.remote.companionUrl)) {
       const newHost = status.companion_url
         .replace(/\/$/, '')
       const path = file.remote.url
-        .replace(file.remote.serverUrl, '')
+        .replace(file.remote.companionUrl, '')
         .replace(/^\//, '')
 
       remote = {
         ...file.remote,
-        serverUrl: newHost,
+        companionUrl: newHost,
         url: `${newHost}/${path}`
       }
     }

+ 1 - 1
packages/@uppy/tus/src/index.js

@@ -271,7 +271,7 @@ module.exports = class Tus extends Plugin {
   connectToServerSocket (file) {
     return new Promise((resolve, reject) => {
       const token = file.serverToken
-      const host = getSocketHost(file.remote.serverUrl)
+      const host = getSocketHost(file.remote.companionUrl)
       const socket = new Socket({ target: `${host}/api/${token}` })
       this.uploaderSockets[file.id] = socket
       this.uploaderEvents[file.id] = createEventTracker(this.uppy)

+ 3 - 3
packages/@uppy/url/src/index.js

@@ -40,7 +40,7 @@ module.exports = class Url extends Plugin {
     this.i18n = this.translator.translate.bind(this.translator)
     this.i18nArray = this.translator.translateArray.bind(this.translator)
 
-    this.hostname = this.opts.serverUrl
+    this.hostname = this.opts.companionUrl
 
     if (!this.hostname) {
       throw new Error('Companion hostname is required, please consult https://uppy.io/docs/companion')
@@ -56,7 +56,7 @@ module.exports = class Url extends Plugin {
     this.handlePaste = this.handlePaste.bind(this)
 
     this.client = new RequestClient(uppy, {
-      serverUrl: this.opts.serverUrl,
+      companionUrl: this.opts.companionUrl,
       serverHeaders: this.opts.serverHeaders
     })
   }
@@ -120,7 +120,7 @@ module.exports = class Url extends Plugin {
             url: url
           },
           remote: {
-            serverUrl: this.opts.serverUrl,
+            companionUrl: this.opts.companionUrl,
             url: `${this.hostname}/url/get`,
             body: {
               fileId: url,

+ 1 - 1
packages/@uppy/url/types/index.d.ts

@@ -2,7 +2,7 @@ import Uppy = require('@uppy/core');
 
 declare module Url {
   export interface UrlOptions extends Uppy.PluginOptions {
-    serverUrl: string;
+    companionUrl: string;
     // TODO inherit from ProviderOptions
   }
 }

+ 1 - 1
packages/@uppy/xhr-upload/src/index.js

@@ -333,7 +333,7 @@ module.exports = class XHRUpload extends Plugin {
       )
       .then((res) => {
         const token = res.token
-        const host = getSocketHost(file.remote.serverUrl)
+        const host = getSocketHost(file.remote.companionUrl)
         const socket = new Socket({ target: `${host}/api/${token}` })
 
         socket.on('progress', (progressData) => emitSocketProgress(this, progressData, file))

+ 2 - 2
packages/uppy/types/uppy-tests.ts

@@ -17,8 +17,8 @@ import * as Uppy from '../';
 (() => {
   const uppy = Uppy.Core({ autoProceed: false })
     .use(Uppy.Dashboard, { trigger: '#select-files' })
-    .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, serverUrl: 'https://companion.uppy.io' })
-    .use(Uppy.Instagram, { target: Uppy.Dashboard, serverUrl: 'https://companion.uppy.io' })
+    .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, companionUrl: 'https://companion.uppy.io' })
+    .use(Uppy.Instagram, { target: Uppy.Dashboard, companionUrl: 'https://companion.uppy.io' })
     .use(Uppy.Webcam, { target: Uppy.Dashboard })
     .use(Uppy.Tus, { endpoint: 'https://master.tus.io/files/' })
     .on('complete', (result) => {

+ 1 - 1
test/endtoend/create-react-app/src/App.js

@@ -15,7 +15,7 @@ class App extends Component {
 
     this.uppy = new Uppy({ id: 'uppy1', autoProceed: true, debug: true })
       .use(Tus, { endpoint: 'https://master.tus.io/files/' })
-      .use(GoogleDrive, { serverUrl: 'https://companion.uppy.io' })
+      .use(GoogleDrive, { companionUrl: 'https://companion.uppy.io' })
 
     this.uppy2 = new Uppy({ id: 'uppy2', autoProceed: false, debug: true })
       .use(Tus, { endpoint: 'https://master.tus.io/files/' })

+ 3 - 3
test/endtoend/providers/main.js

@@ -16,7 +16,7 @@ Uppy({
     target: '#uppyDashboard',
     inline: true
   })
-  .use(GoogleDrive, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Instagram, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Dropbox, { target: Dashboard, serverUrl: 'http://localhost:3020' })
+  .use(GoogleDrive, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Instagram, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Dropbox, { target: Dashboard, companionUrl: 'http://localhost:3020' })
   .use(Tus, { endpoint: 'https://master.tus.io/files/' })

+ 4 - 4
test/endtoend/typescript/main.ts

@@ -32,10 +32,10 @@ const uppy = Core({
     proudlyDisplayPoweredByUppy: true,
     note: '2 files, images and video only'
   })
-  .use(GoogleDrive, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Instagram, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Dropbox, { target: Dashboard, serverUrl: 'http://localhost:3020' })
-  .use(Url, { target: Dashboard, serverUrl: 'http://localhost:3020' })
+  .use(GoogleDrive, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Instagram, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Dropbox, { target: Dashboard, companionUrl: 'http://localhost:3020' })
+  .use(Url, { target: Dashboard, companionUrl: 'http://localhost:3020' })
   .use(Webcam, { target: Dashboard })
   .use(Tus, { endpoint: TUS_ENDPOINT })
   .use(Form, { target: '#upload-form' })

+ 1 - 1
test/endtoend/url-plugin/main.js

@@ -16,7 +16,7 @@ function initUrlPlugin (companionUrl) {
     })
     .use(Url, {
       target: Dashboard,
-      serverUrl: companionUrl
+      companionUrl: companionUrl
     })
     .use(Tus, { endpoint: 'https://master.tus.io/files/' })
 }

+ 2 - 2
website/src/docs/aws-s3-multipart.md

@@ -13,7 +13,7 @@ The `@uppy/aws-s3-multipart` plugin can be used to upload files directly to an S
 const AwsS3Multipart = require('@uppy/aws-s3-multipart')
 uppy.use(AwsS3Multipart, {
   limit: 4,
-  serverUrl: 'https://uppy-companion.myapp.net/'
+  companionUrl: 'https://uppy-companion.myapp.net/'
 })
 ```
 
@@ -41,7 +41,7 @@ The `@uppy/aws-s3-multipart` plugin has the following configurable options:
 
 The maximum amount of chunks to upload simultaneously. Set to `0` to disable limiting.
 
-### serverUrl: null
+### companionUrl: null
 
 The Companion URL to use for proxying calls to the S3 Multipart API.
 

+ 3 - 3
website/src/docs/aws-s3.md

@@ -17,7 +17,7 @@ const ms = require('ms')
 uppy.use(AwsS3, {
   limit: 2,
   timeout: ms('1 minute'),
-  serverUrl: 'https://uppy-companion.myapp.com/'
+  companionUrl: 'https://uppy-companion.myapp.com/'
 })
 ```
 
@@ -49,13 +49,13 @@ The `@uppy/aws-s3` plugin has the following configurable options:
 
 A unique identifier for this plugin. Defaults to `'AwsS3'`.
 
-### `serverUrl`
+### `companionUrl`
 
 When using [Companion][companion docs] to sign S3 uploads, set this option to the root URL of the Companion instance.
 
 ```js
 uppy.use(AwsS3, {
-  serverUrl: 'https://uppy-companion.my-app.com/'
+  companionUrl: 'https://uppy-companion.my-app.com/'
 })
 ```
 

+ 3 - 3
website/src/docs/dropbox.md

@@ -52,7 +52,7 @@ The `@uppy/dropbox` plugin has the following configurable options:
 ```js
 uppy.use(Dropbox, {
   target: Dashboard,
-  serverUrl: 'https://companion.uppy.io/',
+  companionUrl: 'https://companion.uppy.io/',
 })
 ```
 
@@ -68,7 +68,7 @@ Title / name shown in the UI, such as Dashboard tabs. It defaults to `'Dropbox'`
 
 DOM element, CSS selector, or plugin to mount the Dropbox provider into. This should normally be the Dashboard.
 
-### `serverUrl: null`
+### `companionUrl: null`
 
 URL to a [Companion](/docs/companion) instance.
 
@@ -76,7 +76,7 @@ URL to a [Companion](/docs/companion) instance.
 
 Custom headers that should be sent along to [Companion](/docs/companion) on every request.
 
-### `serverPattern: serverUrl`
+### `companionAllowedHosts: companionUrl`
 
 The valid and authorised URL(s) from which OAuth responses should be accepted.
 

+ 3 - 3
website/src/docs/google-drive.md

@@ -51,7 +51,7 @@ The `@uppy/google-drive` plugin has the following configurable options:
 ```js
 uppy.use(GoogleDrive, {
   target: Dashboard,
-  serverUrl: 'https://companion.uppy.io/',
+  companionUrl: 'https://companion.uppy.io/',
 })
 ```
 
@@ -67,7 +67,7 @@ Configures the title / name shown in the UI, for instance, on Dashboard tabs. It
 
 DOM element, CSS selector, or plugin to mount the Google Drive provider into. This should normally be the the [`@uppy/dashboard`](/docs/dashboard) plugin.
 
-### `serverUrl: null`
+### `companionUrl: null`
 
 URL to a [Companion](/docs/companion) instance.
 
@@ -75,7 +75,7 @@ URL to a [Companion](/docs/companion) instance.
 
 Custom headers that should be sent along to [Companion](/docs/companion) on every request.
 
-### `serverPattern: serverUrl`
+### `companionAllowedHosts: companionUrl`
 
 The valid and authorised URL(s) from which OAuth responses should be accepted.
 

+ 3 - 3
website/src/docs/instagram.md

@@ -53,7 +53,7 @@ The `@uppy/instagram` plugin has the following configurable options:
 ```js
 uppy.use(Instagram, {
   target: Dashboard,
-  serverUrl: 'https://companion.uppy.io/',
+  companionUrl: 'https://companion.uppy.io/',
 })
 ```
 
@@ -69,7 +69,7 @@ Configures the title / name shown in the UI, for instance, on Dashboard tabs. It
 
 DOM element, CSS selector, or plugin to mount the Instagram provider into. This should normally be the Dashboard.
 
-### `serverUrl: null`
+### `companionUrl: null`
 
 URL to a [Companion](/docs/companion) instance.
 
@@ -77,7 +77,7 @@ URL to a [Companion](/docs/companion) instance.
 
 Custom headers that should be sent along to [Companion](/docs/companion) on every request.
 
-### `serverPattern: serverUrl`
+### `companionAllowedHosts: companionUrl`
 
 The valid and authorised URL(s) from which OAuth responses should be accepted.
 

+ 5 - 5
website/src/docs/providers.md

@@ -10,7 +10,7 @@ The Provider plugins help you connect to your accounts with remote file provider
 
 As of now, the supported providers are [**Dropbox**](/docs/dropbox), [**GoogleDrive**](/docs/google-drive), [**Instagram**](/docs/instagram), and [**URL**](/docs/url).
 
-Usage of the Provider plugins is not that different from any other *acquirer* plugin, except that it takes an extra option `serverUrl`, which specifies the URL to the Companion that you are running. This allows Uppy to know what server to connect to when datacenter operations are required by the provider plugin.
+Usage of the Provider plugins is not that different from any other *acquirer* plugin, except that it takes an extra option `companionUrl`, which specifies the URL to the Companion that you are running. This allows Uppy to know what server to connect to when datacenter operations are required by the provider plugin.
 
 Here's a quick example:
 
@@ -24,19 +24,19 @@ uppy.use(Dashboard, {
 
 // for Google Drive
 const GoogleDrive = require('@uppy/google-drive')
-uppy.use(GoogleDrive, {target: Dashboard, serverUrl: 'http://localhost:3020'})
+uppy.use(GoogleDrive, {target: Dashboard, companionUrl: 'http://localhost:3020'})
 
 // for Dropbox
 const Dropbox = require('@uppy/dropbox')
-uppy.use(Dropbox, {target: Dashboard, serverUrl: 'http://localhost:3020'})
+uppy.use(Dropbox, {target: Dashboard, companionUrl: 'http://localhost:3020'})
 
 // for Instagram
 const Instagram = require('@uppy/instagram')
-uppy.use(Instagram, {target: Dashboard, serverUrl: 'http://localhost:3020'})
+uppy.use(Instagram, {target: Dashboard, companionUrl: 'http://localhost:3020'})
 
 // for URL
 const Url = require('@uppy/url')
-uppy.use(Url, {target: Dashboard, serverUrl: 'http://localhost:3020'})
+uppy.use(Url, {target: Dashboard, companionUrl: 'http://localhost:3020'})
 ```
 
 ⚠️ The [Dashboard](/docs/dashboard) plugin is recommended as a universal container to all Provider plugins. It also comes with file previews, progress reporting and more. If you are using the Dashboard, it already [comes with all the nessesary styles](/docs/dashboard/#CSS) and functionality for Providers to work well.

+ 2 - 2
website/src/docs/robodog-picker.md

@@ -77,11 +77,11 @@ Array of providers to use. Each entry is the name of a provider. The available o
 - `'url'` – Import files from public Web URLs using [Uppy Companion][companion].
 - `'webcam'` – Take photos and record videos using thee user's device camera.
 
-### `serverUrl: Transloadit.COMPANION`
+### `companionUrl: Transloadit.COMPANION`
 
 The URL to a [Uppy Companion][companion] server to use.
 
-### `serverPattern: Transloadit.COMPANION_PATTERN`
+### `companionAllowedHosts: Transloadit.COMPANION_PATTERN`
 
 The valid and authorised URL(s) from which OAuth responses should be accepted.
 

+ 9 - 9
website/src/docs/transloadit.md

@@ -59,38 +59,38 @@ const Dropbox = require('@uppy/dropbox')
 const Transloadit = require('@uppy/transloadit')
 
 uppy.use(Dropbox, {
-  serverUrl: Transloadit.COMPANION
-  serverPattern: Transloadit.COMPANION_PATTERN
+  companionUrl: Transloadit.COMPANION
+  companionAllowedHosts: Transloadit.COMPANION_PATTERN
 })
 ```
 
-When using `Transloadit.COMPANION`, you should also configure [`serverPattern: Transloadit.COMPANION_PATTERN`](#Transloadit-COMPANION-PATTERN).
+When using `Transloadit.COMPANION`, you should also configure [`companionAllowedHosts: Transloadit.COMPANION_PATTERN`](#Transloadit-COMPANION-PATTERN).
 
 The value of this constant is `https://api2.transloadit.com/companion`. If you are using a custom [`service`](#service) option, you should also set a custom host option in your provider plugins, by taking a Transloadit API url and appending `/companion`:
 
 ```js
 uppy.use(Dropbox, {
-  serverUrl: 'https://api2-us-east-1.transloadit.com/companion'
+  companionUrl: 'https://api2-us-east-1.transloadit.com/companion'
 })
 ```
 
 ### `Transloadit.COMPANION_PATTERN`
 
-A RegExp pattern matching Transloadit's hosted companion endpoints. The pattern is used in remote provider `serverPattern` options, to ensure that third party authentication messages cannot be faked by an attacker's page, but can only originate from Transloadit's servers.
+A RegExp pattern matching Transloadit's hosted companion endpoints. The pattern is used in remote provider `companionAllowedHosts` options, to ensure that third party authentication messages cannot be faked by an attacker's page, but can only originate from Transloadit's servers.
 
-Use it whenever you use `serverUrl: Transloadit.COMPANION`, like so:
+Use it whenever you use `companionUrl: Transloadit.COMPANION`, like so:
 
 ```js
 const Dropbox = require('@uppy/dropbox')
 const Transloadit = require('@uppy/transloadit')
 
 uppy.use(Dropbox, {
-  serverUrl: Transloadit.COMPANION
-  serverPattern: Transloadit.COMPANION_PATTERN
+  companionUrl: Transloadit.COMPANION
+  companionAllowedHosts: Transloadit.COMPANION_PATTERN
 })
 ```
 
-The value of this constant covers _all_ Transloadit's Companion servers, so it does not need to be changed if you are using a custom [`service`](#service) option. However, if you are not using the Transloadit Companion servers at `*.transloadit.com`, make sure to set the `serverPattern` option to something that matches what you do use.
+The value of this constant covers _all_ Transloadit's Companion servers, so it does not need to be changed if you are using a custom [`service`](#service) option. However, if you are not using the Transloadit Companion servers at `*.transloadit.com`, make sure to set the `companionAllowedHosts` option to something that matches what you do use.
 
 ## Options
 

+ 2 - 2
website/src/docs/url.md

@@ -56,7 +56,7 @@ The `@uppy/url` plugin has the following configurable options:
 ```js
 uppy.use(Url, {
   target: Dashboard,
-  serverUrl: 'https://companion.uppy.io/',
+  companionUrl: 'https://companion.uppy.io/',
   locale: {}
 })
 ```
@@ -73,7 +73,7 @@ Configures the title / name shown in the UI, for instance, on Dashboard tabs. It
 
 DOM element, CSS selector, or plugin to mount the URL provider into. This should normally be the Dashboard.
 
-### `serverUrl: null`
+### `companionUrl: null`
 
 URL to an Companion instance.
 

+ 4 - 4
website/src/examples/dashboard/app.es6

@@ -52,19 +52,19 @@ function uppyInit () {
   })
 
   if (opts.GoogleDrive) {
-    uppy.use(GoogleDrive, { target: Dashboard, serverUrl: COMPANION })
+    uppy.use(GoogleDrive, { target: Dashboard, companionUrl: COMPANION })
   }
 
   if (opts.Dropbox) {
-    uppy.use(Dropbox, { target: Dashboard, serverUrl: COMPANION })
+    uppy.use(Dropbox, { target: Dashboard, companionUrl: COMPANION })
   }
 
   if (opts.Instagram) {
-    uppy.use(Instagram, { target: Dashboard, serverUrl: COMPANION })
+    uppy.use(Instagram, { target: Dashboard, companionUrl: COMPANION })
   }
 
   if (opts.Url) {
-    uppy.use(Url, { target: Dashboard, serverUrl: COMPANION })
+    uppy.use(Url, { target: Dashboard, companionUrl: COMPANION })
   }
 
   if (opts.Webcam) {

+ 3 - 3
website/src/examples/dashboard/index.ejs

@@ -52,9 +52,9 @@ const uppy = Uppy({
   ],
   browserBackButtonClose: true
 })
-.use(GoogleDrive, { target: Dashboard, serverUrl: 'https://companion.uppy.io' })
-.use(Dropbox, { target: Dashboard, serverUrl: 'https://companion.uppy.io' })
-.use(Instagram, { target: Dashboard, serverUrl: 'https://companion.uppy.io' })
+.use(GoogleDrive, { target: Dashboard, companionUrl: 'https://companion.uppy.io' })
+.use(Dropbox, { target: Dashboard, companionUrl: 'https://companion.uppy.io' })
+.use(Instagram, { target: Dashboard, companionUrl: 'https://companion.uppy.io' })
 .use(Webcam, { target: Dashboard })
 .use(Tus, { endpoint: 'https://master.tus.io/files/' })
 

+ 2 - 2
website/src/examples/transloadit/app.es6

@@ -61,8 +61,8 @@ function initUppy () {
     })
     .use(Instagram, {
       target: Dashboard,
-      serverUrl: 'https://api2.transloadit.com/companion',
-      serverPattern: Transloadit.COMPANION_PATTERN
+      companionUrl: 'https://api2.transloadit.com/companion',
+      companionAllowedHosts: Transloadit.COMPANION_PATTERN
     })
     .use(Webcam, { target: Dashboard })
 

+ 1 - 1
website/src/examples/transloadit/index.ejs

@@ -126,7 +126,7 @@ uppy
     },
     waitForEncoding: true
   })
-  .use(Instagram, { target: Dashboard, serverUrl: 'https://api2.transloadit.com/companion', serverPattern: /\.transloadit\.com$/ })
+  .use(Instagram, { target: Dashboard, companionUrl: 'https://api2.transloadit.com/companion', companionAllowedHosts: /\.transloadit\.com$/ })
   .use(Dashboard, {
     inline: true,
     maxHeight: 400,

+ 1 - 1
website/src/frontpage-code-sample.ejs

@@ -22,7 +22,7 @@ Uppy()
   })
   .use(Instagram, {
     target: Dashboard,
-    serverUrl: 'https://companion.uppy.io'
+    companionUrl: 'https://companion.uppy.io'
   })
   .use(Tus, { endpoint: 'https://master.tus.io/files/' })
   .on('complete', (result) => {

+ 3 - 3
website/themes/uppy/layout/index.ejs

@@ -102,10 +102,10 @@
         { id: 'caption', name: 'Caption', placeholder: 'describe what the image is about' }
       ]
     })
-    .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, serverUrl: COMPANION_ENDPOINT })
-    .use(Uppy.Instagram, { target: Uppy.Dashboard, serverUrl: COMPANION_ENDPOINT })
+    .use(Uppy.GoogleDrive, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
+    .use(Uppy.Instagram, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
     .use(Uppy.Webcam, { target: Uppy.Dashboard })
-    .use(Uppy.Url, { target: Uppy.Dashboard, serverUrl: COMPANION_ENDPOINT })
+    .use(Uppy.Url, { target: Uppy.Dashboard, companionUrl: COMPANION_ENDPOINT })
     .use(Uppy.Tus, { endpoint: TUS_ENDPOINT})
 
   uppy.on('success', (files) => {

+ 1 - 1
website/themes/uppy/layout/partials/frontpage-code-sample.html

@@ -12,7 +12,7 @@
   <span class="token punctuation">}</span><span class="token punctuation">)</span>
   <span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>Instagram<span class="token punctuation">,</span> <span class="token punctuation">{</span>
     target<span class="token punctuation">:</span> Dashboard<span class="token punctuation">,</span>
-    serverUrl<span class="token punctuation">:</span> <span class="token string">&apos;https://companion.uppy.io&apos;</span>
+    companionUrl<span class="token punctuation">:</span> <span class="token string">&apos;https://companion.uppy.io&apos;</span>
   <span class="token punctuation">}</span><span class="token punctuation">)</span>
   <span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>Tus<span class="token punctuation">,</span> <span class="token punctuation">{</span> endpoint<span class="token punctuation">:</span> <span class="token string">&apos;https://master.tus.io/files/&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span>
   <span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string">&apos;complete&apos;</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token parameter">result</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>