Commit graph

120 commits

Author SHA1 Message Date
Antoine du Hamel
f76d76bafd
@uppy/utils: improve preprocess and postprocess types (#4841) 2023-12-28 17:03:15 +01:00
Murderlon
c48aa82a8a
@uppy/core: refactor to TS
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
2023-12-14 19:39:43 +01:00
Mikael Finstad
ec4bc58508
Provider user sessions (#4619)
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`.
2023-12-05 22:55:41 +01:00
Antoine du Hamel
58869e6287
@uppy/utils: fix import in test files (#4806) 2023-11-30 14:39:51 +01:00
Antoine du Hamel
51ecc66e64
@uppy/utils: refactor to TS (#4699)
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>
2023-11-06 15:01:50 +01:00
Mikael Finstad
17826da517
Companion+client stability fixes, error handling and retry (#4734)
* 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>
2023-11-02 21:31:34 +09:00
Antoine du Hamel
34c78e9093
meta: run Prettier on existing files (#4713) 2023-09-29 11:11:28 +02:00
Antoine du Hamel
2c432b12cd
test: migrate to Vitest for Uppy core and Uppy plugins (#4700) 2023-09-26 17:23:17 +02:00
Merlijn Vos
ef613e6a9f
Move remote file upload logic into companion-client (#4573) 2023-08-24 14:27:28 +02:00
Merlijn Vos
b1fdf8e926
Add VirtualList to ProviderView (#4566)
* Add VirtualList to ProviderView

* Import correctly from lib

* fixup! Import correctly from lib

* fixup! fixup! Import correctly from lib

* Really do it this time

* Only virtual list for lists

* fixup! Only virtual list for lists

* Fix scroll

* Set hardcoded width/height for img, as recommened

---------

Co-authored-by: Artur Paikin <artur@arturpaikin.com>
2023-07-20 15:49:43 +02:00
Mikael Finstad
e054a25ab2
@uppy/provider-views: add support for remote file paths (#4537)
Fixes: https://github.com/transloadit/uppy/issues/4034
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
2023-07-13 18:12:42 +02:00
LinusMain
38de438864
Migrate all lodash' per-method-packages usage to lodash. (#4274)
Fixes: https://github.com/transloadit/uppy/issues/4272
Co-authored-by: R <r@r.com>
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
2023-06-19 15:45:28 +02:00
Artur Paikin
b521a40ebb
When file is removed (or all are canceled), controller.abort queued requests (#4504)
* When file is removed (or all are canceled), controller.abort queued requests

* add controller.abort to all other remote uploaders too

* fix the queue

---------

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-06-19 11:28:23 +01:00
Stephen Wooten
b4f3c178dc
@uppy/utils: rename EventTracker -> EventManager (#4481)
Co-authored-by: Stephen Wooten <stephen.wooten@super.mx>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-06-10 12:10:05 +02:00
stduhpf
0e3be10317
@uppy/status-bar: Filtered ETA (#4458) 2023-05-24 15:40:29 +02:00
Mikael Finstad
90f7fb9197
@uppy/core: improve performance of validating & uploading files (#4402)
* show how many files are added when loading

remake of https://github.com/transloadit/uppy/pull/4388

* add french (cherry pick)

* implement concurrent file listing

* refactor / fix lint

* refactor/reduce duplication

* pull out totals validation

don't do it for every file added, as it's very slow
instead do the check at the end when all files are added.
this allows us to easily work with 10k+ files
fixes #4389

* Update packages/@uppy/core/src/Uppy.js

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

* make restricter.validate validate everything

instead make more specific methods for sub-validation
also rename validateTotals to validateAggregateRestrictions

* improve errors and user feedback

- handle errors centrally so that we can limit the amount of toasts (informers) sent to the users (prevent flooding hundreds/thousands of them)
- introduce FileRestrictionError which is a restriction error for a specific file
- introduce isUserFacing field for RestrictionError

* fix performance issue reintroduced

* improvements

- show "%{count} additional restrictions were not fulfilled" for any restriction errors more than 4
- refactor/rename methods
- improve ghost logic/comments

* improve performance when uploading

- introduce new event "upload-start"  that can contain multiple files
- make a new patchFilesState method to allow updating more files
- unify "upload-start" logic in all plugins (send it before files start uploading)
- defer slicing buffer until we need the data
- refactor to reuse code

* fix e2e build issue

* try to upgrade cypress

maybe it fixes the error

* Revert "fix e2e build issue"

This reverts commit ff3e580c0f.

* upgrade parcel

* move mutation logic to end

* remove FileRestrictionError

merge it with RestrictionError

* fix silly bug

looks like the e2e tests are doing its job 👏

---------

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-04-15 23:50:19 +08:00
Mikael Finstad
3dd1e5e68c
@uppy/provider-views: fix race condition when adding folders (#4384)
* fix race condtion when adding files

don't call addFolder from listAllFiles
because that would call addFile before all folders were loaded

also remove unused selectedFolders state

* fix also the case of adding multiple folders

* fix todo: remove SharedHandler

* remove loaderWrapper

* fix logic

* fix the last race condition

* fix broken duplicate file check

* fix logic

* prettiyfy loop

* add user feedback

so they know that something is happening

* run corepack yarn run build:locale-pack

* Revert "run corepack yarn run build:locale-pack"

This reverts commit 85548ce2fc.

* Revert "add user feedback"

This reverts commit 4060019c35.

* use async generator instead of p-map

* re-fix race-condition

* remove providerFileToId

as suggested by @arturi

* use addFiles instead of addFile

* rename function

* use provider-supplied file ID

instead of generating an ID, for providers that we whitelsit
this allows adding the same time many times (with a different path)

* call core directly

* improve dev dashboard

* disable experimental getAsFileSystemHandle

it seems to be causing problems when dropping folders with subfolders in newest chrome
e.g a folder with 50 files and a subfolder which in turn has another 50 files

also refactor and document the code more

* Update packages/@uppy/provider-views/src/ProviderView/ProviderView.jsx

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

* mov eto utils

---------

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-04-04 12:13:39 +09:00
Mikael Finstad
8673335d47
workaround chrome crash (#4310)
* workaround chrome crash

fixes #4133

* Update packages/@uppy/utils/src/getDroppedFiles/utils/webkitGetAsEntryApi/index.js

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

---------

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-02-15 17:57:14 +00:00
Antoine du Hamel
79bab48dc1
@uppy/utils: better fallbacks for the drag & drop API (#4260)
@uppy/utils: be more defensive when falling back to the old API on drag&drop
2023-01-26 15:39:27 +00:00
Antoine du Hamel
0375a490b5
@uppy/aws-s3-multipart: empty the queue when pausing (#4203)
This is to avoid leaving aborted requests in the queue that would
be reported as errors instead of being ignored.
2022-11-09 20:23:29 +01:00
Antoine du Hamel
f8af58f9b9
@uppy/utils: add cause support for AbortErrors (#4198)
Refs: https://github.com/whatwg/webidl/pull/1179
2022-11-07 22:35:33 +01:00
Antoine du Hamel
c658883cbf
@uppy/utils: fix relativePath when drag&dropping a folder (#4043)
Fixes: https://github.com/transloadit/uppy/issues/4041
2022-08-24 16:28:22 +02:00
Antoine du Hamel
8ed98725c5
@uppy/utils: fix drop of multiple files on Chromium browsers (#3998)
Fixes: https://github.com/transloadit/uppy/issues/3988
2022-08-17 17:08:28 +02:00
Merlijn Vos
90b62c7f21
Fix webp mimetype (#3961) 2022-08-10 12:03:32 +02:00
Antoine du Hamel
65f2551645
@uppy/utils: modernize getDroppedFiles (#3534)
`webkitGetAsEntry` is a non-standard/deprecated API, replacing it with
`getAsFileSystemHandle` when available.
This also work around a Chromium bug with symlinks.

Fixes: https://github.com/transloadit/uppy/issues/3505.
2022-08-04 16:21:23 +02:00
Antoine du Hamel
b8e1f9c995
@uppy/utils: refactor to ESM (#3721) 2022-05-23 09:40:50 +02:00
Merlijn Vos
03b54417c9
Fix getFileType for dicom images (#3610) 2022-04-14 17:55:45 +08:00
Renée Kooi
b22a812db3
Propagate isNetworkError through error wrappers (#3620)
The `ErrorWithCause` class uses the same signature as the builtin Error
does, but it supports the `{ cause }` option in older environments, and
it propagates the `isNetworkError` property from the underlying error.
2022-04-05 15:57:25 +02:00
Antoine du Hamel
a08ec4e0f7
@uppy/tus: pause all requests in response to server rate limiting (#3394)
* @uppy/tus: pause all requests in response to server rate limiting

When the remote server responds with HTTP 429, all requests are
paused for a while in the hope that it can resolve the rate limiting.
Failed requests are also now queued up after the retry delay. Before
that, they were simply scheduled which would sometimes end up
overflowing the `limit` option.

* Address review comments

* fix requests bypassing queue pause state

* Auto rate limiting

* fix `RateLimitedQueue`
2022-01-10 16:41:52 +01:00
Antoine du Hamel
cd8af60bfb
examples: update angular-example to Angular v13 (#3325)
* examples: update angular-example to Angular v13

* meta: upgrade TS version accross the board

* meta: upgrade ESLint packages

* Fix angular-examples tests

* bump lock file

* fix type conflict

* Upgrade `ng-packagr`
2021-11-22 19:12:56 +01:00
Kevin van Zonneveld
bfe659820e
Upgrade linting to 2.0.0-0 (#3280)
* Upgrade linting to 2.0.0-0

* Adjust so we can pass without error

* Fix linting

* Update header-blacklist.js

* Update index.js

* Update Uppy.js

* Update Components.js

* Update StatusBar.js

* Update Assembly.js

* Upgrade to linting 2.0.0 (final release)
2021-11-09 11:19:05 +00:00
Mikael Finstad
56339fc3e5
Rewrite Companion providers to use streams to allow simultaneous upload/download without saving to disk (#3159)
* rewrite to async/await

* Only fetch size (HEAD) if needed #3034

* Update packages/@uppy/companion/src/server/controllers/url.js

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

* Change HEAD to GET in getURLMeta

and abort request immediately upon response headers received
https://github.com/transloadit/uppy/issues/3034#issuecomment-908059234

* fix lint

* fix lint

* cut off length of file names

or else we get
"MetadataTooLarge: Your metadata headers exceed the maximum allowed metadata size" in tus / S3

* try to fix flaky test

* remove iife and cleanup code a bit

* fix lint by reordering code

* rename Uploader to MultipartUploader

* Rewrite Uploader to use fs-capacitor #3098

This allows for upload to start almost immediately without having to first download the file.
And it allows for uploading bigger files, because transloadit assembly will not timeout,
as it will get upload progress events all the time.
No longer need for illusive progress.
Also fix eslint warnings and simplify logic

Still TODO: TUS pause/resume has a bug:
https://github.com/tus/tus-js-client/issues/275

* add comment in dev Dashboard and pull out variable

* fix a bug where remote xhr upload would ignore progress events in the UI

* fix bug where s3 multipart cancel wasn't working

* fix also cancel for xhr

* Rewrite providers to use streams

This removes the need for disk space as data will be buffered in memory and backpressure will be respected
https://github.com/transloadit/uppy/issues/3098#issuecomment-907763809
All providers "download" methods will now return a { stream } which can be consumed by uploader.

Also:
- Remove capacitor (no longer needed)
- Change Provider/SearchProvider API to async (Breaking change for custom companion providers)
- Fix the case with unknown length streams (zoom / google drive). Need to be downloaded first
- rewrite controllers deauth-callback, thumbnail, list, logout to async
- getURLMeta: make sure size is never NaN (NaN gets converted to null in JSON.stringify when sent to client but not when used in backend)
- fix purest mock (it wasn't returning statusCode on('response'))
- add missing http mock for "request" for THUMBNAIL_URL and http://url.myendpoint.com/file (these request errors were never caught by tests previously)
- "upload functions with tus protocol" test: move filename checking to new test where size is null. Fix broken expects
- fix some lint

* Implement streamingUpload flag

COMPANION_STREAMING_UPLOAD
Default to false due to backward compatibility
If set to true, will start to upload files at the same time as dowlnoading them, by piping the streams

- Also implement progress for downloading too
- and fix progress duplication logic
- fix test that assumed file was fully downloaded after first progress event

* rearrange validation logic

* add COMPANION_STREAMING_UPLOAD to env.test.sh too

* implement maxFileSize option in companion

for both unknown length and known length downloads

* fix bug

* fix memory leak when non 200 status

streams were being kept

* fix lint

* Add backward-compatibility for companion providers

Implement a new static field "version" on providers, which when not set to 2,
will cause a compatibility layer to be added for supporting old callback style provider api

also fix some eslint and rename some vars

* document new provider API

* remove static as it doesn't work on node 10

* try to fix build issue

* degrade to node 14 in github actions

due to hitting this error: https://github.com/nodejs/node/issues/40030
https://github.com/transloadit/uppy/pull/3159/checks?check_run_id=3544858518

* pull out duplicated logic into reusable function

* fix lint

* make methods private

* re-add unsplash download_location request

got lost in merge

* add try/catch

as suggested https://github.com/transloadit/uppy/pull/3159#discussion_r727149263

* Only set default chunkSize if needed

for being more compliant with previous behavior when streamingUpload = false

* Improve flaky test

Trying to fix this error:

FAIL packages/@uppy/utils/src/delay.test.js
  ● delay › should reject when signal is aborted

    expect(received).toBeLessThan(expected)

    Expected: < 70
    Received:   107

      32 |     const time = Date.now() - start
      33 |     expect(time).toBeGreaterThanOrEqual(30)
    > 34 |     expect(time).toBeLessThan(70)
         |                  ^
      35 |   })
      36 | })
      37 |

      at Object.<anonymous> (packages/@uppy/utils/src/delay.test.js:34:18)

https://github.com/transloadit/uppy/runs/3984613454?check_suite_focus=true

* Apply suggestions from code review

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

* fix review feedback & lint

* Apply suggestions from code review

Co-authored-by: Merlijn Vos <merlijn@soverin.net>

* remove unneeded ts-ignore

* Update packages/@uppy/companion/src/server/controllers/url.js

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

* Update packages/@uppy/companion/src/server/Uploader.js

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

* reduce nesting

* fix lint

* optimize promisify

https://github.com/transloadit/uppy/pull/3159#discussion_r738160576

* Update packages/@uppy/companion/test/__tests__/uploader.js

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Co-authored-by: Merlijn Vos <merlijn@soverin.net>
2021-11-01 16:35:25 +07:00
Antoine du Hamel
55e0ffd04a
Add retext to markdown linter (#3024)
* remark-lint-uppy: use `retext` to improve doc syntax and grammar

* WIP: start fixing fixing linter errors

* Remove `retext-passive` as I don't see what's wrong with passive voice

* Remove URL plugin, add emphasis/strong marker plugin

* Fix remark settings to avoid conflicts

* WIP: more auto-fixes

* remark-simplify: allow `option`

* zoom.md

* url.md

* vue.md

* tus.md

* webcam.md

* xhrupload.md

* writing-plugins

* thumbnail-generator

* svelte

* react-dragdrop

* stores

* do not over simplify

* statusbar

* robodog

* robodog-upload

* robodog-picker

* robodog-form

* robodog-dashboard

* redux

* privacy

* uppy.md

* transloadit.md

* react-native

* react-initializing

* react-fileinput

* providers

* progressbar

* plugins

* plugin-common-options

* onedrive

* locales

* instagram

* informer

* index

* google-drive

* golden-retriever

* form

* fileinput

* facebook

* dropbox

* drop-target

* dragdrop

* remark-lint-no-unneeded-full-reference-link

* Try to setup unified-message-control

* Upgrade deps

* Fix collapsed link references with inline code

* Revert "remark-lint-no-unneeded-full-reference-link"

This reverts commit ca375f463b771bc81d0868f4d84f5979823cfc0a.

* remark-lint-uppy: add missing `"main"` field

* Update package-lock.json

* add disable comments

* fixup! xhrupload.md

* writing-plugins

* unsplash

* tus

* stores

* migration-guide

* dashboard

* community-projects

* box

* integration_help

* blog posts

* companion

* aws-s3

* aws-s3-multipart

* remark-lint-uppy README

* website/inject

* BUNDLE-README

* READMEs

* architecture

* move Remark settings to the plugin

* add `listItemIndent` setting

* list indent fix

* fix ignored files

* revert changelog changes

* fixup! architecture

* Revert changes in ignored files

* Remove unnecessary HTML tags from READMEs
2021-10-14 16:10:45 +02:00
Mikael Finstad
876f833bd1
Companion: Use GET instead of HEAD for getURLMeta + Cut off length of file names (#3048)
* rewrite to async/await

* Only fetch size (HEAD) if needed #3034

* Update packages/@uppy/companion/src/server/controllers/url.js

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

* Change HEAD to GET in getURLMeta

and abort request immediately upon response headers received
https://github.com/transloadit/uppy/issues/3034#issuecomment-908059234

* fix lint

* fix lint

* cut off length of file names

or else we get
"MetadataTooLarge: Your metadata headers exceed the maximum allowed metadata size" in tus / S3

* try to fix flaky test

* remove iife and cleanup code a bit

* fix lint by reordering code

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-09-30 17:27:13 +07:00
Marcelo Luiz Onhate
c7e0a5a883
fix: AbortController is not defined on Node.js (Server Side Render) (#3169)
* fix: AbortController is not defined

* use globalThis

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-09-13 14:55:10 +02:00
Artur Paikin
dbe3ed25b3
build: add stylelint (#3124)
* add stylelint with stylelint-config-standard

* autofix style issues

* fix more linting issues

* add stylelint-scss

* fix two more

* add stylelint-config-rational-order and autofix order

https://github.com/constverum/stylelint-config-rational-order
2021-08-24 01:37:57 +01:00
Antoine du Hamel
405157ea49
@uppy/aws-s3: refactor to use private fields (#3094) 2021-08-17 20:14:49 +02:00
Antoine du Hamel
c94664613a
@uppy/utils: resolve remaining linter errors (#3091) 2021-08-10 16:06:49 +02:00
Antoine du Hamel
0cccb686fd @uppy/utils: improve support of data URI in dataURItoBlob (#3080) 2021-08-09 16:13:04 +02:00
Antoine du Hamel
6cd5309544 @uppy/utils: simplify canvasToBlob (#3080)
The built-in `HTMLCanvasElement#toBlob` is supported everywhere.
2021-08-09 16:12:59 +02:00
Antoine du Hamel
c8606ae5fe @uppy/utils: use private fields in EventTracker (#3080) 2021-08-09 16:12:54 +02:00
Antoine du Hamel
9866fc1f5c @uppy/utils: remove ponyfill for Array#findIndex (#3080)
The built-in method is supported everywhere.
2021-08-09 16:12:51 +02:00
Antoine du Hamel
2c1287fc52 @uppy/utils: simplify getTimeStamp (#3080) 2021-08-09 16:12:47 +02:00
Antoine du Hamel
126984ece3 @uppy/utils: avoid creating throw-away <div> in isDragDropSupported (#3080) 2021-08-09 16:12:47 +02:00
Antoine du Hamel
2178f531a4 @uppy/utils: simplify code using optional chaining (#3080) 2021-08-09 16:12:37 +02:00
Antoine du Hamel
dc5cab4922 @uppy/utils: use private fields in ProgressTimeout (#3080) 2021-08-09 16:12:33 +02:00
Antoine du Hamel
059870a80b @uppy/utils: refactor prettyETA (#3080) 2021-08-09 16:12:23 +02:00
Antoine du Hamel
3626172b0c @uppy/utils: use private fields in RateLimitedQueue (#3080) 2021-08-09 16:12:18 +02:00
Antoine du Hamel
2cdb19a8c5 @uppy/utils: use Array.from insterad of custom utils (#3080) 2021-08-09 16:12:13 +02:00
Antoine du Hamel
65ffbed1a2 @uppy/utils: refactor truncateString (#3080) 2021-08-09 16:12:08 +02:00