├── loanco.png ├── jsconfig.json ├── src ├── oauth │ ├── ResponseType.js │ ├── BasePath.js │ ├── Scope.js │ ├── Link.js │ ├── Account.js │ ├── Organization.js │ ├── OAuthToken.js │ └── UserInfo.js ├── RestApi.js ├── OAuth.js ├── Configuration.js ├── model │ ├── Filter.js │ ├── Aggregation.js │ ├── AggregateResult.js │ ├── DataSet.js │ ├── CursoredResult.js │ ├── AggregateResultResult.js │ ├── RawRequest.js │ └── WebQuery.js ├── index.js ├── api │ └── DataSetApi.js └── ApiClient.js ├── .gitignore ├── .travis.yml ├── test-config.js ├── .jsdoc.json ├── LICENSE ├── .swagger-codegen-ignore ├── package.json ├── CHANGELOG.md ├── README.md └── test └── SdkUnitTests.js /loanco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/docusign/docusign-monitor-node-client/master/loanco.png -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES6", 4 | "module": "commonjs" 5 | } 6 | } -------------------------------------------------------------------------------- /src/oauth/ResponseType.js: -------------------------------------------------------------------------------- 1 | var CODE = 'code'; 2 | var TOKEN = 'token'; 3 | 4 | module.exports = { 5 | CODE: CODE, 6 | TOKEN: TOKEN, 7 | } 8 | 9 | Object.freeze(module.exports); -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage 3 | .nyc_output/ 4 | *.DS_Store 5 | auth-info.json 6 | config.json 7 | .idea/ 8 | npm-debug.log 9 | package-lock.json 10 | test.txt 11 | .swagger-codegen/ 12 | test-results.xml -------------------------------------------------------------------------------- /src/oauth/BasePath.js: -------------------------------------------------------------------------------- 1 | var PRODUCTION = "account.docusign.com"; 2 | var DEMO = "account-d.docusign.com"; 3 | var STAGE = "account-s.docusign.com"; 4 | 5 | module.exports = { 6 | PRODUCTION: PRODUCTION, 7 | DEMO: DEMO, 8 | STAGE: STAGE 9 | }; 10 | 11 | Object.freeze(module.exports) -------------------------------------------------------------------------------- /src/RestApi.js: -------------------------------------------------------------------------------- 1 | const PRODUCTION_BASE_PATH = 'https://lens.docusign.net'; 2 | const DEMO_BASE_PATH = 'https://lens-d.docusign.net'; 3 | const STAGE_BASE_PATH = 'https://lens-s.docusign.net'; 4 | 5 | module.exports = { 6 | BasePath: { 7 | PRODUCTION: PRODUCTION_BASE_PATH, 8 | DEMO: DEMO_BASE_PATH, 9 | STAGE: STAGE_BASE_PATH 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | branches: 4 | only: 5 | - master 6 | - v2-master 7 | 8 | language: node_js 9 | 10 | notifications: 11 | email: 12 | recipients: 13 | - devcenter@docusign.com 14 | on_success: never 15 | on_failure: change 16 | 17 | node_js: 18 | - "12" 19 | - "14" 20 | - "16" 21 | 22 | cache: 23 | directories: 24 | - "node_modules" 25 | 26 | after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" 27 | 28 | -------------------------------------------------------------------------------- /test-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | integratorKey: process.env.INTEGRATOR_KEY_JWT, 3 | apiEnv: 'demo', 4 | debug: false, 5 | email: process.env.EMAIL, 6 | userId: process.env.USER_ID, 7 | templateId: process.env.TEMPLATE_ID, 8 | templateRole: 'bob', 9 | integratorKeyAuthCode: process.env.INTEGRATOR_KEY_AUTH_CODE, 10 | integratorKeyImplicit: process.env.INTEGRATOR_KEY_IMPLICIT, 11 | clientSecret: process.env.CLIENT_SECRET, 12 | brandId: process.env.BRAND_ID, 13 | privateKey: process.env.PRIVATE_KEY 14 | }; 15 | -------------------------------------------------------------------------------- /src/oauth/Scope.js: -------------------------------------------------------------------------------- 1 | var SIGNATURE = 'signature'; 2 | var EXTENDED = 'extended'; 3 | var IMPERSONATION = 'impersonation'; 4 | var COMPANY_WRITE = 'dtr.company.write'; 5 | var COMPANY_READ = 'dtr.company.read'; 6 | var MONITOR_WRITE = 'dtr.monitor.write'; 7 | var MONITOR_READ = 'dtr.monitor.read'; 8 | 9 | module.exports = { 10 | SIGNATURE: SIGNATURE, 11 | EXTENDED: EXTENDED, 12 | IMPERSONATION: IMPERSONATION, 13 | COMPANY_WRITE: COMPANY_WRITE, 14 | COMPANY_READ: COMPANY_READ, 15 | MONITOR_WRITE: MONITOR_WRITE, 16 | MONITOR_READ: MONITOR_READ 17 | }; 18 | 19 | Object.freeze(module.exports); -------------------------------------------------------------------------------- /.jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true 4 | }, 5 | "source": { 6 | "include": ["src", "package.json"], 7 | "includePattern": ".js$", 8 | "excludePattern": "(node_modules/|docs)" 9 | }, 10 | "plugins": [ 11 | "plugins/markdown" 12 | ], 13 | "markdown": { 14 | "parser": "gfm", 15 | "hardwrap": true 16 | }, 17 | "templates": { 18 | "cleverLinks": false, 19 | "monospaceLinks": true, 20 | "useLongnameInNav": false 21 | }, 22 | "opts": { 23 | "source": "./src/", 24 | "destination": "./docs/", 25 | "encoding": "utf8", 26 | "recurse": true, 27 | "template": "./node_modules/docdash" 28 | }, 29 | "docdash": { 30 | "static": false, 31 | "sort": true 32 | } 33 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2021- DocuSign, Inc. (https://www.docusign.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.swagger-codegen-ignore: -------------------------------------------------------------------------------- 1 | # Swagger Codegen Ignore 2 | 3 | # Use this file to prevent files from being overwritten by the generator. 4 | # The patterns follow closely to .gitignore or .dockerignore. 5 | 6 | # As an example, the C# client generator defines ApiClient.cs. 7 | # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: 8 | #ApiClient.cs 9 | 10 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 11 | #foo/*/qux 12 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 13 | 14 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 15 | #foo/**/qux 16 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 17 | 18 | # You can also negate patterns with an exclamation (!). 19 | # For example, you can ignore all files in a docs folder with the file extension .md: 20 | #docs/*.md 21 | # Then explicitly reverse the ignore rule for a single file: 22 | #!docs/README.md 23 | 24 | # Swagger and Git files 25 | .swagger-codegen-ignore 26 | .gitignore 27 | CHANGELOG.md 28 | README.md 29 | git_push.sh 30 | 31 | # Project files 32 | LICENSE 33 | .travis.yml 34 | mocha.opts 35 | 36 | # Specific src and test files 37 | docs/*.md 38 | test/*/*.spec.js 39 | test/assert-equals.js 40 | src/OAuth.js 41 | src/RestApi.js 42 | src/ApiClient.js 43 | src/oauth/ 44 | -------------------------------------------------------------------------------- /src/OAuth.js: -------------------------------------------------------------------------------- 1 | var Scope_SIGNATURE = require('./oauth/Scope').SIGNATURE; 2 | var Scope_EXTENDED = require('./oauth/Scope').EXTENDED; 3 | var Scope_IMPERSONATION = require('./oauth/Scope').IMPERSONATION; 4 | var Scope_COMPANY_WRITE = require('./oauth/Scope').COMPANY_WRITE; 5 | var Scope_COMPANY_READ = require('./oauth/Scope').COMPANY_READ; 6 | var Scope_MONITOR_WRITE = require('./oauth/Scope').MONITOR_WRITE; 7 | var Scope_MONITOR_READ = require('./oauth/Scope').MONITOR_READ; 8 | 9 | var PRODUCTION_OAUTH_BASE_PATH = require('./oauth/BasePath').PRODUCTION; 10 | var DEMO_OAUTH_BASE_PATH = require('./oauth/BasePath').DEMO; 11 | var STAGE_OAUTH_BASE_PATH = require('./oauth/BasePath').STAGE; 12 | var CODE = require('./oauth/ResponseType').CODE; 13 | var TOKEN = require('./oauth/ResponseType').TOKEN; 14 | var UserInfo = require('./oauth/UserInfo'); 15 | var OAuthToken = require('./oauth/OAuthToken'); 16 | 17 | module.exports = { 18 | Scope: { 19 | SIGNATURE: Scope_SIGNATURE, 20 | EXTENDED: Scope_EXTENDED, 21 | IMPERSONATION: Scope_IMPERSONATION, 22 | COMPANY_WRITE: Scope_COMPANY_WRITE, 23 | COMPANY_READ: Scope_COMPANY_READ, 24 | MONITOR_WRITE: Scope_MONITOR_WRITE, 25 | MONITOR_READ: Scope_MONITOR_READ 26 | }, 27 | ResponseType: { 28 | CODE: CODE, 29 | TOKEN: TOKEN, 30 | }, 31 | BasePath: { 32 | PRODUCTION: PRODUCTION_OAUTH_BASE_PATH, 33 | STAGE: STAGE_OAUTH_BASE_PATH, 34 | DEMO: DEMO_OAUTH_BASE_PATH, 35 | }, 36 | UserInfo: UserInfo, 37 | OAuthToken: OAuthToken 38 | }; 39 | 40 | Object.freeze(module.exports.Scope); 41 | Object.freeze(module.exports.ResponseType); 42 | Object.freeze(module.exports.BasePath); -------------------------------------------------------------------------------- /src/Configuration.js: -------------------------------------------------------------------------------- 1 | (function(root, factory) { 2 | if (typeof define === 'function' && define.amd) { 3 | // AMD. Register as an anonymous module. 4 | define([undefined, './ApiClient'], factory); 5 | } else if (typeof module === 'object' && module.exports) { 6 | // CommonJS-like environments that support module.exports, like Node. 7 | module.exports = factory(undefined, require('./ApiClient')); 8 | } else { 9 | // Browser globals (root is window) 10 | if (!root.Docusign) { 11 | root.Docusign = {}; 12 | } 13 | factory(root.Docusign, root.Docusign.ApiClient); 14 | } 15 | }(this, function(module, ApiClient) { 16 | 'use strict'; 17 | 18 | var Configuration = function Configuration() { 19 | /** 20 | * The API client to use for every API call. 21 | */ 22 | this.defaultApiClient = new ApiClient(); 23 | 24 | /** 25 | * The default HTTP headers to be included for all API calls. 26 | */ 27 | // Add DocuSign Tracking Header 28 | this.defaultHeaders = { "X-DocuSign-SDK": "Node" }; 29 | }; 30 | 31 | /** 32 | * Get the default API client, which would be used when creating API 33 | * instances without providing an API client. 34 | */ 35 | Configuration.prototype.getDefaultApiClient = function getDefaultApiClient() { 36 | return this.defaultApiClient; 37 | }; 38 | 39 | /** 40 | * Sets the default API client. 41 | */ 42 | Configuration.prototype.setDefaultApiClient = function setDefaultApiClient(defaultApiClient) { 43 | this.defaultApiClient = defaultApiClient; 44 | }; 45 | 46 | Configuration.default = new Configuration(); 47 | 48 | return Configuration; 49 | })); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docusign-monitor", 3 | "version": "3.0.0", 4 | "description": "Docusign Node.js API client.", 5 | "license": "MIT", 6 | "main": "src/index.js", 7 | "author": "DocuSign Developer Center ", 8 | "contributors": [ 9 | "https://github.com/docusign/docusign-node-client/contributors" 10 | ], 11 | "files": [ 12 | "src" 13 | ], 14 | "keywords": [ 15 | "docusign", 16 | "signature", 17 | "esignature", 18 | "esign", 19 | "digital", 20 | "electronic", 21 | "transaction", 22 | "document", 23 | "certificate", 24 | "DTM", 25 | "PDF" 26 | ], 27 | "engines": { 28 | "node": ">=2.2.1" 29 | }, 30 | "repository": { 31 | "type": "git", 32 | "url": "https://github.com/docusign/docusign-node-client.git" 33 | }, 34 | "scripts": { 35 | "docs": "npm run update-docs && git add docs/ && git commit -m 'update docs' && npm run push-docs", 36 | "push-docs": "git subtree push --prefix docs origin gh-pages", 37 | "update-docs": "./node_modules/.bin/jsdoc -c .jsdoc.json", 38 | "check-config": "./scripts/check-config.js", 39 | "test": "semistandard --fix && ./node_modules/mocha/bin/mocha --reporter mocha-junit-reporter --timeout 60000" 40 | }, 41 | "semistandard": { 42 | "globals": [ 43 | "before", 44 | "describe", 45 | "it" 46 | ], 47 | "ignore": [ 48 | "/src", 49 | "/docs", 50 | "/scripts" 51 | ] 52 | }, 53 | "dependencies": { 54 | "axios": "^1.6.8", 55 | "@devhigley/parse-proxy":"^1.0.3", 56 | "csv-stringify": "^1.0.0", 57 | "jsonwebtoken": "^9.0.0", 58 | "passport-oauth2": "^1.6.1", 59 | "safe-buffer": "^5.1.2" 60 | }, 61 | "devDependencies": { 62 | "docdash": "0.4.0", 63 | "expect.js": "~0.3.1", 64 | "jsdoc": "3.6.10", 65 | "mocha": "~5.0.4", 66 | "mocha-junit-reporter": "^1.18.0", 67 | "pdf-parse-fork": "^1.2.0", 68 | "semistandard": "^12.0.1" 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/model/Filter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DocuSign Monitor API - v2 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['ApiClient'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // CommonJS-like environments that support module.exports, like Node. 18 | module.exports = factory(require('../ApiClient')); 19 | } else { 20 | // Browser globals (root is window) 21 | if (!root.DocusignMonitor) { 22 | root.DocusignMonitor = {}; 23 | } 24 | root.DocusignMonitor.Filter = factory(root.DocusignMonitor.ApiClient); 25 | } 26 | }(this, function(ApiClient) { 27 | 'use strict'; 28 | 29 | 30 | /** 31 | * The Filter model module. 32 | * @module model/Filter 33 | */ 34 | 35 | /** 36 | * Constructs a new Filter. 37 | * @alias module:model/Filter 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a Filter from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:model/Filter} obj Optional instance to populate. 51 | * @return {module:model/Filter} The populated Filter instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | if (data) { 55 | obj = obj || new exports(); 56 | 57 | if (data.hasOwnProperty('filterName')) { 58 | obj['filterName'] = ApiClient.convertToType(data['filterName'], 'String'); 59 | } 60 | } 61 | return obj; 62 | } 63 | 64 | /** 65 | * @member {String} filterName 66 | */ 67 | exports.prototype['filterName'] = undefined; 68 | 69 | 70 | 71 | return exports; 72 | })); 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/model/Aggregation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DocuSign Monitor API - v2 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['ApiClient'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // CommonJS-like environments that support module.exports, like Node. 18 | module.exports = factory(require('../ApiClient')); 19 | } else { 20 | // Browser globals (root is window) 21 | if (!root.DocusignMonitor) { 22 | root.DocusignMonitor = {}; 23 | } 24 | root.DocusignMonitor.Aggregation = factory(root.DocusignMonitor.ApiClient); 25 | } 26 | }(this, function(ApiClient) { 27 | 'use strict'; 28 | 29 | 30 | /** 31 | * The Aggregation model module. 32 | * @module model/Aggregation 33 | */ 34 | 35 | /** 36 | * Constructs a new Aggregation. 37 | * @alias module:model/Aggregation 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a Aggregation from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:model/Aggregation} obj Optional instance to populate. 51 | * @return {module:model/Aggregation} The populated Aggregation instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | if (data) { 55 | obj = obj || new exports(); 56 | 57 | if (data.hasOwnProperty('aggregationName')) { 58 | obj['aggregationName'] = ApiClient.convertToType(data['aggregationName'], 'String'); 59 | } 60 | } 61 | return obj; 62 | } 63 | 64 | /** 65 | * @member {String} aggregationName 66 | */ 67 | exports.prototype['aggregationName'] = undefined; 68 | 69 | 70 | 71 | return exports; 72 | })); 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/model/AggregateResult.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Monitor API 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['ApiClient', 'model/AggregateResultResult'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // CommonJS-like environments that support module.exports, like Node. 18 | module.exports = factory(require('../ApiClient'), require('./AggregateResultResult')); 19 | } else { 20 | // Browser globals (root is window) 21 | if (!root.DocusignMonitor) { 22 | root.DocusignMonitor = {}; 23 | } 24 | root.DocusignMonitor.AggregateResult = factory(root.DocusignMonitor.ApiClient, root.DocusignMonitor.AggregateResultResult); 25 | } 26 | }(this, function(ApiClient, AggregateResultResult) { 27 | 'use strict'; 28 | 29 | 30 | /** 31 | * The AggregateResult model module. 32 | * @module model/AggregateResult 33 | */ 34 | 35 | /** 36 | * Constructs a new AggregateResult. 37 | * @alias module:model/AggregateResult 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a AggregateResult from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:model/AggregateResult} obj Optional instance to populate. 51 | * @return {module:model/AggregateResult} The populated AggregateResult instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | if (data) { 55 | obj = obj || new exports(); 56 | 57 | if (data.hasOwnProperty('result')) { 58 | obj['result'] = ApiClient.convertToType(data['result'], [AggregateResultResult]); 59 | } 60 | } 61 | return obj; 62 | } 63 | 64 | /** 65 | * @member {Array.} result 66 | */ 67 | exports.prototype['result'] = undefined; 68 | 69 | 70 | 71 | return exports; 72 | })); 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/oauth/Link.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | /** 4 | * DocuSign REST API 5 | * The DocuSign REST API provides you with a powerful, convenient, and simple Web services API for interacting with DocuSign. 6 | * 7 | * OpenAPI spec version: v2 8 | * Contact: devcenter@docusign.com 9 | * 10 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 11 | * 12 | */ 13 | 14 | (function(root, factory) { 15 | if (typeof define === 'function' && define.amd) { 16 | // AMD. Register as an anonymous module. 17 | define(['ApiClient', 'oauth/Account'], factory); 18 | } else if (typeof module === 'object' && module.exports) { 19 | // CommonJS-like environments that support module.exports, like Node. 20 | module.exports = factory(require('../ApiClient')); 21 | } else { 22 | // Browser globals (root is window) 23 | if (!root.Docusign) { 24 | root.Docusign = {}; 25 | } 26 | } 27 | }(this, function(ApiClient, Account) { 28 | 'use strict'; 29 | /** 30 | * The Link model module. 31 | * @module oauth/Link 32 | * @version 3.0.0 33 | */ 34 | 35 | /** 36 | * Constructs a new Link. 37 | * @alias module:oauth/Link 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a Link from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:oauth/Link} obj Optional instance to populate. 51 | * @return {module:oauth/Link} The populated Link instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | var ApiClient = require('../ApiClient'); 55 | 56 | if (data) { 57 | obj = obj || new exports(); 58 | 59 | if (data.hasOwnProperty('rel')) { 60 | obj['rel'] = ApiClient.convertToType(data['rel'], 'String'); 61 | } 62 | if (data.hasOwnProperty('href')) { 63 | obj['href'] = ApiClient.convertToType(data['href'], 'String'); 64 | } 65 | } 66 | 67 | return obj; 68 | } 69 | 70 | /** 71 | * 72 | * @member {String} rel 73 | */ 74 | exports.prototype['rel'] = undefined; 75 | /** 76 | * 77 | * @member {String} href 78 | */ 79 | exports.prototype['href'] = undefined; 80 | 81 | 82 | return exports; 83 | })); -------------------------------------------------------------------------------- /src/model/DataSet.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Monitor API 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['ApiClient'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // CommonJS-like environments that support module.exports, like Node. 18 | module.exports = factory(require('../ApiClient')); 19 | } else { 20 | // Browser globals (root is window) 21 | if (!root.DocusignMonitor) { 22 | root.DocusignMonitor = {}; 23 | } 24 | root.DocusignMonitor.DataSet = factory(root.DocusignMonitor.ApiClient); 25 | } 26 | }(this, function(ApiClient) { 27 | 'use strict'; 28 | 29 | 30 | /** 31 | * The DataSet model module. 32 | * @module model/DataSet 33 | */ 34 | 35 | /** 36 | * Constructs a new DataSet. 37 | * Methods to fetch organization event data. 38 | * @alias module:model/DataSet 39 | * @class 40 | */ 41 | var exports = function() { 42 | var _this = this; 43 | 44 | 45 | }; 46 | 47 | /** 48 | * Constructs a DataSet from a plain JavaScript object, optionally creating a new instance. 49 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 50 | * @param {Object} data The plain JavaScript object bearing properties of interest. 51 | * @param {module:model/DataSet} obj Optional instance to populate. 52 | * @return {module:model/DataSet} The populated DataSet instance. 53 | */ 54 | exports.constructFromObject = function(data, obj) { 55 | if (data) { 56 | obj = obj || new exports(); 57 | 58 | if (data.hasOwnProperty('endCursor')) { 59 | obj['endCursor'] = ApiClient.convertToType(data['endCursor'], 'String'); 60 | } 61 | if (data.hasOwnProperty('data')) { 62 | obj['data'] = ApiClient.convertToType(data['data'], [Object]); 63 | } 64 | } 65 | return obj; 66 | } 67 | 68 | /** 69 | * 70 | * @member {String} endCursor 71 | */ 72 | exports.prototype['endCursor'] = undefined; 73 | /** 74 | * 75 | * @member {Array.} data 76 | */ 77 | exports.prototype['data'] = undefined; 78 | 79 | 80 | 81 | return exports; 82 | })); 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/model/CursoredResult.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Monitor API 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['ApiClient'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // CommonJS-like environments that support module.exports, like Node. 18 | module.exports = factory(require('../ApiClient')); 19 | } else { 20 | // Browser globals (root is window) 21 | if (!root.DocusignMonitor) { 22 | root.DocusignMonitor = {}; 23 | } 24 | root.DocusignMonitor.CursoredResult = factory(root.DocusignMonitor.ApiClient); 25 | } 26 | }(this, function(ApiClient) { 27 | 'use strict'; 28 | 29 | 30 | /** 31 | * The CursoredResult model module. 32 | * @module model/CursoredResult 33 | */ 34 | 35 | /** 36 | * Constructs a new CursoredResult. 37 | * 38 | * @alias module:model/CursoredResult 39 | * @class 40 | */ 41 | var exports = function() { 42 | var _this = this; 43 | 44 | 45 | }; 46 | 47 | /** 48 | * Constructs a CursoredResult from a plain JavaScript object, optionally creating a new instance. 49 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 50 | * @param {Object} data The plain JavaScript object bearing properties of interest. 51 | * @param {module:model/CursoredResult} obj Optional instance to populate. 52 | * @return {module:model/CursoredResult} The populated CursoredResult instance. 53 | */ 54 | exports.constructFromObject = function(data, obj) { 55 | if (data) { 56 | obj = obj || new exports(); 57 | 58 | if (data.hasOwnProperty('endCursor')) { 59 | obj['endCursor'] = ApiClient.convertToType(data['endCursor'], 'String'); 60 | } 61 | if (data.hasOwnProperty('data')) { 62 | obj['data'] = ApiClient.convertToType(data['data'], [Object]); 63 | } 64 | } 65 | return obj; 66 | } 67 | 68 | /** 69 | * 70 | * @member {String} endCursor 71 | */ 72 | exports.prototype['endCursor'] = undefined; 73 | /** 74 | * 75 | * @member {Array.} data 76 | */ 77 | exports.prototype['data'] = undefined; 78 | 79 | 80 | 81 | return exports; 82 | })); 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/model/AggregateResultResult.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Monitor API 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['ApiClient'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // CommonJS-like environments that support module.exports, like Node. 18 | module.exports = factory(require('../ApiClient')); 19 | } else { 20 | // Browser globals (root is window) 21 | if (!root.DocusignMonitor) { 22 | root.DocusignMonitor = {}; 23 | } 24 | root.DocusignMonitor.AggregateResultResult = factory(root.DocusignMonitor.ApiClient); 25 | } 26 | }(this, function(ApiClient) { 27 | 'use strict'; 28 | 29 | 30 | /** 31 | * The AggregateResultResult model module. 32 | * @module model/AggregateResultResult 33 | */ 34 | 35 | /** 36 | * Constructs a new AggregateResultResult. 37 | * @alias module:model/AggregateResultResult 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a AggregateResultResult from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:model/AggregateResultResult} obj Optional instance to populate. 51 | * @return {module:model/AggregateResultResult} The populated AggregateResultResult instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | if (data) { 55 | obj = obj || new exports(); 56 | 57 | if (data.hasOwnProperty('name')) { 58 | obj['name'] = ApiClient.convertToType(data['name'], 'String'); 59 | } 60 | if (data.hasOwnProperty('data')) { 61 | obj['data'] = ApiClient.convertToType(data['data'], [Object]); 62 | } 63 | } 64 | return obj; 65 | } 66 | 67 | /** 68 | * @member {String} name 69 | */ 70 | exports.prototype['name'] = undefined; 71 | /** 72 | * @member {Array.} data 73 | */ 74 | exports.prototype['data'] = undefined; 75 | 76 | 77 | 78 | return exports; 79 | })); 80 | 81 | 82 | -------------------------------------------------------------------------------- /src/oauth/Account.js: -------------------------------------------------------------------------------- 1 | (function(root, factory) { 2 | if (typeof define === 'function' && define.amd) { 3 | // AMD. Register as an anonymous module. 4 | define(['ApiClient'], factory); 5 | } else if (typeof module === 'object' && module.exports) { 6 | // CommonJS-like environments that support module.exports, like Node. 7 | module.exports = factory(require('../ApiClient'), require('./Organization')); 8 | } else { 9 | // Browser globals (root is window) 10 | if (!root.Docusign) { 11 | root.Docusign = {}; 12 | } 13 | //root.Docusign.UserInfo = factory(root.Docusign.ApiClient, root.Docusign.ErrorDetails); 14 | } 15 | }(this, function() { 16 | 'use strict'; 17 | 18 | 19 | /** 20 | * The Account model module. 21 | * @module oauth/Account 22 | * @version 3.0.0 23 | */ 24 | 25 | /** 26 | * Constructs a new Account. 27 | * @alias module:model/UserInfo 28 | * @class 29 | */ 30 | var exports = function() { 31 | var _this = this; 32 | 33 | 34 | }; 35 | 36 | exports.constructFromObject = function (data, obj){ 37 | var ApiClient = require('../ApiClient'); 38 | var Organization = require('./Organization'); 39 | 40 | if (data) { 41 | obj = obj || new exports(); 42 | if (data.hasOwnProperty('account_id')) { 43 | obj['accountId'] = ApiClient.convertToType(data['account_id'], 'String'); 44 | } 45 | if (data.hasOwnProperty('is_default')) { 46 | obj['isDefault'] = ApiClient.convertToType(data['is_default'], 'String'); 47 | } 48 | if (data.hasOwnProperty('account_name')) { 49 | obj['accountName'] = ApiClient.convertToType(data['account_name'], 'String'); 50 | } 51 | if (data.hasOwnProperty('base_uri')) { 52 | obj['baseUri'] = ApiClient.convertToType(data['base_uri'], 'String'); 53 | } 54 | if(data.hasOwnProperty('organization')) { 55 | obj['organization'] = ApiClient.convertToType(data['organization'], Organization) 56 | } 57 | } 58 | return obj; 59 | } 60 | 61 | /** 62 | * 63 | * @member {String} accountId 64 | */ 65 | exports.prototype['accountId'] = undefined; 66 | /** 67 | * 68 | * @member {String} isDefault 69 | */ 70 | exports.prototype['isDefault'] = undefined; 71 | /** 72 | * @member {String} accountName 73 | */ 74 | exports.prototype['accountName'] = undefined; 75 | /** 76 | * @member {String} baseUri 77 | */ 78 | exports.prototype['baseUri'] = undefined; 79 | /** 80 | * @member {Organization} organization 81 | */ 82 | exports.prototype['organization'] = undefined; 83 | 84 | 85 | return exports; 86 | })); 87 | -------------------------------------------------------------------------------- /src/oauth/Organization.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | /** 4 | * DocuSign REST API 5 | * The DocuSign REST API provides you with a powerful, convenient, and simple Web services API for interacting with DocuSign. 6 | * 7 | * OpenAPI spec version: v2 8 | * Contact: devcenter@docusign.com 9 | * 10 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 11 | * 12 | */ 13 | 14 | (function(root, factory) { 15 | if (typeof define === 'function' && define.amd) { 16 | // AMD. Register as an anonymous module. 17 | define(['ApiClient', 'oauth/Account'], factory); 18 | } else if (typeof module === 'object' && module.exports) { 19 | // CommonJS-like environments that support module.exports, like Node. 20 | module.exports = factory(require('../ApiClient')); 21 | } else { 22 | // Browser globals (root is window) 23 | if (!root.Docusign) { 24 | root.Docusign = {}; 25 | } 26 | } 27 | }(this, function(ApiClient, Account) { 28 | 'use strict'; 29 | /** 30 | * The Organization model module. 31 | * @module oauth/Organization 32 | * @version 3.0.0 33 | */ 34 | 35 | /** 36 | * Constructs a new Organization. 37 | * @alias module:oauth/Organization 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a Organization from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:oauth/Organization} obj Optional instance to populate. 51 | * @return {module:oauth/Organization} The populated Organization instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | var ApiClient = require('../ApiClient'); 55 | var Link = require('./Link'); 56 | 57 | if (data) { 58 | obj = obj || new exports(); 59 | 60 | if (data.hasOwnProperty('organization_id')) { 61 | obj['organization_id'] = ApiClient.convertToType(data['organization_id'], 'String'); 62 | } 63 | if (data.hasOwnProperty('links')) { 64 | obj['links'] = ApiClient.convertToType(data['links'], [Link]); 65 | } 66 | } 67 | 68 | return obj; 69 | } 70 | 71 | /** 72 | * 73 | * @member {String} sub 74 | */ 75 | exports.prototype['organization_id'] = undefined; 76 | /** 77 | * 78 | * @member {String} email 79 | */ 80 | exports.prototype['links'] = undefined; 81 | 82 | 83 | return exports; 84 | })); -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Monitor API 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | (function(factory) { 12 | if (typeof define === 'function' && define.amd) { 13 | // AMD. Register as an anonymous module. 14 | define(['Configuration', 'ApiClient', 'model/CursoredResult', 'model/DataSet', 'api/DataSetApi'], factory); 15 | } else if (typeof module === 'object' && module.exports) { 16 | // CommonJS-like environments that support module.exports, like Node. 17 | module.exports = factory(require('./Configuration'), require('./ApiClient'), require('./model/CursoredResult'), require('./model/DataSet'), require('./api/DataSetApi')); 18 | } 19 | }(function(Configuration, ApiClient, CursoredResult, DataSet, DataSetApi) { 20 | 'use strict'; 21 | 22 | /** 23 | * Docusign Node.js API client..
24 | * The index module provides access to constructors for all the classes which comprise the public API. 25 | *

26 | * An AMD (recommended!) or CommonJS application will generally do something equivalent to the following: 27 | *

28 |    * var DocusignMonitor = require('index'); // See note below*.
29 |    * var xxxSvc = new DocusignMonitor.XxxApi(); // Allocate the API class we're going to use.
30 |    * var yyyModel = new DocusignMonitor.Yyy(); // Construct a model instance.
31 |    * yyyModel.someProperty = 'someValue';
32 |    * ...
33 |    * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
34 |    * ...
35 |    * 
36 | * *NOTE: For a top-level AMD script, use require(['index'], function(){...}) 37 | * and put the application logic within the callback function. 38 | *

39 | *

40 | * A non-AMD browser application (discouraged) might do something like this: 41 | *

42 |    * var xxxSvc = new DocusignMonitor.XxxApi(); // Allocate the API class we're going to use.
43 |    * var yyy = new DocusignMonitor.Yyy(); // Construct a model instance.
44 |    * yyyModel.someProperty = 'someValue';
45 |    * ...
46 |    * var zzz = xxxSvc.doSomething(yyyModel); // Invoke the service.
47 |    * ...
48 |    * 
49 | *

50 | * @module index 51 | */ 52 | var exports = { 53 | /** 54 | * The configuration constructor. 55 | * @property {module:Configuration} 56 | */ 57 | Configuration: Configuration, 58 | /** 59 | * The ApiClient constructor. 60 | * @property {module:ApiClient} 61 | */ 62 | ApiClient: ApiClient, 63 | /** 64 | * The CursoredResult model constructor. 65 | * @property {module:model/CursoredResult} 66 | */ 67 | CursoredResult: CursoredResult, 68 | /** 69 | * The DataSet model constructor. 70 | * @property {module:model/DataSet} 71 | */ 72 | DataSet: DataSet, 73 | /** 74 | * The DataSetApi service constructor. 75 | * @property {module:api/DataSetApi} 76 | */ 77 | DataSetApi: DataSetApi 78 | }; 79 | 80 | return exports; 81 | })); -------------------------------------------------------------------------------- /src/model/RawRequest.js: -------------------------------------------------------------------------------- 1 | /** 2 | * DocuSign Monitor API - v2 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['ApiClient'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // CommonJS-like environments that support module.exports, like Node. 18 | module.exports = factory(require('../ApiClient')); 19 | } else { 20 | // Browser globals (root is window) 21 | if (!root.DocusignMonitor) { 22 | root.DocusignMonitor = {}; 23 | } 24 | root.DocusignMonitor.RawRequest = factory(root.DocusignMonitor.ApiClient); 25 | } 26 | }(this, function(ApiClient) { 27 | 'use strict'; 28 | 29 | 30 | /** 31 | * The RawRequest model module. 32 | * @module model/RawRequest 33 | */ 34 | 35 | /** 36 | * Constructs a new RawRequest. 37 | * @alias module:model/RawRequest 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a RawRequest from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:model/RawRequest} obj Optional instance to populate. 51 | * @return {module:model/RawRequest} The populated RawRequest instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | if (data) { 55 | obj = obj || new exports(); 56 | 57 | if (data.hasOwnProperty('queryScope')) { 58 | obj['queryScope'] = ApiClient.convertToType(data['queryScope'], 'String'); 59 | } 60 | if (data.hasOwnProperty('queryScopeId')) { 61 | obj['queryScopeId'] = ApiClient.convertToType(data['queryScopeId'], 'String'); 62 | } 63 | if (data.hasOwnProperty('query')) { 64 | obj['query'] = ApiClient.convertToType(data['query'], 'String'); 65 | } 66 | } 67 | return obj; 68 | } 69 | 70 | /** 71 | * @member {module:model/RawRequest.QueryScopeEnum} queryScope 72 | */ 73 | exports.prototype['queryScope'] = undefined; 74 | /** 75 | * @member {String} queryScopeId 76 | */ 77 | exports.prototype['queryScopeId'] = undefined; 78 | /** 79 | * @member {String} query 80 | */ 81 | exports.prototype['query'] = undefined; 82 | 83 | 84 | /** 85 | * Allowed values for the queryScope property. 86 | * @enum {String} 87 | * @readonly 88 | */ 89 | exports.QueryScopeEnum = { 90 | /** 91 | * value: "AccountId" 92 | * @const 93 | */ 94 | accountId: "AccountId", 95 | 96 | /** 97 | * value: "OrganizationId" 98 | * @const 99 | */ 100 | organizationId: "OrganizationId", 101 | 102 | /** 103 | * value: "None" 104 | * @const 105 | */ 106 | none: "None" 107 | }; 108 | 109 | 110 | return exports; 111 | })); 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/model/WebQuery.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Monitor API 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['ApiClient'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // CommonJS-like environments that support module.exports, like Node. 18 | module.exports = factory(require('../ApiClient')); 19 | } else { 20 | // Browser globals (root is window) 21 | if (!root.DocusignMonitor) { 22 | root.DocusignMonitor = {}; 23 | } 24 | root.DocusignMonitor.WebQuery = factory(root.DocusignMonitor.ApiClient); 25 | } 26 | }(this, function(ApiClient) { 27 | 'use strict'; 28 | 29 | 30 | /** 31 | * The WebQuery model module. 32 | * @module model/WebQuery 33 | */ 34 | 35 | /** 36 | * Constructs a new WebQuery. 37 | * @alias module:model/WebQuery 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a WebQuery from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:model/WebQuery} obj Optional instance to populate. 51 | * @return {module:model/WebQuery} The populated WebQuery instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | if (data) { 55 | obj = obj || new exports(); 56 | 57 | if (data.hasOwnProperty('filters')) { 58 | obj['filters'] = ApiClient.convertToType(data['filters'], [Object]); 59 | } 60 | if (data.hasOwnProperty('aggregations')) { 61 | obj['aggregations'] = ApiClient.convertToType(data['aggregations'], [Object]); 62 | } 63 | if (data.hasOwnProperty('queryScope')) { 64 | obj['queryScope'] = ApiClient.convertToType(data['queryScope'], 'String'); 65 | } 66 | if (data.hasOwnProperty('queryScopeId')) { 67 | obj['queryScopeId'] = ApiClient.convertToType(data['queryScopeId'], 'String'); 68 | } 69 | } 70 | return obj; 71 | } 72 | 73 | /** 74 | * @member {Array.} filters 75 | */ 76 | exports.prototype['filters'] = undefined; 77 | /** 78 | * @member {Array.} aggregations 79 | */ 80 | exports.prototype['aggregations'] = undefined; 81 | /** 82 | * @member {module:model/WebQuery.QueryScopeEnum} queryScope 83 | */ 84 | exports.prototype['queryScope'] = undefined; 85 | /** 86 | * @member {String} queryScopeId 87 | */ 88 | exports.prototype['queryScopeId'] = undefined; 89 | 90 | 91 | /** 92 | * Allowed values for the queryScope property. 93 | * @enum {String} 94 | * @readonly 95 | */ 96 | exports.QueryScopeEnum = { 97 | /** 98 | * value: "OrganizationId" 99 | * @const 100 | */ 101 | organizationId: "OrganizationId" 102 | }; 103 | 104 | 105 | return exports; 106 | })); 107 | 108 | 109 | -------------------------------------------------------------------------------- /src/oauth/OAuthToken.js: -------------------------------------------------------------------------------- 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. 4 | * 5 | * OpenAPI spec version: v2 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['ApiClient'], factory); 16 | 17 | } else if (typeof module === 'object' && module.exports) { 18 | // CommonJS-like environments that support module.exports, like Node. 19 | module.exports = factory(require('../ApiClient')); 20 | 21 | } else { 22 | // Browser globals (root is window) 23 | if (!root.Docusign) { 24 | root.Docusign = {}; 25 | } 26 | root.Docusign.ApiClient = factory(root.Docusign.ApiClient); 27 | } 28 | }(this, function() { 29 | 'use strict'; 30 | /** 31 | * The OauthAccess model module. 32 | * @module model/OauthAccess 33 | * @version 3.0.0 34 | */ 35 | /** 36 | * Constructs a new OauthAccess. 37 | * @alias module:model/OauthAccess 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a OauthAccess from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:model/OauthAccess} obj Optional instance to populate. 51 | * @return {module:model/OauthAccess} The populated OauthAccess instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | var ApiClient = require('../ApiClient'); 55 | if (data) { 56 | obj = obj || new exports(); 57 | 58 | if (data.hasOwnProperty('access_token')) { 59 | obj['accessToken'] = ApiClient.convertToType(data['access_token'], 'String'); 60 | } 61 | if (data.hasOwnProperty('data')) { 62 | obj['data'] = ApiClient.convertToType(data['data'], [NameValue]); 63 | } 64 | if (data.hasOwnProperty('expires_in')) { 65 | obj['expiresIn'] = ApiClient.convertToType(data['expires_in'], 'String'); 66 | } 67 | if (data.hasOwnProperty('refresh_token')) { 68 | obj['refreshToken'] = ApiClient.convertToType(data['refresh_token'], 'String'); 69 | } 70 | if (data.hasOwnProperty('scope')) { 71 | obj['scope'] = ApiClient.convertToType(data['scope'], 'String'); 72 | } 73 | if (data.hasOwnProperty('token_type')) { 74 | obj['tokenType'] = ApiClient.convertToType(data['token_type'], 'String'); 75 | } 76 | } 77 | return obj; 78 | } 79 | 80 | /** 81 | * Access token information. 82 | * @member {String} access_token 83 | */ 84 | exports.prototype['accessToken'] = undefined; 85 | /** 86 | * 87 | * @member {Array.} data 88 | */ 89 | exports.prototype['data'] = undefined; 90 | /** 91 | * 92 | * @member {String} expires_in 93 | */ 94 | exports.prototype['expiresIn'] = undefined; 95 | /** 96 | * 97 | * @member {String} refresh_token 98 | */ 99 | exports.prototype['refreshToken'] = undefined; 100 | /** 101 | * Must be set to \"api\". 102 | * @member {String} scope 103 | */ 104 | exports.prototype['scope'] = undefined; 105 | /** 106 | * 107 | * @member {String} token_type 108 | */ 109 | exports.prototype['tokenType'] = undefined; 110 | 111 | return exports; 112 | })); 113 | 114 | 115 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # DocuSign Node Client Changelog 2 | 3 | 4 | See [DocuSign Support Center](https://support.docusign.com/en/releasenotes/) for Product Release Notes. 5 | 6 | ## [v3.0.0] - Monitor API v2.0-2.0.0 - 2024-11-20 7 | ### Breaking Changes 8 | 9 |
10 | 11 | Click here for change details 12 | **Security Updates** 13 | - Updated HTTP Client: Due to identified security vulnerabilities in Superagent proxy version 3.0.0, we have transitioned from using Superagent to the more secure Axios HTTP client. This update helps in safeguarding your interactions by patching potential security gaps. 14 | 15 | **New Features** 16 | - Proxy Support for HTTP Requests: We've introduced the ability to make HTTP requests through a proxy. This enhancement is particularly useful for users operating within corporate or restricted networks. 17 | - JWT Token Request Functionality: The new sendJWTTokenRequest method allows you to obtain authentication tokens without exposing your privateKey. This method is designed to enhance security in your authentication processes. 18 | 19 | **Changes to Existing Features** 20 | - Updated Callback Response Structure: We have made changes to the response structure for callbacks. If you are using callback functions in your integration, please note the updated response object attributes: 21 | > statusCode 22 | header 23 | body 24 | 25 | **Migration Guide** 26 | - For those using callback functions, please adjust your implementation to handle the new response structure as detailed above. 27 | 28 |
29 | 30 | ## [v2.1.0-rc1] - Monitor API v2.0-2.0.0 - 2024-04-23 31 | ### Changed 32 | **Security Updates** 33 | - Updated HTTP Client: Due to identified security vulnerabilities in Superagent proxy version 3.0.0, we have transitioned from using Superagent to the more secure Axios HTTP client. This update helps in safeguarding your interactions by patching potential security gaps. 34 | 35 | **New Features** 36 | - Proxy Support for HTTP Requests: We've introduced the ability to make HTTP requests through a proxy. This enhancement is particularly useful for users operating within corporate or restricted networks. 37 | - JWT Token Request Functionality: The new sendJWTTokenRequest method allows you to obtain authentication tokens without exposing your privateKey. This method is designed to enhance security in your authentication processes. 38 | 39 | **Changes to Existing Features** 40 | - Updated Callback Response Structure: We have made changes to the response structure for callbacks. If you are using callback functions in your integration, please note the updated response object attributes: 41 | > statusCode 42 | header 43 | body 44 | 45 | **Migration Guide** 46 | - For those using callback functions, please adjust your implementation to handle the new response structure as detailed above. 47 | 48 | ## [v2.1.0] - Monitor API v2.0-2.0.0 - 2023-06-14 49 | ### Changed 50 | - Added support for version v2.0-2.0.0 of the DocuSign Monitor API. 51 | - Updated the SDK release version. 52 | 53 | ## [v2.0.0] - Monitor API v2.0-1.1.0 - 2023-01-23 54 | ### Breaking 55 | - Deprecating Node versions <12 56 | ### Security 57 | - Update jsonwebtoken package to 9.0.0 addressing CVE-2022-23529 58 | 59 | ### Changed 60 | - Added support for version v2.0-1.1.0 of the DocuSign Monitor API. 61 | - Updated the SDK release version. 62 | 63 | ## [v1.1.0] - Monitor API v2.0-1.1.0 - 2022-04-11 64 | ### Changed 65 | - Added support for version v2.0-1.1.0 of the DocuSign Monitor API. 66 | - Updated the SDK release version. 67 | 68 | ## [v1.0.1] - Monitor API v2.0-1.0.1 - 2022-01-10 69 | ### Changed 70 | - Added support for version v2.0-1.0.1 of the DocuSign Monitor API. 71 | - Updated the SDK release version. 72 | 73 | ## [v1.0.0] - Monitor API v2.0-1.0.0 - 2021-06-24 74 | ### Changed 75 | - Updated the SDK release version. 76 | 77 | ## [v1.0.0-beta] - Monitor API v2-1.0.7 78 | ### Added 79 | - Added first beta version of the DocuSign Monitor API. 80 | -------------------------------------------------------------------------------- /src/oauth/UserInfo.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | /** 4 | * DocuSign REST API 5 | * The DocuSign REST API provides you with a powerful, convenient, and simple Web services API for interacting with DocuSign. 6 | * 7 | * OpenAPI spec version: v2 8 | * Contact: devcenter@docusign.com 9 | * 10 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 11 | * 12 | */ 13 | 14 | (function(root, factory) { 15 | if (typeof define === 'function' && define.amd) { 16 | // AMD. Register as an anonymous module. 17 | define(['ApiClient', 'oauth/Account'], factory); 18 | } else if (typeof module === 'object' && module.exports) { 19 | // CommonJS-like environments that support module.exports, like Node. 20 | module.exports = factory(require('../ApiClient'), require('./Account')); 21 | } else { 22 | // Browser globals (root is window) 23 | if (!root.Docusign) { 24 | root.Docusign = {}; 25 | } 26 | } 27 | }(this, function(ApiClient, Account) { 28 | 'use strict'; 29 | /** 30 | * The UserInfo model module. 31 | * @module model/UserInfo 32 | * @version 3.0.0 33 | */ 34 | 35 | /** 36 | * Constructs a new UserInfo. 37 | * @alias module:model/UserInfo 38 | * @class 39 | */ 40 | var exports = function() { 41 | var _this = this; 42 | 43 | 44 | }; 45 | 46 | /** 47 | * Constructs a UserInfo from a plain JavaScript object, optionally creating a new instance. 48 | * Copies all relevant properties from data to obj if supplied or a new instance if not. 49 | * @param {Object} data The plain JavaScript object bearing properties of interest. 50 | * @param {module:model/UserInfo} obj Optional instance to populate. 51 | * @return {module:model/UserInfo} The populated UserInfo instance. 52 | */ 53 | exports.constructFromObject = function(data, obj) { 54 | var ApiClient = require('../ApiClient'); 55 | 56 | if (data) { 57 | obj = obj || new exports(); 58 | 59 | if (data.hasOwnProperty('sub')) { 60 | obj['sub'] = ApiClient.convertToType(data['sub'], 'String'); 61 | } 62 | if (data.hasOwnProperty('email')) { 63 | obj['email'] = ApiClient.convertToType(data['email'], 'String'); 64 | } 65 | if (data.hasOwnProperty('accounts')) { 66 | obj['accounts'] = ApiClient.convertToType(data['accounts'], [Account]); 67 | } 68 | if (data.hasOwnProperty('name')) { 69 | obj['name'] = ApiClient.convertToType(data['name'], 'String'); 70 | } 71 | if (data.hasOwnProperty('given_name')) { 72 | obj['givenName'] = ApiClient.convertToType(data['given_name'], 'String'); 73 | } 74 | if (data.hasOwnProperty('family_name')) { 75 | obj['familyName'] = ApiClient.convertToType(data['family_name'], 'String'); 76 | } 77 | if (data.hasOwnProperty('created')) { 78 | obj['created'] = ApiClient.convertToType(data['created'], 'String'); 79 | } 80 | } 81 | 82 | return obj; 83 | } 84 | 85 | /** 86 | * 87 | * @member {String} sub 88 | */ 89 | exports.prototype['sub'] = undefined; 90 | /** 91 | * 92 | * @member {String} email 93 | */ 94 | exports.prototype['email'] = undefined; 95 | /** 96 | * @member {module:oauth/Account} accounts 97 | */ 98 | exports.prototype['accounts'] = undefined; 99 | /** 100 | * 101 | * @member {String} name 102 | */ 103 | exports.prototype['name'] = undefined; 104 | /** 105 | * 106 | * @member {String} givenName 107 | */ 108 | exports.prototype['givenName'] = undefined; 109 | /** 110 | * 111 | * @member {String} familyName 112 | */ 113 | exports.prototype['familyName'] = undefined; 114 | /** 115 | * 116 | * @member {String} created 117 | */ 118 | exports.prototype['created'] = undefined; 119 | 120 | return exports; 121 | })); 122 | 123 | 124 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Official DocuSign Monitor Node Client 2 | 3 | [![NPM version][npm-image]][npm-url] 4 | [![NPM downloads][downloads-image]][downloads-url] 5 | [![Build status][travis-image]][travis-url] 6 | [![Coverage Status][coveralls-image]][coveralls-url] 7 | 8 | [NPM module](https://www.npmjs.com/package/docusign-monitor) that wraps the DocuSign Monitor API 9 | 10 | [Documentation about the DocuSign Monitor API](https://developers.docusign.com/docs/monitor-api) 11 | 12 | 16 | 17 | 18 | ## Requirements 19 | - Node 12 20 | - Free [Developer Account](https://go.docusign.com/sandbox/productshot/?elqCampaignId=16531) 21 | - DocuSign Monitor account connected to your Developer account. [Here is how to create a Monitor developer account](https://developers.docusign.com/docs/monitor-api/monitor101/create-account) 22 | 23 | ## Compatibility 24 | 25 | - Node 12+ 26 | 27 | ## Note: 28 | 29 | This SDK will soon be provided as open-source for cases where you would like to make additional changes that the SDK does not provide out-of-the-box. If you simply want to use the SDK with any of the examples shown in the [Developer Center](https://developers.docusign.com/docs/monitor-api/how-to/), follow the installation instructions below. 30 | 31 | ## Installation 32 | 33 | ## NPM: 34 | 35 | 1. Open your preferred command-line console, then navigate to your project. 36 | 2. In the console, type the following commands: 37 | **npm install docusign-monitor -save** 38 | 39 | 40 | ## Dependencies 41 | 42 | This client has the following external dependencies: 43 | 44 | ### Minimum: 45 | 46 | - Axios 1.6.8 47 | 48 | ### Optional: 49 | 50 | - Async v2.6.2 51 | - Jsonwebtoken v9.0.0 52 | - Passport-oauth2 53 | - Path 54 | 55 | ## Code Examples 56 | 57 | ### Launchers 58 | 59 | DocuSign provides a sample application referred to as a [Launcher](https://github.com/docusign/code-examples-node/). The Launcher contains a set of 6 common use cases and associated source files. These examples use DocuSign's [Authorization Code Grant](https://developers.docusign.com/platform/auth/authcode/authcode-get-token/) flow. 60 | 61 | ## OAuth Implementations 62 | 63 | For details regarding which type of OAuth grant will work best for your DocuSign integration, see the [Monitor API Authentication Overview](https://developers.docusign.com/docs/monitor-api/monitor101/auth/) guide located on the [DocuSign Developer Center](https://developers.docusign.com/). 64 | 65 | For security purposes, DocuSign recommends using the [Authorization Code Grant](https://developers.docusign.com/platform/auth/authcode/authcode-get-token/) or [JWT](https://developers.docusign.com/platform/auth/jwt/) flow. 66 | 67 | There are other use-case scenarios, such as **single-page applications** (SPA) that use **Cross-Origin Resource Sharing** (CORS), or where there may not be a user to interact with your Service Account. For these use cases, DocuSign also supports [JWT](https://developers.docusign.com/platform/auth/jwt/jwt-get-token/) and [Implicit](https://developers.docusign.com/platform/auth/implicit/implicit-get-token/) grants. For Code eExamples, see the links below: 68 | 69 | 70 | ## Support 71 | 72 | Log issues against this client through GitHub. We also have an [active developer community on Stack Overflow](http://stackoverflow.com/questions/tagged/docusignapi). 73 | 74 | ## License 75 | 76 | The DocuSign Monitor Node Client is licensed under the [MIT License](https://github.com/docusign/docusign-monitor-node-client/blob/master/LICENSE). 77 | 78 | [npm-image]: https://img.shields.io/npm/v/docusign-monitor.svg?style=flat 79 | [npm-url]: https://npmjs.org/package/docusign-monitor 80 | [downloads-image]: https://img.shields.io/npm/dm/docusign-monitor.svg?style=flat 81 | [downloads-url]: https://npmjs.org/package/docusign-monitor 82 | [travis-image]: https://img.shields.io/travis/docusign/docusign-monitor-node-client.svg?style=flat 83 | [travis-url]: https://travis-ci.org/docusign/docusign-node-client 84 | [coveralls-image]: https://coveralls.io/repos/github/docusign/DocuSign-Node-Client/badge.svg?branch=master 85 | [coveralls-url]: https://coveralls.io/github/docusign/DocuSign-Node-Client?branch=master 86 | -------------------------------------------------------------------------------- /src/api/DataSetApi.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Monitor API 3 | * An API for an integrator to access the features of DocuSign Monitor 4 | * 5 | * OpenAPI spec version: v2.0 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function(root, factory) { 13 | if (typeof define === 'function' && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(['Configuration', 'ApiClient', 'model/CursoredResult'], factory); 16 | } else if (typeof module === 'object' && module.exports) { 17 | // CommonJS-like environments that support module.exports, like Node. 18 | module.exports = factory(require('../Configuration'), require('../ApiClient'), require('../model/CursoredResult')); 19 | } else { 20 | // Browser globals (root is window) 21 | if (!root.DocusignMonitor) { 22 | root.DocusignMonitor = {}; 23 | } 24 | root.DocusignMonitor.DataSetApi = factory(root.DocusignMonitor.Configuration, root.DocusignMonitor.ApiClient, root.DocusignMonitor.CursoredResult); 25 | } 26 | }(this, function(Configuration, ApiClient, CursoredResult) { 27 | 'use strict'; 28 | 29 | /** 30 | * DataSet service. 31 | * @module api/DataSetApi 32 | */ 33 | 34 | /** 35 | * Constructs a new DataSetApi. 36 | * @alias module:api/DataSetApi 37 | * @class 38 | * @param {module:ApiClient} apiClient Optional API client implementation to use, 39 | * default to {@link module:ApiClient#instance} if unspecified. 40 | */ 41 | var exports = function(apiClient) { 42 | this.apiClient = apiClient || Configuration.default.getDefaultApiClient() || ApiClient.instance; 43 | 44 | 45 | this.setApiClient = function(apiClient) { 46 | this.apiClient = apiClient; 47 | }; 48 | 49 | this.getApiClient = function() { 50 | return this.apiClient; 51 | }; 52 | 53 | 54 | /** 55 | * (Optional) Callback function to receive the result of the getStream operation. If none specified a Promise will be returned. 56 | * @callback module:api/DataSetApi~getStreamCallback 57 | * @param {String} error Error message, if any. 58 | * @param {module:model/CursoredResult} data The data returned by the service call. 59 | * @param {String} If a callback was specified, the response The complete HTTP response, else a Promise resolving the response Data. 60 | */ 61 | 62 | /** 63 | * Gets customer event data for an organization. 64 | * Gets customer event data for the organization that owns the integration key. 65 | 66 | The results for this endpoint are paginated by event timestamp. Use the `cursor` parameter to specify where the query begins in the dataset. Use the `limit` parameter to set the number of records returned. 67 | 68 | * @param {String} version Must be `2`. 69 | 70 | * @param {String} dataSetName Must be `monitor`. 71 | * @param {Object} optsOrCallback Optional parameters, if you are passing no optional parameters, you can either pass a null or omit this parameter entirely. 72 | * @param {String} optsOrCallback.cursor Specifies a pointer into the dataset where your query will begin. You can either provide an ISO DateTime or a string cursor (from the `endCursor` value in the response). If no value is provided, the query begins from seven days ago. For example, to fetch event data beginning from January 1, 2022, set this value to `2022-01-01T00:00:00Z`. The response will include data about events starting from that date in chronological order. The response also includes an `endCursor` property. To fetch the next page of event data, call this endpoint again with `cursor` set to the previous `endCursor` value. 73 | * @param {Number} optsOrCallback.limit The maximum number of records to return. The default value is 1000. (default to 1000) 74 | * @param {module:api/DataSetApi~getStreamCallback} callback The callback function, accepting three arguments: error, data, response 75 | * data is of type: {@link module:model/CursoredResult} 76 | */ 77 | this.getStream = function(version, dataSetName, optsOrCallback, callback) { 78 | optsOrCallback = optsOrCallback || {}; 79 | 80 | if (typeof optsOrCallback === 'function') { 81 | callback = optsOrCallback; 82 | optsOrCallback = {}; 83 | } 84 | 85 | var postBody = null; 86 | 87 | // verify the required parameter 'version' is set 88 | if (version === undefined || version === null) { 89 | throw new Error("Missing the required parameter 'version' when calling getStream"); 90 | } 91 | 92 | // verify the required parameter 'dataSetName' is set 93 | if (dataSetName === undefined || dataSetName === null) { 94 | throw new Error("Missing the required parameter 'dataSetName' when calling getStream"); 95 | } 96 | 97 | if (typeof callback !== 'function' && arguments.length && typeof arguments[arguments.length-1] === 'function'){ 98 | if (typeof optsOrCallback !== 'undefined') { 99 | optsOrCallback = callback; 100 | } 101 | callback = arguments[arguments.length-1]; 102 | } 103 | 104 | var pathParams = { 105 | 'version': version, 106 | 'dataSetName': dataSetName 107 | }; 108 | var queryParams = { 109 | 'cursor': optsOrCallback['cursor'], 110 | 'limit': optsOrCallback['limit'] 111 | }; 112 | var headerParams = { 113 | }; 114 | var formParams = { 115 | }; 116 | 117 | var authNames = ['docusignAccessCode']; 118 | var contentTypes = ['application/json']; 119 | var accepts = ['application/json']; 120 | var returnType = CursoredResult; 121 | 122 | return this.apiClient.callApi( 123 | '/api/v{version}/datasets/{dataSetName}/stream', 'GET', 124 | pathParams, queryParams, headerParams, formParams, postBody, 125 | authNames, contentTypes, accepts, returnType, callback 126 | ); 127 | }; 128 | }; 129 | 130 | return exports; 131 | })); -------------------------------------------------------------------------------- /test/SdkUnitTests.js: -------------------------------------------------------------------------------- 1 | const docusign = require("../src/index"); 2 | const oAuth = docusign.ApiClient.OAuth; 3 | const restApi = docusign.ApiClient.RestApi; 4 | let config; 5 | try { 6 | config = require("../test-config"); 7 | } catch (err) { 8 | console.error(err); 9 | } 10 | const assert = require("assert"); 11 | const path = require("path"); 12 | const axios = require("axios"); 13 | const Buffer = global.Buffer.from 14 | ? global.Buffer 15 | : require("safe-buffer").Buffer; 16 | const fs = require("fs"); 17 | 18 | const { privateKey, integratorKey, integratorKeyAuthCode } = config || {}; 19 | 20 | const basePath = restApi.BasePath.DEMO; 21 | const oAuthBasePath = oAuth.BasePath.DEMO; 22 | 23 | const userId = config.userId; 24 | const RedirectURI = "https://www.docusign.com/api"; 25 | const privateKeyFilename = "keys/docusign_private_key.txt"; 26 | const expiresIn = 3600; 27 | 28 | if (privateKey) { 29 | let buf; 30 | if (typeof Buffer.from === "function") { 31 | // Node 5.10+ 32 | buf = Buffer.from(privateKey, "base64"); // Ta-da 33 | } else { 34 | // older Node versions, now deprecated 35 | buf = new Buffer(privateKey, "base64"); // Ta-da 36 | } 37 | 38 | const text = buf.toString("ascii"); 39 | fs.writeFileSync(path.resolve("test", privateKeyFilename), text); 40 | } 41 | 42 | describe("SDK Unit Tests:", function (done) { 43 | const apiClient = new docusign.ApiClient({ 44 | basePath: basePath, 45 | oAuthBasePath: oAuthBasePath, 46 | }); 47 | const scopes = [oAuth.Scope.IMPERSONATION, oAuth.Scope.SIGNATURE]; 48 | 49 | before(function (done) { 50 | // IMPORTANT NOTE: 51 | // the first time you ask for a JWT access token, you should grant access by making the following call 52 | // get DocuSign OAuth authorization url: 53 | const oauthLoginUrl = apiClient.getJWTUri( 54 | integratorKey, 55 | RedirectURI, 56 | oAuthBasePath 57 | ); 58 | // open DocuSign OAuth authorization url in the browser, login and grant access 59 | console.log(oauthLoginUrl); 60 | // END OF NOTE 61 | const fs = require("fs"); 62 | const privateKeyFile = fs.readFileSync( 63 | path.resolve(__dirname, privateKeyFilename) 64 | ); 65 | 66 | apiClient 67 | .requestJWTUserToken( 68 | integratorKey, 69 | userId, 70 | scopes, 71 | privateKeyFile, 72 | expiresIn 73 | ) 74 | .then(function (res) { 75 | apiClient.setJWTToken(res.body.access_token); 76 | 77 | apiClient 78 | .getUserInfo(res.body.access_token) 79 | .then(function (userInfo) { 80 | console.log("LoginInformation: " + JSON.stringify(userInfo)); 81 | done(); 82 | }) 83 | .catch(function (error) { 84 | if (error) { 85 | console.log(error); 86 | return done(error); 87 | } 88 | }); 89 | }) 90 | .catch(function (err) { 91 | if (err) { 92 | return done(err); 93 | } 94 | }); 95 | }); 96 | 97 | it("oAuthBasePAth should update whenever BasePath does and match the environment", function (done) { 98 | const apiClient = new docusign.ApiClient({ 99 | basePath: restApi.BasePath.DEMO, 100 | }); 101 | assert.equal(apiClient.oAuthBasePath, apiClient.OAuth.BasePath.DEMO); 102 | assert.notEqual( 103 | apiClient.oAuthBasePath, 104 | apiClient.OAuth.BasePath.PRODUCTION 105 | ); 106 | 107 | apiClient.setBasePath(restApi.BasePath.STAGE); 108 | assert.equal(apiClient.oAuthBasePath, apiClient.OAuth.BasePath.STAGE); 109 | 110 | apiClient.setBasePath(restApi.BasePath.PRODUCTION); 111 | assert.equal(apiClient.oAuthBasePath, apiClient.OAuth.BasePath.PRODUCTION); 112 | 113 | apiClient.setBasePath(restApi.BasePath.DEMO); 114 | assert.equal(apiClient.oAuthBasePath, apiClient.OAuth.BasePath.DEMO); 115 | 116 | return done(); 117 | }); 118 | 119 | it("should be able to request a JWT user token", function (done) { 120 | const fs = require("fs"); 121 | const privateKeyFile = fs.readFileSync( 122 | path.resolve(__dirname, privateKeyFilename) 123 | ); 124 | apiClient 125 | .requestJWTUserToken( 126 | integratorKey, 127 | userId, 128 | scopes, 129 | privateKeyFile, 130 | expiresIn 131 | ) 132 | .then(function (response) { 133 | assert.ok(response.body.access_token); 134 | done(); 135 | }) 136 | .catch(function (err) { 137 | return done(err); 138 | }); 139 | }); 140 | 141 | it("should be able to request a JWT application token", function (done) { 142 | const fs = require("fs"); 143 | const privateKeyFile = fs.readFileSync( 144 | path.resolve(__dirname, privateKeyFilename) 145 | ); 146 | 147 | apiClient 148 | .requestJWTApplicationToken( 149 | integratorKey, 150 | scopes, 151 | privateKeyFile, 152 | expiresIn 153 | ) 154 | .then(function (response) { 155 | assert.ok(response.body.access_token); 156 | done(); 157 | }) 158 | .catch(function (err) { 159 | return done(err); 160 | }); 161 | }); 162 | 163 | it("should return a properly formatted authorization uri", function (done) { 164 | const responseType = apiClient.OAuth.ResponseType.CODE; 165 | const scopes = [apiClient.OAuth.Scope.EXTENDED]; 166 | const randomState = "*^.$DGj*)+}Jk"; 167 | const formattedScopes = scopes.join(encodeURI(" ")); 168 | let authUri; 169 | let correctAuthUri; 170 | authUri = apiClient.getAuthorizationUri( 171 | integratorKeyAuthCode, 172 | scopes, 173 | RedirectURI, 174 | responseType, 175 | randomState 176 | ); 177 | correctAuthUri = 178 | "https://" + 179 | oAuthBasePath + 180 | "/oauth/auth" + 181 | "?response_type=" + 182 | responseType + 183 | "&scope=" + 184 | formattedScopes + 185 | "&client_id=" + 186 | integratorKeyAuthCode + 187 | "&redirect_uri=" + 188 | encodeURIComponent(RedirectURI) + 189 | (randomState ? "&state=" + randomState : ""); 190 | 191 | assert.equal(authUri, correctAuthUri); 192 | done(); 193 | }); 194 | 195 | it("retrieves data set stream", function (done) { 196 | const dataSetApi = new docusign.DataSetApi(apiClient); 197 | const datasetName = "monitor"; 198 | const version = "2.0"; 199 | dataSetApi 200 | .getStream(version, datasetName) 201 | .then(function (data) { 202 | assert.notEqual(data, undefined); 203 | return done(); 204 | }) 205 | .catch(function (e) { 206 | return done(e); 207 | }); 208 | }); 209 | 210 | it("should return an authorization uri to a valid page", function (done) { 211 | let responseType = apiClient.OAuth.ResponseType.CODE; 212 | let scopes = [apiClient.OAuth.Scope.EXTENDED]; 213 | let randomState = "*^.$DGj*)+}Jk"; 214 | let authUri = apiClient.getAuthorizationUri( 215 | integratorKeyAuthCode, 216 | scopes, 217 | RedirectURI, 218 | responseType, 219 | randomState 220 | ); 221 | 222 | axios 223 | .get(authUri) 224 | .then(function (res) { 225 | //this will be updated later to statuscode 226 | assert.equal(res.status, 200); 227 | done(); 228 | }) 229 | .catch((err) => { 230 | assert.notEqual(err, undefined); 231 | }); 232 | }); 233 | }); 234 | -------------------------------------------------------------------------------- /src/ApiClient.js: -------------------------------------------------------------------------------- 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. 4 | * 5 | * OpenAPI spec version: v2 6 | * Contact: devcenter@docusign.com 7 | * 8 | * NOTE: This class is auto generated. Do not edit the class manually and submit a new issue instead. 9 | * 10 | */ 11 | 12 | (function (root, factory) { 13 | if (typeof define === "function" && define.amd) { 14 | // AMD. Register as an anonymous module. 15 | define(["axios"], factory); 16 | define(["@devhigley/parse-proxy"], factory); 17 | } else if (typeof module === "object" && module.exports) { 18 | // CommonJS-like environments that support module.exports, like Node. 19 | module.exports = factory( 20 | require("axios"), 21 | require("@devhigley/parse-proxy") 22 | ); 23 | } else { 24 | // Browser globals (root is window) 25 | if (!root.Docusign) { 26 | root.Docusign = {}; 27 | } 28 | root.Docusign.ApiClient = factory(root.axios, opts); 29 | } 30 | })(this, function (axios, parseProxy, opts) { 31 | "use strict"; 32 | 33 | /* 34 | * The default HTTP headers to be included for all API calls. 35 | * @type {Array.} 36 | * @default {} 37 | * */ 38 | 39 | var defaultHeaders = { 40 | "X-DocuSign-SDK": "Node", 41 | "Node-Ver": process.version, 42 | "User-Agent": `Swagger-Codegen/node/${process.version}`, 43 | }; 44 | 45 | var removeNulls = function (obj) { 46 | var isArray = obj instanceof Array; 47 | for (var k in obj) { 48 | if (typeof obj[k] === "object") removeNulls(obj[k]); 49 | if (isArray && obj.length === k) removeNulls(obj); 50 | if (obj[k] instanceof Array && obj[k].length === 0) delete obj[k]; 51 | } 52 | return obj; 53 | }; 54 | 55 | var generateAndSignJWTAssertion = function ( 56 | clientId, 57 | scopes, 58 | privateKey, 59 | oAuthBasePath, 60 | expiresIn, 61 | userId 62 | ) { 63 | if (typeof expiresIn !== "number" || expiresIn < 0) 64 | throw new Error("Invalid expires in param detected"); 65 | 66 | var MILLESECONDS_PER_SECOND = 1000, 67 | JWT_SIGNING_ALGO = "RS256", 68 | now = Math.floor(Date.now() / MILLESECONDS_PER_SECOND), 69 | later = now + expiresIn, 70 | jwt = require("jsonwebtoken"), 71 | parsedScopes = Array.isArray(scopes) ? scopes.join(" ") : scopes; 72 | 73 | var jwtPayload = { 74 | iss: clientId, 75 | aud: oAuthBasePath, 76 | iat: now, 77 | exp: later, 78 | scope: parsedScopes, 79 | }; 80 | 81 | /** optional parameters **/ 82 | if (userId) { 83 | jwtPayload.sub = userId; 84 | } 85 | return jwt.sign(jwtPayload, privateKey, { algorithm: JWT_SIGNING_ALGO }); 86 | }; 87 | 88 | var sendJWTTokenRequest = function ( 89 | assertion, 90 | oAuthBasePath, 91 | proxy, 92 | callback 93 | ) { 94 | const requestConfig = { 95 | baseURL: `https://${oAuthBasePath}`, 96 | method: "post", 97 | url: "/oauth/token", 98 | headers: { 99 | "Content-Type": "application/x-www-form-urlencoded", 100 | "Cache-Control": "no-store", 101 | Pragma: "no-cache", 102 | }, 103 | timeout: exports.prototype.timeout, 104 | data: { 105 | assertion: assertion, 106 | grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer", 107 | }, 108 | }; 109 | 110 | if (proxy) { 111 | const proxyObj = parseProxy(proxy); 112 | requestConfig.proxy = proxyObj[0]; 113 | } 114 | 115 | const oauthRequest = axios.request(requestConfig); 116 | 117 | if (!callback) { 118 | return new Promise(function (resolve, reject) { 119 | oauthRequest 120 | .then((response) => { 121 | const stdResponse = normalizeResponseFormat(response); 122 | resolve(stdResponse); 123 | }) 124 | .catch((err) => { 125 | const stdErrorResponse = normalizeResponseFormat(err.response); 126 | reject(stdErrorResponse); 127 | }); 128 | }); 129 | } else { 130 | oauthRequest 131 | .then((response) => { 132 | const stdResponse = normalizeResponseFormat(response); 133 | callback(null, stdResponse.body, stdResponse); 134 | }) 135 | .catch((err) => { 136 | const stdErrorResponse = normalizeResponseFormat(err.response); 137 | callback(stdErrorResponse); 138 | }); 139 | } 140 | }; 141 | 142 | const normalizeResponseFormat = (res) => { 143 | if (res) { 144 | const { data: body, headers: header, status: statusCode } = res; 145 | return { 146 | statusCode, 147 | header, 148 | body, 149 | }; 150 | } 151 | return null; 152 | }; 153 | 154 | var deriveOAuthBasePathFromRestBasePath = function (basePath) { 155 | if (basePath == null) { 156 | return exports.prototype.OAuth.BasePath.PRODUCTION; 157 | } 158 | if (basePath.includes("https://lens-s")) { 159 | return exports.prototype.OAuth.BasePath.STAGE; 160 | } 161 | if (basePath.includes("https://lens-d")) { 162 | return exports.prototype.OAuth.BasePath.DEMO; 163 | } 164 | if (basePath.includes("https://lens.")) { 165 | return exports.prototype.OAuth.BasePath.PRODUCTION; 166 | } 167 | return exports.prototype.OAuth.BasePath.PRODUCTION; 168 | }; 169 | 170 | /** 171 | * @module ApiClient 172 | * @version 3.0.0 173 | */ 174 | 175 | /** 176 | * Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an 177 | * application to use this class directly - the *Api and model classes provide the public API for the service. The 178 | * contents of this file should be regarded as internal but are documented for completeness. 179 | * @alias module:ApiClient 180 | * @class 181 | */ 182 | var exports = function (opts) { 183 | var defaults = { 184 | basePath: "https://www.docusign.net/restapi".replace(/\/+$/, ""), 185 | oAuthBasePath: require("./OAuth").BasePath.PRODUCTION, 186 | }; 187 | 188 | opts = Object.assign({}, defaults, opts); 189 | opts.oAuthBasePath = deriveOAuthBasePathFromRestBasePath(opts.basePath); 190 | 191 | /** 192 | * The full URI for the desired proxy. 193 | * A complete list of supported proxies can be found here: https://www.npmjs.com/package/proxy-agent. 194 | * @type {String} 195 | * @default 196 | */ 197 | this.proxy = opts.proxy; 198 | 199 | /** 200 | * The base URL against which to resolve every API call's (relative) path. 201 | * @type {String} 202 | * @default https://www.docusign.net/restapi 203 | */ 204 | this.basePath = opts.basePath; 205 | 206 | /** 207 | * The base URL against which to resolve every authentication API call's (relative) path. 208 | * @type {String} 209 | * @default https://www.docusign.net/restapi 210 | */ 211 | this.oAuthBasePath = opts.oAuthBasePath; 212 | 213 | /** 214 | * The authentication methods to be included for all API calls. 215 | * @type {Array.} 216 | */ 217 | this.authentications = { 218 | docusignAccessCode: { type: "oauth2" }, 219 | }; 220 | 221 | /** 222 | * The default HTTP timeout for all API calls. 223 | * @type {Number} 224 | * @default 60000 225 | */ 226 | this.timeout = 60000; 227 | 228 | /** 229 | * If set to false an additional timestamp parameter is added to all API GET calls to 230 | * prevent browser caching 231 | * @type {Boolean} 232 | * @default true 233 | */ 234 | this.cache = true; 235 | }; 236 | 237 | /** 238 | * Gets the API endpoint base URL. 239 | */ 240 | exports.prototype.getBasePath = function getBasePath() { 241 | return this.basePath; 242 | }; 243 | 244 | /** 245 | * Sets the API endpoint base URL. 246 | */ 247 | exports.prototype.setBasePath = function setBasePath(basePath) { 248 | this.basePath = basePath; 249 | this.oAuthBasePath = deriveOAuthBasePathFromRestBasePath(basePath); 250 | }; 251 | 252 | /** 253 | * Gets the authentication server endpoint base URL. 254 | */ 255 | exports.prototype.getOAuthBasePath = function getOAuthBasePath() { 256 | return this.oAuthBasePath; 257 | }; 258 | 259 | /** 260 | * Sets the authentication server endpoint base URL. 261 | */ 262 | exports.prototype.setOAuthBasePath = function setOAuthBasePath( 263 | oAuthBasePath 264 | ) { 265 | this.oAuthBasePath = oAuthBasePath; 266 | }; 267 | 268 | /** 269 | * Adds request headers to the API client. Useful for Authentication. 270 | */ 271 | exports.prototype.addDefaultHeader = function addDefaultHeader( 272 | header, 273 | value 274 | ) { 275 | defaultHeaders[header] = value; 276 | }; 277 | 278 | /** 279 | * Sets default JWT authorization token for APIs. 280 | */ 281 | exports.prototype.setJWTToken = function setJWTToken(token) { 282 | if(!token){ 283 | throw new Error("Missing the required parameter 'token' when calling setJWTToken."); 284 | } 285 | defaultHeaders["Authorization"] = `Bearer ${token}`; 286 | }; 287 | 288 | /** 289 | * Returns a string representation for an actual parameter. 290 | * @param param The actual parameter. 291 | * @returns {String} The string representation of param. 292 | */ 293 | exports.prototype.paramToString = function (param) { 294 | if (param == undefined || param == null) { 295 | return ""; 296 | } 297 | if (param instanceof Date) { 298 | return param.toJSON(); 299 | } 300 | return param.toString(); 301 | }; 302 | 303 | /** 304 | * Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values. 305 | * NOTE: query parameters are not handled here. 306 | * @param {String} path The path to append to the base URL. 307 | * @param {Object} pathParams The parameter values to append. 308 | * @returns {String} The encoded path with parameter values substituted. 309 | */ 310 | exports.prototype.buildUrl = function (path, pathParams) { 311 | if (!path.match(/^\//)) { 312 | path = "/" + path; 313 | } 314 | var url = this.basePath + path; 315 | var _this = this; 316 | url = url.replace(/\{([\w-]+)\}/g, function (fullMatch, key) { 317 | var value; 318 | if (pathParams.hasOwnProperty(key)) { 319 | value = _this.paramToString(pathParams[key]); 320 | } else { 321 | value = fullMatch; 322 | } 323 | return encodeURIComponent(value); 324 | }); 325 | return url; 326 | }; 327 | 328 | /** 329 | * Checks whether the given content type represents JSON.
330 | * JSON content type examples:
331 | *
    332 | *
  • application/json
  • 333 | *
  • application/json; charset=UTF8
  • 334 | *
  • APPLICATION/JSON
  • 335 | *
336 | * @param {String} contentType The MIME content type to check. 337 | * @returns {Boolean} true if contentType represents JSON, otherwise false. 338 | */ 339 | exports.prototype.isJsonMime = function (contentType) { 340 | return Boolean( 341 | contentType != null && contentType.match(/^application\/json(;.*)?$/i) 342 | ); 343 | }; 344 | 345 | /** 346 | * Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first. 347 | * @param {Array.} contentTypes 348 | * @returns {String} The chosen content type, preferring JSON. 349 | */ 350 | exports.prototype.jsonPreferredMime = function (contentTypes) { 351 | for (var i = 0; i < contentTypes.length; i++) { 352 | if (this.isJsonMime(contentTypes[i])) { 353 | return contentTypes[i]; 354 | } 355 | } 356 | return contentTypes[0]; 357 | }; 358 | 359 | /** 360 | * Checks whether the given parameter value represents file-like content. 361 | * @param param The parameter to check. 362 | * @returns {Boolean} true if param represents a file. 363 | */ 364 | exports.prototype.isFileParam = function (param) { 365 | // fs.ReadStream in Node.js (but not in runtime like browserify) 366 | if ( 367 | typeof window === "undefined" && 368 | typeof require === "function" && 369 | require("fs") && 370 | param instanceof require("fs").ReadStream 371 | ) { 372 | return true; 373 | } 374 | // Buffer in Node.js 375 | if (typeof Buffer === "function" && param instanceof Buffer) { 376 | return true; 377 | } 378 | // Blob in browser 379 | if (typeof Blob === "function" && param instanceof Blob) { 380 | return true; 381 | } 382 | // File in browser (it seems File object is also instance of Blob, but keep this for safe) 383 | if (typeof File === "function" && param instanceof File) { 384 | return true; 385 | } 386 | return false; 387 | }; 388 | 389 | /** 390 | * Normalizes parameter values: 391 | *
    392 | *
  • remove nils
  • 393 | *
  • keep files and arrays
  • 394 | *
  • format to string with `paramToString` for other cases
  • 395 | *
396 | * @param {Object.} params The parameters as object properties. 397 | * @returns {Object.} normalized parameters. 398 | */ 399 | exports.prototype.normalizeParams = function (params) { 400 | var newParams = {}; 401 | for (var key in params) { 402 | if ( 403 | params.hasOwnProperty(key) && 404 | params[key] != undefined && 405 | params[key] != null 406 | ) { 407 | var value = params[key]; 408 | if (this.isFileParam(value) || Array.isArray(value)) { 409 | newParams[key] = value; 410 | } else { 411 | newParams[key] = this.paramToString(value); 412 | } 413 | } 414 | } 415 | return newParams; 416 | }; 417 | 418 | /** 419 | * Enumeration of collection format separator strategies. 420 | * @enum {String} 421 | * @readonly 422 | */ 423 | exports.CollectionFormatEnum = { 424 | /** 425 | * Comma-separated values. Value: csv 426 | * @const 427 | */ 428 | CSV: ",", 429 | /** 430 | * Space-separated values. Value: ssv 431 | * @const 432 | */ 433 | SSV: " ", 434 | /** 435 | * Tab-separated values. Value: tsv 436 | * @const 437 | */ 438 | TSV: "\t", 439 | /** 440 | * Pipe(|)-separated values. Value: pipes 441 | * @const 442 | */ 443 | PIPES: "|", 444 | /** 445 | * Native array. Value: multi 446 | * @const 447 | */ 448 | MULTI: "multi", 449 | }; 450 | 451 | /** 452 | * Builds a string representation of an array-type actual parameter, according to the given collection format. 453 | * @param {Array} param An array parameter. 454 | * @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy. 455 | * @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns 456 | * param as is if collectionFormat is multi. 457 | */ 458 | exports.prototype.buildCollectionParam = function buildCollectionParam( 459 | param, 460 | collectionFormat 461 | ) { 462 | if (param == null) { 463 | return null; 464 | } 465 | switch (collectionFormat) { 466 | case "csv": 467 | return param.map(this.paramToString).join(","); 468 | case "ssv": 469 | return param.map(this.paramToString).join(" "); 470 | case "tsv": 471 | return param.map(this.paramToString).join("\t"); 472 | case "pipes": 473 | return param.map(this.paramToString).join("|"); 474 | case "multi": 475 | // return the array directly as axios will handle it as expected 476 | return param.map(this.paramToString); 477 | default: 478 | throw new Error("Unknown collection format: " + collectionFormat); 479 | } 480 | }; 481 | 482 | /** 483 | * Applies authentication headers to the request. 484 | * @param {Object} requestConfig The request configuration object used for Axios Request. 485 | * @param {Array.} authNames An array of authentication method names. 486 | */ 487 | exports.prototype.applyAuthToRequest = function (requestConfig, authNames) { 488 | var _this = this; 489 | authNames.forEach(function (authName) { 490 | var auth = _this.authentications[authName]; 491 | switch (auth.type) { 492 | case "basic": 493 | if (auth.username || auth.password) { 494 | requestConfig.auth = { 495 | username: auth.username || "", 496 | password: auth.password || "", 497 | }; 498 | } 499 | break; 500 | case "apiKey": 501 | if (auth.apiKey) { 502 | var data = {}; 503 | if (auth.apiKeyPrefix) { 504 | data[auth.name] = auth.apiKeyPrefix + " " + auth.apiKey; 505 | } else { 506 | data[auth.name] = auth.apiKey; 507 | } 508 | if (auth["in"] === "header") { 509 | requestConfig.headers = { 510 | ...requestConfig.headers, 511 | ...data, 512 | }; 513 | } else { 514 | requestConfig.params = { ...requestConfig.params, ...data }; 515 | } 516 | } 517 | break; 518 | case "oauth2": 519 | if (auth.accessToken) { 520 | requestConfig.headers = { 521 | ...requestConfig.headers, 522 | Authorization: "Bearer " + auth.accessToken, 523 | }; 524 | } 525 | break; 526 | default: 527 | throw new Error("Unknown authentication type: " + auth.type); 528 | } 529 | }); 530 | }; 531 | 532 | /** 533 | * Deserializes an HTTP response body into a value of the specified type. 534 | * @param {Object} response An Axios response object. 535 | * @param {(String|Array.|Object.|Function)} returnType The type to return. Pass a string for simple types 536 | * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To 537 | * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type: 538 | * all properties on data will be converted to this type. 539 | * @returns A value of the specified type. 540 | */ 541 | exports.prototype.deserialize = function deserialize(response, returnType) { 542 | if (response == null || returnType == null || response.status == 204) { 543 | return null; 544 | } 545 | // Rely on Axios Response Schema. 546 | // See https://axios-http.com/docs/res_schema 547 | var data = response.data; 548 | return exports.convertToType(data, returnType); 549 | }; 550 | 551 | /** 552 | * (Optional)Callback function to receive the result of the operation. If none specified a Promise will be returned. 553 | * @callback module:ApiClient~callApiCallback 554 | * @param {String} error Error message, if any. 555 | * @param data The data returned by the service call. 556 | * @param {String} response The complete HTTP response. 557 | */ 558 | 559 | /** 560 | * Invokes the REST service using the supplied settings and parameters. 561 | * @param {String} path The base URL to invoke. 562 | * @param {String} httpMethod The HTTP method to use. 563 | * @param {Object.} pathParams A map of path parameters and their values. 564 | * @param {Object.} queryParams A map of query parameters and their values. 565 | * @param {Object.} headerParams A map of header parameters and their values. 566 | * @param {Object.} formParams A map of form parameters and their values. 567 | * @param {Object} bodyParam The value to pass as the request body. 568 | * @param {Array.} authNames An array of authentication type names. 569 | * @param {Array.} contentTypes An array of request MIME types. 570 | * @param {Array.} accepts An array of acceptable response MIME types. 571 | * @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the 572 | * constructor for a complex type. 573 | * @param {module:ApiClient~callApiCallback} callback The callback function. If this is left undefined, this method will return a promise instead. 574 | * @returns {Object} The axios request object if a callback is specified, else {Promise} A {@link https://www.promisejs.org/|Promise} object. 575 | */ 576 | exports.prototype.callApi = function callApi( 577 | path, 578 | httpMethod, 579 | pathParams, 580 | queryParams, 581 | headerParams, 582 | formParams, 583 | bodyParam, 584 | authNames, 585 | contentTypes, 586 | accepts, 587 | returnType, 588 | callback 589 | ) { 590 | var _this = this; 591 | var url = this.buildUrl(path, pathParams); 592 | 593 | const requestConfig = { 594 | method: httpMethod, 595 | url, 596 | timeout: this.timeout, 597 | paramsSerializer: { 598 | indexes: null, 599 | }, 600 | }; 601 | 602 | if (this.proxy) { 603 | const proxyObj = parseProxy(this.proxy); 604 | requestConfig.proxy = proxyObj[0]; 605 | } 606 | 607 | var _formParams = this.normalizeParams(formParams); 608 | var body = 609 | httpMethod.toUpperCase() === "GET" && !bodyParam 610 | ? undefined 611 | : bodyParam || {}; 612 | 613 | // apply authentications 614 | this.applyAuthToRequest(requestConfig, authNames); 615 | 616 | // set query parameters 617 | if (httpMethod.toUpperCase() === "GET" && this.cache === false) { 618 | queryParams["_"] = new Date().getTime(); 619 | } 620 | const _queryParams = this.normalizeParams(queryParams); 621 | requestConfig.params = { ...requestConfig.params, ..._queryParams }; 622 | 623 | // set header parameters 624 | const _headerParams = this.normalizeParams(headerParams); 625 | requestConfig.headers = { 626 | ...requestConfig.headers, 627 | ...defaultHeaders, 628 | ..._headerParams, 629 | }; 630 | 631 | // set request timeout 632 | requestConfig.timeout = this.timeout; 633 | 634 | var contentType = this.jsonPreferredMime(contentTypes); 635 | 636 | if (contentType) { 637 | if (contentType != "multipart/form-data") { 638 | requestConfig.headers = { 639 | ...requestConfig.headers, 640 | "Content-Type": contentType, 641 | }; 642 | } 643 | } else if (!requestConfig.headers["Content-Type"]) { 644 | requestConfig.headers = { 645 | ...requestConfig.headers, 646 | "Content-Type": "application/json", 647 | }; 648 | } 649 | 650 | if (contentType === "application/x-www-form-urlencoded") { 651 | //automatic serialization happens with axios. ref: https://axios-http.com/docs/urlencoded 652 | requestConfig.data = this.normalizeParams(formParams); 653 | } else if (contentType == "multipart/form-data") { 654 | if (this.hasBufferFormParam(_formParams)) { 655 | requestConfig.headers = { 656 | ...requestConfig.headers, 657 | "Content-Disposition": 'form-data; name="file"; filename="file.xml"', 658 | "Content-Type": "application/octet-stream", 659 | }; 660 | var formAttachmentKey = Object.keys(formParams).find(function (key) { 661 | return _this.isFileParam(_formParams[key]); 662 | }); 663 | requestConfig.data = removeNulls(formParams[formAttachmentKey]); 664 | } else { 665 | //automatic serialization for formData is supported in axios as of 0.27.0. ref: https://axios-http.com/docs/multipart 666 | requestConfig.headers = { 667 | ...requestConfig.headers, 668 | "Content-Type": "multipart/form-data", 669 | }; 670 | var _formParams = this.normalizeParams(formParams); 671 | requestConfig.data = _formParams; 672 | } 673 | } else if (body) { 674 | requestConfig.data = removeNulls(body); 675 | } 676 | 677 | var accept = this.jsonPreferredMime(accepts); 678 | 679 | if (accept) { 680 | requestConfig.headers = { ...requestConfig.headers, Accept: accept }; 681 | } 682 | 683 | if (requestConfig.headers["Accept"] === "application/pdf") { 684 | requestConfig.responseType = "stream"; 685 | } 686 | 687 | const request = axios.request(requestConfig); 688 | 689 | var data = null; 690 | if (!callback) { 691 | return new Promise(function (resolve, reject) { 692 | request 693 | .then((response) => { 694 | try { 695 | let streamData; 696 | if (requestConfig.headers["Accept"] === "application/pdf") { 697 | response.data.on("data", (chunks) => { 698 | streamData += chunks; 699 | }); 700 | response.data.on("end", () => { 701 | resolve(streamData); 702 | }); 703 | } else { 704 | data = _this.deserialize(response, returnType); 705 | resolve(data); 706 | } 707 | } catch (err) { 708 | reject(err); 709 | } 710 | }) 711 | .catch((err) => { 712 | const stdErrResponse = normalizeResponseFormat(err.response); 713 | reject(stdErrResponse); 714 | }); 715 | }); 716 | } else { 717 | request 718 | .then((response) => { 719 | try { 720 | let streamData; 721 | const stdResponse = normalizeResponseFormat(response); 722 | if (requestConfig.headers["Accept"] === "application/pdf") { 723 | response.data.on("data", (chunks) => { 724 | streamData += chunks; 725 | }); 726 | response.data.on("end", () => { 727 | callback(null, streamData, stdResponse); 728 | }); 729 | } else { 730 | data = _this.deserialize(response, returnType); 731 | callback(null, data, stdResponse); 732 | } 733 | } catch (err) { 734 | callback(err); 735 | } 736 | }) 737 | .catch((err) => { 738 | const stdErrResponse = normalizeResponseFormat(err.response); 739 | callback(stdErrResponse); 740 | }); 741 | return request; 742 | } 743 | }; 744 | 745 | /** 746 | * Parses an ISO-8601 string representation of a date value. 747 | * @param {String} str The date value as a string. 748 | * @returns {Date} The parsed date object. 749 | */ 750 | exports.parseDate = function (str) { 751 | return new Date(str.replace(/T/i, " ")); 752 | }; 753 | 754 | /** 755 | * Converts a value to the specified type. 756 | * @param {(String|Object)} data The data to convert, as a string or object. 757 | * @param {(String|Array.|Object.|Function)} type The type to return. Pass a string for simple types 758 | * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To 759 | * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type: 760 | * all properties on data will be converted to this type. 761 | * @returns An instance of the specified type. 762 | */ 763 | exports.convertToType = function (data, type) { 764 | switch (type) { 765 | case "Boolean": 766 | return Boolean(data); 767 | case "Integer": 768 | return parseInt(data, 10); 769 | case "Number": 770 | return parseFloat(data); 771 | case "String": 772 | return String(data); 773 | case "Date": 774 | return this.parseDate(String(data)); 775 | default: 776 | if (type === Object) { 777 | // generic object, return directly 778 | return data; 779 | } else if (typeof type === "function") { 780 | // for model type like: User 781 | return type.constructFromObject(data); 782 | } else if (Array.isArray(type)) { 783 | // for array type like: ['String'] 784 | var itemType = type[0]; 785 | return data.map(function (item) { 786 | return exports.convertToType(item, itemType); 787 | }); 788 | } else if (typeof type === "object") { 789 | // for plain object type like: {'String': 'Integer'} 790 | var keyType, valueType; 791 | for (var k in type) { 792 | if (type.hasOwnProperty(k)) { 793 | keyType = k; 794 | valueType = type[k]; 795 | break; 796 | } 797 | } 798 | var result = {}; 799 | for (var k in data) { 800 | if (data.hasOwnProperty(k)) { 801 | var key = exports.convertToType(k, keyType); 802 | var value = exports.convertToType(data[k], valueType); 803 | result[key] = value; 804 | } 805 | } 806 | return result; 807 | } else { 808 | // for unknown type, return the data directly 809 | return data; 810 | } 811 | } 812 | }; 813 | 814 | /** 815 | * Constructs a new map or array model from REST data. 816 | * @param data {Object|Array} The REST data. 817 | * @param obj {Object|Array} The target object or array. 818 | */ 819 | exports.constructFromObject = function (data, obj, itemType) { 820 | if (Array.isArray(data)) { 821 | for (var i = 0; i < data.length; i++) { 822 | if (data.hasOwnProperty(i)) 823 | obj[i] = exports.convertToType(data[i], itemType); 824 | } 825 | } else { 826 | for (var k in data) { 827 | if (data.hasOwnProperty(k)) 828 | obj[k] = exports.convertToType(data[k], itemType); 829 | } 830 | } 831 | }; 832 | 833 | /** 834 | * Helper method to configure the OAuth accessCode/implicit flow parameters 835 | * @param clientId OAuth2 client ID: Identifies the client making the request. 836 | * Client applications may be scoped to a limited set of system access. 837 | * @param scopes the list of requested scopes. 838 | * @param redirectUri this determines where to deliver the response containing the authorization code or access token. 839 | * @param responseType determines the response type of the authorization request. 840 | *
Note: these response types are mutually exclusive for a client application. 841 | * A public/native client application may only request a response type of "token"; 842 | * a private/trusted client application may only request a response type of "code". 843 | * @param state Allows for arbitrary state that may be useful to your application. 844 | * The value in this parameter will be round-tripped along with the response so you can make sure it didn't change. 845 | */ 846 | exports.prototype.getAuthorizationUri = function ( 847 | clientId, 848 | scopes, 849 | redirectUri, 850 | responseType, 851 | state 852 | ) { 853 | if (!clientId) throw new Error("Error clientId is required"); 854 | if (!scopes) throw new Error("Error scopes is required"); 855 | if (!scopes) throw new Error("Error scopes is required"); 856 | if (!this.hasNoInvalidScopes(scopes)) 857 | throw new Error("Error invalid scope detected"); 858 | if (!redirectUri) throw new Error("Error redirectUri is required"); 859 | if (!responseType) throw new Error("Error responseType is required"); 860 | 861 | var formattedScopes = scopes.join(encodeURI(" ")); 862 | return ( 863 | "https://" + 864 | this.getOAuthBasePath() + 865 | "/oauth/auth" + 866 | "?response_type=" + 867 | responseType + 868 | "&scope=" + 869 | formattedScopes + 870 | "&client_id=" + 871 | clientId + 872 | "&redirect_uri=" + 873 | encodeURIComponent(redirectUri) + 874 | (state ? "&state=" + state : "") 875 | ); 876 | }; 877 | 878 | /** 879 | * @param clientId OAuth2 client ID: Identifies the client making the request. 880 | * 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. 882 | * @param code The authorization code that you received from the getAuthorizationUri callback. 883 | * @return OAuthToken object.xx 884 | */ 885 | exports.prototype.generateAccessToken = function ( 886 | clientId, 887 | clientSecret, 888 | code, 889 | callback 890 | ) { 891 | if (!clientId) throw new Error("Error clientId is required", null); 892 | if (!clientSecret) throw new Error("Error clientSecret is required", null); 893 | if (!code) throw new Error("Error code is required", null); 894 | 895 | var clientString = clientId + ":" + clientSecret, 896 | postData = { 897 | grant_type: "authorization_code", 898 | code: code, 899 | }, 900 | headers = { 901 | Authorization: "Basic " + new Buffer(clientString).toString("base64"), 902 | "Cache-Control": "no-store", 903 | Pragma: "no-cache", 904 | }, 905 | OAuthToken = require("./OAuth").OAuthToken; 906 | const requestConfig = { 907 | baseURL: `https://${oAuthBasePath}`, 908 | method: "post", 909 | url: "/oauth/token", 910 | headers: { 911 | ...headers, 912 | "Content-Type": "application/x-www-form-urlencoded", 913 | }, 914 | data: postData, 915 | }; 916 | const request = axios.request(requestConfig); 917 | 918 | if (!callback) { 919 | return new Promise(function (resolve, reject) { 920 | request 921 | .then((response) => { 922 | resolve(OAuthToken.constructFromObject(response.data)); 923 | }) 924 | .catch((err) => { 925 | const stdErrResponse = normalizeResponseFormat(err.response); 926 | reject(stdErrResponse); 927 | }); 928 | }); 929 | } else { 930 | request 931 | .then((response) => { 932 | let OAuthToken = require("./OAuth").OAuthToken; 933 | const stdResponse = normalizeResponseFormat(response); 934 | return callback( 935 | null, 936 | OAuthToken.constructFromObject(response.data), 937 | stdResponse 938 | ); 939 | }) 940 | .catch((err) => { 941 | const stdErrorResponse = normalizeResponseFormat(err.response); 942 | return callback(stdErrorResponse); 943 | }); 944 | } 945 | }; 946 | 947 | /** 948 | * @param accessToken the bearer token to use to authenticate for this call. 949 | * @return OAuth UserInfo model 950 | */ 951 | exports.prototype.getUserInfo = function (accessToken, callback) { 952 | if (!accessToken) throw new Error("Error accessToken is required", null); 953 | 954 | var headers = { 955 | Authorization: "Bearer " + accessToken, 956 | "Cache-Control": "no-store", 957 | Pragma: "no-cache", 958 | }; 959 | 960 | const requestConfig = { 961 | baseURL: `https://${this.oAuthBasePath}`, 962 | method: "get", 963 | url: "/oauth/userinfo", 964 | headers: headers, 965 | }; 966 | if (this.proxy) { 967 | const proxyObj = parseProxy(this.proxy); 968 | requestConfig.proxy = proxyObj[0]; 969 | } 970 | 971 | const request = axios.request(requestConfig); 972 | 973 | var UserInfo = require("./OAuth").UserInfo; 974 | 975 | if (!callback) { 976 | try { 977 | return new Promise(function (resolve, reject) { 978 | request 979 | .then((response) => { 980 | try { 981 | return resolve(UserInfo.constructFromObject(response.data)); 982 | } catch (err) { 983 | reject(err); 984 | } 985 | }) 986 | .catch((err) => { 987 | const stdErrorResponse = normalizeResponseFormat(err.response); 988 | reject(stdErrorResponse); 989 | }); 990 | }); 991 | } catch (err) { 992 | throw err; 993 | } 994 | } else { 995 | request 996 | .then((response) => { 997 | const stdResponse = normalizeResponseFormat(response); 998 | return callback( 999 | null, 1000 | UserInfo.constructFromObject(response.data), 1001 | stdResponse 1002 | ); 1003 | }) 1004 | .catch((err) => { 1005 | const stdErrorResponse = normalizeResponseFormat(err.response); 1006 | return callback(stdErrorResponse); 1007 | }); 1008 | } 1009 | }; 1010 | 1011 | /** 1012 | * Helper method to build the OAuth JWT grant uri (used once to get a user consent for impersonation) 1013 | * @param clientId OAuth2 client ID 1014 | * @param redirectURI OAuth2 redirect uri 1015 | * @param oAuthBasePath DocuSign OAuth base path (account-d.docusign.com for the developer sandbox 1016 | * and account.docusign.com for the production platform) 1017 | * @returns {string} the OAuth JWT grant uri as a String 1018 | */ 1019 | exports.prototype.getJWTUri = function ( 1020 | clientId, 1021 | redirectURI, 1022 | oAuthBasePath 1023 | ) { 1024 | return ( 1025 | "https://" + 1026 | oAuthBasePath + 1027 | "/oauth/auth" + 1028 | "?" + 1029 | "response_type=code&" + 1030 | "client_id=" + 1031 | encodeURIComponent(clientId) + 1032 | "&" + 1033 | "scope=" + 1034 | encodeURIComponent( 1035 | "signature impersonation organization_monitor_config_read organization_monitor_config_write organization_monitor_events_read" 1036 | ) + 1037 | "&" + 1038 | "redirect_uri=" + 1039 | encodeURIComponent(redirectURI) 1040 | ); 1041 | }; 1042 | 1043 | /** 1044 | * @deprecated since version 4.1.0 1045 | * Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign 1046 | * @param privateKeyFilename the filename of the RSA private key 1047 | * @param oAuthBasePath DocuSign OAuth base path (account-d.docusign.com for the developer sandbox 1048 | * and account.docusign.com for the production platform) 1049 | * @param clientId DocuSign OAuth Client Id (AKA Integrator Key) 1050 | * @param userId DocuSign user Id to be impersonated (This is a UUID) 1051 | * @param expiresIn in seconds for the token time-to-live 1052 | * @param callback the callback function. 1053 | */ 1054 | exports.prototype.configureJWTAuthorizationFlow = function ( 1055 | privateKeyFilename, 1056 | oAuthBasePath, 1057 | clientId, 1058 | userId, 1059 | expiresIn, 1060 | callback 1061 | ) { 1062 | console.warn( 1063 | "configureJWTAuthorizationFlow is a deprecated function! Please use requestJWTUserToken()" 1064 | ); 1065 | var _this = this; 1066 | var jwt = require("jsonwebtoken"), 1067 | fs = require("fs"), 1068 | private_key = fs.readFileSync(privateKeyFilename), 1069 | now = Math.floor(Date.now() / 1000), 1070 | later = now + expiresIn; 1071 | 1072 | var jwt_payload = { 1073 | iss: clientId, 1074 | sub: userId, 1075 | aud: oAuthBasePath, 1076 | iat: now, 1077 | exp: later, 1078 | scope: "signature", 1079 | }; 1080 | 1081 | var assertion = jwt.sign(jwt_payload, private_key, { algorithm: "RS256" }); 1082 | 1083 | const requestConfig = { 1084 | baseURL: `https://${oAuthBasePath}`, 1085 | method: "post", 1086 | url: "/oauth/token", 1087 | headers: { 1088 | "Content-Type": "application/x-www-form-urlencoded", 1089 | "Cache-Control": "no-store", 1090 | Pragma: "no-cache", 1091 | ...defaultHeaders, 1092 | }, 1093 | timeout: this.timeout, 1094 | data: { 1095 | assertion: assertion, 1096 | grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer", 1097 | }, 1098 | }; 1099 | 1100 | const request = axios.request(requestConfig); 1101 | const onSuccess = (response) => { 1102 | if (callback) { 1103 | if (response.data && response.data.access_token) { 1104 | _this.addDefaultHeader( 1105 | "Authorization", 1106 | "Bearer " + response.data.access_token 1107 | ); 1108 | } 1109 | const stdResponse = normalizeResponseFormat(response); 1110 | callback(null, stdResponse.body, stdResponse); 1111 | } 1112 | }; 1113 | 1114 | const onFailure = (error) => { 1115 | if (callback) { 1116 | const stdErrorResponse = normalizeResponseFormat(error.response); 1117 | callback(stdErrorResponse); 1118 | } 1119 | }; 1120 | request.then(onSuccess, onFailure); 1121 | }; 1122 | 1123 | exports.prototype.hasNoInvalidScopes = function (scopes) { 1124 | var validScopes = require("./oauth/Scope"); 1125 | 1126 | return ( 1127 | Array.isArray(scopes) && 1128 | scopes.length > 0 && 1129 | scopes.every(function (scope) { 1130 | return Object.keys(validScopes).some(function (key) { 1131 | return validScopes[key] === scope; 1132 | }); 1133 | }) 1134 | ); 1135 | }; 1136 | 1137 | exports.prototype.sendJWTTokenRequest = function (assertion, callback) { 1138 | return sendJWTTokenRequest( 1139 | assertion, 1140 | this.oAuthBasePath, 1141 | this.proxy, 1142 | callback 1143 | ); 1144 | }; 1145 | 1146 | exports.prototype.requestJWTUserToken = function ( 1147 | clientId, 1148 | userId, 1149 | scopes, 1150 | rsaPrivateKey, 1151 | expiresIn, 1152 | callback 1153 | ) { 1154 | var privateKey = rsaPrivateKey, 1155 | assertion = generateAndSignJWTAssertion( 1156 | clientId, 1157 | scopes, 1158 | privateKey, 1159 | this.getOAuthBasePath(), 1160 | expiresIn, 1161 | userId 1162 | ); 1163 | 1164 | return sendJWTTokenRequest( 1165 | assertion, 1166 | this.oAuthBasePath, 1167 | this.proxy, 1168 | callback 1169 | ); 1170 | }; 1171 | 1172 | exports.prototype.requestJWTApplicationToken = function ( 1173 | clientId, 1174 | scopes, 1175 | rsaPrivateKey, 1176 | expiresIn, 1177 | callback 1178 | ) { 1179 | var privateKey = rsaPrivateKey, 1180 | assertion = generateAndSignJWTAssertion( 1181 | clientId, 1182 | scopes, 1183 | privateKey, 1184 | this.getOAuthBasePath(), 1185 | expiresIn 1186 | ); 1187 | 1188 | return sendJWTTokenRequest( 1189 | assertion, 1190 | this.oAuthBasePath, 1191 | this.proxy, 1192 | callback 1193 | ); 1194 | }; 1195 | 1196 | exports.prototype.OAuth = require("./OAuth"); 1197 | exports.prototype.RestApi = require("./RestApi"); 1198 | /** 1199 | * The default API client implementation. 1200 | * @type {module:ApiClient} 1201 | */ 1202 | exports.instance = new exports(opts); 1203 | 1204 | return exports; 1205 | }); 1206 | 1207 | module.exports.OAuth = require("./OAuth"); 1208 | module.exports.RestApi = require("./RestApi"); 1209 | --------------------------------------------------------------------------------