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

feat: add parameter to ProxyAgent options, which is type of authentication #1705

Merged
merged 5 commits into from Oct 17, 2022

Conversation

oooshima
Copy link
Contributor

Implements: add parameter to ProxyAgent options

Benefits: ProxyAgent can use a variety of authentication types.

Also see: About this issue #1704

@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2022

Codecov Report

Base: 94.11% // Head: 94.19% // Increases project coverage by +0.08% 🎉

Coverage data is based on head (0ba193c) compared to base (8d6ddb7).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1705      +/-   ##
==========================================
+ Coverage   94.11%   94.19%   +0.08%     
==========================================
  Files          53       53              
  Lines        4943     4961      +18     
==========================================
+ Hits         4652     4673      +21     
+ Misses        291      288       -3     
Impacted Files Coverage Δ
lib/proxy-agent.js 93.50% <100.00%> (+0.35%) ⬆️
lib/fetch/formdata.js 95.95% <0.00%> (-0.12%) ⬇️
lib/fetch/util.js 85.16% <0.00%> (+1.22%) ⬆️
lib/fetch/headers.js 96.57% <0.00%> (+2.09%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@oooshima oooshima changed the title feat: add parameter to ProxyAgent options, whitch is type of authentication feat: add parameter to ProxyAgent options, which is type of authentication Oct 15, 2022
@ronag ronag requested a review from KhafraDev October 15, 2022 15:08
Copy link
Member

@KhafraDev KhafraDev left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

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

Could you please include docs for this new property? Would be great to mention the deprecation of auth in the docs too.

Comment on lines 61 to 63
}

if (opts.token) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
if (opts.token) {
} else if (opts.token) {

@@ -55,10 +55,15 @@ class ProxyAgent extends DispatcherBase {
this[kProxyTls] = opts.proxyTls
this[kProxyHeaders] = {}

// deprecated
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// deprecated
// @deprecated in favour of opts.token

@@ -15,6 +15,7 @@ declare namespace ProxyAgent {
export interface Options extends Agent.Options {
uri: string;
auth?: string;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
auth?: string;
/**
* @deprecated use opts.token
*/
auth?: string;

Copy link
Member

Choose a reason for hiding this comment

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

Fix the lint too

@oooshima
Copy link
Contributor Author

@RafaelGSS
Thank you!
I have fixed it based on your comments.
b2c64c0


const proxyAgent = new ProxyAgent({
uri: 'my.proxy.server',
token 'Bearer xxxx'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
token 'Bearer xxxx'
token: 'Bearer xxxx'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cola119
Sorry! I have fixed it.
fb7a9c4

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Can you add a test for the types?

@oooshima oooshima force-pushed the fix-proxyagent-authentication branch from 596b887 to 0ba193c Compare October 16, 2022 14:36
@oooshima
Copy link
Contributor Author

@mcollina
I have added a test for the types.
0ba193c

Copy link
Member

@RafaelGSS RafaelGSS left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 6714f9d into nodejs:main Oct 17, 2022
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
…ation (nodejs#1705)

* feat: add parameter to ProxyAgent options, whitch is type of authentication.

* fix: docs and comments

* fix: docs

* add: throw error when using auth in combination with token

* add: test for the types

Co-authored-by: oshimaharuna <ooooooshim115@gmail.com>
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
…ation (nodejs#1705)

* feat: add parameter to ProxyAgent options, whitch is type of authentication.

* fix: docs and comments

* fix: docs

* add: throw error when using auth in combination with token

* add: test for the types

Co-authored-by: oshimaharuna <ooooooshim115@gmail.com>
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.

None yet

7 participants