Skip to content

Conversation

@Jason-Benson
Copy link
Contributor

Updating the @types/express dependency to the current version required making changes to authentication.ts
getSamlStrategy had mixed verify-signature forms, so TypeScript picked an overload that caused the library to pass different arguments at runtime — the done parameter ended up being a non-function, producing the "done is not callable" error. Making both callbacks the same form, giving explicit types, and removing the invalid placeholder ensured that overload resolution, runtime argument order, and TypeScript types all lined up.

Copy link
Collaborator

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @Jason-Benson! See below for a few thoughts and suggestions.

} else if (authStrategy === "saml") {
const samlStrategy = this.getSamlStrategy();
passport.use(samlStrategy);
passport.use(samlStrategy as unknown as passport.Strategy);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
passport.use(samlStrategy as unknown as passport.Strategy);
passport.use(samlStrategy);

Do we actually need this change? samlStrategy should always be a subclass of passport.Strategy, so I don't think there's a need to recast it. When I remove this, tests and lint still pass for me, and the build still builds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argument of type 'import("/opt/vudl/api/node_modules/@node-saml/passport-saml/lib/strategy").Strategy' is not assignable to parameter of type 'import("/opt/vudl/api/node_modules/@types/passport/index").Strategy'.
Types of property 'authenticate' are incompatible.
Type '(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, options: AuthenticateOptions) => void' is not assignable to type '(this: StrategyCreated<Strategy, Strategy & StrategyCreatedStatic>, req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, options?: any) => any'.
Types of parameters 'req' and 'req' are incompatible.
Property 'param' is missing in type 'import("/opt/vudl/api/node_modules/@types/express/index").Request<import("/opt/vudl/api/node_modules/@types/express-serve-static-core/index").ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>' but required in type 'import("/opt/vudl/api/node_modules/@node-saml/passport-saml/node_modules/@types/express/index").Request<import("/opt/vudl/api/node_modules/@node-saml/passport-saml/node_modules/@types/express-serve-static-core/index").ParamsDictionary, any, any, qs.ParsedQs, Record<...>>'.ts(2345)

}.bind(this),
// TODO: implement a logout function here:
() => null,
done(null, user ? (user as unknown as Record<string, unknown>) : undefined);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer using null here instead of undefined since we're explicitly saying "there is no valid user" rather than "we haven't defined a user yet." But maybe I'm splitting hairs. If nothing else, it's shorter. ;-)

Suggested change
done(null, user ? (user as unknown as Record<string, unknown>) : undefined);
done(null, user ? (user as unknown as Record<string, unknown>) : null);

@demiankatz demiankatz changed the title Depend6 Upgrade to Express 5 (along with some other minor dependency updates) Jan 5, 2026
@demiankatz
Copy link
Collaborator

Superseded by #350.

@demiankatz demiankatz closed this Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants