question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issuer.discover is returning a spread string

See original GitHub issue

Describe the bug The request call inside the Issuer.discover method is returning a string instead of the object, which in turn is getting spread by the spread operator.

code from issuer.js

 const response = await request.call(this, {
          method: 'GET',
          responseType: 'json',
          url: wellKnownUri,
        });
        const body = processResponse(response);

The body is coming as string instead of object as expected. Which is then getting spread in the below code, hence the bug.

return new Issuer({
          ...ISSUER_DEFAULTS,
          ...body,
          [AAD_MULTITENANT]: !!AAD_MULTITENANT_DISCOVERY.find(
            (discoveryURL) => wellKnownUri.startsWith(discoveryURL),
          ),
        });

To Reproduce Well Known Configuration link generated by the openid-client package: https://login.microsoftonline.com/18a59a81-eea8-4c30-948a-d8824cdc2580/v2.0/.well-known/openid-configuration Issuer and Client configuration: (inline or gist) - Don’t forget to redact your secrets.



Issuer is constructed by discovery.


Steps to reproduce the behaviour:

1.  call `Issuer.discover` method and pass the issuer url. 
`Issuer.discover('https://login.microsoftonline.com/18a59a81-eea8-4c30-948a-d8824cdc2580/v2.0')`

**Expected behaviour**
`Issuer.discover` returns an object containing Issuer and it's metadata.

**Environment:**
 - openid-client version: [e.g. v4.7.4]
 - node version: [e.g. v12.16.2]

**Additional context**
Add any other context about the problem here.

 - [x] the bug is happening on latest openid-client too.
 - [x] i have searched the issues tracker on github for similar issues and couldn't find anything related.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
panvacommented, Jul 8, 2021

@ktikku I can reproduce the issue, but it seems to be related to a node.js version, not the library. Upgrading to latest v14 (v14.16.0) the issue is gone.

Also note that the engines version actually covers this problem as the minimum v14 is 14.2.0. It must’ve been a known issue I just don’t remember.

"node": "^10.19.0 || >=12.0.0 < 13 || >=13.7.0 < 14 || >= 14.2.0"
0reactions
ktikkucommented, Jul 8, 2021

ya, just checked, it’s working fine now with node 14.2.0. Thanks for the assistance @panva 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spread syntax (...) - JavaScript - MDN Web Docs - Mozilla
The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments...
Read more >
Incorrectly converted spread operator on string · Issue #215 · bublejs ...
I had a function in my code that was meant to transform a base64-encoded string into a Uint8Array: base64 => new Uint8Array([...atob(base64)].map(char =>...
Read more >
Using spread syntax and new Set() with typescript
To make it work, you either need "target": "ES6" (or higher) or "downlevelIteration": true in the compilerOptions of your tsconfig.json . This resolved...
Read more >
How to use the openid-client.Issuer.discover function in ... - Snyk
Issuer.discover examples, based on popular ways it is used in public projects. ... if (!isOidcEnabled) { return; } debug('OidcStrategy: setting up.
Read more >
Rest parameters and spread syntax
The spread syntax internally uses iterators to gather elements, the same way as for..of does. So, for a string, for..of returns characters and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found