title: "Uppy 1.8 and 1.9: security, error handling and better types" date: 2020-03-06 author: arturi
Uppy 1.8, 1.9 and a few important security patches are out! Here’s are the highlights:
@uppy/companion
and the @uppy/url
plugin. Many thanks you the parties involved in reporting and disclosing this vulnerability with the Uppy team. The patch is available in @uppy/companion version 1.9.5@uppy/companion
goes, not much has changed. The only difference is that you will now be retrieving your Instagram credentials from the Facebook Developer Platform, and no longer the Instagram Developer Platform@uppy/core
, @uppy/transloadit
and @uppy/dashboard
. Retry button on the Status Bar, which was broken in some edge cases, now works as expected.The Dashboard plugin has gained new file type icons: for images — useful before the preview is generated, or when there’s no preview at all, like with images from the Url plugin — and for archives.
Our typings got a significant upgrade: plugin options can now be type-checked! In the past, we did have typings for plugin options, but the uppy.use()
function had a fallback that would accept any object as options. If your plugin options were wrong, typescript would just use the fallback and not tell you about it!
Stricter typings normally mean that old code may no longer type-check. So, although this is a bugfix, you have to opt in to the new types. In 2.0, the old way will be removed and only the strict types will be available.
You can opt in by specifying the StrictTypes
type parameter to the Uppy
type:
import Uppy = require('@uppy/core')
const uppy = Uppy<Uppy.StrictTypes>({
// options here
})
This type parameter must also be specified if you are storing the uppy
instance anywhere. For example, inside a class:
class UppyProvider extends React.Component {
private uppy: Uppy<Uppy.StrictTypes>
constructor (props) {
super(props)
this.uppy = Uppy<Uppy.StrictTypes>({
// etc
})
}
}
If you do not specify the StrictTypes
parameter, the old fallback for the uppy.use()
method remains available.
The typings for @uppy/react
component props are now derived from plugin options types, so they will no longer get out of sync, as sometimes they have in the past. For example, in version 1.7, the @uppy/drag-drop
plugin supported a note
option to add some text to the drop area. The React typings didn't include that option, so you couldn't use it from typescript! Now, that's permanently fixed:
import components = require('@uppy/react')
const { DragDrop } = components
// assuming some `uppy` variable already exists
declare var uppy: Uppy<Uppy.StrictTypes>
function MyComponent () {
return (
<DragDrop
uppy={uppy}
note='This prop is now supported!'
/>
)
}
Finally, the locale
options and React props now have full typings. Your editor should now be able to provide autocompletion for language keys!
We now also use tsd
, so our typings are actually tested.
See PR #1918 for all the details.
Uppy is now available as a downloadable zip archive from the Transloadit CDN! NPM down? Don’t like build tools? Quick way to play with Uppy? We’ve got you covered:
https://transloadit.edgly.net/releases/uppy/v1.9.3/uppy-v1.9.3.zip
As always, you can find the full list of changes and package versions, as well as future plans, in our changelog.