-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[ Demo ] @uppy/companion: express 5.0.0 compatibility #5457
Conversation
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@types/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected] |
Diff output filesdiff --git a/packages/@uppy/companion/lib/companion.js b/packages/@uppy/companion/lib/companion.js
index 055c7ec..b05770a 100644
--- a/packages/@uppy/companion/lib/companion.js
+++ b/packages/@uppy/companion/lib/companion.js
@@ -89,7 +89,7 @@ module.exports.app = (optionsArg = {}) => {
// Making `POST` request to the `/connect/:provider/:override?` route requires a form body parser middleware:
// See https://github.com/simov/grant#dynamic-http
app.use(
- "/connect/:oauthProvider/:override?",
+ "/connect/:oauthProvider/:override",
express.urlencoded({ extended: false }),
getCredentialsOverrideMiddleware(providers, options),
);
@@ -103,7 +103,7 @@ module.exports.app = (optionsArg = {}) => {
});
app.use(middlewares.cors(options));
// add uppy options to the request object so it can be accessed by subsequent handlers.
- app.use("*", middlewares.getCompanionMiddleware(options));
+ app.use(/(.*)/, middlewares.getCompanionMiddleware(options));
app.use("/s3", s3(options.s3));
if (options.enableUrlEndpoint) {
app.use("/url", url());
@@ -175,7 +175,7 @@ module.exports.app = (optionsArg = {}) => {
middlewares.hasSimpleAuthProvider,
controllers.simpleAuth,
);
- app.get("/:providerName/list/:id?", middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list);
+ app.get("/:providerName/list/:id", middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list);
// backwards compat:
app.get("/search/:providerName/list", middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list);
app.post( |
Hi, are you sure that there are no breaking changes for people integrating Companion into their own Express 4.x or people making custom providers? If that would break some cases, this can't be merged as we won't do a another major for a while. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be a breaking change and so needs a new major release of Companion
@@ -103,7 +103,7 @@ module.exports.app = (optionsArg = {}) => { | |||
// override provider credentials at request time | |||
// Making `POST` request to the `/connect/:provider/:override?` route requires a form body parser middleware: | |||
// See https://github.com/simov/grant#dynamic-http | |||
app.use('/connect/:oauthProvider/:override?', express.urlencoded({ extended: false }), getCredentialsOverrideMiddleware(providers, options)) | |||
app.use('/connect/:oauthProvider/:override', express.urlencoded({ extended: false }), getCredentialsOverrideMiddleware(providers, options)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at https://expressjs.com/en/guide/migrating-5.html#path-syntax i think wee need this instead?
app.use('/connect/:oauthProvider/:override', express.urlencoded({ extended: false }), getCredentialsOverrideMiddleware(providers, options)) | |
app.use('/connect/:oauthProvider{/:override}', express.urlencoded({ extended: false }), getCredentialsOverrideMiddleware(providers, options)) |
source: https://www.npmjs.com/package/path-to-regexp#optional
@@ -117,7 +117,7 @@ module.exports.app = (optionsArg = {}) => { | |||
app.use(middlewares.cors(options)) | |||
|
|||
// add uppy options to the request object so it can be accessed by subsequent handlers. | |||
app.use('*', middlewares.getCompanionMiddleware(options)) | |||
app.use(/(.*)/, middlewares.getCompanionMiddleware(options)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this should be
app.use(/(.*)/, middlewares.getCompanionMiddleware(options)) | |
app.use(middlewares.getCompanionMiddleware(options)) |
@@ -132,7 +132,7 @@ module.exports.app = (optionsArg = {}) => { | |||
|
|||
app.post('/:providerName/simple-auth', express.json(), middlewares.hasSessionAndProvider, middlewares.hasBody, middlewares.hasSimpleAuthProvider, controllers.simpleAuth) | |||
|
|||
app.get('/:providerName/list/:id?', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list) | |||
app.get('/:providerName/list/:id', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
app.get('/:providerName/list/:id', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list) | |
app.get('/:providerName/list{/:id}', middlewares.hasSessionAndProvider, middlewares.verifyToken, controllers.list) |
@mifi @maximilianschmid Just wanted to bump this here-- projects I'm working with which use companion have been complaining about security vulnerabilities from the old package versions for a while and I would feel a lot better getting this merged in. If it's not something you have the resources to work on now, is there something I can do to help this along? |
@Kelketek I‘ll have a look next week if we‘ll work on this. |
Which vulnerabilities? Note that warnings does not equal that Companion is actually vulnerable. If there are any security issues, that's a separate issue to resolve, not something to rush a major release for (unless there's no other way). |
@Murderlon Here's the output of
These warnings have appeared for four months or so, and they've been pretty concerning to me since they seem plausibly like they would affect companion. But if you're able to verify that companion is not affected, that would do a lot to assuage my fears. I agree that major version shouldn't be rushed, though in this case even if the major version is just 'we bump to the latest version of express and any other changes are minimal', that doesn't seem like rushing, it just seems like following semantic versioning and making sure security is up to date. If there are other changes that are going into the next version bump that aren't well-vetted, that would give me more pause, or if you expect marketing pushes alongside major version numbers (which might happen with a project like Express itself). An alternative would be to modify this PR to better verify backwards compatibility, in which case a major version update would not be needed. It might be done by adding in some conditionals checking between versions. It doesn't seem like the changes included in this PR are especially massive, so that looks like a plausible route-- to me, at least. |
I'm not able to guarantee compatibility of a [email protected] companion version that works in a [email protected] app. So I have created a repo which you can use to use a [email protected] companion app version in your v5 express app. Just use it in your package.json like this:
It works for us in our production app. Hope this helps if you want to do the same. |
As express@5 is not the default yet I think it make sense for uppy to stay on express@4 and upgrade to express@5 along with the next major version. To bridge the time you can use our repo. |
Thank you, @Murderlon ! |
No description provided.