这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@sinha-sahil
Copy link
Contributor

  • added parameter for passing https/http agent in https call made for getAccessToken
  • updated types

@sinha-sahil sinha-sahil force-pushed the feat/add-proxy-agent-support branch 3 times, most recently from bd511ce to 56c1b3e Compare March 9, 2023 19:35
index.js Outdated
this.sharedSecret = options.sharedSecret;
this.redirectUri = options.redirectUri;
this.apiKey = options.apiKey;
this.proxyAgent = 'proxyAgent' in options ? options.proxyAgent : null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can actually be any agent so I would rename the option to just agent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated name to agent

@lpinca
Copy link
Owner

lpinca commented Mar 9, 2023

The new option should also be added to README.md.

@sinha-sahil sinha-sahil force-pushed the feat/add-proxy-agent-support branch from 56c1b3e to 8aac89c Compare March 10, 2023 07:51
index.js Outdated
* @param {String} options.apiKey The API Key for the app
* @param {String} [options.accessMode] The API access mode
* @param {Number} [options.timeout] The request timeout
* @param {https.Agent|http.Agent} [options.agent] The agent for all http/https calls
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The endpoint is HTTPS only so I think this should be only https.Agent, no?

Copy link
Contributor Author

@sinha-sahil sinha-sahil Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there can be different kind of tunnelling using agents.
All possible combinations are:

  1. Http-Over-Http
  2. Http-Over-Https
  3. Https-Over-Http
  4. Https-Over-Https

In getAccessToken 's use case point 3 & point 4 are valid & useful.
Hence added the support for http.Agent & https.Agent

Copy link
Owner

@lpinca lpinca Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proxy can be HTTP or HTTPS but the endpoint is always HTTPS so I think it's 3 & 4 in your list. For example, see https://github.com/delvedor/hpagent/tree/v1.2.0#usage and https://github.com/delvedor/hpagent/blob/v1.2.0/index.js#L64.

index.js Outdated
this.sharedSecret = options.sharedSecret;
this.redirectUri = options.redirectUri;
this.apiKey = options.apiKey;
this.agent = 'agent' in options ? options.agent : null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.agent = 'agent' in options ? options.agent : null;
this.agent = options.agent;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR.

README.md Outdated
Comment on lines 48 to 50
- `agent` - Optional - An http/https agent which will be passed on to https
request made for obtaining auth token. This is useful when trying to obtain
token from a server which has constraints on internet access.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `agent` - Optional - An http/https agent which will be passed on to https
request made for obtaining auth token. This is useful when trying to obtain
token from a server which has constraints on internet access.
- `agent` - Optional - An HTTPS agent which will be passed to the HTTPS
request made for obtaining the auth token. This is useful when trying to
obtain a token from a server that has restrictions on internet access.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the README.md

@sinha-sahil sinha-sahil force-pushed the feat/add-proxy-agent-support branch 2 times, most recently from 0203b5b to 1496ad6 Compare March 11, 2023 03:00
- added parameter for passing https/http agent in https call made for getAccessToken
- updated types & readme for agent parameter
@sinha-sahil sinha-sahil force-pushed the feat/add-proxy-agent-support branch from 1496ad6 to aa1d6b6 Compare March 11, 2023 03:03
@lpinca lpinca merged commit 5354cc2 into lpinca:master Mar 11, 2023
@lpinca
Copy link
Owner

lpinca commented Mar 11, 2023

Thank you.

@sinha-sahil
Copy link
Contributor Author

@lpinca Please publish this change to the NPM as well. I need it one of my applications 😅 (currently pointing it to git repo link, will move it back to NPM package version once this is published).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants