Skip to content
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

[REQ][typescript] Expose Agent option in RequestContext interface #11394

Closed
davidgamero opened this issue Jan 25, 2022 · 0 comments
Closed

[REQ][typescript] Expose Agent option in RequestContext interface #11394

davidgamero opened this issue Jan 25, 2022 · 0 comments

Comments

@davidgamero
Copy link
Contributor

davidgamero commented Jan 25, 2022

Is your feature request related to a problem? Please describe.

When implementing SSL Auth, passing certificates requires access to the agent option on the fetch(url: RequestInfo, init?: RequestInit): Promise<Response>; call in order to pass ca and cert params.
The RequestContext interface bridges the SecurityAuthentication implementation to the fetch call, and therefore is the optimal choice for passing an optional agent: http.Agent | https.Agent.

Describe the solution you'd like

The addition of an agent: http.Agent | https.Agent | undefined instance variable on the RequestContext class as well as the following methods:

setAgent(agent: http.Agent | https.Agent)
getAgent() : http.Agent | https.Agent | undefined

Then, the isomorphic fetch implementation would call getAgent() to pass the value into the agent option on the fetch call in isomorphic-fetch.ts

Describe alternatives you've considered

Another viable option is the allow direct access to the fetch options in the RequestContext, which was the approach in the previous iteration of the typescript generator. This would prevent future one-off additions for other options, but would significantly increase the scope of the PR, and may be unnecessary given the major auth options are already exposed excluding the agent.

This could introduce undesired behavior in which the same option could be potentially passed twice in one call (once in RequestContext instance var and once via fetch options override)

Additional context

This would expand the typescript generator's auth compatibility :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant