* fix uploadRemoteFile undefined
for some reason, only when testing locally using VITE_COMPANION_URL=https://api2.transloadit.com/companion only
we get this error...
i'm thinking for some reason, the remote file gets serialized into state and then de-serialized again
causing remote.requestClient to be gone
so I solve it by instead storing the request clients in Uppy
fixes#4791
* fix bugs
* remove unrelated space changes
* apply suggestions
* Update Uppy.js
* fix lint
---------
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
* fix double uploads
fixes#4815
also improve error logging when canceling
* don't close socket when pausing
because it prevented us from canceling an upload that is paused
note that we here sacrifice the ability to pause uploads and have other uploads take over the paused upload's rate limit queue spot.
this is sacrificed because we will soon remove the ability to pause/resume uploads anyways
* Update packages/@uppy/companion/src/server/Uploader.js
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
* Revert "don't close socket when pausing"
This reverts commit e4dbe77d2f.
---------
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
* remove useless line
* fix broken cookie removal logic
related #4426
* fix mime type of thumbnails
not critical but some browsers might have problems
* simplify/speedup token generation
so we don't have to decode/decrypt/encode/encrypt so many times
* use instanceof instead of prop check
* Implement alternative provider auth
New concept "simple auth" - authentication that happens immediately (in one http request) without redirecting to any third party.
uppyAuthToken initially used to simply contain an encrypted & json encoded OAuth2 access_token for a specific provider. Then we added refresh tokens as well inside uppyAuthToken #4448. Now we also allow storing other state or parameters needed for that specific provider, like username, password, host name, webdav URL etc... This is needed for providers like webdav, ftp etc, where the user needs to give some more input data while authenticating
Companion:
- `providerTokens` has been renamed to `providerUserSession` because it now includes not only tokens, but a user's session with a provider.
Companion `Provider` class:
- New `hasSimpleAuth` static boolean property - whether this provider uses simple auth
- uppyAuthToken expiry default 24hr again for providers that don't support refresh tokens
- make uppyAuthToken expiry configurable per provider - new `authStateExpiry` static property (defaults to 24hr)
- new static property `grantDynamicToUserSession`, allows providers to specify which state from Grant `dynamic` to include into the provider's `providerUserSession`.
* refactor
* use respondWithError
also for thumbnails
for consistency
* fix prepareStream
it wasn't returning the status code (like `got` does on error)
it's needed to respond properly with a http error
* don't throw when missing i18n key
instead log error and show the key
this in on par with other i18n frameworks
* fix bugged try/catch
* allow aborting login too
and don't replace the whole view with a loader when plugin state loading
it will cause auth views to lose state
an inter-view loading text looks much more graceful and is how SearchProviderView works too
* add json http error support
add support for passing objects and messages from companion to uppy
this allows companion to for example give a more detailed error when authenticating
* don't tightly couple auth form with html form
don't force the user to use html form
and use preact for it, for flexibility
* fix i18n
* make contentType parameterized
* allow sending certain errors to the user
this is useful because:
// onedrive gives some errors here that the user might want to know about
// e.g. these happen if you try to login to a users in an organization,
// without an Office365 licence or OneDrive account setup completed
// 400: Tenant does not have a SPO license
// 403: You do not have access to create this personal site or you do not have a valid license
* make `authProvider` consistent
always use the static property
ignoring the instance propety
fixes#4460
* fix bug
* fix test also
* don't have default content-type
* make a loginSimpleAuth api too
* make removeAuthToken protected
(cherry picked from commit 4be2b6fd91)
* fix lint
* run yarn format
* Apply suggestions from code review
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
* fix broken merge conflict
* improve inheritance
* fix bug
* fix bug with dynamic grant config
* use duck typing for error checks
see discussion here: https://github.com/transloadit/uppy/pull/4619#discussion_r1406225982
* Apply suggestions from code review
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
* fix broken lint fix script
* fix broken merge code
* try to fix flakey tets
* fix lint
* fix merge issue
---------
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
* remove useless line
* fix broken cookie removal logic
related #4426
* fix mime type of thumbnails
not critical but some browsers might have problems
* simplify/speedup token generation
so we don't have to decode/decrypt/encode/encrypt so many times
* use instanceof instead of prop check
* Implement alternative provider auth
New concept "simple auth" - authentication that happens immediately (in one http request) without redirecting to any third party.
uppyAuthToken initially used to simply contain an encrypted & json encoded OAuth2 access_token for a specific provider. Then we added refresh tokens as well inside uppyAuthToken #4448. Now we also allow storing other state or parameters needed for that specific provider, like username, password, host name, webdav URL etc... This is needed for providers like webdav, ftp etc, where the user needs to give some more input data while authenticating
Companion:
- `providerTokens` has been renamed to `providerUserSession` because it now includes not only tokens, but a user's session with a provider.
Companion `Provider` class:
- New `hasSimpleAuth` static boolean property - whether this provider uses simple auth
- uppyAuthToken expiry default 24hr again for providers that don't support refresh tokens
- make uppyAuthToken expiry configurable per provider - new `authStateExpiry` static property (defaults to 24hr)
- new static property `grantDynamicToUserSession`, allows providers to specify which state from Grant `dynamic` to include into the provider's `providerUserSession`.
* refactor
* use respondWithError
also for thumbnails
for consistency
* fix prepareStream
it wasn't returning the status code (like `got` does on error)
it's needed to respond properly with a http error
* don't throw when missing i18n key
instead log error and show the key
this in on par with other i18n frameworks
* fix bugged try/catch
* allow aborting login too
and don't replace the whole view with a loader when plugin state loading
it will cause auth views to lose state
an inter-view loading text looks much more graceful and is how SearchProviderView works too
* add json http error support
add support for passing objects and messages from companion to uppy
this allows companion to for example give a more detailed error when authenticating
* don't tightly couple auth form with html form
don't force the user to use html form
and use preact for it, for flexibility
* fix i18n
* make contentType parameterized
* allow sending certain errors to the user
this is useful because:
// onedrive gives some errors here that the user might want to know about
// e.g. these happen if you try to login to a users in an organization,
// without an Office365 licence or OneDrive account setup completed
// 400: Tenant does not have a SPO license
// 403: You do not have access to create this personal site or you do not have a valid license
* sending certain onedrive errors to the user
this is useful because:
// onedrive gives some errors here that the user might want to know about
// e.g. these happen if you try to login to a users in an organization,
// without an Office365 licence or OneDrive account setup completed
// 400: Tenant does not have a SPO license
// 403: You do not have access to create this personal site or you do not have a valid license
* don't have default content-type
* make a loginSimpleAuth api too
* make removeAuthToken protected
(cherry picked from commit 4be2b6fd91)
* fix lint
* run yarn format
* Apply suggestions from code review
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
* fix broken merge conflict
* improve inheritance
* fix bug
* fix bug with dynamic grant config
* use duck typing for error checks
see discussion here: https://github.com/transloadit/uppy/pull/4619#discussion_r1406225982
* Apply suggestions from code review
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
* fix broken lint fix script
* fix broken merge code
* try to fix flakey tets
* fix lint
---------
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
New concept "simple auth" - authentication that happens immediately (in one http request) without redirecting to any third party.
uppyAuthToken initially used to simply contain an encrypted & json encoded OAuth2 access_token for a specific provider. Then we added refresh tokens as well inside uppyAuthToken #4448. Now we also allow storing other state or parameters needed for that specific provider, like username, password, host name, webdav URL etc... This is needed for providers like webdav, ftp etc, where the user needs to give some more input data while authenticating
Companion:
- `providerTokens` has been renamed to `providerUserSession` because it now includes not only tokens, but a user's session with a provider.
Companion `Provider` class:
- New `hasSimpleAuth` static boolean property - whether this provider uses simple auth
- uppyAuthToken expiry default 24hr again for providers that don't support refresh tokens
- make uppyAuthToken expiry configurable per provider - new `authStateExpiry` static property (defaults to 24hr)
- new static property `grantDynamicToUserSession`, allows providers to specify which state from Grant `dynamic` to include into the provider's `providerUserSession`.
According to https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests, we have so many preflight requests because we add `Uppy-Versions` header and `Content-Type: application/json` to each request. It's particularly not useful for for requests with no body / an empty body because the remote Companion doesn't check `Content-Type`.
It was added in b25f243627, and since f0f1105ef0, it is only used for log
purposes.
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
* don't cancel assembly when clicking "done"
* Reset state to default when Done button is pressed
* reuse code
* Apply suggestions from code review
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
---------
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Co-authored-by: Nick Rutten <2504906+nickrttn@users.noreply.github.com>
Co-authored-by: Murderlon <merlijn@soverin.net>
Co-authored-by: Artur Paikin <artur@arturpaikin.com>
* respond with 500 if unhandled upload error
400 seems inappropriate
* add todo
* fix companion download error
respond with correct response code when calling /get
and request to the upstream server fail
also add a unit test for this
* forward 429 from provider
allows us to retry it
* rename fn
* add a way to test refresh tokens
* fix race condtiion with refreshing token
* implement retry and fix socket
- Make sure we don't instantiate a new Provider for every file uploaded (reuse the original provider instead) - this caused the refresh token synchronization not to work
- Retry most errors when uploading (`/get`) using companion, but for HTTP, only retry certain HTTP status codes
- Reimplement the websocket code to be more stable and retry as well
* remove unused socket wrapper
* remove useFastRemoteRetry
because it isn't supported in Companion as far as I can tell
* fix error handling
* remove unneeded logic
* apply review suggestion
* retry awaiting for companion socket too
* retry whole operation instead of individually
or else we risk getting stuck retrying just half of the operation, which might never recover
* improvements
- rewrite so we can use p-retry for exponential backoff for socket reconnect too
- improve logging
- simplify/reuse code
* Update packages/@uppy/utils/src/fetchWithNetworkError.js
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
* Explain requestClient Symbol with comment
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
* Update packages/@uppy/provider-views/src/View.js
* fixes
preventing socket.send when the socket is not in the connected state
catch errors in handlers
* log if trying to refresh with no token
* log whether we got a refresh token
* dont log retrying when in reality not
* always prompt: consent
for google drive
* add signal to post
* refactor away eventmanager
and event handler error catching
* don't fail with upload-error
if a file is canceled
* fix expect
* add capabilities support
* make requestClient non-enumerable
---------
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
When chunks have already been uploaded, they are removed from memory.
If the user resume an upload whose first chunk has been uploaded, they
were getting a `TypeError` back.
* Dashboard: auto discover plugins no matter when they were installed
* Remove target from RemoteSoruces, making it compatible with @uppy/react
* Update packages/@uppy/dashboard/src/Dashboard.jsx
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
* Removed comments, added comments
* better comment
* Change type — otherwise gets listed on Dashboard sources
* Add RemoteSources to React test
* Add RemoteSources to React example
* Add tests
* Refactor for less iteration for each plugin, rename functions
* Prevent error when opts are undefined
* remove console.logs
* prettier
---------
Co-authored-by: Mikael Finstad <finstaden@gmail.com>