Skip to content

Commit a0e859a

Browse files
Merge branch 'master' into feature/create-account
2 parents 68392cd + aabbd5a commit a0e859a

File tree

10 files changed

+4250
-4898
lines changed

10 files changed

+4250
-4898
lines changed

.gitignore

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,75 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
.idea/
8-
*.iml
9-
.idea/*
10-
11-
# Runtime data
12-
pids
13-
*.pid
14-
*.seed
15-
*.pid.lock
16-
17-
# Directory for instrumented libs generated by jscoverage/JSCover
18-
lib-cov
19-
20-
# Coverage directory used by tools like istanbul
21-
coverage
22-
23-
# nyc test coverage
24-
.nyc_output
25-
26-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27-
.grunt
28-
29-
# Bower dependency directory (https://bower.io/)
30-
bower_components
31-
32-
# node-waf configuration
33-
.lock-wscript
34-
35-
# Compiled binary addons (http://nodejs.org/api/addons.html)
36-
build/Release
37-
38-
# Dependency directories
39-
node_modules/
40-
jspm_packages/
41-
42-
# Typescript v1 declaration files
43-
typings/
44-
45-
# Optional npm cache directory
46-
.npm
47-
48-
# Optional eslint cache
49-
.eslintcache
50-
51-
# Optional REPL history
52-
.node_repl_history
53-
54-
# Output of 'npm pack'
55-
*.tgz
56-
57-
# Yarn Integrity file
58-
.yarn-integrity
59-
60-
# dotenv environment variables file
61-
.env
62-
63-
# ignore config file
64-
appsettings.json
65-
secret
66-
67-
# ignore vs settings
68-
.vs
69-
70-
# ignore RSA keys
71-
private.key
72-
73-
# ignore Web Form config
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
.idea/
8+
*.iml
9+
.idea/*
10+
11+
# Runtime data
12+
pids
13+
*.pid
14+
*.seed
15+
*.pid.lock
16+
17+
# Directory for instrumented libs generated by jscoverage/JSCover
18+
lib-cov
19+
20+
# Coverage directory used by tools like istanbul
21+
coverage
22+
23+
# nyc test coverage
24+
.nyc_output
25+
26+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27+
.grunt
28+
29+
# Bower dependency directory (https://bower.io/)
30+
bower_components
31+
32+
# node-waf configuration
33+
.lock-wscript
34+
35+
# Compiled binary addons (http://nodejs.org/api/addons.html)
36+
build/Release
37+
38+
# Dependency directories
39+
node_modules/
40+
jspm_packages/
41+
42+
# Typescript v1 declaration files
43+
typings/
44+
45+
# Optional npm cache directory
46+
.npm
47+
48+
# Optional eslint cache
49+
.eslintcache
50+
51+
# Optional REPL history
52+
.node_repl_history
53+
54+
# Output of 'npm pack'
55+
*.tgz
56+
57+
# Yarn Integrity file
58+
.yarn-integrity
59+
60+
# dotenv environment variables file
61+
.env
62+
63+
# ignore config file
64+
appsettings.json
65+
jwtConfig.json
66+
secret
67+
68+
# ignore vs settings
69+
.vs
70+
71+
# ignore RSA keys
72+
private.key
73+
74+
# ignore Web Form config
7475
web-form-config.json

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Node.js Launcher Code Examples
22

33
>
4-
>### PLEASE! Share your feedback in a [two-question survey](https://docs.google.com/forms/d/e/1FAIpQLScPa74hwhJwi7XWDDj4-XZVOQTF9jJWgbIFEpulXokCqYWT4A/viewform?usp=pp_url&entry.680551577=Node.js).
4+
>### PLEASE! Share your feedback in a [two-question survey](https://docs.google.com/forms/d/e/1FAIpQLScPa74hwhJwi7XWDDj4-XZVOQTF9jJWgbIFEpulXokCqYWT4A/viewform?usp=pp_url&entry.680551577=Node).
55
>
66
>
77
### GitHub repo: [code-examples-node](./README.md)

jwt_console_project/jwtConsole.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ const docusign = require('docusign-esign');
22
const signingViaEmail = require('../lib/eSignature/examples/signingViaEmail');
33
const fs = require('fs');
44
const path = require('path');
5-
const prompt = require('prompt-sync')();
65

76
const jwtConfig = require('./jwtConfig.json');
8-
const { ProvisioningInformation } = require('docusign-esign');
97
const demoDocsPath = path.resolve(__dirname, '../demo_documents');
108
const doc2File = 'World_Wide_Corp_Battle_Plan_Trafalgar.docx';
119
const doc3File = 'World_Wide_Corp_lorem.pdf';
1210

11+
const readline = require('readline').createInterface({
12+
input: process.stdin,
13+
output: process.stdout
14+
});
15+
1316

1417
const SCOPES = [
1518
'signature', 'impersonation'
@@ -62,11 +65,11 @@ async function authenticate(){
6265
};
6366
} catch (e) {
6467
console.log(e);
65-
let body = e.response && e.response.body;
68+
let body = e?.response?.body || e?.response?.data;
6669
// Determine the source of the error
6770
if (body) {
6871
// The user needs to grant consent
69-
if (body.error && body.error === 'consent_required') {
72+
if (body?.error === 'consent_required') {
7073
if (getConsent()){ return authenticate(); };
7174
} else {
7275
// Consent has been granted. Show status code for DocuSign API error
@@ -77,11 +80,11 @@ async function authenticate(){
7780
}
7881
}
7982

80-
function getArgs(apiAccountId, accessToken, basePath){
81-
signerEmail = prompt("Enter the signer's email address: ");
82-
signerName = prompt("Enter the signer's name: ");
83-
ccEmail = prompt("Enter the carbon copy's email address: ");
84-
ccName = prompt("Enter the carbon copy's name: ");
83+
async function getArgs(apiAccountId, accessToken, basePath){
84+
signerEmail = await prompt("Enter the signer's email address: ");
85+
signerName = await prompt("Enter the signer's name: ");
86+
ccEmail = await prompt("Enter the carbon copy's email address: ");
87+
ccName = await prompt("Enter the carbon copy's name: ");
8588

8689
const envelopeArgs = {
8790
signerEmail: signerEmail,
@@ -102,10 +105,18 @@ function getArgs(apiAccountId, accessToken, basePath){
102105
return args;
103106
}
104107

108+
function prompt(prompt) {
109+
return new Promise((resolve) => {
110+
readline.question(prompt, (answer) => {
111+
resolve(answer);
112+
});
113+
});
114+
}
115+
105116

106117
async function main(){
107118
let accountInfo = await authenticate();
108-
let args = getArgs(accountInfo.apiAccountId, accountInfo.accessToken, accountInfo.basePath);
119+
let args = await getArgs(accountInfo.apiAccountId, accountInfo.accessToken, accountInfo.basePath);
109120
let envelopeId = await signingViaEmail.sendEnvelope(args);
110121
console.log(envelopeId);
111122
}

0 commit comments

Comments
 (0)