[REQ][typescript] Expose Agent option in RequestContext interface
Created by: davidgamero
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 :)