Skip to content

Typescript issue with nodenext module resolution, bump openid-client version ? #680

@hugo-daclon

Description

@hugo-daclon

Checklist

Description

When using this package with TypeScript configured to NodeNext module resolution, which is the recommended value, we face an issue with three types, the most annoying for me being IdTokenClaims.

Image

This problem is on openid-client's side, and they already fixed it in version 5.1.6 (cf this commit line 33 of the package.json).

So now the issue is on your side. The version used in this project is ^4.9.1 which is 2 whole major version behind the latest one (6.6.2 as of this issue's creation). It should be fixed by bumping the openid-client version, though there might

Reproduction

  1. Create a project with express-openid-connect, express and typescript
  2. Set tsconfig.json to have the following configuration:
    {
        "compilerOptions": {
            "moduleResolution": "nodeNext",
            "module": "NodeNext",
        }
    }
  3. Create the following file
    import express from "express";
    
    import expressOpenidConnect from "express-openid-connect";
    const { auth } = expressOpenidConnect;
    
    const app = express();
    app.use(
      auth({
        issuerBaseURL: process.env.OIDC_ISSUER_BASEURL,
        baseURL: process.env.OIDC_BASEURL,
        clientID: process.env.OIDC_CLIENT_ID,
        secret: process.env.OIDC_ENCRYPTION_SECRET,
        clientSecret: process.env.OIDC_CLIENT_SECRET,
        attemptSilentLogin: true,
        idpLogout: true,
        authorizationParams: {
          response_type: "code",
          scope: "openid profile email",
        },
        routes: {
          callback: "/auth/redirect",
          login: "/auth/login",
          logout: "/auth/logout",
        },
      })
    );
    app.use((req, _res, next) => {
      console.debug("idTokenClaims", req.oidc.idTokenClaims);
      if (!req.oidc.idTokenClaims.email) {
        throw new Error("Aucun utilisateur détecté, merci de contacter le support technique.");
      }
      next()
    });
  4. Here is the issue :
    Image

Additional context

I'd like to avoid changing the module to ESNext and moduleResolution to node as much as possible, as I don't really know the impact.

This also raises another question: openid-client should be one of, if not the most important dependency of this project. So why has it not been updated for nearly 4 years even though this project is still actively maintained. It seems voluntary (cf. #491), but I don't get why.

express-openid-connect version

[email protected]

Express version

[email protected]

Node.js version

v22.17.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions