|
1 | 1 | /** |
2 | | - * DocuSign REST API |
3 | | - * The DocuSign REST API provides you with a powerful, convenient, and simple Web services API for interacting with DocuSign. |
| 2 | + * Docusign eSignature REST API |
| 3 | + * The Docusign eSignature REST API provides you with a powerful, convenient, and simple Web services API for interacting with Docusign. |
4 | 4 | * |
5 | 5 | * OpenAPI spec version: v2.1 |
6 | 6 | |
|
34 | 34 | * @type {Array.<String>} |
35 | 35 | * @default {} |
36 | 36 | */ |
37 | | - var defaultHeaders = { |
38 | | - "X-DocuSign-SDK": "Node", |
39 | | - "Node-Ver": process.version, |
40 | | - "User-Agent": `Swagger-Codegen/v2.1/7.0.2/node/${process.version}`, |
41 | | - }; |
42 | | - |
43 | 37 | var SCOPE_SIGNATURE = "signature"; |
44 | 38 | var SCOPE_EXTENDED = "extended"; |
45 | 39 | var SCOPE_IMPERSONATION = "impersonation"; |
|
91 | 85 | assertion, |
92 | 86 | oAuthBasePath, |
93 | 87 | proxy, |
| 88 | + defaultHeaders, |
94 | 89 | callback |
95 | 90 | ) { |
96 | 91 | const requestConfig = { |
|
162 | 157 | return exports.prototype.OAuth.BasePath.PRODUCTION; |
163 | 158 | }; |
164 | 159 |
|
| 160 | + const encodeBase64 = (str) => { |
| 161 | + if (typeof Buffer !== 'undefined') { |
| 162 | + return Buffer.from(str).toString('base64'); |
| 163 | + } else { |
| 164 | + return btoa(unescape(encodeURIComponent(str))); |
| 165 | + } |
| 166 | + } |
| 167 | + |
165 | 168 | /** |
166 | 169 | * @module ApiClient |
167 | 170 | */ |
|
179 | 182 | oAuthBasePath: require("./OAuth").BasePath.PRODUCTION, |
180 | 183 | }; |
181 | 184 |
|
182 | | - opts = Object.assign({},defaults, opts); |
| 185 | + this.defaultHeaders = { |
| 186 | + "X-DocuSign-SDK": "Node", |
| 187 | + "Node-Ver": process.version, |
| 188 | + "User-Agent": `Swagger-Codegen/v2.1/7.0.3/node/${process.version}`, |
| 189 | + }; |
| 190 | + |
| 191 | + opts = {...defaults, ...opts}; |
183 | 192 | opts.oAuthBasePath = deriveOAuthBasePathFromRestBasePath(opts.basePath); |
184 | 193 |
|
185 | 194 | /** |
|
266 | 275 | header, |
267 | 276 | value |
268 | 277 | ) { |
269 | | - defaultHeaders[header] = value; |
| 278 | + this.defaultHeaders[header] = value; |
270 | 279 | }; |
271 | 280 |
|
272 | 281 | /** |
|
276 | 285 | if(!token){ |
277 | 286 | throw new Error("Missing the required parameter 'token' when calling setJWTToken.") |
278 | 287 | } |
279 | | - defaultHeaders["Authorization"] = `Bearer ${token}`; |
| 288 | + this.defaultHeaders["Authorization"] = `Bearer ${token}`; |
280 | 289 | }; |
281 | 290 |
|
282 | 291 | /** |
|
627 | 636 | const _headerParams = this.normalizeParams(headerParams); |
628 | 637 | requestConfig.headers = { |
629 | 638 | ...requestConfig.headers, |
630 | | - ...defaultHeaders, |
| 639 | + ...this.defaultHeaders, |
631 | 640 | ..._headerParams, |
632 | 641 | }; |
633 | 642 |
|
|
878 | 887 | /** |
879 | 888 | * @param clientId OAuth2 client ID: Identifies the client making the request. |
880 | 889 | * Client applications may be scoped to a limited set of system access. |
881 | | - * @param clientSecret the secret key you generated when you set up the integration in DocuSign Admin console. |
| 890 | + * @param clientSecret the secret key you generated when you set up the integration in Docusign Admin console. |
882 | 891 | * @param code The authorization code that you received from the <i>getAuthorizationUri</i> callback. |
883 | 892 | * @return OAuthToken object.xx |
884 | 893 | */ |
|
898 | 907 | code: code, |
899 | 908 | }, |
900 | 909 | headers = { |
901 | | - Authorization: "Basic " + new Buffer(clientString).toString("base64"), |
| 910 | + ...this.defaultHeaders, |
| 911 | + Authorization: "Basic " + encodeBase64(clientString), |
902 | 912 | "Cache-Control": "no-store", |
903 | 913 | Pragma: "no-cache", |
904 | | - ...defaultHeaders, |
905 | 914 | }, |
906 | 915 | OAuthToken = require("./OAuth").OAuthToken; |
907 | 916 |
|
|
947 | 956 | if(!accessToken) throw new Error("Error accessToken is required", null); |
948 | 957 |
|
949 | 958 | var headers = { |
| 959 | + ...this.defaultHeaders, |
950 | 960 | Authorization: "Bearer " + accessToken, |
951 | 961 | "Cache-Control": "no-store", |
952 | 962 | Pragma: "no-cache", |
953 | | - ...defaultHeaders, |
954 | 963 | }; |
955 | 964 |
|
956 | 965 | const requestConfig = { |
|
1001 | 1010 | * Helper method to build the OAuth JWT grant uri (used once to get a user consent for impersonation) |
1002 | 1011 | * @param clientId OAuth2 client ID |
1003 | 1012 | * @param redirectURI OAuth2 redirect uri |
1004 | | - * @param oAuthBasePath DocuSign OAuth base path (account-d.docusign.com for the developer sandbox |
| 1013 | + * @param oAuthBasePath Docusign OAuth base path (account-d.docusign.com for the developer sandbox |
1005 | 1014 | * and account.docusign.com for the production platform) |
1006 | 1015 | * @returns {string} the OAuth JWT grant uri as a String |
1007 | 1016 | */ |
|
1029 | 1038 |
|
1030 | 1039 | /** |
1031 | 1040 | * @deprecated since version 4.1.0 |
1032 | | - * Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign |
| 1041 | + * Configures the current instance of ApiClient with a fresh OAuth JWT access token from Docusign |
1033 | 1042 | * @param privateKeyFilename the filename of the RSA private key |
1034 | | - * @param oAuthBasePath DocuSign OAuth base path (account-d.docusign.com for the developer sandbox |
| 1043 | + * @param oAuthBasePath Docusign OAuth base path (account-d.docusign.com for the developer sandbox |
1035 | 1044 | * and account.docusign.com for the production platform) |
1036 | | - * @param clientId DocuSign OAuth Client Id (AKA Integrator Key) |
1037 | | - * @param userId DocuSign user Id to be impersonated (This is a UUID) |
| 1045 | + * @param clientId Docusign OAuth Client Id (AKA Integrator Key) |
| 1046 | + * @param userId Docusign user Id to be impersonated (This is a UUID) |
1038 | 1047 | * @param expiresIn in seconds for the token time-to-live |
1039 | 1048 | * @param callback the callback function. |
1040 | 1049 | */ |
|
1072 | 1081 | method: "post", |
1073 | 1082 | url: "/oauth/token", |
1074 | 1083 | headers: { |
| 1084 | + ...this.defaultHeaders, |
1075 | 1085 | "Content-Type": "application/x-www-form-urlencoded", |
1076 | 1086 | "Cache-Control": "no-store", |
1077 | 1087 | Pragma: "no-cache", |
1078 | | - ...defaultHeaders, |
1079 | 1088 | }, |
1080 | 1089 | timeout: this.timeout, |
1081 | 1090 | data: { |
|
1124 | 1133 | assertion, |
1125 | 1134 | this.oAuthBasePath, |
1126 | 1135 | this.proxy, |
| 1136 | + this.defaultHeaders, |
1127 | 1137 | callback |
1128 | 1138 | ); |
1129 | 1139 | }; |
|
1150 | 1160 | assertion, |
1151 | 1161 | this.oAuthBasePath, |
1152 | 1162 | this.proxy, |
| 1163 | + this.defaultHeaders, |
1153 | 1164 | callback |
1154 | 1165 | ); |
1155 | 1166 | }; |
|
1174 | 1185 | assertion, |
1175 | 1186 | this.oAuthBasePath, |
1176 | 1187 | this.proxy, |
| 1188 | + this.defaultHeaders, |
1177 | 1189 | callback |
1178 | 1190 | ); |
1179 | 1191 | }; |
|
0 commit comments