uppy/packages/@uppy
Mikael Finstad a329a15f33
@uppy/companion: fix authProvider property inconsistency (#4672)
* 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>
2023-12-12 18:59:30 +08:00
..
angular Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
audio Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
aws-s3 @uppy/aws-s3: change Companion URL in tests 2023-12-06 14:31:14 +01:00
aws-s3-multipart Release: uppy@3.19.0 (#4781) 2023-11-08 23:42:11 +00:00
box Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
companion @uppy/companion: fix authProvider property inconsistency (#4672) 2023-12-12 18:59:30 +08:00
companion-client Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
compressor Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
core Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
dashboard Release: uppy@3.19.1 (#4790) 2023-11-12 02:30:15 +00:00
drag-drop Release: uppy@3.14.0 (#4626) 2023-08-15 14:25:39 +00:00
drop-target Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
dropbox Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
facebook Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
file-input Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
form Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
golden-retriever Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
google-drive Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
image-editor @uppy/image-editor: respect cropperOptions.initialAspectRatio (#4805) 2023-11-27 13:25:29 +01:00
informer Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
instagram Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
locales Release: uppy@3.20.0 (#4804) 2023-11-24 00:32:49 +00:00
onedrive Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
progress-bar Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
provider-views Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
react Release: uppy@3.19.1 (#4790) 2023-11-12 02:30:15 +00:00
react-native Release: uppy@3.19.1 (#4790) 2023-11-12 02:30:15 +00:00
redux-dev-tools Release: uppy@3.14.0 (#4626) 2023-08-15 14:25:39 +00:00
remote-sources Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
screen-capture Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
status-bar Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
store-default @uppy/set-state: fix types 2023-12-06 10:42:21 +01:00
store-redux Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
svelte Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
thumbnail-generator Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
transloadit Release: uppy@3.19.0 (#4781) 2023-11-08 23:42:11 +00:00
tus Release: uppy@3.19.0 (#4781) 2023-11-08 23:42:11 +00:00
unsplash Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
url Release: uppy@3.19.0 (#4781) 2023-11-08 23:42:11 +00:00
utils Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00
vue Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
webcam Release: uppy@3.18.0 (#4754) 2023-10-20 15:20:18 +00:00
xhr-upload Release: uppy@3.19.0 (#4781) 2023-11-08 23:42:11 +00:00
zoom Provider user sessions (#4619) 2023-12-05 22:55:41 +01:00