Issuer.discover is returning a spread string
See original GitHub issueDescribe 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:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
ya, just checked, it’s working fine now with node
14.2.0
. Thanks for the assistance @panva 😄