Skip to content

Commit 91fe102

Browse files
author
acooper4960
authored
Merge pull request #117 from docusign/v4.1.0-rc1
V4.1.0
2 parents 34429cd + 43380b7 commit 91fe102

39 files changed

+3322
-289
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
See [DocuSign Support Center](https://support.docusign.com/en/releasenotes/) for Product Release Notes.
44

5+
## [v4.1.0] - eSignature API v18.3.00 - 9/13/2018
6+
### Changed
7+
- The `getOAuthBasePath()` method is now an accessor function for the new `oAuthBasePath` property, rather than being derived from `basePath`.
8+
- Updated the swagger spec to version 18.3.00.00
9+
### Added
10+
- Created a new `ApiClient` property, `oAuthBasePath`. This property is retrieved using `getOAuthBasePath()` and set by **setOAuthBasePath()**. DCM-2834
11+
- Created a new `docusign.ApiClient.OAuth.BasePath` collection that holds base path data for the following environments: `STAGE, DEMO, PRODUCTION`.
12+
- Created a new `docusign.ApiClient.RestApi.BasePath` collection that holds rest API base paths for the following environments: `STAGE, DEMO, PRODUCTION`. These recorded path values can be accessed using an instantiated `docusign.apiClient` object.
13+
- Added an `opts` parameter that allows you to specify parameter values when instantiating an `apiClient`. The `opts` parameter currently supports passing in `basePath` and `oAuthBasePath` values. If not set during instantiation of an `apiClient`, they default to their production values.
14+
- An `Organization` value has been added to the account model. DCM-2710
15+
### Deprecated
16+
- The `configureJWTAuthorizationFlow` method is now deprecated. Please use `requestJWTUserToken` instead, which takes the private key as byte array or a Stream. DCM-2765
17+
18+
519
## [v4.0.2] - eSignature API v18.1.02 - 7/3/2018
620
### Changed
721
- All SDK methods have been updated such that the `opts` parameter may now contain the callback, making the other opts parameters optional, and it has been renamed `optsOrCallback`.

README.md

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,53 +109,70 @@ The following example can be used with an older version of Node.JS.
109109

110110
```javascript
111111
var docusign = require('docusign-esign');
112+
var oAuth = docusign.ApiClient.OAuth;
113+
var restApi = docusign.ApiClient.RestApi;
112114
var async = require('async');
113115
var path = require('path');
114116

115117
var integratorKey = '***'; // Integrator Key associated with your DocuSign Integration
116118
var userId = 'YOUR_USER_ID'; // API Username for your DocuSign Account (use the GUID not the email address)
117-
var docusignEnv = 'demo'; // DocuSign Environment generally demo for testing purposes
118119
var fullName = 'Joan Jett'; // Recipient's Full Name
119120
var recipientEmail = '[email protected]'; // Recipient's Email
120121
var templateId = '***'; // ID of the Template you want to create the Envelope with
121122
var templateRoleName = '***'; // Role name of the Recipient for the Template
122123

123-
var baseUrl = 'https://' + docusignEnv + '.docusign.net/restapi';
124-
var oAuthBaseUrl = 'account-d.docusign.com'; // use account.docusign.com for Live/Production
124+
var expiresIn = 3600; // Number of seconds until the JWT assertion is invalid
125+
var basePath = restApi.BasePath.DEMO;
126+
var oAuthBasePath = oAuth.BasePath.DEMO;
125127
var redirectURI = 'https://www.docusign.com/api';
126128
var privateKeyFilename = 'keys/docusign_private_key.txt'; //path to the file storing the private key from the RSA Keypair associated to the Integrator Key
127129

128-
var apiClient = new docusign.ApiClient();
129-
130+
var apiClient = new docusign.ApiClient({
131+
basePath: basePath,
132+
oAuthBasePath: oAuthBasePath
133+
});
134+
var scopes = [
135+
oAuth.Scope.IMPERSONATION,
136+
oAuth.Scope.SIGNATURE
137+
];
138+
130139
async.waterfall([
131140
function initApiClient (next) {
132-
apiClient.setBasePath(baseUrl);
141+
133142
// assign the api client to the Configuration object
134143
docusign.Configuration.default.setDefaultApiClient(apiClient);
135144

136145
// IMPORTANT NOTE:
137146
// the first time you ask for a JWT access token, you should grant access by making the following call
138147
// get DocuSign OAuth authorization url:
139-
var oauthLoginUrl = apiClient.getJWTUri(integratorKey, redirectURI, oAuthBaseUrl);
148+
var oauthLoginUrl = apiClient.getJWTUri(integratorKey, redirectURI, oAuthBasePath);
140149
// open DocuSign OAuth authorization url in the browser, login and grant access
141150
console.log(oauthLoginUrl);
142151
// END OF NOTE
143152

144153
// configure the ApiClient to asynchronously get an access to token and store it
145154

146-
apiClient.configureJWTAuthorizationFlow(path.resolve(__dirname, privateKeyFilename), oAuthBaseUrl, integratorKey, userId, 3600, function (err, res) {
147-
if (!err && res.body && res.body.access_token) {
148-
apiClient.getUserInfo(res.body.access_token, function (err, userInfo) {
149-
accountId = userInfo.accounts[0].accountId;
150-
var baseUri = userInfo.accounts[0].baseUri;
151-
var accountDomain = baseUri.split('/v2');
152-
// below code required for production, no effect in demo (same domain)
153-
apiClient.setBasePath(accountDomain[0] + "/restapi");
154-
console.log('LoginInformation: ' + JSON.stringify(userInfo.accounts));
155-
156-
next(null, userInfo.accounts[0]);
157-
});
155+
var fs = require('fs');
156+
var privateKeyFile = fs.readFileSync(path.resolve(__dirname, privateKeyFilename));
157+
apiClient.requestJWTUserToken(integratorKey, userId, scopes, privateKeyFile, expiresIn, function (err, res) {
158+
var baseUri,
159+
accountDomain;
160+
if (err) {
161+
return next(err);
158162
}
163+
apiClient.addDefaultHeader('Authorization', 'Bearer ' + res.body.access_token);
164+
165+
apiClient.getUserInfo(res.body.access_token, function (err, userInfo) {
166+
if (err) {
167+
return next(err);
168+
}
169+
accountId = userInfo.accounts[0].accountId;
170+
baseUri = userInfo.accounts[0].baseUri;
171+
accountDomain = baseUri.split('/v2');
172+
apiClient.setBasePath(accountDomain[0] + '/restapi');
173+
console.log('LoginInformation: ' + JSON.stringify(userInfo));
174+
return next(null, userInfo.accounts[0]);
175+
});
159176
});
160177
},
161178

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docusign-esign",
3-
"version": "4.0.2",
3+
"version": "4.1.0",
44
"description": "DocuSign Node.js API client.",
55
"license": "MIT",
66
"main": "src/index.js",

0 commit comments

Comments
 (0)