panva / openid-client

OAuth 2 / OpenID Connect Client API for JavaScript Runtimes
MIT License
1.83k stars 392 forks source link

Client is not a constructor. Erroneous typescript definition. Misleading docs. #416

Closed PaulSzymanski closed 3 years ago

PaulSzymanski commented 3 years ago

Describe the bug The TS definition exposes the Client constructor. However, the Client constructor is only accessible on an Issuer instance.

Hence TS will not complain if you write new Client(clientMetadata).

Also the docs are misleading.

To Reproduce

const client = new Client(recoveredClientMetadata)

Expected behaviour Either TS complaining or the library directly exposing the constructor.

Environment:

Additional context This bug was probably causing confusion here as well: https://github.com/panva/node-openid-client/issues/213

panva commented 3 years ago

I find nothing misleading about the docs, all examples show how to obtain the Client constructor. That the types are messed up is a pity, PR is welcome, they've been like this since their inclusion two years ago. Not a big deal IMHO since all the docs show the correct way of instantiating a Client.