Skip to content

Commit 22a3b11

Browse files
committed
fix(trivial): docs cleanup
1 parent d6c5585 commit 22a3b11

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,18 @@ This provides a wrapper for fetch that facilitates proxy auth authorization.
144144
**Kind**: global class
145145

146146
* [ProxyFetch](#ProxyFetch)
147-
* [new ProxyFetch(authOptions)](#new_ProxyFetch_new)
147+
* [new ProxyFetch(proxyAuthOptions)](#new_ProxyFetch_new)
148148
* [.fetch(resource, options)](#ProxyFetch+fetch) ⇒ <code>Promise.&lt;Response&gt;</code>
149149

150150
<a name="new_ProxyFetch_new"></a>
151151

152-
### new ProxyFetch(authOptions)
152+
### new ProxyFetch(proxyAuthOptions)
153153
Initialize this class with Proxy auth options
154154

155155

156156
| Param | Type | Description |
157157
| --- | --- | --- |
158-
| authOptions | [<code>ProxyAuthOptions</code>](#ProxyAuthOptions) | the auth options to connect with |
158+
| proxyAuthOptions | [<code>ProxyAuthOptions</code>](#ProxyAuthOptions) | the auth options to connect with |
159159

160160
<a name="ProxyFetch+fetch"></a>
161161

@@ -220,6 +220,8 @@ Proxy Auth Options
220220
| Name | Type | Description |
221221
| --- | --- | --- |
222222
| proxyUrl | <code>string</code> | the proxy's url |
223+
| [username] | <code>string</code> | the username for basic auth |
224+
| [password] | <code>string</code> | the password for basic auth |
223225
| rejectUnauthorized | <code>boolean</code> | set to false to not reject unauthorized server certs |
224226

225227
### Debug Logs

src/ProxyFetch.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const { urlToHttpOptions } = require('./utils')
2525
*
2626
* See https://github.com/TooTallNate/proxy-agents/issues/89
2727
* An alternative is to use https://github.com/delvedor/hpagent
28+
* @private
2829
*/
2930
class PatchedHttpsProxyAgent extends HttpsProxyAgent {
3031
constructor (proxyUrl, opts) {
@@ -41,11 +42,11 @@ class PatchedHttpsProxyAgent extends HttpsProxyAgent {
4142
* @private
4243
*
4344
* @param {string} resourceUrl an endpoint url for proxyAgent selection
44-
* @param {object} authOptions an object which contains auth information
45+
* @param {ProxyAuthOptions} proxyOptions an object which contains auth information
4546
* @returns {http.Agent} a http.Agent for basic auth proxy
4647
*/
47-
function proxyAgent (resourceUrl, authOptions) {
48-
const { proxyUrl, username, password, rejectUnauthorized = true } = authOptions
48+
function proxyAgent (resourceUrl, proxyAuthOptions) {
49+
const { proxyUrl, username, password, rejectUnauthorized = true } = proxyAuthOptions
4950
const proxyOpts = urlToHttpOptions(proxyUrl)
5051

5152
if (!proxyOpts.auth && username && password) {
@@ -70,6 +71,8 @@ function proxyAgent (resourceUrl, authOptions) {
7071
*
7172
* @typedef {object} ProxyAuthOptions
7273
* @property {string} proxyUrl - the proxy's url
74+
* @property {string} [username] the username for basic auth
75+
* @property {string} [password] the password for basic auth
7376
* @property {boolean} rejectUnauthorized - set to false to not reject unauthorized server certs
7477
*/
7578

@@ -80,11 +83,11 @@ class ProxyFetch {
8083
/**
8184
* Initialize this class with Proxy auth options
8285
*
83-
* @param {ProxyAuthOptions} authOptions the auth options to connect with
86+
* @param {ProxyAuthOptions} proxyAuthOptions the auth options to connect with
8487
*/
85-
constructor (authOptions = {}) {
86-
logger.debug(`constructor - authOptions: ${JSON.stringify(authOptions)}`)
87-
const { proxyUrl } = authOptions
88+
constructor (proxyAuthOptions = {}) {
89+
logger.debug(`constructor - authOptions: ${JSON.stringify(proxyAuthOptions)}`)
90+
const { proxyUrl } = proxyAuthOptions
8891
const { auth } = urlToHttpOptions(proxyUrl)
8992

9093
if (!proxyUrl) {
@@ -96,7 +99,7 @@ class ProxyFetch {
9699
logger.debug('constructor: username or password not set, proxy is anonymous.')
97100
}
98101

99-
this.authOptions = authOptions
102+
this.authOptions = proxyAuthOptions
100103
return this
101104
}
102105

types.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,23 @@ declare class HttpExponentialBackoff {
3232
/**
3333
* Proxy Auth Options
3434
* @property proxyUrl - the proxy's url
35+
* @property [username] - the username for basic auth
36+
* @property [password] - the password for basic auth
3537
* @property rejectUnauthorized - set to false to not reject unauthorized server certs
3638
*/
3739
declare type ProxyAuthOptions = {
3840
proxyUrl: string;
41+
username?: string;
42+
password?: string;
3943
rejectUnauthorized: boolean;
4044
};
4145

4246
/**
4347
* Initialize this class with Proxy auth options
44-
* @param authOptions - the auth options to connect with
48+
* @param proxyAuthOptions - the auth options to connect with
4549
*/
4650
declare class ProxyFetch {
47-
constructor(authOptions: ProxyAuthOptions);
51+
constructor(proxyAuthOptions: ProxyAuthOptions);
4852
/**
4953
* Fetch function, using the configured NTLM Auth options.
5054
* @param resource - the url or Request object to fetch from

0 commit comments

Comments
 (0)