-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate from Request #134
Migrate from Request #134
Conversation
41020bf
to
42550d5
Compare
src/JwksClient.js
Outdated
...this.options.httpOptions | ||
}) | ||
.then(res => { | ||
if (res.statusCode < 200 || res.statusCode >= 300) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default axios
rejects non 2xx status codes, using the validateStatus option. So this code path will never be hit (unless the user overriders validateStatus
)
src/JwksClient.js
Outdated
if (res) { | ||
return cb(new JwksError(res.body && (res.body.message || res.body) || res.statusMessage || `Http Error ${res.statusCode}`)); | ||
|
||
return axios.request({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would favour removing the return
statement, just because it might confuse
tests/jwksClient.tests.js
Outdated
|
||
const client = new JwksClient({ | ||
jwksUri: `${jwksHost}/.well-known/jwks.json` | ||
}); | ||
|
||
client.getKeys(err => { | ||
expect(err).not.to.be.null; | ||
expect(err.message).to.equal('Unknown Server Error'); | ||
expect(err.message).to.equal('Request failed with status code 500'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add an assertion that error is of type JwksError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the JwksError
expectation, correctly exposes this issue #134 (comment)
42550d5
to
99d2c68
Compare
Closing this PR in favor of opening a new one where we will replace request library without any breaking changes. |
Description
In response to the Request Deprecation request/request#3142 we have done our own assessment of the situation and potential replacements.
Requirements
We looked into our use of Request and found that we wanted to continue to support the current 5 features we use with request:
Additionally, we have had requests for further use of the request library. Because of this, we want to expose the config of the under pinning http library we choose.
Research
We looked into using the following
Axios is the only library that supports all 5 features out of the box. Got and node-fetch met all requirements, however required workaround or external library for using a proxy. After testing each option, Axios required the least amount of configuration on this libraries end.
Migration
To expose the under pinning library we use to make requests, we will be changing the API for controlling the http agent, headers, proxy, and exposing a new option
httpOptions
that will passthrough to Axios https://github.com/axios/axios/tree/v0.19.2#request-configFixes issue #126