Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging #3638

Merged
merged 4 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ VITE_UPLOADER=tus
# VITE_UPLOADER=transloadit-xhr

VITE_COMPANION_URL=http://localhost:3020
# See also Transloadit.COMPANION_PATTERN
VITE_COMPANION_ALLOWED_HOSTS=/\.transloadit\.com$/
VITE_TUS_ENDPOINT=https://tusd.tusdemo.net/files/
VITE_XHR_ENDPOINT=https://xhr-server.herokuapp.com/upload

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,28 @@ export default class ProviderView extends View {

const authWindow = window.open(link, '_blank')
const handleToken = (e) => {
if (e.source !== authWindow) {
this.plugin.uppy.log('rejecting event from unknown source')
return
}
if (!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
}

// Check if it's a string before doing the JSON.parse to maintain support
// for older Companion versions that used object references
const data = typeof e.data === 'string' ? JSON.parse(e.data) : e.data

if (data.error) {
this.plugin.uppy.log('auth aborted')
this.plugin.uppy.log('auth aborted', 'warning')
const { uppy } = this.plugin
const message = uppy.i18n('authAborted')
uppy.info({ message }, 'warning', 5000)
return
}

if (!data.token) {
this.plugin.uppy.log('did not receive token from auth window')
this.plugin.uppy.log('did not receive token from auth window', 'error')
return
}

Expand Down
20 changes: 11 additions & 9 deletions private/dev/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import generateSignatureIfSecret from './generateSignatureIfSecret.js'
const {
VITE_UPLOADER : UPLOADER,
VITE_COMPANION_URL : COMPANION_URL,
VITE_COMPANION_ALLOWED_HOSTS : companionAllowedHosts,
VITE_TUS_ENDPOINT : TUS_ENDPOINT,
VITE_XHR_ENDPOINT : XHR_ENDPOINT,
VITE_TRANSLOADIT_KEY : TRANSLOADIT_KEY,
Expand Down Expand Up @@ -75,18 +76,19 @@ export default () => {
proudlyDisplayPoweredByUppy: true,
note: '2 files, images and video only',
})
// .use(GoogleDrive, { target: Dashboard, companionUrl: COMPANION_URL })
// .use(Instagram, { target: Dashboard, companionUrl: COMPANION_URL })
// .use(Dropbox, { target: Dashboard, companionUrl: COMPANION_URL })
// .use(Box, { target: Dashboard, companionUrl: COMPANION_URL })
// .use(Facebook, { target: Dashboard, companionUrl: COMPANION_URL })
// .use(OneDrive, { target: Dashboard, companionUrl: COMPANION_URL })
// .use(Zoom, { target: Dashboard, companionUrl: COMPANION_URL })
// .use(Url, { target: Dashboard, companionUrl: COMPANION_URL })
// .use(Unsplash, { target: Dashboard, companionUrl: COMPANION_URL })
// .use(GoogleDrive, { target: Dashboard, companionUrl: COMPANION_URL, companionAllowedHosts })
// .use(Instagram, { target: Dashboard, companionUrl: COMPANION_URL, companionAllowedHosts })
// .use(Dropbox, { target: Dashboard, companionUrl: COMPANION_URL, companionAllowedHosts })
// .use(Box, { target: Dashboard, companionUrl: COMPANION_URL, companionAllowedHosts })
// .use(Facebook, { target: Dashboard, companionUrl: COMPANION_URL, companionAllowedHosts })
// .use(OneDrive, { target: Dashboard, companionUrl: COMPANION_URL, companionAllowedHosts })
// .use(Zoom, { target: Dashboard, companionUrl: COMPANION_URL, companionAllowedHosts })
// .use(Url, { target: Dashboard, companionUrl: COMPANION_URL, companionAllowedHosts })
// .use(Unsplash, { target: Dashboard, companionUrl: COMPANION_URL, companionAllowedHosts })
.use(RemoteSources, {
companionUrl: COMPANION_URL,
sources: ['Box', 'Dropbox', 'Facebook', 'GoogleDrive', 'Instagram', 'OneDrive', 'Unsplash', 'Url'],
companionAllowedHosts,
})
.use(Webcam, {
target: Dashboard,
Expand Down