|
@@ -15,6 +15,8 @@ function defaultGetAssemblyOptions (file, options) {
|
|
}
|
|
}
|
|
|
|
|
|
const COMPANION = 'https://api2.transloadit.com/companion'
|
|
const COMPANION = 'https://api2.transloadit.com/companion'
|
|
|
|
+// Regex matching acceptable postMessage() origins for authentication feedback from companion.
|
|
|
|
+const ALLOWED_COMPANION_PATTERN = /\.transloadit\.com$/
|
|
// Regex used to check if a Companion address is run by Transloadit.
|
|
// Regex used to check if a Companion address is run by Transloadit.
|
|
const TL_COMPANION = /https?:\/\/api2(?:-\w+)?\.transloadit\.com\/companion/
|
|
const TL_COMPANION = /https?:\/\/api2(?:-\w+)?\.transloadit\.com\/companion/
|
|
const TL_UPPY_SERVER = /https?:\/\/api2(?:-\w+)?\.transloadit\.com\/uppy-server/
|
|
const TL_UPPY_SERVER = /https?:\/\/api2(?:-\w+)?\.transloadit\.com\/uppy-server/
|
|
@@ -116,10 +118,11 @@ module.exports = class Transloadit extends Plugin {
|
|
this.uppy.log(err)
|
|
this.uppy.log(err)
|
|
throw err
|
|
throw err
|
|
}
|
|
}
|
|
|
|
+
|
|
if (file.remote && TL_COMPANION.test(file.remote.serverUrl)) {
|
|
if (file.remote && TL_COMPANION.test(file.remote.serverUrl)) {
|
|
- let newHost = status.companion_url
|
|
|
|
|
|
+ const newHost = status.companion_url
|
|
.replace(/\/$/, '')
|
|
.replace(/\/$/, '')
|
|
- let path = file.remote.url
|
|
|
|
|
|
+ const path = file.remote.url
|
|
.replace(file.remote.serverUrl, '')
|
|
.replace(file.remote.serverUrl, '')
|
|
.replace(/^\//, '')
|
|
.replace(/^\//, '')
|
|
|
|
|
|
@@ -695,3 +698,4 @@ module.exports = class Transloadit extends Plugin {
|
|
|
|
|
|
module.exports.COMPANION = COMPANION
|
|
module.exports.COMPANION = COMPANION
|
|
module.exports.UPPY_SERVER = COMPANION
|
|
module.exports.UPPY_SERVER = COMPANION
|
|
|
|
+module.exports.COMPANION_PATTERN = ALLOWED_COMPANION_PATTERN
|