Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ This client has the following external dependencies:
**Minimum:**
* docusign-esign
* Axios v1.6.8+
* @devhigley/parse-proxy v1.0.3+
* Csv-stringify v1.0.0+
* Jsonwebtoken v9.0.0+
* Passport-oauth2 v1.6.1+
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
},
"dependencies": {
"axios": "^1.6.8",
"@devhigley/parse-proxy":"^1.0.3",
"csv-stringify": "^1.0.0",
"jsonwebtoken": "^9.0.0",
"passport-oauth2": "^1.6.1",
Expand Down
41 changes: 29 additions & 12 deletions src/ApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,43 @@
if (typeof define === "function" && define.amd) {
// AMD. Register as an anonymous module.
define(["axios"], factory);
define(["@devhigley/parse-proxy"], factory);
} else if (typeof module === "object" && module.exports) {
} else if (typeof module === "object" && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(
require("axios"),
require("@devhigley/parse-proxy")
require("axios")
);
} else {
// Browser globals (root is window)
if (!root.Docusign) {
root.Docusign = {};
}
root.Docusign.ApiClient = factory(root.axios, root.parseProxy, opts);
root.Docusign.ApiClient = factory(root.axios, opts);
}
})(this, function (axios, parseProxy, opts) {
})(this, function (axios, opts) {
"use strict";

var DEFAULT_PROXY_PORTS = { "http:": 80, "https:": 443 };
var parseProxy = function (proxyUri) {
var input = /:\/\//.test(proxyUri) ? proxyUri : "http://" + proxyUri;
var parsed = new URL(input);
// URL strips the default port for the scheme (e.g. http://x:80 -> port "").
// Restore it from the protocol so axios receives an explicit port.
var proxyConfig = {
host: parsed.hostname,
port: parsed.port
? parseInt(parsed.port, 10)
: DEFAULT_PROXY_PORTS[parsed.protocol],
protocol: parsed.protocol.replace(":", ""),
};
if (parsed.username || parsed.password) {
proxyConfig.auth = {
username: decodeURIComponent(parsed.username),
password: decodeURIComponent(parsed.password),
};
}
return proxyConfig;
};

/**
* The default HTTP headers to be included for all API calls.
* @type {Array.<String>}
Expand Down Expand Up @@ -105,8 +125,7 @@
};

if (proxy) {
const proxyObj = parseProxy(proxy);
requestConfig.proxy = proxyObj[0];
requestConfig.proxy = parseProxy(proxy);
}

const oauthRequest = axios.request(requestConfig);
Expand Down Expand Up @@ -608,8 +627,7 @@
};

if (this.proxy) {
const proxyObj = parseProxy(this.proxy);
requestConfig.proxy = proxyObj[0];
requestConfig.proxy = parseProxy(this.proxy);
}

var _formParams = this.normalizeParams(formParams);
Expand Down Expand Up @@ -977,8 +995,7 @@
headers: headers,
};
if (this.proxy) {
const proxyObj = parseProxy(this.proxy);
requestConfig.proxy = proxyObj[0];
requestConfig.proxy = parseProxy(this.proxy);
}

const request = axios.request(requestConfig);
Expand Down