Skip to content

Arity check does not work. Therefore Id token will never work. #168

@arturohernandez10

Description

@arturohernandez10

The google client code, returns an accessToken, refreshToken, and the result itself. Which now returns the idToken, or at least in my case. The way to get that back id to read the "params".

For that this library attempts to check the arity but because of the many layers of passport it proves to be a bad interface choice. Passport can apply a mixin, in which case the callback has zero parameters during runtime. Effectively breaking this code:

Mixin code

var arity = self._verify.length;
if (arity == 5) {
  self._verify(accessToken, refreshToken, params, profile, verified);
} else { // arity == 4
  self._verify(accessToken, refreshToken, profile, verified);
}

the solution really is to do away with the arity and leave the optional parameters to the end. To avoid breaking changes you could do something like this:

var arity = self._verify.length;
if (legacyCheck && arity == 5) {
  self._verify(accessToken, refreshToken, params, profile, verified);
} else (legacyCheck) { // arity == 4
  self._verify(accessToken, refreshToken, profile, verified);
} else { 
  self._verify(accessToken, refreshToken, profile, verified, params);
}

Ideally legacyCheck is a configuration variable so that users can keep the old behavior. The biggest issue is the typescript types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions