panva / openid-client

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

bug(ts): statics missing on TypeOfGenericClient #540

Closed flashtheman closed 1 year ago

flashtheman commented 1 year ago

I'm following an example I found and where it should be possible to call Client.register. See below.

const issuer = await Issuer.discover(baseURL);

const issuer = await issuer.Client.register({
     redirect_uris,
 });

However, the register method seems not to be implemented, and therefore typescript shows the following error:

Property 'register' does not exist on type 'TypeOfGenericClient'.ts(2339)

I would expect the register method to exist and not throw an error.

Environment:

panva commented 1 year ago

I see no runtime issue, the method is there, it's type definition issue. Feel free to submit a PR fixing this. I suspect all static getters/setters and methods will be missing on TypeOfGenericClient.

flashtheman commented 1 year ago

Ok thanks. I was assuming that below error I receive on runtime is related to the missing register type definition. But maybe it's something else.

TypeError: registration_endpoint must be configured on the issuer
    at assertIssuerConfiguration (/core/node_modules/openid-client/lib/helpers/assert.js:17:11)
    at Function.register (/core/node_modules/openid-client/lib/client.js:1419:5)
    at App.<anonymous> (/core/src/app.ts:128:54)
    at Generator.next (<anonymous>)
    at fulfilled (/core/src/app.ts:5:58)
panva commented 1 year ago

Completely unrelated. Maybe your IdP does not support dynamic client registration and you ought to just be instantiating a client like so, new issuer.Client(metadata) using metadata given to you.

flashtheman commented 1 year ago

ok thanks a lot. You are right - I hadn't enabled dynamic registration! Thank you!!!